Permalink
Switch branches/tags
Nothing to show
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
33 lines (16 sloc) 845 Bytes
grammar nl.dslmeinte.xtext.ambiguity.MyPL with org.eclipse.xtext.common.Terminals
generate myPL "http://www.dslmeinte.nl/xtext/ambiguity/MyPL"
Program: elements += (Class | Statement)*;
Class: 'class' name=ID '{' features+=Feature* '}';
Feature: Class | Attribute;
Attribute: name=ID ':' type=ID; // (a DataType enum is nicer but unnecessary for the example)
Expression: IntegerLiteral;
IntegerLiteral: int=INT;
Variable: name=ID;
// our naive grammar:
Statement: VariableDeclaration | Assignment;
VariableDeclaration: typeRef=ClassRef variable=Variable (':=' value=Expression)?;
ClassRef: type=[Class] tail=FeatureRefTail?;
Assignment: lhs=AssignableSite ':=' value=Expression;
AssignableSite: var=[VariableDeclaration] tail=FeatureRefTail?;
FeatureRefTail: '.' feature=[Feature] tail=FeatureRefTail?;