I'm new to Xtext and I'm trying to create a simple DSL for railway systems, here's my grammar :
grammar org.xtext.railway.RailWay with org.eclipse.xtext.common.Terminals
generate railWay "http://www.xtext.org/railway/RailWay"
Model:
(trains+=Train)*
| (paths+=Path)*
| (sections+=Section)*
;
Train:
'Train' name=ID ':'
'Path' path=[Path]
'Speed' speed=INT
'end'
;
Path:
'Path' name=ID ':'
'Sections' ('{' sections+=[Section] (',' sections+=[Section] )+ '}' ) | sections+=[Section]
'end'
;
Section:
'Section' name=ID ':'
'Start' start=INT
'End' end=INT
('SpeedMax' speedMax=INT)?
'end'
;
But when I put this code at the Eclipse instance :
Section brestStBrieux :
Start 0
End 5
end
Section StBrieuxLeMan :
Start 5
End 10
end
Section leManParis :
Start 1
End 12
end
Path brestParis :
Sections { brestStBrieux, StBrieuxLeMan, leManParis}
end
Train tgv :
Path brestParis
Speed 23
end
I got this error three times:
mismatched input '0' expecting RULE_INT mismatched input '1' expecting RULE_INT mismatched input '5' expecting RULE_INT
I can't see where those errors come from, what can I do to fix them. Any idea?
Christian is right, since the FLOAT terminal is no longer defined, the original problem is resolved. Anyway, a remaining issue is the rule
Path:
'Path' name=ID ':'
'Sections' ('{' sections+=[Section] (',' sections+=[Section] )+ '}' ) | sections+=[Section]
'end'
;
which currently has this precedence:
Path:
(
'Path' name=ID ':' 'Sections'
('{' sections+=[Section] (',' sections+=[Section] )+ '}' )
)
|
(sections+=[Section] 'end')
;
You may want to rewrite it to
Path:
'Path' name=ID ':'
'Sections'
(
('{' sections+=[Section] (',' sections+=[Section] )+ '}' )
| sections+=[Section]
) 'end'
;
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments