[antlr-interest] Re: Python support for ANTLR
Marq Kole
marq.kole at philips.com
Mon Nov 1 08:17:25 PST 2004
--- In antlr-interest at yahoogroups.com, Ric Klaren <klaren at c...>
wrote:
> On Mon, Nov 01, 2004 at 09:13:02AM -0000, marqkole wrote:
> > Explanation: instead of braces, Python uses indentation to mark
blocks of
> > code.
>
> Once more *sigh* It would have been such a nice language without
it ;)
>
> > In the case of the generated code, the opening brace could be
replaced by
> > an if statement that is always open (example: "if True:")
followed by an
> > increased indentation level, while the closing brace can be
replaced by
> > just a decreased indentation level.
>
> > My problem is that I just can't find where to do this for a
single action
> > item, such as a pair of spurious braces. Just have a look at the
generated
> > code in the lexertester examples to see what I mean.
>
> It looks like it's related to to method
>
> public void gen(AlternativeBlock blk);
>
> and single alternatives. E.g. try remove the () around the 'A'
alternative
> in simplelexer2.g this will fix the output for the 2nd lexer.
Adding an
> extra "if True:" to the start of the gen() method does not work
100% of the
> cases. There's another "if True:" cropping up from somewhere
else.. hrmm..
> Looks like it's fixed with commenting inside:
>
> protected void genAlt(Alternative alt, AlternativeBlock blk)
>
> The lines:
>
> // else
> // if (!(elem.next instanceof BlockEndElement) && (grammar
instanceof LexerGrammar)) {
> // println("if True: # needed to get the indents right
genalt");
> // }
>
> Now all the lexertest things run without indentation errors.
Thanks, this indeed solves a number of issues. A few still remain,
but I am working on those. I've uploaded to the Files section an
updated patch that includes this stuff and then some.
> I wonder how stringtemplate would deal with this kind off stuff for
> antlr3...
Sure, we'll cross that bridge when we come to it.
> Cheers,
>
> Ric
Marq
Yahoo! Groups Links
<*> To visit your group on the web, go to:
http://groups.yahoo.com/group/antlr-interest/
<*> To unsubscribe from this group, send an email to:
antlr-interest-unsubscribe at yahoogroups.com
<*> Your use of Yahoo! Groups is subject to:
http://docs.yahoo.com/info/terms/
More information about the antlr-interest
mailing list