[antlr-interest] Different result using Java and Python runtime

Benjamin Niemann pink at odahoda.de
Thu Sep 13 02:19:07 PDT 2007


Hi again,

ok, I found the issue.
The patch is pretty simple, but you'll have to fetch the 3.0.1 source
tarball and rebuild ANTLR, because the changed file is hidden in antlr.jar.

The patch must be applied to the file
<src/org/antlr/codegen/templates/Python/Python.stg>. Afterwards the
template 'lexerRule' at line 450 should look like

[..snip..]
<else>
        _type = <ruleName>

        <ruleMemoization(name=ruleName)>
        <lexerRuleLabelDefs()>
        <ruleDescriptor.actions.init>
        <block>
        <ruleCleanUp()>
        self.type = _type
        <(ruleDescriptor.actions.after):execAction()>
<endif>
[..snip..]

But: it's probably easier for you to fix your grammar ;) What I did not
noticed is that you should declare the lexer rules QUOTE..STRING as
fragments, because they are only called by another lexer rule (STRINGDECL)
and not directly.
Like
fragment QUOTE    : '\'';
and so on.


HTH

-- 
Benjamin Niemann
Email: pink at odahoda dot de
WWW: http://pink.odahoda.de/
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: Python.stg.diff
Url: http://www.antlr.org/pipermail/antlr-interest/attachments/20070913/7ad2814f/attachment.pl 


More information about the antlr-interest mailing list