|Re: Same keysimbol causes ambiguity [message #990284 is a reply to message #990167]
||Tue, 11 December 2012 12:29
| Henrik Lindberg
Registered: July 2009
On 2012-11-12 10:00, Tommaso De Sica wrote:|
> Henrik Lindberg wrote on Mon, 10 December 2012 17:45
>> You 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
>> 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.
Do you mean how to validate/convert the string passed to the terminal
converter for time_of_day ?
Well - look at the generated MyDSLTerminalConverters class (MyDSL is the
name of your language). There you should write a converter associated
with your "time_of_day" rule, and perform bidirectional conversion -
from string form to internal representation, and vice versa. If you do
not use a datatype other that String, you can simply just do validation
Alternatively, just add a validation method and validate the model.
Powered by FUDForum
. Page generated in 0.01761 seconds