Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » A couple of rules and recursion overflow - help appreciated
A couple of rules and recursion overflow - help appreciated [message #1767159] Sun, 02 July 2017 17:40 Go to next message
David BlackFriend
Messages: 33
Registered: June 2017
Member
Hi,

I am a newbie to Xtext and keeping scratching my head over the following problem.

My grammar is this simple:

MyGrammar:
	source+=(IDENTIFIER | TYPE)*
;

terminal TYPE:
	IDENTIFIER |
	(IDENTIFIER '<' TYPE '>')
;


And the part defining the IDENTIFIER is this (it's not complicated, just long because of the characters specification involved):

terminal fragment DECIMAL_DIGIT:
	INT
;
terminal fragment IDENTIFIER_HEAD:
	('a'..'z') | ('A'..'Z') |
	'_' |
	'\u00A8' | '\u00AA' | '\u00AD' | '\u00AF' | ('\u00B2'..'\u00B5') | ('\u00B7'..'\u00BA')	|
	('\u00BC'..'\u00BE') | ('\u00C0'..'\u00D6') | ('\u00D8'..'\u00F6') | ('\u00F8'..'\u00FF') |
	('\u0100'..'\u02FF') | ('\u0370'..'\u167F') | ('\u1681'..'\u180D') | ('\u180F'..'\u1DBF') |
	('\u1E00'..'\u1FFF') |
	('\u200B'..'\u200D') | ('\u202A'..'\u202E') | ('\u203F'..'\u2040') | '\u2054' | ('\u2060'..'\u206F') |
	('\u2070'..'\u20CF') | ('\u2100'..'\u218F') | ('\u2460'..'\u24FF') | ('\u2776'..'\u2793') |
	('\u2C00'..'\u2DFF') | ('\u2E80'..'\u2FFF') |
	('\u3004'..'\u3007') | ('\u3021'..'\u302F') | ('\u3031'..'\u303F') | ('\u3040'..'\uD7FF') |
	('\uF900'..'\uFD3D') | ('\uFD40'..'\uFDCF') | ('\uFDF0'..'\uFE1F') | ('\uFE30'..'\uFE44') |
	('\uFE47'..'\uFFFD') 
;


terminal  IDENTIFIER:
	(IDENTIFIER_HEAD IDENTIFIER_CHARACTERS*) |
	('`'(IDENTIFIER_HEAD IDENTIFIER_CHARACTERS*)'`') |
	IMPLICIT_PARAMETER_NAME
;
terminal fragment IDENTIFIER_CHARACTER:
	DECIMAL_DIGIT | 
	('\u0300'..'\u036F') | ('\u1DC0'..'\u1DFF') | ('\u20D0'..'\u20FF') | ('\uFE20'..'\uFE2F') |
	IDENTIFIER_HEAD
;

terminal fragment IDENTIFIER_CHARACTERS:
	IDENTIFIER_CHARACTER+
;


The error I am getting is this one:
error(206): ../org.instrumenteddreams.swift.s2.xtext/src-gen/org/instrumenteddreams/parser/antlr/internal/InternalSwiftJ.g:1:8: 

Alternative 3: after matching input such as
 
'\u3021'..'\u302F''\u0300'..'\u036F''\u1DC0'..'\u1DFF''<'
	{'\u3021'..'\u302F', '\uFE00'..'\uFE0F'}'\u0300'..'\u036F''\u1DC0'..'\u1DFF''<'
		{'\u3021'..'\u302F', '\uFE00'..'\uFE0F'}'\u0300'..'\u036F''\u1DC0'..'\u1DFF''<'
			{'\u3021'..'\u302F', '\uFE00'..'\uFE0F'}'\u0300'..'\u036F''\u1DC0'..'\u1DFF''<'
				{'\u3021'..'\u302F', '\uFE00'..'\uFE0F'}'\u0300'..'\u036F'<EOT> 

decision cannot predict what comes next due to recursion overflow to RULE_TYPE from RULE_TYPE


Every hint or suggestion will be appreciated.

[Updated on: Mon, 03 July 2017 21:22]

Report message to a moderator

Re: A couple of rules and recursion overflow - help appreciated [message #1767171 is a reply to message #1767159] Mon, 03 July 2017 07:19 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 7655
Registered: July 2009
Senior Member
Hi

You don't provide all of your grammar so it is difficult to answer. My guess is that you continue to inherit the org.eclipse.xtext.common.Terminals and have overridden inconsistently.

The default behavior of Xtext is 'helpful' for standard usage, but unfortunately if you deviate from the standard you may have to remedy the 'help'. The default Terminal provides some standard terminals and standard names that are BUILT_IN to Xtext. If you need something different you can try to just override, but may need to replace the common Terminals, keeping the terminal names unchanged. As soon as you create alternatives, expect to need to understand how the Xtext 'help' works so that you can remedy it.

Suggest fold the contents of org.eclipse.xtext.common.Terminals into your own grammar then evolve.

Regards

Ed Willink

Re: A couple of rules and recursion overflow - help appreciated [message #1767190 is a reply to message #1767171] Mon, 03 July 2017 11:37 Go to previous messageGo to next message
David BlackFriend
Messages: 33
Registered: June 2017
Member
Hi Ed,

thanks for your input. I am rolling back changes and building again everything bit by bit. I will post the solution, just for the record, when I have it.

David
Re: A couple of rules and recursion overflow - help appreciated [message #1767234 is a reply to message #1767190] Mon, 03 July 2017 22:23 Go to previous message
David BlackFriend
Messages: 33
Registered: June 2017
Member
Well, it's one of those situations in which after rolling back all the changes and buiding the whole thing bit by bit, it looks I am not able to reproduce that error anymore. At least in that scenario.

It's a pity. I'd like to come up with a smart solution to guide and shape young generations of XText fighters to come, but it's not the case.

Cheers
Previous Topic:Expression evaluation for org.xtext.calc.lsp4e?
Next Topic:How to maka a rule LL(*) while preserving semantics?
Goto Forum:
  


Current Time: Tue Mar 19 03:34:29 GMT 2024

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

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

Back to the top