[antlr-interest] python-lang parser to python target

Aaron Maxwell amax at redsymbol.net
Wed Jul 23 10:55:35 PDT 2008


On Wednesday 23 July 2008 10:18:23 am you wrote:
[regarding empty elif clause in lexer]
> > Can someone suggest a fix?  I tried just putting { pass;} in there,
> > but it is not placed at the correct indentation level.  Plus that is just
> > hackish.
>
> Mmm.. that should work. This is the only way to get empty alternatives
> to work right now, and I've used it several times without problems.
> I'll have a look at the code and checkout why it doesn't work in this
> case - but probably not before the weekend.

I wrote it like this:

{{{
CONTINUED_LINE
    :    '\\' ('\r')? '\n' (' '|'\t')*  { $channel=HIDDEN; }
         ( nl=NEWLINE 
{self.emit(ClassicToken(type=NEWLINE,text=nl.getText()))}
         | {pass;}
         )
    ;
}}}

I also tried "{    pass;}", i.e. manually placing four spaces in there - both 
produced the same lexer code.  Is that the right syntax?

-- 
Aaron Maxwell
http://redsymbol.net


More information about the antlr-interest mailing list