Can someone explain to me the difference between a production and datatype rule in xtext?
I know so far that both are parser rules and Datatype Rule returns a primitive EDataype and production rule creates an EObject in the AST.. But I can’t see a differnce in their grammar definition:
Dataype Rule:
Decimal:
INT ‘.’ INT
;
Producion Rule:
Model:
(stats += Statement)*
;
How did the parser know which is what rule?
The parser uses the (inferred) return type of the parser rule to distinguish between productions and data types. If the returned type is an EMF EDataType, the rule is a data type rule, otherwise it’s a production rule.
This blog entry tries to highlight some differences between the kinds of rules in Xtext.