Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » ambiguity in the grammar
ambiguity in the grammar [message #1053224] Fri, 03 May 2013 04:49 Go to next message
junior developer is currently offline junior developer
Messages: 335
Registered: January 2013
Senior Member
Hi all ,

I want to generate meta model from the grammar .Lookup element inheritance from the Field Element ,and Field element is inheritance from Content Unit .I have a ambiguity problem Sad

My grammar :

[size=4][color=red]ContentUnit returns C[/size]ontentUnit:[/color]
	ContentModel | WebApplication | SiteCollection | Web | List | SiteField | ContentType | [color=red][colo[/color]r=firebrick]Field[/color];

ContentModel returns ContentModel:
	'ContentModel'
	name=ID
	'{'
	'guID' '=' guID=STRING
	('description' '=' description=STRING)?
	ownedWebApplication=WebApplication
	'}';

WebApplication returns WebApplication:
	'WebApplication'
	name=ID
	'{'
	'guID' '=' guID=STRING
	('description' '=' description=STRING)?
	ownedSiteColection+=SiteCollection (ownedSiteColection+=SiteCollection)*
	'}';

SiteCollection returns SiteCollection:
	'SiteCollection'
	name=ID
	'{'
	'guID' '=' guID=STRING
	('description' '=' description=STRING)?
	ownedWeb=Web
	'}';

Web returns Web:
	'Web'
	name=ID
	'{'
	'guID' '=' guID=STRING
	('description' '=' description=STRING)?
	(ownedList+=List (ownedList+=List)*)?
	(ownedWeb+=Web (ownedWeb+=Web)*)?
	(ownedSiteField+=SiteField (ownedSiteField+=SiteField)*)?
	'}';

List returns List:
	'List'
	name=ID
	'{'
	'guID' '=' guID=STRING
	'type' '=' type=ListType
	('description' '=' description=STRING)?
	(ownedListField+=ListField (ownedListField+=ListField)*)?
	(ownedListContentType+=ListContentType (ownedListContentType+=ListContentType)*)?
	'}';

enum ListType returns ListType:
	Library | Custom | Discussion | Calendar | Task;

SiteField returns SiteField:
	SiteField_Impl | ListField | LookUp ;

ListField returns ListField:
	ListField_Impl | LookUp ;

ContentType returns ContentType:
	ListContentType | SiteContentType;

[size=4][color=red]Field ret[/size]urns Field:[/color]
	LookUp ;

SiteField_Impl returns SiteField:
	'SiteField'
	name=ID
	'{'
	'guID' '=' guID=STRING
	('description' '=' description=STRING)?
	'}';

ListField_Impl returns ListField:
	'ListField'
	name=ID
	'{'
	'guID' '=' guID=STRING
	('description' '=' description=STRING)?
	('parent' '=' parent=[SiteField|STRING])?
	'}';

ListContentType returns ListContentType:
	'ListContentType'
	name=ID
	'{'
	'guID' '=' guID=STRING
	('description' '=' description=STRING)?
	('group' '=' group=STRING)?
	('parentContentType' '=' parentContentType=[ContentType|STRING])?
	('parent' '=' parent=[SiteContentType|STRING])?
	('field' '=' '(' field+=[ListField|STRING] (field+=[ListField|STRING])* ')')?
	'}';

SiteContentType returns SiteContentType:
	'SiteContentType'
	name=ID
	'{'
	'guID' '=' guID=STRING
	('description' '=' description=STRING)?
	('group' '=' group=STRING)?
	('parentContentType' '=' parentContentType=[ContentType|STRING])?
	('field' '=' '(' field+=[SiteField|STRING] (field+=[SiteField|STRING])* ')')?
	'}';

enum Releationship returns Releationship:
	Association | Composition;

[size=4][size=3][color=red]LookUp retu[/size]rns LookUp:[/color][/size]
	'LookUp'
	name=ID
	'{'
	('guID' '=' guID=STRING)
	(required?='required')?
	(unlimitedLenghtInDocumentLibraries?='unlimitedLenghtInDocumentLibraries')?
	('description' '=' description=STRING)?
	('displayName' '=' displayName=STRING)?
	('group' '=' group=STRING)?
	('default' '=' default=STRING)?
	 ('releationship' '=' releationship=Releationship)
	('parent' '=' parent=[SiteField|STRING])?
	( 'contentType' '=' contentType=[ContentType|STRING])
	 ('showField' '=' showField=[Field|STRING])
	'}';




-----------------------------------------------------------------------------
I receive an warning and I con not generate language artifact
Error :


warning(200): ../com.unit.sharepoint.content/src-gen/com/unit/sharepoint/content/parser/antlr/internal/InternalContent.g:81:1: Decision can match input such as "'LookUp' RULE_ID '{' 'guID' '=' RULE_STRING 'required' 'unlimitedLenghtInDocumentLibraries' 'description' '=' RULE_STRING 'displayName' '=' RULE_STRING 'group' '=' RULE_STRING 'default' '=' RULE_STRING 'releationship' '=' 'Association' 'parent' '=' RULE_STRING 'contentType' '=' RULE_STRING 'showField' '=' RULE_STRING '}'" using multiple alternatives: 6, 8
As a result, alternative(s) 8 were disabled for that input
error(201): ../com.unit.sharepoint.content/src-gen/com/unit/sharepoint/content/parser/antlr/internal/InternalContent.g:81:1: The following alternatives can never be matched: 8

warning(200): ../com.unit.sharepoint.content/src-gen/com/unit/sharepoint/content/parser/antlr/internal/InternalContent.g:974:1: Decision can match input such as "'LookUp' RULE_ID '{' 'guID' '=' RULE_STRING 'required' 'unlimitedLenghtInDocumentLibraries' 'description' '=' RULE_STRING 'displayName' '=' RULE_STRING 'group' '=' RULE_STRING 'default' '=' RULE_STRING 'releationship' '=' 'Association' 'parent' '=' RULE_STRING 'contentType' '=' RULE_STRING 'showField' '=' RULE_STRING '}'" using multiple alternatives: 2, 3
As a result, alternative(s) 3 were disabled for that input
error(201): ../com.unit.sharepoint.content/src-gen/com/unit/sharepoint/content/parser/antlr/internal/InternalContent.g:974:1: The following alternatives can never be matched: 3

11693 [main] ERROR enerator.CompositeGeneratorFragment  - java.io.FileNotFoundException: ..\com.unit.sharepoint.content\src-gen\com\unit\sharepoint\content\parser\antlr\internal\InternalContentLexer.java (The system cannot find the file specified)
org.eclipse.emf.common.util.WrappedException: java.io.FileNotFoundException: ..\com.unit.sharepoint.content\src-gen\com\unit\sharepoint\content\parser\antlr\internal\InternalContentLexer.java (The system cannot find the file specified)
	at org.eclipse.xtext.util.Files.readFileIntoString(Files.java:129)
	at org.eclipse.xtext.generator.parser.antlr.AbstractAntlrGeneratorFragment.suppressWarningsImpl(AbstractAntlrGeneratorFragment.java:132)
	at org.eclipse.xtext.generator.parser.antlr.AbstractAntlrGeneratorFragment.suppressWarnings(AbstractAntlrGeneratorFragment.java:142)
	at org.eclipse.xtext.generator.parser.antlr.AbstractAntlrGeneratorFragment.suppressWarnings(AbstractAntlrGeneratorFragment.java:138)
	at org.eclipse.xtext.generator.parser.antlr.XtextAntlrGeneratorFragment.generate(XtextAntlrGeneratorFragment.java:49)
	at org.eclipse.xtext.generator.CompositeGeneratorFragment.generate(CompositeGeneratorFragment.java:92)
	at org.eclipse.xtext.generator.LanguageConfig.generate(LanguageConfig.java:113)
	at org.eclipse.xtext.generator.Generator.generate(Generator.java:361)
	at org.eclipse.xtext.generator.Generator.invokeInternal(Generator.java:128)
	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)
Caused by: java.io.FileNotFoundException: ..\com.unit.sharepoint.content\src-gen\com\unit\sharepoint\content\parser\antlr\internal\InternalContentLexer.java (The system cannot find the file specified)
	at java.io.FileInputStream.open(Native Method)
	at java.io.FileInputStream.<init>(Unknown Source)
	at java.io.FileInputStream.<init>(Unknown Source)
	at org.eclipse.xtext.util.Files.readFileIntoString(Files.java:126)
	... 18 more
11695 [main] INFO  or.validation.JavaValidatorFragment  - generating Java-based EValidator API
warning(200): ../com.unit.sharepoint.content.ui/src-gen/com/unit/sharepoint/content/ui/contentassist/antlr/internal/InternalContent.g:522:1: Decision can match input such as "'LookUp' RULE_ID '{' 'guID' '=' RULE_STRING 'required' 'unlimitedLenghtInDocumentLibraries' 'description' '=' RULE_STRING 'displayName' '=' RULE_STRING 'group' '=' RULE_STRING 'default' '=' RULE_STRING 'releationship' '=' 'Association' 'parent' '=' RULE_STRING 'contentType' '=' RULE_STRING 'showField' '=' RULE_STRING '}'" using multiple alternatives: 6, 8
As a result, alternative(s) 8 were disabled for that input
error(201): ../com.unit.sharepoint.content.ui/src-gen/com/unit/sharepoint/content/ui/contentassist/antlr/internal/InternalContent.g:522:1: The following alternatives can never be matched: 8

warning(200): ../com.unit.sharepoint.content.ui/src-gen/com/unit/sharepoint/content/ui/contentassist/antlr/internal/InternalContent.g:580:1: Decision can match input such as "'LookUp' RULE_ID '{' 'guID' '=' RULE_STRING 'required' 'unlimitedLenghtInDocumentLibraries' 'description' '=' RULE_STRING 'displayName' '=' RULE_STRING 'group' '=' RULE_STRING 'default' '=' RULE_STRING 'releationship' '=' 'Association' 'parent' '=' RULE_STRING 'contentType' '=' RULE_STRING 'showField' '=' RULE_STRING '}'" using multiple alternatives: 2, 3
As a result, alternative(s) 3 were disabled for that input
error(201): ../com.unit.sharepoint.content.ui/src-gen/com/unit/sharepoint/content/ui/contentassist/antlr/internal/InternalContent.g:580:1: The following alternatives can never be matched: 3

12908 [main] ERROR enerator.CompositeGeneratorFragment  - java.io.FileNotFoundException: ..\com.unit.sharepoint.content.ui\src-gen\com\unit\sharepoint\content\ui\contentassist\antlr\internal\InternalContentLexer.java (The system cannot find the file specified)
org.eclipse.emf.common.util.WrappedException: java.io.FileNotFoundException: ..\com.unit.sharepoint.content.ui\src-gen\com\unit\sharepoint\content\ui\contentassist\antlr\internal\InternalContentLexer.java (The system cannot find the file specified)
	at org.eclipse.xtext.util.Files.readFileIntoString(Files.java:129)
	at org.eclipse.xtext.generator.parser.antlr.AbstractAntlrGeneratorFragment.suppressWarningsImpl(AbstractAntlrGeneratorFragment.java:132)
	at org.eclipse.xtext.generator.parser.antlr.AbstractAntlrGeneratorFragment.suppressWarnings(AbstractAntlrGeneratorFragment.java:142)
	at org.eclipse.xtext.generator.parser.antlr.AbstractAntlrGeneratorFragment.suppressWarnings(AbstractAntlrGeneratorFragment.java:138)
	at org.eclipse.xtext.generator.parser.antlr.XtextAntlrUiGeneratorFragment.generate(XtextAntlrUiGeneratorFragment.java:53)
	at org.eclipse.xtext.generator.CompositeGeneratorFragment.generate(CompositeGeneratorFragment.java:92)
	at org.eclipse.xtext.generator.LanguageConfig.generate(LanguageConfig.java:113)
	at org.eclipse.xtext.generator.Generator.generate(Generator.java:361)
	at org.eclipse.xtext.generator.Generator.invokeInternal(Generator.java:128)
	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)
Caused by: java.io.FileNotFoundException: ..\com.unit.sharepoint.content.ui\src-gen\com\unit\sharepoint\content\ui\contentassist\antlr\internal\InternalContentLexer.java (The system cannot find the file specified)
	at java.io.FileInputStream.open(Native Method)
	at java.io.FileInputStream.<init>(Unknown Source)
	at java.io.FileInputStream.<init>(Unknown Source)
	at org.eclipse.xtext.util.Files.readFileIntoString(Files.java:126)
	... 18 more



Best Regardas

Re: ambiguity in the grammar [message #1053239 is a reply to message #1053224] Fri, 03 May 2013 06:23 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian Dietrich
Messages: 6198
Registered: July 2009
Senior Member
Hi,

the problem is clear: Everything can be a Lookup.

ContentUnit returns ContentUnit:
ContentModel | WebApplication | SiteCollection | Web | List | SiteField | ContentType | Field;

SiteField returns SiteField:
SiteField_Impl | ListField | LookUp ;

ListField returns ListField:
ListField_Impl | LookUp ;

ContentType returns ContentType:
ListContentType | SiteContentType;

Field returns Field:
LookUp ;
Re: ambiguity in the grammar [message #1053246 is a reply to message #1053239] Fri, 03 May 2013 07:22 Go to previous messageGo to next message
junior developer is currently offline junior developer
Messages: 335
Registered: January 2013
Senior Member
Hi Christian ,

Thank you for your help,did not realize this problem .my problem is solved now .

I have one question about this grammar :existing field relation in the SiteContentType and ListContentType.this field relations (terminal rule) shows unique false in the generated meta model,but I will use this meta model in the GMF tool.GMF tool wants to "unique =true" .How can I change this property from the grammar or I can customize it from the Xtext.

ListContentType returns ListContentType:
	'ListContentType'
	name=ID
	'{'
	'guID' '=' guID=STRING
	('description' '=' description=STRING)?
	('group' '=' group=STRING)?
	('parentContentType' '=' parentContentType=[ContentType|STRING])?
	('parent' '=' parent=[SiteContentType|STRING])?
	('field' '=' '(' field+=[ListField|STRING] (field+=[ListField|STRING])* ')')?
	'}';

SiteContentType returns SiteContentType:
	'SiteContentType'
	name=ID
	'{'
	'guID' '=' guID=STRING
	('description' '=' description=STRING)?
	('group' '=' group=STRING)?
	('parentContentType' '=' parentContentType=[ContentType|STRING])?
	('field' '=' '(' field+=[SiteField|STRING] (field+=[SiteField|STRING])* ')')?
	'}';



Thank you & Best regards
Re: ambiguity in the grammar [message #1053249 is a reply to message #1053246] Fri, 03 May 2013 07:35 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian Dietrich
Messages: 6198
Registered: July 2009
Senior Member
Hi,

the keywordS are
- manually maintained metamodel
- org.eclipse.xtext.xtext.ecoreInference.IXtext2EcorePostProcessor
Re: ambiguity in the grammar [message #1053252 is a reply to message #1053249] Fri, 03 May 2013 07:52 Go to previous messageGo to next message
junior developer is currently offline junior developer
Messages: 335
Registered: January 2013
Senior Member
Hi Christian ,

can i manualy change this property from meta-model ? If i change this prroperty and re create genmodel , Does

my DSL program is corrupted ?

Regards

[Updated on: Fri, 03 May 2013 07:55]

Report message to a moderator

Re: ambiguity in the grammar [message #1053254 is a reply to message #1053252] Fri, 03 May 2013 08:05 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian Dietrich
Messages: 6198
Registered: July 2009
Senior Member
no i mean you create the metamodel on your own in a separate project.
Re: ambiguity in the grammar [message #1053259 is a reply to message #1053254] Fri, 03 May 2013 08:14 Go to previous messageGo to next message
junior developer is currently offline junior developer
Messages: 335
Registered: January 2013
Senior Member
Hi ,

okey but I must use metamodel in the same xtext project because of synchronization with GMF. so xtext must create metamodel which gmf can accept.

And i dont understand how can i change
org.eclipse.xtext.xtext.ecoreInference.IXtext2EcorePostProcessor.

can u give me more information about this ?

Regards

Re: ambiguity in the grammar [message #1053260 is a reply to message #1053259] Fri, 03 May 2013 08:16 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian Dietrich
Messages: 6198
Registered: July 2009
Senior Member
It lets you change the ecore generated by xtext

http://christiandietrich.wordpress.com/2011/07/22/customizing-xtext-metamodel-inference-using-xtend2/
Re: ambiguity in the grammar [message #1053270 is a reply to message #1053260] Fri, 03 May 2013 09:20 Go to previous messageGo to next message
junior developer is currently offline junior developer
Messages: 335
Registered: January 2013
Senior Member
Hi Christian ,

Thank you for your help

Best Regards
Re: ambiguity in the grammar [message #1053550 is a reply to message #1053260] Mon, 06 May 2013 09:25 Go to previous messageGo to next message
junior developer is currently offline junior developer
Messages: 335
Registered: January 2013
Senior Member
Hi Christian ,

I want to generate abstract element .When I generate my grammar,Abstract ecore Class cerated
Can I solved abstract with IXtext2EcorePostProcessor .it is possible.


Christian Dietrich wrote on Fri, 03 May 2013 08:16
It lets you change the ecore generated by xtext

http://christiandietrich.wordpress.com/2011/07/22/customizing-xtext-metamodel-inference-using-xtend2/


Best regards
Re: ambiguity in the grammar [message #1053562 is a reply to message #1053550] Mon, 06 May 2013 10:25 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian Dietrich
Messages: 6198
Registered: July 2009
Senior Member
Manuiplulate create EClasses as you want
Re: ambiguity in the grammar [message #1053574 is a reply to message #1053562] Mon, 06 May 2013 10:58 Go to previous message
junior developer is currently offline junior developer
Messages: 335
Registered: January 2013
Senior Member
Hi Christian

Thank you for your help

Best regrads,
Previous Topic:Take an integer typed in the DSL and generate a java variable with it
Next Topic:Self-triggered Autocomplete
Goto Forum:
  


Current Time: Wed Aug 20 18:27:37 EDT 2014

Powered by FUDForum. Page generated in 0.02002 seconds