[antlr-interest] AST with optional parameters

Jim Idle jimi at temporal-wave.com
Tue Jun 7 10:57:12 PDT 2011

It was not in any earlier message than the one I replied to. MATLAB is such
an abysmal language ;-)


*From:* Bart Kiers [mailto:bkiers at gmail.com]
*Sent:* Tuesday, June 07, 2011 10:14 AM
*To:* Jim Idle
*Cc:* antlr-interest at antlr.org
*Subject:* Re: [antlr-interest] AST with optional parameters


>From an earlier message, David wrote: *"**Yes, the language is Matlab and a
semicolon on the end of an assignment expression suppresses display of the
result of the assignment. ...**"*


On Tue, Jun 7, 2011 at 6:30 PM, Jim Idle <jimi at temporal-wave.com> wrote:

Why do you want the SEMI in your AST?


> -----Original Message-----
> From: antlr-interest-bounces at antlr.org [mailto:antlr-interest-
> bounces at antlr.org] On Behalf Of David Smith
> Sent: Tuesday, June 07, 2011 4:41 AM
> To: antlr-interest at antlr.org
> Subject: [antlr-interest] AST with optional parameters

> 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
>     |   (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

More information about the antlr-interest mailing list