Hi
Below an example of me trying to use fragment lexer rules to use in rewrite
rules. But when I try this out in the interpreter:
- 'test bar', with a fragment rule AGTEST conflicting with reading 'test',
doesn't parse
- 'foo bar', where no fragmented rule conflicts with reading input, parses
I thought fragment rules only tokenize input when used by other lexer rules?
Besides using literals as tree roots, what other alternatives do I have for
rewriting to abstract grammar elements?
=============================
grammar Foo;
options {
language = Java;
output = AST;
ASTLabelType=CommonTree;
}
program
: 'test' t=test
-> ^(AGTEST $t)
| 'foo' t=test
-> ^(AGTEST $t)
;
test
: NAM
;
NAM
: LETTER ( LETTER | DIGIT )*
;
fragment AGTEST : 'test';
fragment LETTER
: 'a'..'z' | 'A'..'Z'
;
fragment DIGIT
: '0'..'9'
;
=============================
Regards,
Ben
List: http://www.antlr.org/mailman/listinfo/antlr-interest
Unsubscribe:
http://www.antlr.org/mailman/options/antlr-interest/your-email-address
--
You received this message because you are subscribed to the Google Groups
"il-antlr-interest" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/il-antlr-interest?hl=en.