Using data rule Id instead of ID terminal [message #1021177] |
Tue, 19 March 2013 12:02  |
Eclipse User |
|
|
|
Hi,
I am writing a grammar using Xtext.
I have a rule representing a Display Format:
FormatSpec :
DecimalFrmt |
ExponentialFrmt
;
DecimalFrmt:
'S'? 'D' FieldWidth ('.' FracWidth)?;
FieldWidth:
INT;
FracWidth:
INT;
ExponentialFrmt:
'S'? 'E' FieldWidth '.' FracWidth;
So the intention is to be able to read format strings as: D5.3 (meaning to display an integer using 5-digits and 3 decimals) SD5, E12.2, SE15.2 and so on.
The problem is that this kind of formats are shadowed by the (default) terminal ID. and I can't write them without white spaces ('S D 5' works fine but is not what I want).
So I tried to use a data Type Rule 'Id' instead of the terminal ID (which I disable).
terminal ALFA:
'a'..'z' | 'A'..'Z'
;
terminal DIGIT:
'0'..'9'
;
AlfaNumber :
ALFA | DIGIT
;
Id:
ALFA AlfaNumber*
;
The problem I have now is that the parser tries to match some parts of the id with some keywords. For example if I have a keyword 'FRMT' I get an error if I try to define an Id 'idFRM02'.
Is this normal? If yes, are there any work-arounds? I have run out of ideas. Thank you for helping!
Stefan
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.48450 seconds