Open cdietrich opened 7 years ago
Reproducing grammar and test model
problem happens when delete the ln from println and save
thing Xxxxx {
blocka {
}
blockb {
println("hello")
//xxx.execute();
// xxx2.execute();
//xxx3.execute();
}
}
import "http://www.eclipse.org/xtext/xbase/Xbase"
import "http://www.eclipse.org/xtext/common/JavaVMTypes"
import "http://www.eclipse.org/Xtext/Xbase/XAnnotations"
import "http://www.eclipse.org/emf/2002/Ecore" as ecore
Model:
thing=Thing;
Thing:
{Thing}
'thing' name=ID
'{'
(a=BlockA? & b=BlockB?)
'}';
BlockA:
{BlockA}
'blocka' '{'
'}';
BlockB:
'blockb' body=XBlockExpression;
XCastedExpression returns XExpression:
XPostfixOperation;
// remove 'instanceof' operator
XRelationalExpression returns XExpression:
XOtherOperatorExpression
(=> ({XBinaryOperation.leftOperand=current} feature=[JvmIdentifiableElement|OpCompare])
rightOperand=XOtherOperatorExpression)*;
// reduced set of primary expressions
XPrimaryExpression returns XExpression:
XLiteral | XBlockExpression | XIfExpression | XForLoopExpression | XParenthesizedExpression |
=> XFeatureCall;
// reduced set of literals
XLiteral returns XExpression:
XStringLiteral;
// no "val" expressions
// initializer is required
XVariableDeclaration returns XExpression:
{XVariableDeclaration} "var" name=ID "=" right=XExpression;
JvmSimpleFormalParameter returns JvmFormalParameter:
name=ValidID;
XForLoopExpression returns XExpression:
=>({XForLoopExpression}
'for' '(' declaredParam=JvmSimpleFormalParameter ':') forExpression=XExpression ')'
eachExpression=XExpression;
FeatureCallID:
ValidID | 'blockb';
it seem to help to reorder the primary expressions
XPrimaryExpression returns XExpression:
XFeatureCall | XLiteral | XBlockExpression | XIfExpression | XForLoopExpression | XParenthesizedExpression
;
It appears to be related to the predicate on XFeatureCall in your initial grammar. The predicate should not appear on the last but on the first alternative.
Seems like Xtext could do with sone validations on the placement of predicates.