Reputation: 388
I've written an Xtext grammar that describes a list of coordinates:
Model:
coordinates+=Coordinates*
;
Coordinates:
'(' x=INT ',' y=INT ')'
;
However, when using the parsingTest automatically created with a new Xtext project and printing println(EmfFormatter.objToStr(result))
for this program:
(2,1)
(2,0)
(0,1)
(0,0)
(1,1)
I get the following representation of the AST:
Model {
cref Coordinates coordinates [
0: Coordinates {
attr EInt x '2'
attr EInt y '1'
}
1: Coordinates {
attr EInt x '2'
}
2: Coordinates {
attr EInt y '1'
}
3: Coordinates {
}
4: Coordinates {
attr EInt x '1'
attr EInt y '1'
}
]
}
What I think is happening is that '0' does not match INT for some reason. I could create a new datatype, but seems quite ugly not to use the provided INT. Any ideas?
Upvotes: 0
Views: 50
Reputation: 11868
The answer is easy. There is no problem. The EmfFormatter simply does not print values equal to default values
Upvotes: 1