Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » NullPointer when generating parser
NullPointer when generating parser [message #1386288] Mon, 16 June 2014 11:39 Go to next message
Jan Rosczak is currently offline Jan RosczakFriend
Messages: 53
Registered: July 2009
Location: Hamburg, Germany
Member
I am using Xtext 2.6.1 and I have two grammars:

1. A lang grammar that is based on the Xtend grammar and basically limits the number of types in a file to one

2. A base grammar that extends my lang grammar adding some common parser rules I am going to need in other grammars later.

Now I can generate the parser etc. for my lang grammar without problem, but when I try to generate the parser for my base grammar I always get lots of the following exception:
[ERROR]: GeneratorException: (Element: -UNKNOWN-; Reported by: Generator)
	 java.lang.NullPointerException
	at org.eclipse.xtext.serializer.analysis.Context2NameFunction.getUniqueActionName(Context2NameFunction.java:59)
	at org.eclipse.xtext.serializer.analysis.Context2NameFunction.getContextName(Context2NameFunction.java:36)
	at org.eclipse.xtext.serializer.analysis.GrammarConstraintProvider.getConstraints(GrammarConstraintProvider.java:1376)
	at org.eclipse.xtext.serializer.analysis.GrammarConstraintProvider.getConstraints(GrammarConstraintProvider.java:1408)
	at org.eclipse.xtext.generator.serializer.SemanticSequencerUtil.getGrammarConstraints(SemanticSequencerUtil.java:113)
	at org.eclipse.xtext.generator.serializer.AbstractSemanticSequencer.getFileContents(AbstractSemanticSequencer.java:153)
	at org.eclipse.xtext.generator.serializer.SerializerFragment.generate(SerializerFragment.java:130)
	at org.eclipse.xtext.generator.Xtend2GeneratorFragment.generate(Xtend2GeneratorFragment.java:75)
	at org.eclipse.xtext.generator.Xtend2GeneratorFragment.generate(Xtend2GeneratorFragment.java:68)
	at org.eclipse.xtext.generator.DefaultGeneratorFragment.generate(DefaultGeneratorFragment.java:122)
	at org.eclipse.xtext.generator.CompositeGeneratorFragment.generate(CompositeGeneratorFragment.java:154)
	at org.eclipse.xtext.generator.Generator.generate(Generator.java:396)
	at org.eclipse.xtext.generator.Generator.invokeInternal(Generator.java:138)
	at org.eclipse.emf.mwe.core.lib.AbstractWorkflowComponent.invoke(AbstractWorkflowComponent.java:126)
	at org.eclipse.emf.mwe.core.lib.Mwe2Bridge.invoke(Mwe2Bridge.java:34)
	at org.eclipse.emf.mwe.core.lib.AbstractWorkflowComponent.invoke(AbstractWorkflowComponent.java:201)
	at org.eclipse.emf.mwe2.runtime.workflow.AbstractCompositeWorkflowComponent.invoke(AbstractCompositeWorkflowComponent.java:35)
	at org.eclipse.emf.mwe2.runtime.workflow.Workflow.run(Workflow.java:19)
	at org.eclipse.emf.mwe2.launch.runtime.Mwe2Runner.run(Mwe2Runner.java:102)
	at org.eclipse.emf.mwe2.launch.runtime.Mwe2Runner.run(Mwe2Runner.java:62)
	at org.eclipse.emf.mwe2.launch.runtime.Mwe2Runner.run(Mwe2Runner.java:52)
	at org.eclipse.emf.mwe2.launch.runtime.Mwe2Launcher.run(Mwe2Launcher.java:74)
	at org.eclipse.emf.mwe2.launch.runtime.Mwe2Launcher.main(Mwe2Launcher.java:35)


Any idea what might have caused this? Because I remember when my base grammar directly extended the Xbase grammar and everything could be generated.
Re: NullPointer when generating parser [message #1386318 is a reply to message #1386288] Mon, 16 June 2014 13:50 Go to previous message
Jan Rosczak is currently offline Jan RosczakFriend
Messages: 53
Registered: July 2009
Location: Hamburg, Germany
Member
I looked further into my grammars. In my lang grammer I have something like:

Type returns xtend::XtendTypeDeclaration :
	{xtend::XtendTypeDeclaration} annotations+=XAnnotation*   
	(
		{MyLangClass.annotationInfo = current}
		modifiers+=CommonModifier*
	  	'class' name=ValidID ('<' typeParameters+=JvmTypeParameter (',' typeParameters+=JvmTypeParameter)* '>')?  
	   	("extends" extends=JvmParameterizedTypeReference)? 
	   	('implements' implements+=JvmParameterizedTypeReference (',' implements+=JvmParameterizedTypeReference)*)?'{'
		   (members+=Member)*
	   	'}'
	)
;


Where the EObject MyLangClass directly extends the EObject XtendClass.

With this parser rule in the Lang grammar the generation of my base grammar fails. If I revert the parser rule to the rule in the Xtend grammar that is replacing {MyLangClass.annotationInfo} with {xtend::XtendClass) I can generate my base grammar just fine.

So why does the generator not recognize the {MyLangClass.annotationInfo) action correctly, it seems to not find a name for it?

[Updated on: Mon, 16 June 2014 13:53]

Report message to a moderator

Previous Topic:[Solved] How2 access top AST from Validator,Quickfix,Proposal
Next Topic:Scope of JvmDeclaredType
Goto Forum:
  


Current Time: Tue Jan 21 20:18:30 GMT 2020

Powered by FUDForum. Page generated in 0.01562 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top