Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Understanding Rule Priority
Understanding Rule Priority [message #1723904] Fri, 19 February 2016 03:45 Go to next message
pranay roy is currently offline pranay royFriend
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 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14062
Registered: July 2009
Senior Member
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')
;


Need professional support for Xtext, Xpand, EMF?
Go to: https://www.itemis.com/en/it-services/methods-and-tools/xtext
Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Understanding Rule Priority [message #1723911 is a reply to message #1723910] Fri, 19 February 2016 04:49 Go to previous messageGo to next message
pranay roy is currently offline pranay royFriend
Messages: 196
Registered: January 2016
Senior Member
I am very new to this. Could you direct me to a good resource or documentation about writing in a better way. I did not get any hint when I did mvn clean install. Do I need to activate.?

[Updated on: Fri, 19 February 2016 04:53]

Report message to a moderator

Re: Understanding Rule Priority [message #1723915 is a reply to message #1723911] Fri, 19 February 2016 05:02 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14062
Registered: July 2009
Senior Member
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?


Need professional support for Xtext, Xpand, EMF?
Go to: https://www.itemis.com/en/it-services/methods-and-tools/xtext
Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Understanding Rule Priority [message #1723917 is a reply to message #1723915] Fri, 19 February 2016 05:06 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14062
Registered: July 2009
Senior Member
p.s.

i dont know if there is a documentation that handles that in details besides

https://www.eclipse.org/Xtext/documentation/301_grammarlanguage.html

and lorenzo bettinis book "Implementing Domain-Specific Languages with Xtext and Xtend " which targets Xtext <= 2.9 and is currently updated


Need professional support for Xtext, Xpand, EMF?
Go to: https://www.itemis.com/en/it-services/methods-and-tools/xtext
Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Understanding Rule Priority [message #1723925 is a reply to message #1723917] Fri, 19 February 2016 06:38 Go to previous messageGo to next message
pranay roy is currently offline pranay royFriend
Messages: 196
Registered: January 2016
Senior Member
Thank you for your help on this Smile Smile . How can I get over this warning message. I think ,text has multiple matching with ID and TimeGroup names .!
Re: Understanding Rule Priority [message #1723926 is a reply to message #1723917] Fri, 19 February 2016 06:43 Go to previous messageGo to next message
Sven Efftinge is currently offline Sven EfftingeFriend
Messages: 83
Registered: January 2016
Location: Kiel
Member

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 #1723928 is a reply to message #1723926] Fri, 19 February 2016 06:49 Go to previous messageGo to next message
pranay roy is currently offline pranay royFriend
Messages: 196
Registered: January 2016
Senior Member
I intend to keep the Dimension separate as I have to trigger something if the only Dimension rule matches. What do you suggest.

[Updated on: Fri, 19 February 2016 06:57]

Report message to a moderator

Re: Understanding Rule Priority [message #1723931 is a reply to message #1723928] Fri, 19 February 2016 06:58 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14062
Registered: July 2009
Senior Member
Did you have a look at the grammar I proposed?

Need professional support for Xtext, Xpand, EMF?
Go to: https://www.itemis.com/en/it-services/methods-and-tools/xtext
Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Understanding Rule Priority [message #1723934 is a reply to message #1723931] Fri, 19 February 2016 07:20 Go to previous messageGo to next message
pranay roy is currently offline pranay royFriend
Messages: 196
Registered: January 2016
Senior Member
Yes , I looked at it . Thanks for your suggestion . I intend to perform some logic for Dimension Rule. so in this case even if I type "month" that logic will be executed. I want it to be separate for Dimension and TimeGroup . Thinking how can I achieve this
Re: Understanding Rule Priority [message #1723935 is a reply to message #1723934] Fri, 19 February 2016 07:23 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14062
Registered: July 2009
Senior Member
Sry I cannot follow your requirement. Please explain

Need professional support for Xtext, Xpand, EMF?
Go to: https://www.itemis.com/en/it-services/methods-and-tools/xtext
Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Understanding Rule Priority [message #1723939 is a reply to message #1723935] Fri, 19 February 2016 07:35 Go to previous messageGo to next message
pranay roy is currently offline pranay royFriend
Messages: 196
Registered: January 2016
Senior Member
plot profit by product

plot profit by month

for my application ,product and month should belong to different categories. product should be ID type while month belongs to TimgGroup category with some other specific words like "day","quarter" ,etc.

For rule matching , if there is TimeGroup category it should be given priority over matching an ID.
Re: Understanding Rule Priority [message #1723941 is a reply to message #1723939] Fri, 19 February 2016 07:43 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14062
Registered: July 2009
Senior Member
My grammar does that doesn't it?

Need professional support for Xtext, Xpand, EMF?
Go to: https://www.itemis.com/en/it-services/methods-and-tools/xtext
Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Understanding Rule Priority [message #1723942 is a reply to message #1723941] Fri, 19 February 2016 07:53 Go to previous messageGo to next message
pranay roy is currently offline pranay royFriend
Messages: 196
Registered: January 2016
Senior Member
Query:
	key?='plot'? names+=ID ("and" names+=ID)* ('by' groupBy+=TimeOrDimension)+;

TimeOrDimension:
   ID|'month'|'year'|'quarter'|'day';



Ok I wish to understand few points.
* Here TimeorDimension is combining Dimension and Time into one. For an input say "by country" i wish to trigger only Dimension and not Time.
* When the input is "by month" How is it prioritized to match just the Time Rule and not Dimension

Re: Understanding Rule Priority [message #1723944 is a reply to message #1723942] Fri, 19 February 2016 08:06 Go to previous messageGo to next message
Sven Efftinge is currently offline Sven EfftingeFriend
Messages: 83
Registered: January 2016
Location: Kiel
Member

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 #1723947 is a reply to message #1723944] Fri, 19 February 2016 08:23 Go to previous messageGo to next message
pranay roy is currently offline pranay royFriend
Messages: 196
Registered: January 2016
Senior Member
Ok ThankYou Smile . In this case dimension is of type ID. The reason I kept it separate because in next iteration Dimension could also occur at a different place that mentioned

For example

profit by country for apac as region. Here country and region are dimensions
.So I have to have to know , whether the dimension comes under group by as a condition.

Could you suggest if my approach is ok.

[Updated on: Fri, 19 February 2016 08:25]

Report message to a moderator

Re: Understanding Rule Priority [message #1724159 is a reply to message #1723947] Mon, 22 February 2016 02:54 Go to previous messageGo to next message
pranay roy is currently offline pranay royFriend
Messages: 196
Registered: January 2016
Senior Member
What do you suggest
Re: Understanding Rule Priority [message #1724167 is a reply to message #1724159] Mon, 22 February 2016 04:56 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14062
Registered: July 2009
Senior Member
pranay roy <forums-noreply@xxxxxxxx> wrote:
> What do you suggest
>

I still don't get why you don't change the grammar as I proposed in my very
first answer


Need professional support for Xtext, Xpand, EMF?
Go to: https://www.itemis.com/en/it-services/methods-and-tools/xtext
Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Understanding Rule Priority [message #1724173 is a reply to message #1724167] Mon, 22 February 2016 06:35 Go to previous messageGo to next message
pranay roy is currently offline pranay royFriend
Messages: 196
Registered: January 2016
Senior Member
Hello,
I have used the example you have sent.

My first question is towards resolving to resolving ambiguity issue. How do I resolve it. I know this is because words like "month" etc can also come under ID (which is a different type).

So , In summary .

I have Dimension ID type and a another type Time which is text of "month" ,"day" ,"year".

My question is :

Is it possible to control the rule priority such that the text with content "month" only triggers the Time Rule and not the Dimension Type(which is ID type)

Re: Understanding Rule Priority [message #1724174 is a reply to message #1724173] Mon, 22 February 2016 06:39 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14062
Registered: July 2009
Senior Member
no it can not. ?!??!?!?!?
please share a grammar and a unit test that reproduces your problem


Need professional support for Xtext, Xpand, EMF?
Go to: https://www.itemis.com/en/it-services/methods-and-tools/xtext
Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Understanding Rule Priority [message #1724177 is a reply to message #1724174] Mon, 22 February 2016 07:12 Go to previous messageGo to next message
pranay roy is currently offline pranay royFriend
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

Re: Understanding Rule Priority [message #1724179 is a reply to message #1724177] Mon, 22 February 2016 07:32 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14062
Registered: July 2009
Senior Member
for me this looks like a bug in xtext. respectivlely how xtext handles unordered groups does not fit your grammar.
you can workaround this like

GroupList:
	(=> "by" (timeGroups+=TimeGroup|dimensionGroups+=Dimension))+
;


can you please file a ticket anyway


Need professional support for Xtext, Xpand, EMF?
Go to: https://www.itemis.com/en/it-services/methods-and-tools/xtext
Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Understanding Rule Priority [message #1724182 is a reply to message #1724179] Mon, 22 February 2016 07:37 Go to previous messageGo to next message
pranay roy is currently offline pranay royFriend
Messages: 196
Registered: January 2016
Senior Member
Thanks Christian. Where to file the ticket.?
Re: Understanding Rule Priority [message #1724183 is a reply to message #1724182] Mon, 22 February 2016 07:40 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14062
Registered: July 2009
Senior Member
http://www.eclipse.org/Xtext/community.html

Need professional support for Xtext, Xpand, EMF?
Go to: https://www.itemis.com/en/it-services/methods-and-tools/xtext
Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Understanding Rule Priority [message #1724184 is a reply to message #1724183] Mon, 22 February 2016 08:13 Go to previous messageGo to next message
pranay roy is currently offline pranay royFriend
Messages: 196
Registered: January 2016
Senior Member
I have two questions regarding this.

Measure:ID+;
I wish to modify this to accept
*Special Characters .For example "Profit #"
*Space after last word .For example "Profit margin "

Please suggest how can I modify the definition of ID or should I create a new type?






Re: Understanding Rule Priority [message #1724195 is a reply to message #1724184] Mon, 22 February 2016 09:35 Go to previous messageGo to next message
pranay roy is currently offline pranay royFriend
Messages: 196
Registered: January 2016
Senior Member
terminal WS : (' '|'\t'|'\r'|'\n')+;
Measure:ID WS(ID WS)+;

I tried this. But ,The Measure rule does not trigger and match the last space in the text text on "plot abc "
Re: Understanding Rule Priority [message #1724199 is a reply to message #1724195] Mon, 22 February 2016 09:47 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14062
Registered: July 2009
Senior Member
id not model explicit whitespace here. i dont see any reason for it

Need professional support for Xtext, Xpand, EMF?
Go to: https://www.itemis.com/en/it-services/methods-and-tools/xtext
Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Understanding Rule Priority [message #1724203 is a reply to message #1724199] Mon, 22 February 2016 09:49 Go to previous messageGo to next message
pranay roy is currently offline pranay royFriend
Messages: 196
Registered: January 2016
Senior Member
"id not model explicit whitespace here" Please elaborate.
Re: Understanding Rule Priority [message #1724204 is a reply to message #1724203] Mon, 22 February 2016 09:52 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14062
Registered: July 2009
Senior Member
i dont understand why you want to model the ws explicitely. you need to type a ws anyway to separate the tokens
if you want to unhide WS you have to model that

Rule hidden(/* list of hidden tokens, do not include ws here*/) : ...


Need professional support for Xtext, Xpand, EMF?
Go to: https://www.itemis.com/en/it-services/methods-and-tools/xtext
Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Understanding Rule Priority [message #1724210 is a reply to message #1724204] Mon, 22 February 2016 10:08 Go to previous messageGo to next message
pranay roy is currently offline pranay royFriend
Messages: 196
Registered: January 2016
Senior Member
This is because for both
"plot profit" and "plot profit " The measure is "profit" while for the second option it should be "profit " (profit with a space). I wish to capture the last space as well.

[Updated on: Mon, 22 February 2016 10:09]

Report message to a moderator

Re: Understanding Rule Priority [message #1724223 is a reply to message #1724210] Mon, 22 February 2016 11:10 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14062
Registered: July 2009
Senior Member
pranay roy <forums-noreply@xxxxxxxx> wrote:
> This is because for both
> "plot profit" and "plot profit " The measure is "profit" while for the
> second option it should be "profit " (profit with a space)
>

I have no idea on that


Need professional support for Xtext, Xpand, EMF?
Go to: https://www.itemis.com/en/it-services/methods-and-tools/xtext
Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Understanding Rule Priority [message #1724319 is a reply to message #1724179] Tue, 23 February 2016 07:25 Go to previous messageGo to next message
pranay roy is currently offline pranay royFriend
Messages: 196
Registered: January 2016
Senior Member
No Message Body

[Updated on: Tue, 23 February 2016 07:33]

Report message to a moderator

Re: Understanding Rule Priority [message #1724321 is a reply to message #1724319] Tue, 23 February 2016 07:33 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14062
Registered: July 2009
Senior Member
?!? there are 3 by s in your model ?!?

Assert.assertEquals(groupList.getDimensionGroups.get(1).getDimensions.get(0),"state")


Need professional support for Xtext, Xpand, EMF?
Go to: https://www.itemis.com/en/it-services/methods-and-tools/xtext
Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Understanding Rule Priority [message #1724331 is a reply to message #1724321] Tue, 23 February 2016 08:39 Go to previous messageGo to next message
pranay roy is currently offline pranay royFriend
Messages: 196
Registered: January 2016
Senior Member
Sorry for this. cannot debug test class so didnt catch the issue Sad
Re: Understanding Rule Priority [message #1724335 is a reply to message #1724331] Tue, 23 February 2016 09:06 Go to previous message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14062
Registered: July 2009
Senior Member
btw this i still do not understand why debug does not work for you.

Need professional support for Xtext, Xpand, EMF?
Go to: https://www.itemis.com/en/it-services/methods-and-tools/xtext
Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Previous Topic:Description Resource Path Location Type Bound mismatch: The generic method create(Class<T>) of
Next Topic:how to install antlrWorks in xtext??
Goto Forum:
  


Current Time: Wed Sep 22 00:47:43 GMT 2021

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

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

Back to the top