Terminal [message #1138802] |
Tue, 15 October 2013 06:38  |
Eclipse User |
|
|
|
Hi,
While creating a rule, I am facing issue related to overlapping of terminals. In grammar below I am trying to input Reference one1.111GGG.two.three but it fails as the terminal conflicts with whole number terminal being a '.' in between.
It can however be resolved by either creating the Greeting name as a terminal rule or by changing NUM & TOKEN_STARTING_WITH_NUMBER to a non terminal rule. But converting from non terminal rule to a data type rule would have performance impact.
What should be the ideal ways to handle such use cases?
Model:
'Reference' hello=GreetingName
;
GreetingName:
ID '.' TOKEN_STARTING_WITH_NUMBER '.' ID '.' ID;
terminal ID:
'^'? ('a'..'z' | 'A'..'Z' | '_') ('a'..'z' | 'A'..'Z' | '_' | '0'..'9' | '-' | '+')*;
terminal NUM:
('0'..'9')* ('.' ('0'..'9')+)?
;
terminal TOKEN_STARTING_WITH_NUMBER:
('0'..'9')* ID;
terminal INT returns ecore::EInt:
"not to be used";
Attaching xtext file for various scenarios along with junit test case.
Regards
Vishal
|
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.24455 seconds