[antlr-interest] Spaces in names
Gavin Lambert
antlr at mirality.co.nz
Tue Aug 7 14:07:52 PDT 2007
At 03:27 8/08/2007, Dave Raskin wrote:
>Everything works well, except that values cannot accept spaces ('
>') in the string. I would like to be able to parse statements
>such as
>
> name=' value value1'
>
>I am using Antlr version 2.7.5.
This is happening because the WS rule is skipping whitespace
tokens, so they're never making it into the parser. Instead,
you're getting "value" as one NAME token and "value1" as another
NAME token, and your value rule specifies that only one NAME is
permitted between two TICKs. Hence why it'll fail to match.
You could change it so that multiple NAMEs are allowed, but that
will result in collapsing the whitespace and changing the query
string, which is probably not what you want. Instead, you should
change 'value' into a lexer rule so that it can match an entire
quoted string as a single token. See the example grammars
provided with ANTLR -- this sort of thing is fairly common.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.antlr.org/pipermail/antlr-interest/attachments/20070808/85934a19/attachment.html
More information about the antlr-interest
mailing list