Hi David,

Try this:

(ID GETS) => ID GETS expr SEMI? -> ^(GETS ID expr SEMI?)


Regards,

Bart.


On Tue, Jun 7, 2011 at 1:41 PM, David Smith <david.sm...@cc.gatech.edu>wrote:

> I'm parsing a grammar in which the semicolon on the end of a line is
> optional. So two of the statement rules might be:
>    |   (ID GETS expr SEMI) => ID GETS expr SEMI -> ^(GETS ID expr SEMI)
>    |   (ID GETS) => ID GETS expr -> ^(GETS ID expr)
> Since this occurs with a number of different assignment statements, I
> would really like to collapse this into one rule that looks something
> like this:
>    |   (ID GETS) => ID GETS e=expr (s=SEMI)? -> ^(GETS ID $e $s)
> but every implementation I can think of either refuses to generate
> the grammar or, as in the case above, generates the grammar but
> decides that the variable 's' is unknown.
> Is there a any way to achieve this?
>
>                                 DMS
>
> David M. Smith http://www.cc.gatech.edu/fac/David.Smith
> Georgia Institute of Technology, College of Computing
> Sent from my ASR-33 Teletype
>
>
> List: http://www.antlr.org/mailman/listinfo/antlr-interest
> Unsubscribe:
> http://www.antlr.org/mailman/options/antlr-interest/your-email-address
>

List: http://www.antlr.org/mailman/listinfo/antlr-interest
Unsubscribe: 
http://www.antlr.org/mailman/options/antlr-interest/your-email-address

-- 
You received this message because you are subscribed to the Google Groups 
"il-antlr-interest" group.
To post to this group, send email to il-antlr-inter...@googlegroups.com.
To unsubscribe from this group, send email to 
il-antlr-interest+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/il-antlr-interest?hl=en.

Reply via email to