Re: Why LL(1) Parsers do not support left recursion?

"Dmitry A. Kazakov" <mailbox@dmitry-kazakov.de>
25 Jul 2006 17:58:49 -0400

          From comp.compilers

Related articles
[11 earlier articles]
Re: Why LL(1) Parsers do not support left recursion? egagnon@sablevm.org (Etienne Gagnon) (2006-07-22)
Re: Why LL(1) Parsers do not support left recursion? wyrmwif@tsoft.org (SM Ryan) (2006-07-23)
Re: Why LL(1) Parsers do not support left recursion? max@gustavus.edu (Max Hailperin) (2006-07-23)
Re: Why LL(1) Parsers do not support left recursion? cbarron413@adelphia.net (Carl Barron) (2006-07-24)
Re: Why LL(1) Parsers do not support left recursion? DrDiettrich1@aol.com (Hans-Peter Diettrich) (2006-07-25)
Re: Why LL(1) Parsers do not support left recursion? DrDiettrich1@aol.com (Hans-Peter Diettrich) (2006-07-25)
Re: Why LL(1) Parsers do not support left recursion? mailbox@dmitry-kazakov.de (Dmitry A. Kazakov) (2006-07-25)
Re: Why LL(1) Parsers do not support left recursion? DrDiettrich1@aol.com (Hans-Peter Diettrich) (2006-07-25)
Re: Why LL(1) Parsers do not support left recursion? ajonospam@andrew.cmu.edu (Arthur J. O'Dwyer) (2006-07-25)
Re: Why LL(1) Parsers do not support left recursion? wyrmwif@tsoft.org (SM Ryan) (2006-07-28)
Re: Why LL(1) Parsers do not support left recursion? cfc@shell01.TheWorld.com (Chris F Clark) (2006-07-28)
Re: Why LL(1) Parsers do not support left recursion? cfc@shell01.TheWorld.com (Chris F Clark) (2006-07-28)
Re: Why LL(1) Parsers do not support left recursion? cfc@shell01.TheWorld.com (Chris F Clark) (2006-07-28)
[12 later articles]
| List of all articles for this month |
From: "Dmitry A. Kazakov" <mailbox@dmitry-kazakov.de>
Newsgroups: comp.compilers
Date: 25 Jul 2006 17:58:49 -0400
Organization: cbb software GmbH
References: 06-07-059 06-07-065 06-07-071
Keywords: parse
Posted-Date: 25 Jul 2006 17:58:49 EDT

On 25 Jul 2006 00:40:16 -0400, Hans-Peter Diettrich wrote:


> SM Ryan schrieb:
>
>> If the semantics of a subtract production are the value of the right
>> subtree is subtracted from the value of left subtree, then
>> 3 - 2 - 1
>> with left recursion is
>> = (3 - 2) - 1 = 1 - 1 = 0
>> with right recursion is
>> = 3 - (2 - 1) = 3 - 1 = 2
>
> This is a property of the asymmetric subtraction operation, which
> doesn't apply to the symmetric addition or multiplication operations. Of
> course it's a good idea to enforce a unique sequence of *numerical*
> operations in program code, whereas in mathematical formulas such
> additional restrictions should *not* be built into a grammar.


Do you mean that association should be handled after parsing? That would be
a strange language. However, if you merely argue that 3 - 2 - 1 should be
parsed as:


" -"
  /|\
3 2 1


or (maybe better) as


        "+"
      / | \
    / "-""-"
  / | \
3 2 1


then I would certainly agree with you. But this is also "built in grammar"
to me.


--
Regards,
Dmitry A. Kazakov
http://www.dmitry-kazakov.de


Post a followup to this message

Return to the comp.compilers page.
Search the comp.compilers archives again.