[antlr-interest] How to apply predicates
Horst Dehmer
horst.dehmer at gmail.com
Tue Dec 1 02:11:18 PST 2009
Hello!
I have the following rather simple grammar (which is probable not
context-free).
The input 'X0110000063{...' is (naturally) matched as a LITERAL
'X0110000063', whereas I need it to be X01 followed by the literal/
entity_id '10000063'. I am sure this can be achieved by using a
(syntactic/semantic) predicate, but I just don't know how.
Any help is highly appreciated.
Thanks,
Horst
transaction: X01 (update_type)+ EOF;
update_type: entity_id '{' (basic_update)+ '}';
basic_update: '{' field ('|' field)* '}';
field: (description)?;
entity_id returns [String value]: LITERAL { $value = $LITERAL.text; };
description returns [String value]: LITERAL { $value = $LITERAL.text; };
fragment ESCAPE_CHARACTER: '`';
fragment SPECIAL_CHARACTER: ESCAPE_CHARACTER | '|' | '{' | '}';
ESCAPE: ESCAPE_CHARACTER SPECIAL_CHARACTER;
X01: 'X01';
LITERAL
: ( ESCAPE |
'\u0009'..'\u000A' |
'\u000D' |
'\u0020'..'\u005F' |
'\u0061'..'\u007A' |
'\u007E'
)+
;
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.antlr.org/pipermail/antlr-interest/attachments/20091201/415d5cbd/attachment.html
More information about the antlr-interest
mailing list