ID and a more relaxed version living together [message #1755879] |
Wed, 08 March 2017 15:52  |
Eclipse User |
|
|
|
Hi i need to support a structure like this:
varname=nodeOne/node-2/node-3
at first i implemented it changing the definition for ID, just including the '-' in it, but since i also support math expressions, if you do this:
sum= node1-node2 (without space in the middle)
the parser will think node1-node2 is a single ID.
If i try to include a more relaxed version of ID, like SEGMENT to live along with ID then the parser can't distinguish between ID and SEGMENT, forcing me to put an ^ before my id, which is bad for my users.
Do you have any tip for situations like this?
this is my definition for SEGMENT and ID (the standard one):
terminal SEGMENT: ('a'..'z'|'A'..'Z'|'_') ( 'a'..'z'|'A'..'Z'|'_'|'-'|'0'..'9')*;
@Override
terminal ID : '^'?('a'..'z'|'A'..'Z'|'_') ('a'..'z'|'A'..'Z'|'_'|'0'..'9')*;
Thanks for your help!
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.03129 seconds