[antlr-interest] Dot won't match forward slash
John B. Brodie
jbb at acm.org
Tue Jul 8 15:35:14 PDT 2008
Greetings!
Ben Dotte asked:
>I have a parser rule in my ANTLR 3 grammar like this:
>
>quotedSearch : '"'^ .+ '"'! ;
>
>The strange thing is, forward slashes result in a "no viable
>alternative at character'/'" exception and get thrown out of the
>resultant tree. I don't seem to have any problems with other
>characters like \()[]* etc.
>
>Is there something special about forward slashes
No.
>or could there be any reason for this error?
Yes.
Your quotedSearch rule is a parser rule. thus the . inside it will
match any TOKEN produced by your LEXER.
Is your LEXER able to recognize the '/' as a token in the context of
the input sentence you are trying to match using the quotedString rule?
The `no viable alt` exception you are observing would strongly suggest
that your LEXER does not properly handle a '/' character in the input.
Hope this helps...
-jbb
More information about the antlr-interest
mailing list