Related articles |
---|
[6 earlier articles] |
Re: Parsing Expression Grammar pohjalai@cc.helsinki.fi (A Pietu Pohjalainen) (2005-09-07) |
Re: Parsing Expression Grammar paul@highpersoft.com (Paul Mann) (2005-09-07) |
Re: Parsing Expression Grammar wclodius@lanl.gov (2005-09-10) |
Re: Parsing Expression Grammar cfc@shell01.TheWorld.com (Chris F Clark) (2005-09-10) |
Re: Parsing Expression Grammar gneuner2@comcast.net (George Neuner) (2005-09-10) |
Re: Parsing Expression Grammar DrDiettrich@compuserve.de (Hans-Peter Diettrich) (2005-09-10) |
Re: Parsing Expression Grammar paul@parsetec.com (Paul Mann) (2005-09-11) |
Re: Parsing Expression Grammar paul@parsetec.com (Paul Mann) (2005-09-11) |
Re: Parsing Expression Grammar DrDiettrich@compuserve.de (Hans-Peter Diettrich) (2005-09-14) |
Re: Parsing Expression Grammar gneuner2@comcast.net (George Neuner) (2005-09-14) |
Re: Parsing Expression Grammar Meyer-Eltz@t-online.de (Detlef Meyer-Eltz) (2005-09-14) |
Re: Parsing Expression Grammar cleos@nb.sympatico.ca (Cleo Saulnier) (2005-09-17) |
Re: Parsing Expression Grammar DrDiettrich@compuserve.de (Hans-Peter Diettrich) (2005-09-17) |
[21 later articles] |
From: | "Paul Mann" <paul@parsetec.com> |
Newsgroups: | comp.compilers |
Date: | 11 Sep 2005 11:11:57 -0400 |
Organization: | Compilers Central |
References: | 05-09-023 |
Keywords: | parse |
Posted-Date: | 11 Sep 2005 11:11:57 EDT |
"Paul Mann" <paul@highpersoft.com> wrote
> "Chris F Clark" <cfc@shell01.TheWorld.com> wrote in message
>> But, as a potential language designer, you need to think long and hard
>> about why you want to create a language which has no LL(1) grammar.
>
> Answer: Readability for human's sake.
First of all, readability in the grammar. Perhaps that is what I was
thinking about, rather than readability in a programming language.
But I might be able to find some cases where LALR(1) allows greater
readability in the language being parsed also.
I find these LALR(1) grammar rules to be more readable and more
natural:
StatementList -> Statement
-> StatementList Statement
Than the LL(1) equivalent:
StatementList -> Statement
-> Statement StatementList
I know you do it like this:
StatementList : Statement+
But LL(1) is a way of thinking that is limited. With LL, you are
forced to use LL(2) or LL(3) to do things that are very easy for
LALR(1).
----------------------------------------------
Outside of readability in the grammar ...
I'm sure I could find some programming language constructs which
cannot be expressed in LL(1) that are expressible in LALR(1). So
again, why constrain yourself to LL(1).
Now LL(k) can handle anything in the universe, but the discussion is
about which is easier to program and easy to read both.
For me, LL(k) is not easier to program than LALR(1).
----------------------------------------------
About actions in the middle of a rule with LL(1) parsers ...
I have hardly ever needed to do this. Usually, there is already a need
for a nonterminal at this point in the rule and when reducing the
nonterminal, I can have an action take place easily with LALR.
Most of the action takes place when processing the AST anyway. So
actions in the middle of a rule are not the main issue in compiler
front ends.
BTW, processing the AST can be done with a top-down traversal (for
those who don't like LALR's bottom-up characteristic).
--------------------------------------------
I don't like to see code in a grammar any more than I like to put
assembly language code in my C++ programs.
I don't like to put words like SEMI in a grammar, when I can put ';'
instead ... what happens when a language has a keyword, SEMI ? (Yes
I know it's rare) ...
You use 'SEMI', right?
I find
'SEMI' ';'
more readable than
'SEMI' SEMI
Actually I prefer
SEMI ';'
-------------------------------------------
Finally, I don't like the Forth programming language, because of
readability issues. I'm sure you LL(k) people will disagree with me
about this.
Paul Mann
http://parsetec.com
Return to the
comp.compilers page.
Search the
comp.compilers archives again.