ph09
ph09

Reputation: 1052

Xtext: Difference between production and datatype rule

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?

Upvotes: 1

Views: 1191

Answers (1)

Sebastian Zarnekow
Sebastian Zarnekow

Reputation: 6729

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.

Upvotes: 4

Related Questions