[antlr-interest] Capturing a grammar block as a string
Ilya Sterin
sterini at gmail.com
Sun Nov 23 16:22:52 PST 2008
So in my grammar, I capture blocks of JSON-like structures. I don't
want antlr to try to parse that structure, but rather to evaluate it
as a string.
Here is a sample code...
define project as {
"name": "some_widget",
"version": "0.01-alpha"
}
Here is a simple grammar rule to demonstrate the issue I'm having...
definesomething
: define IDENT as json
;
json
: '{' .* '}'
;
IDENT
: ('0'..'9'|'a'..'z'|'A'..'Z'|'_')+;
WHITESPACE
: ( '\t' | ' ' | '\r' | '\n' | '\u000C' )+ { $channel=HIDDEN; } ;
This is fact tries to evaluate the content between the braces. I
actually would like the rule to evaluate all the content as one
string, though I will later parse it within my application. Is there
a way I can accomplish this?
Thanks.
Ilya
More information about the antlr-interest
mailing list