Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » mismatched input
mismatched input [message #689754] Tue, 28 June 2011 05:41 Go to next message
Robin  is currently offline Robin
Messages: 25
Registered: August 2010
Junior Member
Hi,

I am a bit stuck while designing a grammar. Hopefully, someone can help.

This is my grammar so far:
grammar org.xtext.example.mydsl.MyDsl with org.eclipse.xtext.common.Terminals

generate myDsl "http://www.xtext.org/example/mydsl/MyDsl"

Model:
	{Model}
	(tokens+=Token)*;

Token:
	'<TOKEN var1="' var1=ID '" var2="' var2=ID '">';


And this is an instance of the language:
<TOKEN var1="value1" var2="value2">


But I get the error: mismatched input '<EOF>' expecting '">'.

Why? It seems to me it is just consuming the '">' ??! Confused

Regards, Robin
Re: mismatched input [message #689769 is a reply to message #689754] Tue, 28 June 2011 06:14 Go to previous messageGo to next message
Alexander Nittka is currently offline Alexander Nittka
Messages: 1151
Registered: July 2009
Senior Member
Hi,
your token rule does not look good. Why not use something like

Token:'<TOKEN' 'var1' '=' var1=STRING 'var2' '=' var2=STRING '>';

Whitespaces in tokens are not recommended and parsing within Strings ist not trivial.

Alex


Need training, onsite consulting or any other kind of help for Xtext?
Go visit http://xtext.itemis.com or send a mail to xtext@itemis.de
Re: mismatched input [message #689797 is a reply to message #689754] Tue, 28 June 2011 07:32 Go to previous messageGo to next message
Robin  is currently offline Robin
Messages: 25
Registered: August 2010
Junior Member
Ah, that works! Thank you so much! Smile
So I guess, the parser just consumes everything that is not declared to be taken care of??

Regards, Robin
Re: mismatched input [message #689820 is a reply to message #689797] Tue, 28 June 2011 08:37 Go to previous messageGo to next message
Alexander Nittka is currently offline Alexander Nittka
Messages: 1151
Registered: July 2009
Senior Member
Hi,

before the parser does anything, the lexer chops up the input into tokens according to the definitions of terminals (and keywords) defined in your grammar (and the ones you inherit from). It is well possible that already the lexer does not produce the tokens you were expecting.

Alex


Need training, onsite consulting or any other kind of help for Xtext?
Go visit http://xtext.itemis.com or send a mail to xtext@itemis.de
Re: mismatched input [message #689949 is a reply to message #689820] Tue, 28 June 2011 12:16 Go to previous message
Robin  is currently offline Robin
Messages: 25
Registered: August 2010
Junior Member
Ahhhh, I see! Thanks for clearing that up!

Regards, Robin
Previous Topic:[xtext 2.0] importURI functionality totally messed up
Next Topic:Need some pointers setting up an xtext interpreter
Goto Forum:
  


Current Time: Wed Aug 20 20:26:16 EDT 2014

Powered by FUDForum. Page generated in 0.01594 seconds