Same keysimbol causes ambiguity [message #990045] |
Mon, 10 December 2012 16:20 |
|
Good week everyone.
This is an extract from my grammar:
terminal INT returns ecore::EInt : ('0'..'9')+;
terminal TIME_OF_DAY returns ecore::EString: (('0' | '1')('0'..'9') | ('2')('0'..'3'))(':')('0'..'5')('0'..'9')(':')('0'..'5')('0'..'9')('.')('0'..'9')('0'..'9');
[...]
CaseStatement:
{CaseStatement}
'CASE' caseValue=GenericExpression 'OF'
listOfCases+=Case*
'END_CASE'';'
;
Case:
{Case}
value=INT '..'finalValue=INT ':'
instructionCase+=Instruction*
;
As you can see, TIME_OF_DAY constants are composed with this pattern:
number:number:number.number
A 'case' is like this:
CASE number..number:
The problem is located on ':' keysimbol: if I write, in my dsl, this:
I'll receive an error becuse it interprets "10:" as a (not complete) part of TIME_OF_DAY constant.
Any suggests for these situations?
|
|
|
|
|
Re: Same keysimbol causes ambiguity [message #990167 is a reply to message #990057] |
Tue, 11 December 2012 09:00 |
|
Henrik Lindberg wrote on Mon, 10 December 2012 17:45You need to use a Data rule instead of a terminal, anything that
requires context to parse can not be a terminal. Change your TIME_OF_DAY
to:
time_of_day : INT ':' INT '.' INT
Add a converter for that rule that checks the formatting
(You may want a custom datatype as well - here it is just a string).
Hope that helps.
- henrik
Thanks for help, I think this is the better solution for my case but I can't understand how force INT to my value ranges.
|
|
|
|
Powered by
FUDForum. Page generated in 0.03732 seconds