Lexer problem [message #1722766] |
Mon, 08 February 2016 18:03  |
Eclipse User |
|
|
|
Hello,
I have created a new Literal that takes a number and a unit of measurement.
It works well with a prefix token, but I would like to make it work without, since the expected units are predefined.
The thing is that it does work, but it prevents the DECIMAL terminal from being used. There might be a way to set options etc. to accomplish that goal. So I am open to any suggestion.
terminal MEASURE:
INT ('.' INT)? ('in'|'mm'|'cm'|'dm'|'m'|'in2'|'mm2'|'cm2'|'dm2'|'m2'|'in3'|'mm3'|'cm3'|'dm3'|'m3'|'lb'|'mg'|'g'|'kg');
I tried other variations like
terminal MEASURE_TERMINAL:
(INT '.')? INT ('in'|'mm'|'cm'|'dm'|'m'|'in2'|'mm2'|'cm2'|'dm2'|'m2'|'in3'|'mm3'|'cm3'|'dm3'|'m3'|'lb'|'mg'|'g'|'kg');
But nothing worked yet.
Examples of strings that parse ok:
val length = 9392.3923mm
val weight = 100kg
val l = 1932
but
val d = 2392.99 // THAT fails. DECIMAL is not matched
thanks!
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.07000 seconds