[antlr-interest] Matching an arbitrary string until the next whitespace occurrence
peedee.nick at gmail.com
Wed Oct 19 08:51:53 PDT 2011
I just started using antlr and was able to construct a nice grammar that
fulfills my application's needs. There is one thing which I haven't been
able to get to work though.
My grammar is parsing program arguments which the user supplied when
starting the program, and some of that input will need to be forwarded to
another program. This implies that I have almost no control over those
strings and need to be able to parse them only knowing that they are
delimited by whitespace. So what I need (I think) is a lexer rule to match
an arbitrary string which doesn't contain whitespace.
Here is what I tried, with the intention that it should match anything that
doesn't contain one of the four characters.
STRING : (~(' '|'\t'|'\r'|'\n'))+ ;
However, that does not seem to be working, it doesn't recognize numbers for
example, and I don't understand why.
More information about the antlr-interest