[antlr-interest] Strangeness when parsing strings and spaces
Kevin Jackson
foamdino at gmail.com
Mon Jan 17 22:41:13 PST 2011
Hi,
I know that this is a problem with my lexer and I'm doing something
stupid, but I have a problem with simple k,v pairs of the format:
[String "quoted string with spaces and non-alhpa chars"]
My grammar
------------------
LEFT_SQUARE: '[';
RIGHT_SQUARE: ']';
STRING: 'a'..'z'|'A'..'Z';
TEXT: ('a'..z'|'A'..'Z'|' '|',')+
pair: LEFT_SQUARE (info=STRING) ' ' '"' (value=TEXT) '"' RIGHT_SQUARE
NEWLINE+ -> transform(i={$info.text},v={$value.text});
This fails with "mismatched input expecting 'Test ' expecting STRING"
(note the space that should not be present).
pair: LEFT_SQUARE (info=TEXT) ' ' '"' (value=TEXT) '"' RIGHT_SQUARE
NEWLINE+ -> transform(i={$info.text},v={$value.text});
This grabs the space and passes it to transform (which I really don't want)
Can anyone see what I'm doing wrong? I know the answer is probably simple
Thanks,
Kev
More information about the antlr-interest
mailing list