Re: Need help with grammars!

"John Williams" <>
21 Apr 1998 00:42:02 -0400

          From comp.compilers

Related articles
Need help with grammars! (1998-04-15)
Re: Need help with grammars! (John Williams) (1998-04-21)
Re: Need help with grammars! (Torben Mogensen) (1998-05-07)
| List of all articles for this month |

From: "John Williams" <>
Newsgroups: comp.compilers
Date: 21 Apr 1998 00:42:02 -0400
Organization: The University of Texas at Austin, Austin, Texas
References: 98-04-064
Keywords: parse, question wrote in message 98-04-064...
>lvalue ::= id | id [ exp ] | lvalue . lvalue
>exp ::= id ( functargs )
>exp ::= id [ arrayinit ]
>exp ::= lvalue
>exp ::= lvalue := exp
>exp ::= exp + exp

I don't have the experience to say for sure, but the distinction
between an lvalue and an rvalue mostly semantic, and trying to encode
it in your grammar rules will be more trouble and it's worth, assuming
it's possible at all.

(Someone call me on this if I'm wrong, since I'd like to know better
next time I try to write a parser :)

[You're right. Making distinctions semantically is often easier and
always lets you give better error messages, e.g. "expression where
variable name required" rather than "syntax error". -John]


Post a followup to this message

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