Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Parsing Problem: Colon and negative number
Parsing Problem: Colon and negative number [message #1760653] Sun, 30 April 2017 10:02 Go to next message
Philipp Sahrmann is currently offline Philipp SahrmannFriend
Messages: 1
Registered: April 2017
Junior Member
Hi together,

I am relatively new to xtext and try to integrate JSONPath syntax elements into an existing grammar.

At the moment, the only problem is that expressions like array[0:-1] (which will return all the elements except the last one) are not parsed correctly. It seems like the parser always uses :- as a token, although only the colon should be one token. The following rules are involved:

Attribute:
        ...
	{IndexAttribute} '[' indices+=AttributeIndex (',' indices+=AttributeIndex)* ']';

AttributeIndex:
	{WildcardIndex} '*' |
	{NumberIndex} index=JSONNUMBER (':' to=JSONNUMBER (':' step=JSONNUMBER)?)? |
	{ExpressionIndex} '(' expression=Expression ')' |
	{ConditionIndex} '?' '(' expression=Expression ')';

terminal JSONNUMBER returns ecore::EFloat: // Definition according to JSON standard
	'-'? ('0' | ('1'..'9') DIGIT*) ('.' DIGIT+)? (('E' | 'e') ('+' | '-')? DIGIT+)?;

terminal fragment DIGIT:
	('0'..'9');


Does anybody have an idea what I am doing wrong here? This would really help me.

Many thanks in advance
Philipp
Re: Parsing Problem: Colon and negative number [message #1760683 is a reply to message #1760653] Mon, 01 May 2017 17:47 Go to previous message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
hi,

i cannot follow you. whats the problem?

can you please share a complete grammar that shows the problem and a unit test?
maybe you have other tokens involving -


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Previous Topic:scoping.ImportURIScopingFragment in new generator?
Next Topic:Strange conflict on xtext grammar
Goto Forum:
  


Current Time: Fri Apr 26 06:50:11 GMT 2024

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

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

Back to the top