ANTLR mismatched token in simple grammar

153 views Asked by At

I am currently debugging my grammar in ANTLRworks, and reduced it far more than is reasonable to this:

grammar DebugInternalGrammar;


RULE_STRING :
    '"' (
        ('\\' .) |
        (~ (
            '\\' |
            '"'
        ))
    )* '"'
;

Which, when testing in the interpreter against the String

"L"

just yields

MismatchedTokenException(76!=34)

What does work is matching "", also reducing the grammar to:

grammar DebugInternalGrammar;


RULE_STRING :
    '"' (
        (~ (
            '\\' |
            '"'
        ))
    )* '"'
;

matches "L" (I assume this is what it means when the parse tree in ANTLRworks shows <epsilon> as leaf).

What is wrong here? This is not the part of the grammar which caused me trouble before, so I am scratching my head as to what the problem could be and what ANTLRworks is trying to tell me.

0

There are 0 answers