[antlr-interest] speaking of => etc...

Jim Idle jimi at temporal-wave.com
Thu Dec 8 13:31:20 PST 2005



> And in the name of all that's holy, please don't bring in angle 
> brackets!  What's next, dollar signs and percents?  :-).

rule
 scope { String fred }
 : blah blah bl=blah

   {    $rule::fred = $bl.toString() }
 ;

Too late to object to dollars! Now, what should % be used for?...

Actually I wonder about the option of making a verbose and a symbolic
syntax. Most people look at things akin: {fred} ##<$>><1>//!!%

And go "huh?", whereas once you are familiar with the symbols it is
easy. If there were more wordy forms like (sorry, couldn't resist the %
here ;-)):

%synpred   [ ]
%rulepred  [ ]
%hoistpred [ ]
%gatepred  [ ]

And so on, it might be useful for people new to the stuff, though I
don't suggest this being the only form.

However, the hash/pound symbol # looks to me very much like a gate,
otherwise it means NOT in a lot of languages I have to work with. 

Optional rules being [ ] depends on what language manual you are looking
at of course. A lot of manuals seem to use {}:

CRT {Identifier}

- Identifier is optional

And use [] for "one of":

WRITE [Identifier | Expression] {:}


I think that once the symbols are settled upon that people will soon
forget the ANTLR 2 syntax (which could of course be a bit of a problem
when you go back to look at ANTLR 2 grammars). 

I think then that the best thing to do is be mindful of "syntaxes which
have gone before" but in the main to concentrate on making the ANTLR3
syntax as logical as possible.

Jim


More information about the antlr-interest mailing list