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
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)
	at org.eclipse.xtext.serializer.analysis.Context2NameFunction.getUniqueActionName(
	at org.eclipse.xtext.serializer.analysis.Context2NameFunction.getContextName(
	at org.eclipse.xtext.serializer.analysis.GrammarConstraintProvider.getConstraints(
	at org.eclipse.xtext.serializer.analysis.GrammarConstraintProvider.getConstraints(
	at org.eclipse.xtext.generator.serializer.SemanticSequencerUtil.getGrammarConstraints(
	at org.eclipse.xtext.generator.serializer.AbstractSemanticSequencer.getFileContents(
	at org.eclipse.xtext.generator.serializer.SerializerFragment.generate(
	at org.eclipse.xtext.generator.Xtend2GeneratorFragment.generate(
	at org.eclipse.xtext.generator.Xtend2GeneratorFragment.generate(
	at org.eclipse.xtext.generator.DefaultGeneratorFragment.generate(
	at org.eclipse.xtext.generator.CompositeGeneratorFragment.generate(
	at org.eclipse.xtext.generator.Generator.generate(
	at org.eclipse.xtext.generator.Generator.invokeInternal(
	at org.eclipse.emf.mwe.core.lib.AbstractWorkflowComponent.invoke(
	at org.eclipse.emf.mwe.core.lib.Mwe2Bridge.invoke(
	at org.eclipse.emf.mwe.core.lib.AbstractWorkflowComponent.invoke(
	at org.eclipse.emf.mwe2.runtime.workflow.AbstractCompositeWorkflowComponent.invoke(
	at org.eclipse.emf.mwe2.launch.runtime.Mwe2Launcher.main(

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
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}
	  	'class' name=ValidID ('<' typeParameters+=JvmTypeParameter (',' typeParameters+=JvmTypeParameter)* '>')?  
	   	("extends" extends=JvmParameterizedTypeReference)? 
	   	('implements' implements+=JvmParameterizedTypeReference (',' implements+=JvmParameterizedTypeReference)*)?'{'

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 Aug 04 06:20:35 GMT 2020

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

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

Back to the top