Related articles |
---|
Need help with grammars! dan.hovang@usa.net (1998-04-15) |
Re: Need help with grammars! jrw@pobox.com (John Williams) (1998-04-21) |
Re: Need help with grammars! torbenm@diku.dk (Torben Mogensen) (1998-05-07) |
From: | "John Williams" <jrw@pobox.com> |
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 |
dan.hovang@usa.net 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
>etc.
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 :)
jw
[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]
--
Return to the
comp.compilers page.
Search the
comp.compilers archives again.