Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [gmt-dev] parsing array definition in xText grammar

It's a bug. (Thanks for finding it ;-))
In the meantime I think you could alternatively write:

Program:
	ArrayLiteral ";"
SimpleExpression :
	"true" | "false";
ArrayLiteral :
		"[" ((elements+=SimpleExpression ",")* elements+=SimpleExpression)? "]";


regards,
Sven

Michal Ceresna schrieb:
Hello,

I've a problem with the xText grammar, and I'm not sure
if it is a bug or a problem in my grammar.
I've the following grammar rules:
Program:
	ArrayLiteral ";"
SimpleExpression :
	"true" | "false";
ArrayLiteral :
		"[" "]"
	|	"[" (elements+=SimpleExpression ",")* elements+=SimpleExpression "]";

The last rule is in the model correctly generated as an EMF object 'ArrayLiteral' with a child (reference) feature 'elements' of multiplicity [0..*].

But when executing the generated editor exceptions occur:

Parsing
	[false];
	[ true, false];
works fine, but when parsing
	[];
a null pointer exception is thrown:

org.openarchitectureware.expression.EvaluationException: null:in nofile on line 1 'exprs.addAll(arg1)'
	at org.openarchitectureware.expression.ast.Expression.evaluate(Expression.java:46)
	at org.openarchitectureware.expression.ExpressionFacade.evaluate(ExpressionFacade.java:62)
	at org.openarchitectureware.expression.ExpressionFacade.evaluate(ExpressionFacade.java:51)
	at org.openarchitectureware.xtext.parser.EcoreModelFactory.create(EcoreModelFactory.java:82)
	at org.openarchitectureware.xtext.parser.EcoreModelFactory.create(EcoreModelFactory.java:48)
	at org.weblearn.js.ecmascript262.parser.ecmascript262Parser.ruleExpression(ecmascript262Parser.java:433)
	at org.weblearn.js.ecmascript262.parser.ecmascript262Parser.ruleExpressionStatement(ecmascript262Parser.java:456)
	at org.weblearn.js.ecmascript262.parser.ecmascript262Parser.ruleStatement(ecmascript262Parser.java:132)
	at org.weblearn.js.ecmascript262.parser.ecmascript262Parser.ruleTopStatement(ecmascript262Parser.java:98)
	at org.weblearn.js.ecmascript262.parser.ecmascript262Parser.ruleProgram(ecmascript262Parser.java:70)
	at org.weblearn.js.ecmascript262.ecmascript262Utilities.internalParse(ecmascript262Utilities.java:25)
	at org.openarchitectureware.xtext.AbstractLanguageUtilities.parse(AbstractLanguageUtilities.java:47)
	at org.openarchitectureware.xtext.editor.marker.XtextResourceChangeListener.internalParse(XtextResourceChangeListener.java:198)
	at org.openarchitectureware.xtext.editor.marker.XtextResourceChangeListener.analyze(XtextResourceChangeListener.java:132)
	at org.openarchitectureware.xtext.editor.marker.XtextResourceChangeListener$2$1.execute(XtextResourceChangeListener.java:101)
	at org.eclipse.ui.actions.WorkspaceModifyOperation$1.run(WorkspaceModifyOperation.java:101)
	at org.eclipse.core.internal.resources.Workspace.run(Workspace.java:1737)
	at org.eclipse.ui.actions.WorkspaceModifyOperation.run(WorkspaceModifyOperation.java:113)
	at org.openarchitectureware.xtext.editor.marker.XtextResourceChangeListener$2.run(XtextResourceChangeListener.java:104)
	at org.eclipse.core.internal.jobs.Worker.run(Worker.java:58)
Caused by: java.lang.IllegalArgumentException: The 'no null' constraint is violated
	at org.eclipse.emf.common.util.BasicEList.validate(BasicEList.java:172)
	at org.eclipse.emf.ecore.util.EcoreEList.validate(EcoreEList.java:59)
	at org.eclipse.emf.common.util.BasicEList.addAllUnique(BasicEList.java:774)
	at org.eclipse.emf.common.notify.impl.NotifyingListImpl.doAddAllUnique(NotifyingListImpl.java:494)
	at org.eclipse.emf.common.notify.impl.NotifyingListImpl.addAllUnique(NotifyingListImpl.java:467)
	at org.eclipse.emf.common.notify.impl.NotifyingListImpl.addAllUnique(NotifyingListImpl.java:396)
	at org.eclipse.emf.common.util.BasicEList.addAll(BasicEList.java:688)
	at org.openarchitectureware.type.baseimpl.types.CollectionTypeImpl$7.evaluateInternal(CollectionTypeImpl.java:179)
	at org.openarchitectureware.type.baseimpl.OperationImpl.evaluate(OperationImpl.java:38)
	at org.openarchitectureware.expression.ast.OperationCall.evaluateInternal(OperationCall.java:81)
	at org.openarchitectureware.expression.ast.Expression.evaluate(Expression.java:42)
	... 19 more

Michal
_______________________________________________
gmt-dev mailing list
gmt-dev@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/gmt-dev


--

Sven Efftinge
Am Sophienhof 33
24941 Flensburg

mail : sven@xxxxxxxxxxx
fon  : +49 176 21769757



Back to the top