Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Strange conflict on xtext grammar
icon9.gif  Strange conflict on xtext grammar [message #1760839] Wed, 03 May 2017 14:20 Go to next message
Josselin Kerdraon is currently offline Josselin KerdraonFriend
Messages: 29
Registered: February 2016
Junior Member
Hi everyone,

I'm on project that uses xtext grammar to produce a script langage.
I have problem with rules tha should not do conflict, but they do.

Here is a part of my grammar:

Variable:
	name='valeur' |
	(producer=STR '.') ( parameter=STR '.') attribut = VariableAttribut
	;

VariableAttribut:
	name='unité' |
	name='valeur'
	;


GetBit:
	variable=Variable '.getBit' '(' index=INT ')'	
;

TurnBitOn:
	variable=Variable '.allumerBit' '(' index=INT ')'
;

TurnBitOff:
	variable=Variable '.eteindreBit' '(' index=INT ')'
;

terminal STR : ('a'..'z'|'A'..'Z'|'_') ('a'..'z'|'A'..'Z'|'0'..'9'|'_'|'\\')*;


Well, the problem is when I type something like this (I expect this to enter "Variable" rule):

valeur=PRODUCTEUR.ENTIER2.valeur;


I get errors:
- no viable alternative at input 'TIER2'
- mismatched character 'N' expecting set null


And I checked it, this is because of "TurnBitOff". i have the same error with parameters starting with "g" and "a".

Do you know why this problem happens ?

Thanks for your answers
Re: Strange conflict on xtext grammar [message #1760840 is a reply to message #1760839] Wed, 03 May 2017 14:30 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14730
Registered: July 2009
Senior Member
can you please share a minimal but complete grammar and unit test?

Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Day Job: https://www.everest-systems.com
Re: Strange conflict on xtext grammar [message #1760841 is a reply to message #1760840] Wed, 03 May 2017 14:33 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14730
Registered: July 2009
Senior Member
p.s.

and try to use this pattern:

variable=Variable '.''getBit' '(' index=INT ')'


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Day Job: https://www.everest-systems.com
Re: Strange conflict on xtext grammar [message #1760844 is a reply to message #1760841] Wed, 03 May 2017 14:58 Go to previous messageGo to next message
Josselin Kerdraon is currently offline Josselin KerdraonFriend
Messages: 29
Registered: February 2016
Junior Member
Thank you very much Christian, it works perfectly !

Is it an xText issue or is there any reason to split the ".getBit" ?


Re: Strange conflict on xtext grammar [message #1760846 is a reply to message #1760844] Wed, 03 May 2017 15:01 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14730
Registered: July 2009
Senior Member
its a problem with how antlr lexers work

Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Day Job: https://www.everest-systems.com
Re: Strange conflict on xtext grammar [message #1760847 is a reply to message #1760846] Wed, 03 May 2017 15:06 Go to previous message
Josselin Kerdraon is currently offline Josselin KerdraonFriend
Messages: 29
Registered: February 2016
Junior Member
Ok.

Thank you again !
Previous Topic:Parsing Problem: Colon and negative number
Next Topic:Exception when accessing xtext index
Goto Forum:
  


Current Time: Tue Nov 12 07:47:57 GMT 2024

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

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

Back to the top