Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Error 'no viable alternative at character '<EOF>'
Error 'no viable alternative at character '<EOF>' [message #1070545] Thu, 18 July 2013 07:30 Go to next message
chris yo is currently offline chris yoFriend
Messages: 47
Registered: February 2013
Member
I have this grammar:

Model:
  definitions += Locations*
;

Locations:
  Global | Local
;

Global:
  '@Global_Save' path=STR2 ';'
;

Local: {Local}
  local='Locale' 'Save' ('To' path=STR2)? ';'
;

STR2 hidden():
   STRING2;

terminal STRING2: '"' -> '"' ;


I have this configuration in a text file:

@Global_Save "dir_01\";
Locale Save "dir_01\";


But I keep on getting this error:
ERROR:no viable alternative at character '<EOF>'
ERROR:mismatched input 'dir_01' expecting RULE_STR2
ERROR:mismatched input '\' expecting 'Locale'
ERROR:no viable alternative at character '<EOF>'

If I put "dir_01\" in @Global_Save, my generation works successfully. But if I use the same input in Locale, I get the errors I mentioned above. Does somebody know what the problem is?

I've tried setting the Local to "dir_01" and "dir_01/", and I did not get any errors.

[Updated on: Thu, 18 July 2013 07:36]

Report message to a moderator

Re: Error 'no viable alternative at character '<EOF>' [message #1071120 is a reply to message #1070545] Fri, 19 July 2013 11:40 Go to previous messageGo to next message
Ian McDevitt is currently offline Ian McDevittFriend
Messages: 70
Registered: December 2012
Location: Belfast
Member
You have a syntax error on your second line.
According to your language, Locale Save can only be followed by 'To' or ';' but you have followed it with a ".
Re: Error 'no viable alternative at character '<EOF>' [message #1077648 is a reply to message #1071120] Fri, 02 August 2013 01:12 Go to previous messageGo to next message
Hema Vidal is currently offline Hema VidalFriend
Messages: 1
Registered: August 2013
Junior Member
I have the same problem, but with the character ' '

-------------------
My grammar is:

Program_heading: "program" IDENTIFIER '(' Identifier_list ')' ';';

Identifier_list: IDENTIFIER ( ',' IDENTIFIER )*;

terminal IDENTIFIER: LETTER (LETTER | DIGIT)*;

terminal fragment LETTER: ('A'..'Z'|'a'..'z');

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

When i run in a new Eclipse Aplication, the follow program input make an ERROR(no viable alternative at character ' ')

program Program1 (id);.

Why this error occurs?
It was for the compiler simply ignore whitespace!
Re: Error 'no viable alternative at character '<EOF>' [message #1078071 is a reply to message #1077648] Fri, 02 August 2013 13:55 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 8291
Registered: July 2009
Senior Member
Hi,

do you use terminals or not if so you have to redefine ws and set it to be hidden.


Need professional support for Xtext, Xpand, EMF?
Go to: http://xtext.itemis.com
Twitter : @chrdietrich
Blog : christiandietrich.wordpress.com
Re: Error 'no viable alternative at character '<EOF>' [message #1096222 is a reply to message #1071120] Wed, 28 August 2013 05:20 Go to previous messageGo to next message
chris yo is currently offline chris yoFriend
Messages: 47
Registered: February 2013
Member
Ian McDevitt wrote on Fri, 19 July 2013 07:40
You have a syntax error on your second line.
According to your language, Locale Save can only be followed by 'To' or ';' but you have followed it with a ".


I have edited the grammar.
@Global_Save "dir_01\";
Locale Save To "dir_01\";


Why can't I use "\" in the path? I am using terminal and have set STR2 to hidden.

Model:
  definitions += Locations*
;

Locations:
  Global | Local
;

Global:
  '@Global_Save' path=STR2 ';'
;

Local: {Local}
  local='Locale' 'Save' ('To' path=STR2)? ';'
;

STR2 hidden():
   STRING2;

terminal STRING2: '"' -> '"' ;
Re: Error 'no viable alternative at character '<EOF>' [message #1096302 is a reply to message #1096222] Wed, 28 August 2013 08:00 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 8291
Registered: July 2009
Senior Member
Hi,

have a look at Xtexts default STRINGValueConverter which does \\ escaping


Need professional support for Xtext, Xpand, EMF?
Go to: http://xtext.itemis.com
Twitter : @chrdietrich
Blog : christiandietrich.wordpress.com
Re: Error 'no viable alternative at character '<EOF>' [message #1106352 is a reply to message #1096302] Wed, 11 September 2013 01:59 Go to previous message
chris yo is currently offline chris yoFriend
Messages: 47
Registered: February 2013
Member
Hi,

I have read the documentation for string value converter. Do you have tutorial/example that can show me how to implement this?

I cannot do STRING2.toEscapedString, can I?

Thank you.
Previous Topic:Help parsing 4.1+3., with a '.' at the end
Next Topic:How to get absolute path
Goto Forum:
  


Current Time: Thu Feb 11 08:56:44 GMT 2016

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

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