Understanding Rule Priority [message #1723904] |
Fri, 19 February 2016 03:45 |
pranay roy Messages: 196 Registered: January 2016 |
Senior Member |
|
|
Hi ,
This is my grammar.
grammar org.xtext.example.mydsl.EinDsl with org.eclipse.xtext.common.Terminals
generate einDsl "http://www.xtext.org/example/mydsl/EinDsl"
Model:
greetings=Query;
Query:
(key=QTypekeyWord)? (measure=MeasureList) groupBy=GroupBy ;
QTypekeyWord:
qKeyword='plot'
;
MeasureList : names+=Measure ("and" names+=Measure)*;
Measure:ID+;
Dimension:
dimensions+=ID+
;
DimensionValue:
value=ID+
;
TimeGroupList:
timeGroupList+= TimeGroup ("by" timeGroups+=TimeGroup)*
;
DimensionGroupList:
dimensionGroups+= Dimension ("by" dimensionGroups+=Dimension)*
;
GroupBy:
(("by" dimGroups=DimensionGroupList) ?& ("by" timeGroups=TimeGroupList))
;
TimeGroup:
timeGroup= 'month'|'year'|'quarter'|'day'
;
I wish to understand the rule priority for Two Categories.
Two Category
- In group by I can have
- Time group
- Dimension group
- These categories can be present in any order
- Example :year and month are from Time Group Category , country and region are from dimension category.
- plot profit by year by country
- plot profit by country by year
- plot profit by year by month
- plot profit by country by region
- In the grammar I have dimension defined as ID while TimeGroup defined with specific words.
- When I fire content assist
- It works as expected and suggests me correctly for
- "plot profit by m " -->month
- "plot profit by year by m "--> month
- "plot profit by country by y " -->year
- While Content assist works as expected ,The test cases fails to identify the correct type
- This first test case
- "plot profit by country by month" is successful to identify country as category and month as time group
- While in another test case "plot profit by month" fails to group "month" as time group ,this is categorized as dimension
- I understand that dimension is ID type and can be matched to "month"
- How can I prioritise the rule matching for "month" for TimeGroup
- At the same time how does first test pass and match corretly. and second one fails while in all the cases I get correct content assist.
Please suggest.
[Updated on: Fri, 19 February 2016 04:42] Report message to a moderator
|
|
|
Re: Understanding Rule Priority [message #1723910 is a reply to message #1723904] |
Fri, 19 February 2016 04:45 |
|
hi,
neither your grammar nor your observations make sense to me
if you generate the grammar you get hints that your grammar is ambigous.
this is bad.
warning(200): ../org.xtext.example.mydsl1/src-gen/org/xtext/example/mydsl1/parser/antlr/internal/InternalMyDsl.g:389:3: Decision can match input such as "'by' 'year'" using multiple alternatives: 1, 2
As a result, alternative(s) 2 were disabled for that input
Semantic predicates were present but were hidden by actions.
warning(200): ../org.xtext.example.mydsl1/src-gen/org/xtext/example/mydsl1/parser/antlr/internal/InternalMyDsl.g:389:3: Decision can match input such as "'by' 'quarter'" using multiple alternatives: 1, 2
As a result, alternative(s) 2 were disabled for that input
Semantic predicates were present but were hidden by actions.
warning(200): ../org.xtext.example.mydsl1/src-gen/org/xtext/example/mydsl1/parser/antlr/internal/InternalMyDsl.g:389:3: Decision can match input such as "'by' 'day'" using multiple alternatives: 1, 2
As a result, alternative(s) 2 were disabled for that input
Semantic predicates were present but were hidden by actions.
warning(200): ../org.xtext.example.mydsl1/src-gen/org/xtext/example/mydsl1/parser/antlr/internal/InternalMyDsl.g:389:3: Decision can match input such as "'by' 'month'" using multiple alternatives: 1, 2
As a result, alternative(s) 2 were disabled for that input
Semantic predicates were present but were hidden by actions.
warning(200): ../org.xtext.example.mydsl1/src-gen/org/xtext/example/mydsl1/parser/antlr/internal/InternalMyDsl.g:452:3: Decision can match input such as "'by' RULE_ID" using multiple alternatives: 1, 2
As a result, alternative(s) 2 were disabled for that input
Semantic predicates were present but were hidden by actions.
warning(200): ../org.xtext.example.mydsl1.ide/src-gen/org/xtext/example/mydsl1/ide/contentassist/antlr/internal/InternalMyDsl.g:583:34: Decision can match input such as "'by' 'month'" using multiple alternatives: 1, 2
As a result, alternative(s) 2 were disabled for that input
Semantic predicates were present but were hidden by actions.
warning(200): ../org.xtext.example.mydsl1.ide/src-gen/org/xtext/example/mydsl1/ide/contentassist/antlr/internal/InternalMyDsl.g:583:34: Decision can match input such as "'by' 'quarter'" using multiple alternatives: 1, 2
As a result, alternative(s) 2 were disabled for that input
Semantic predicates were present but were hidden by actions.
warning(200): ../org.xtext.example.mydsl1.ide/src-gen/org/xtext/example/mydsl1/ide/contentassist/antlr/internal/InternalMyDsl.g:583:34: Decision can match input such as "'by' 'year'" using multiple alternatives: 1, 2
As a result, alternative(s) 2 were disabled for that input
Semantic predicates were present but were hidden by actions.
warning(200): ../org.xtext.example.mydsl1.ide/src-gen/org/xtext/example/mydsl1/ide/contentassist/antlr/internal/InternalMyDsl.g:583:34: Decision can match input such as "'by' 'day'" using multiple alternatives: 1, 2
As a result, alternative(s) 2 were disabled for that input
Semantic predicates were present but were hidden by actions.
warning(200): ../org.xtext.example.mydsl1.ide/src-gen/org/xtext/example/mydsl1/ide/contentassist/antlr/internal/InternalMyDsl.g:691:39: Decision can match input such as "'by' RULE_ID" using multiple alternatives: 1, 2
As a result, alternative(s) 2 were disabled for that input
Semantic predicates were present but were hidden by actions.
then your grammar does not allow to mix times and dimensions
(once it is a kind of list it stays in that kind)
then you have to make sure that the priorities of assignments and or are handled correct
Model:
greetings=Query;
Query:
(key=QTypekeyWord)? (measure=MeasureList) groupBy=GroupList ;
QTypekeyWord:
qKeyword='plot'
;
MeasureList : names+=Measure ("and" names+=Measure)*;
Measure:ID+;
Dimension:
dimensions+=ID+
;
GroupList:
"by" (timeGroupList+=TimeGroup|dimensionGroups+= Dimension) ("by" (timeGroups+=TimeGroup|dimensionGroups+= Dimension))*
;
TimeGroup:
timeGroup=('month'|'year'|'quarter'|'day')
;
Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
|
|
|
|
Re: Understanding Rule Priority [message #1723915 is a reply to message #1723911] |
Fri, 19 February 2016 05:02 |
|
hi,
i did just a run as workflow in eclipse.
if i do a maven clean install i get
[INFO] --- exec-maven-plugin:1.4.0:java (mwe2Launcher) @ org.xtext.example.mydsl2 ---
0 [org.eclipse.emf.mwe2.launch.runtime.Mwe2Launcher.main()] INFO text.xtext.generator.XtextGenerator - Initializing Xtext generator
Feb 19, 2016 6:01:47 AM org.eclipse.emf.mwe.utils.StandaloneSetup addRegisterGeneratedEPackage
INFORMATION: Adding generated EPackage 'org.eclipse.xtext.common.types.TypesPackage'
Feb 19, 2016 6:01:47 AM org.eclipse.emf.mwe.utils.StandaloneSetup registerMapping
WARNUNG: Skipping conflicting project maven at 'archive:file:/Users/dietrich/.m2/repository/org/apache/maven/maven-error-diagnostics/2.2.1/maven-error-diagnostics-2.2.1.jar!/' and using 'archive:file:/Users/dietrich/.m2/repository/org/apache/maven/maven-settings/2.2.1/maven-settings-2.2.1.jar!/' instead.
Feb 19, 2016 6:01:47 AM org.eclipse.emf.mwe.utils.StandaloneSetup registerMapping
WARNUNG: Skipping conflicting project maven at 'archive:file:/Users/dietrich/.m2/repository/org/apache/maven/maven-settings/2.2.1/maven-settings-2.2.1.jar!/' and using 'archive:file:/Users/dietrich/.m2/repository/org/apache/maven/maven-artifact-manager/2.2.1/maven-artifact-manager-2.2.1.jar!/' instead.
Feb 19, 2016 6:01:47 AM org.eclipse.emf.mwe.utils.StandaloneSetup registerMapping
WARNUNG: Skipping conflicting project maven at 'archive:file:/Users/dietrich/.m2/repository/org/apache/maven/maven-artifact-manager/2.2.1/maven-artifact-manager-2.2.1.jar!/' and using 'archive:file:/Users/dietrich/.m2/repository/org/apache/maven/maven-core/2.2.1/maven-core-2.2.1.jar!/' instead.
Feb 19, 2016 6:01:47 AM org.eclipse.emf.mwe.utils.StandaloneSetup registerMapping
WARNUNG: Skipping conflicting project maven at 'archive:file:/Users/dietrich/.m2/repository/org/apache/maven/maven-core/2.2.1/maven-core-2.2.1.jar!/' and using 'archive:file:/Users/dietrich/.m2/repository/org/apache/maven/maven-project/2.2.1/maven-project-2.2.1.jar!/' instead.
Feb 19, 2016 6:01:47 AM org.eclipse.emf.mwe.utils.StandaloneSetup registerMapping
WARNUNG: Skipping conflicting project maven at 'archive:file:/Users/dietrich/.m2/repository/org/apache/maven/maven-project/2.2.1/maven-project-2.2.1.jar!/' and using 'archive:file:/Users/dietrich/.m2/repository/org/apache/maven/maven-plugin-api/2.2.1/maven-plugin-api-2.2.1.jar!/' instead.
Feb 19, 2016 6:01:47 AM org.eclipse.emf.mwe.utils.StandaloneSetup registerMapping
WARNUNG: Skipping conflicting project maven at 'archive:file:/Users/dietrich/.m2/repository/org/apache/maven/maven-plugin-api/2.2.1/maven-plugin-api-2.2.1.jar!/' and using 'archive:file:/Users/dietrich/.m2/repository/org/apache/maven/maven-repository-metadata/2.2.1/maven-repository-metadata-2.2.1.jar!/' instead.
Feb 19, 2016 6:01:47 AM org.eclipse.emf.mwe.utils.StandaloneSetup registerMapping
WARNUNG: Skipping conflicting project maven at 'archive:file:/Users/dietrich/.m2/repository/org/apache/maven/maven-repository-metadata/2.2.1/maven-repository-metadata-2.2.1.jar!/' and using 'archive:file:/Users/dietrich/.m2/repository/org/apache/maven/maven-toolchain/1.0/maven-toolchain-1.0.jar!/' instead.
Feb 19, 2016 6:01:47 AM org.eclipse.emf.mwe.utils.StandaloneSetup registerMapping
WARNUNG: Skipping conflicting project maven at 'archive:file:/Users/dietrich/.m2/repository/org/apache/maven/maven-toolchain/1.0/maven-toolchain-1.0.jar!/' and using 'archive:file:/Users/dietrich/.m2/repository/org/apache/maven/maven-artifact/2.2.1/maven-artifact-2.2.1.jar!/' instead.
Feb 19, 2016 6:01:47 AM org.eclipse.emf.mwe.utils.StandaloneSetup registerMapping
WARNUNG: Skipping conflicting project maven at 'archive:file:/Users/dietrich/.m2/repository/org/apache/maven/maven-artifact/2.2.1/maven-artifact-2.2.1.jar!/' and using 'archive:file:/Users/dietrich/.m2/repository/org/apache/maven/maven-plugin-descriptor/2.2.1/maven-plugin-descriptor-2.2.1.jar!/' instead.
Feb 19, 2016 6:01:47 AM org.eclipse.emf.mwe.utils.StandaloneSetup registerMapping
WARNUNG: Skipping conflicting project maven at 'archive:file:/Users/dietrich/.m2/repository/org/apache/maven/maven-plugin-descriptor/2.2.1/maven-plugin-descriptor-2.2.1.jar!/' and using 'archive:file:/Users/dietrich/.m2/repository/org/apache/maven/maven-monitor/2.2.1/maven-monitor-2.2.1.jar!/' instead.
Feb 19, 2016 6:01:47 AM org.eclipse.emf.mwe.utils.StandaloneSetup registerMapping
WARNUNG: Skipping conflicting project maven at 'archive:file:/Users/dietrich/.m2/repository/org/apache/maven/maven-monitor/2.2.1/maven-monitor-2.2.1.jar!/' and using 'archive:file:/Users/dietrich/.m2/repository/org/apache/maven/maven-profile/2.2.1/maven-profile-2.2.1.jar!/' instead.
Feb 19, 2016 6:01:47 AM org.eclipse.emf.mwe.utils.StandaloneSetup registerMapping
WARNUNG: Skipping conflicting project plexus at 'archive:file:/Users/dietrich/.m2/repository/org/codehaus/plexus/plexus-interactivity-api/1.0-alpha-4/plexus-interactivity-api-1.0-alpha-4.jar!/' and using 'archive:file:/Users/dietrich/.m2/repository/org/sonatype/plexus/plexus-sec-dispatcher/1.3/plexus-sec-dispatcher-1.3.jar!/' instead.
Feb 19, 2016 6:01:47 AM org.eclipse.emf.mwe.utils.StandaloneSetup registerMapping
WARNUNG: Skipping conflicting project maven at 'archive:file:/Users/dietrich/.m2/repository/org/apache/maven/maven-profile/2.2.1/maven-profile-2.2.1.jar!/' and using 'archive:file:/Users/dietrich/.m2/repository/org/apache/maven/reporting/maven-reporting-api/2.2.1/maven-reporting-api-2.2.1.jar!/' instead.
Feb 19, 2016 6:01:47 AM org.eclipse.emf.mwe.utils.StandaloneSetup registerMapping
WARNUNG: Skipping conflicting project maven at 'archive:file:/Users/dietrich/.m2/repository/org/apache/maven/reporting/maven-reporting-api/2.2.1/maven-reporting-api-2.2.1.jar!/' and using 'archive:file:/Users/dietrich/.m2/repository/org/apache/maven/maven-plugin-parameter-documenter/2.2.1/maven-plugin-parameter-documenter-2.2.1.jar!/' instead.
Feb 19, 2016 6:01:47 AM org.eclipse.emf.mwe.utils.StandaloneSetup registerMapping
WARNUNG: Skipping conflicting project plexus at 'archive:file:/Users/dietrich/.m2/repository/org/sonatype/plexus/plexus-sec-dispatcher/1.3/plexus-sec-dispatcher-1.3.jar!/' and using 'archive:file:/Users/dietrich/.m2/repository/org/codehaus/plexus/plexus-utils/3.0.20/plexus-utils-3.0.20.jar!/' instead.
Feb 19, 2016 6:01:47 AM org.eclipse.emf.mwe.utils.StandaloneSetup registerMapping
WARNUNG: Skipping conflicting project maven at 'archive:file:/Users/dietrich/.m2/repository/org/apache/maven/maven-plugin-parameter-documenter/2.2.1/maven-plugin-parameter-documenter-2.2.1.jar!/' and using 'archive:file:/Users/dietrich/.m2/repository/org/apache/maven/maven-model/2.2.1/maven-model-2.2.1.jar!/' instead.
Feb 19, 2016 6:01:47 AM org.eclipse.emf.mwe.utils.StandaloneSetup registerMapping
WARNUNG: Skipping conflicting project plexus at 'archive:file:/Users/dietrich/.m2/repository/org/codehaus/plexus/plexus-utils/3.0.20/plexus-utils-3.0.20.jar!/' and using 'archive:file:/Users/dietrich/.m2/repository/org/codehaus/plexus/plexus-interpolation/1.11/plexus-interpolation-1.11.jar!/' instead.
Feb 19, 2016 6:01:47 AM org.eclipse.emf.mwe.utils.StandaloneSetup registerMapping
WARNUNG: Skipping conflicting project doxia at 'archive:file:/Users/dietrich/.m2/repository/org/apache/maven/doxia/doxia-sink-api/1.1/doxia-sink-api-1.1.jar!/' and using 'archive:file:/Users/dietrich/.m2/repository/org/apache/maven/doxia/doxia-logging-api/1.1/doxia-logging-api-1.1.jar!/' instead.
Feb 19, 2016 6:01:47 AM org.eclipse.emf.mwe.utils.StandaloneSetup registerMapping
WARNUNG: Skipping conflicting project plexus at 'archive:file:/Users/dietrich/.m2/repository/org/codehaus/plexus/plexus-interpolation/1.11/plexus-interpolation-1.11.jar!/' and using 'archive:file:/Users/dietrich/.m2/repository/org/sonatype/plexus/plexus-cipher/1.4/plexus-cipher-1.4.jar!/' instead.
Feb 19, 2016 6:01:47 AM org.eclipse.emf.mwe.utils.StandaloneSetup registerMapping
WARNUNG: Skipping conflicting project maven at 'archive:file:/Users/dietrich/.m2/repository/org/apache/maven/maven-model/2.2.1/maven-model-2.2.1.jar!/' and using 'archive:file:/Users/dietrich/.m2/repository/org/apache/maven/maven-plugin-registry/2.2.1/maven-plugin-registry-2.2.1.jar!/' instead.
Feb 19, 2016 6:01:47 AM org.eclipse.emf.mwe.utils.StandaloneSetup registerMapping
WARNUNG: Skipping conflicting project plexus at 'archive:file:/Users/dietrich/.m2/repository/org/sonatype/plexus/plexus-cipher/1.4/plexus-cipher-1.4.jar!/' and using 'archive:file:/Users/dietrich/.m2/repository/org/codehaus/plexus/plexus-container-default/1.0-alpha-9-stable-1/plexus-container-default-1.0-alpha-9-stable-1.jar!/' instead.
Feb 19, 2016 6:01:47 AM org.eclipse.emf.mwe.utils.StandaloneSetup registerMapping
WARNUNG: Skipping conflicting project antlr at 'archive:file:/Users/dietrich/.m2/repository/org/antlr/antlr-runtime/3.2/antlr-runtime-3.2.jar!/' and using 'archive:file:/Users/dietrich/.m2/repository/org/xtext/antlr-generator/3.2.1/antlr-generator-3.2.1.jar!/' instead.
Feb 19, 2016 6:01:47 AM org.eclipse.emf.mwe.utils.StandaloneSetup addProjectMapping
INFORMATION: Registering project org.xtext.example.mydsl2 at 'file:/Users/dietrich/Documents/workspacex29x2xxxx23/org.xtext.example.mydsl2.parent/org.xtext.example.mydsl2/'
Feb 19, 2016 6:01:47 AM org.eclipse.emf.mwe.utils.StandaloneSetup addProjectMapping
INFORMATION: Registering project org.xtext.example.mydsl2 at 'file:/Users/dietrich/Documents/workspacex29x2xxxx23/org.xtext.example.mydsl2.parent/org.xtext.example.mydsl2/'
Feb 19, 2016 6:01:47 AM org.eclipse.emf.mwe.utils.StandaloneSetup addProjectMapping
INFORMATION: Registering project org.xtext.example.mydsl2.ide at 'file:/Users/dietrich/Documents/workspacex29x2xxxx23/org.xtext.example.mydsl2.parent/org.xtext.example.mydsl2.ide/'
Feb 19, 2016 6:01:47 AM org.eclipse.emf.mwe.utils.StandaloneSetup addProjectMapping
INFORMATION: Registering project org.xtext.example.mydsl2.web at 'file:/Users/dietrich/Documents/workspacex29x2xxxx23/org.xtext.example.mydsl2.parent/org.xtext.example.mydsl2.web/'
Feb 19, 2016 6:01:47 AM org.eclipse.emf.mwe.utils.StandaloneSetup setResourceSet
INFORMATION: Using resourceSet registry. The registered Packages will not be registered in the global EPackage.Registry.INSTANCE!
Feb 19, 2016 6:01:47 AM org.eclipse.emf.mwe.utils.GenModelHelper registerGenModel
INFORMATION: Registered GenModel 'http://www.eclipse.org/Xtext/Xbase/XAnnotations' from 'platform:/resource/org.eclipse.xtext.xbase/model/Xbase.genmodel'
Feb 19, 2016 6:01:47 AM org.eclipse.emf.mwe.utils.GenModelHelper registerGenModel
INFORMATION: Registered GenModel 'http://www.eclipse.org/xtext/xbase/Xtype' from 'platform:/resource/org.eclipse.xtext.xbase/model/Xbase.genmodel'
Feb 19, 2016 6:01:47 AM org.eclipse.emf.mwe.utils.GenModelHelper registerGenModel
INFORMATION: Registered GenModel 'http://www.eclipse.org/xtext/xbase/Xbase' from 'platform:/resource/org.eclipse.xtext.xbase/model/Xbase.genmodel'
Feb 19, 2016 6:01:47 AM org.eclipse.emf.mwe.utils.GenModelHelper registerGenModel
INFORMATION: Registered GenModel 'http://www.eclipse.org/xtext/common/JavaVMTypes' from 'platform:/resource/org.eclipse.xtext.common.types/model/JavaVMTypes.genmodel'
745 [org.eclipse.emf.mwe2.launch.runtime.Mwe2Launcher.main()] INFO text.xtext.generator.XtextGenerator - Generating org.xtext.example.mydsl2.MyDsl
2219 [org.eclipse.emf.mwe2.launch.runtime.Mwe2Launcher.main()] INFO nerator.ecore.EMFGeneratorFragment2 - Generating EMF model code
Feb 19, 2016 6:01:49 AM org.eclipse.emf.mwe.utils.GenModelHelper registerGenModel
INFORMATION: Registered GenModel 'http://www.xtext.org/example/mydsl2/MyDsl' from 'platform:/resource/org.xtext.example.mydsl2/model/generated/MyDsl.genmodel'
warning(200): //Users/dietrich/Documents/workspacex29x2xxxx23/org.xtext.example.mydsl2.parent/org.xtext.example.mydsl2/../org.xtext.example.mydsl2/src/main/xtext-gen/org/xtext/example/mydsl2/parser/antlr/internal/InternalMyDsl.g:389:3: Decision can match input such as "'by' 'year'" using multiple alternatives: 1, 2
As a result, alternative(s) 2 were disabled for that input
Semantic predicates were present but were hidden by actions.
warning(200): //Users/dietrich/Documents/workspacex29x2xxxx23/org.xtext.example.mydsl2.parent/org.xtext.example.mydsl2/../org.xtext.example.mydsl2/src/main/xtext-gen/org/xtext/example/mydsl2/parser/antlr/internal/InternalMyDsl.g:389:3: Decision can match input such as "'by' 'quarter'" using multiple alternatives: 1, 2
As a result, alternative(s) 2 were disabled for that input
Semantic predicates were present but were hidden by actions.
warning(200): //Users/dietrich/Documents/workspacex29x2xxxx23/org.xtext.example.mydsl2.parent/org.xtext.example.mydsl2/../org.xtext.example.mydsl2/src/main/xtext-gen/org/xtext/example/mydsl2/parser/antlr/internal/InternalMyDsl.g:389:3: Decision can match input such as "'by' 'day'" using multiple alternatives: 1, 2
As a result, alternative(s) 2 were disabled for that input
Semantic predicates were present but were hidden by actions.
warning(200): //Users/dietrich/Documents/workspacex29x2xxxx23/org.xtext.example.mydsl2.parent/org.xtext.example.mydsl2/../org.xtext.example.mydsl2/src/main/xtext-gen/org/xtext/example/mydsl2/parser/antlr/internal/InternalMyDsl.g:389:3: Decision can match input such as "'by' 'month'" using multiple alternatives: 1, 2
As a result, alternative(s) 2 were disabled for that input
Semantic predicates were present but were hidden by actions.
warning(200): //Users/dietrich/Documents/workspacex29x2xxxx23/org.xtext.example.mydsl2.parent/org.xtext.example.mydsl2/../org.xtext.example.mydsl2/src/main/xtext-gen/org/xtext/example/mydsl2/parser/antlr/internal/InternalMyDsl.g:452:3: Decision can match input such as "'by' RULE_ID" using multiple alternatives: 1, 2
As a result, alternative(s) 2 were disabled for that input
Semantic predicates were present but were hidden by actions.
warning(200): //Users/dietrich/Documents/workspacex29x2xxxx23/org.xtext.example.mydsl2.parent/org.xtext.example.mydsl2/../org.xtext.example.mydsl2.ide/src/main/xtext-gen/org/xtext/example/mydsl2/ide/contentassist/antlr/internal/InternalMyDsl.g:583:34: Decision can match input such as "'by' 'month'" using multiple alternatives: 1, 2
As a result, alternative(s) 2 were disabled for that input
Semantic predicates were present but were hidden by actions.
warning(200): //Users/dietrich/Documents/workspacex29x2xxxx23/org.xtext.example.mydsl2.parent/org.xtext.example.mydsl2/../org.xtext.example.mydsl2.ide/src/main/xtext-gen/org/xtext/example/mydsl2/ide/contentassist/antlr/internal/InternalMyDsl.g:583:34: Decision can match input such as "'by' 'quarter'" using multiple alternatives: 1, 2
As a result, alternative(s) 2 were disabled for that input
Semantic predicates were present but were hidden by actions.
warning(200): //Users/dietrich/Documents/workspacex29x2xxxx23/org.xtext.example.mydsl2.parent/org.xtext.example.mydsl2/../org.xtext.example.mydsl2.ide/src/main/xtext-gen/org/xtext/example/mydsl2/ide/contentassist/antlr/internal/InternalMyDsl.g:583:34: Decision can match input such as "'by' 'year'" using multiple alternatives: 1, 2
As a result, alternative(s) 2 were disabled for that input
Semantic predicates were present but were hidden by actions.
warning(200): //Users/dietrich/Documents/workspacex29x2xxxx23/org.xtext.example.mydsl2.parent/org.xtext.example.mydsl2/../org.xtext.example.mydsl2.ide/src/main/xtext-gen/org/xtext/example/mydsl2/ide/contentassist/antlr/internal/InternalMyDsl.g:583:34: Decision can match input such as "'by' 'day'" using multiple alternatives: 1, 2
As a result, alternative(s) 2 were disabled for that input
Semantic predicates were present but were hidden by actions.
warning(200): //Users/dietrich/Documents/workspacex29x2xxxx23/org.xtext.example.mydsl2.parent/org.xtext.example.mydsl2/../org.xtext.example.mydsl2.ide/src/main/xtext-gen/org/xtext/example/mydsl2/ide/contentassist/antlr/internal/InternalMyDsl.g:691:39: Decision can match input such as "'by' RULE_ID" using multiple alternatives: 1, 2
As a result, alternative(s) 2 were disabled for that input
Semantic predicates were present but were hidden by actions.
3968 [org.eclipse.emf.mwe2.launch.runtime.Mwe2Launcher.main()] INFO text.xtext.generator.XtextGenerator - Generating common infrastructure
3969 [org.eclipse.emf.mwe2.launch.runtime.Mwe2Launcher.main()] INFO .emf.mwe2.runtime.workflow.Workflow - Done.
[INFO]
[INFO] --- xtend-maven-plugin:2.9.1:compile (default) @ org.xtext.example.mydsl2 ---
[INFO] Downloading: https://oss.sonatype.org/content/repositories/snapshots/org/eclipse/xtend/org.eclipse.xtend.core/maven-metadata.xml
did you do any customizations to your workflow?
Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
|
|
|
|
|
Re: Understanding Rule Priority [message #1723926 is a reply to message #1723917] |
Fri, 19 February 2016 06:43 |
|
You should further simplify your grammar, as there are a lot of unnecessary AST nodes created.
Here is how I would write it:
Query:
key?='plot'? names+=ID ("and" names+=ID)* ('by' groupBy+=TimeOrDimension)+;
TimeOrDimension:
ID|'month'|'year'|'quarter'|'day'
;
This way, not only the grammar but also the resulting AST will be smaller and simpler.
|
|
|
|
|
|
|
|
|
|
Re: Understanding Rule Priority [message #1723944 is a reply to message #1723942] |
Fri, 19 February 2016 08:06 |
|
In your initial grammar there was no distinction between the values from the parsing perspective it would only be stored in two different lists.
As an effect you will loose the ordering information. If you want to keep having two different lists, than just do it like you did before.
e.g.
Query:
key?='plot'? names+=ID ("and" names+=ID)* ('by' (time+=Time | dimension+=ID))+;
Time:
'month'|'year'|'quarter'|'day';
|
|
|
|
|
|
|
|
Re: Understanding Rule Priority [message #1724177 is a reply to message #1724174] |
Mon, 22 February 2016 07:12 |
pranay roy Messages: 196 Registered: January 2016 |
Senior Member |
|
|
This is my modified grammar (including your changes). I wish to understand the ambiguity issue. This could be a simple thing(by my addition) . But I wish to understand why?
grammar org.xtext.example.mydsl.EinDsl with org.eclipse.xtext.common.Terminals
generate einDsl "http://www.xtext.org/example/mydsl/EinDsl"
Model:
greetings=Query;
Query:
(key=QTypekeyWord)? (aggregation=Aggregation)? (measure=MeasureList) ((groupBy=GroupList)? &(condition=Condtition)? &(range=Transition)?) ;
QTypekeyWord:
qKeyword='plot'
;
Aggregation:
agg=('average'|'number of'|'total')
;
Condtition:
con+='for' dimVal=DimensionValue 'as' dim=Dimension ('and' dimValue=DimensionValue 'as' dimen=Dimension)*
;
MeasureList : names+=Measure ("and" names+=Measure)*;
Measure:ID+;
Dimension:
dimensions+=ID+
;
DimensionValue:
value=ID+
;
GroupList:
"by" (timeGroupList+=TimeGroup|dimensionGroups+= Dimension) ("by" (timeGroups+=TimeGroup|dimensionGroups+= Dimension))*
;
Transition:
'from' dateStart=Date 'to' dateEnd=Date
;
TimeGroup:
timeGroup=('month'|'year'|'quarter'|'day'|'week')
;
Date:
d=Day m=Month y=Year ;
Day : INT ;
Month : 'Jan'|'Feb'|'Mar'|'Apr' ;
Year : INT ;
[Updated on: Mon, 22 February 2016 07:12] Report message to a moderator
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|