ambiguity in the grammar [message #1053224] |
Fri, 03 May 2013 08:49 |
junior developer Messages: 354 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
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 10:23 |
|
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 ;
Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
|
|
|
|
|
|
|
|
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.04817 seconds