[antlr-interest] Tree matching: wildcard-operator

Tobias Diez webmaster at altertoby.de
Mon Jul 25 15:01:48 PDT 2011


Hi,

are there special concerns regarding the wildcard operator in a tree grammar
(with filter=true)?

I ask because 
^(ENVIRONMENT_BEGIN .) . * ^(ENVIRONMENT_END .)

did not match the correct input EXCEPT the LAST subtree in the file is of
the form "^(ENVIRONMENT_END .)".
A deeper investigation showed that the "next token equals endtoken than
cancel"-logic of the wildcard did not fire, although it should recognize the
environment-end subtree. So the .* matchs everything and the parser runs
until reaching the last subtree of the input stream. This last subtree is
than compared to  "^(ENVIRONMENT_END .)".
So "^(ENVIRONMENT_BEGIN a) b ^(ENVIRONMENT_END c)" is recognized but
"^(ENVIRONMENT_BEGIN a) b ^(ENVIRONMENT_END c) SOMETHING" not.

Is everything correct in the code above or is there a bug in ANTLR?

Thanks!



More information about the antlr-interest mailing list