[antlr-interest] advice on creating a grammar for a given DSL example

Jim Idle jimi at temporal-wave.com
Tue Aug 17 13:59:09 PDT 2010


No problem.

Jim

> -----Original Message-----
> From: antlr-interest-bounces at antlr.org [mailto:antlr-interest-
> bounces at antlr.org] On Behalf Of aryoo
> Sent: Tuesday, August 17, 2010 1:55 PM
> To: antlr-interest at antlr.org
> Cc: howaryoo at gmail.com
> Subject: Re: [antlr-interest] advice on creating a grammar for a given DSL
> example
> 
> Dear Jim,
> 
> I followed your recommendations, avoided the "I don't want delimiters in
my
> language" temptation, and created the grammar from scratch using
> ANTLRWorks successfully.
> Next steps for me: AST + StringTemplate output.
> 
> Thanks a lot for your answer. It was exactly what I needed.
> 
> Sincerely,
> Arye.
> 
> Remove your tokens section and place those keywords as real lexer rules
> that
> > are listed before the ID rule.
> > Remove any 'literals' in your parser and make these real lexer rules
> > and tokens.
> > Change your ANY rule to just: ANY :. { issue error message; skip(); };
> > Use {skip();} rather than HIDDEN unless you need the whitespace later
> > for some reason;
> >
> > Then you have to look at where you are putting your NEWLINEs in the
> > grammar.
> > It looks like you have too many specified and are expecting NEWLINE
> > NEWLINE at some point. You should try skipping newlines and see how
> > ambiguous your grammar is. If this is your own language, don't fall
> > for the "I don't want delimiters in my language" myth as it makes
> > giving out informative error messages nigh on impossible.
> >
> > But more than all this, you need to run your grammar in the ANTLR
> > works debugger, which will allow you to trace out what is wrong with
> > your grammar specification.
> >
> > Jim
> >
> 
> List: http://www.antlr.org/mailman/listinfo/antlr-interest
> Unsubscribe: http://www.antlr.org/mailman/options/antlr-interest/your-
> email-address



More information about the antlr-interest mailing list