Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » What is this: " missing EOF at " error?
icon5.gif  What is this: " missing EOF at " error? [message #1028671] Thu, 28 March 2013 15:32 Go to next message
Lefteris Skoutaris is currently offline Lefteris SkoutarisFriend
Messages: 24
Registered: March 2013
Junior Member
Hello everybody. I am new to Xtext and I am facing the following problem.
I have written a simple grammar and use it to parse a file but I get the "missin EOF at ''" error. I think that the grammar is correct. What is wrong?
Why do I get this error at the first line? No other error alerts are generated.

Grammar:

Type:
scl=SClass msg smn=MessageName '\r\n';

SClass:
'(' lvl=ID ')';

MessageName:
name=STRING;

File:
fst=Section '\r\n' nxt=File?;

Section:
cl=Class ut=Utilisation se=SectionNumber at=Attribute '=' va=Value;

Class:
'(' lv=ID ')';

Utilisation:
'(' ut=ID ')';

SectionNumber:
major=INT '.' minor=INT;

Attribute:
name=ID;

Value:
val=STRING;

terminal msg:
'MessageType:';

I use the above grammar to parse the contents of the file below. The error points that some is wrong with the first line of the file. As you see in the grammar I have added the '\r\n' as terminal so that after parses the first line to jump to the 2nd. At the 2nd line it loops every other lines it finds until the end of the file.

File Contents:

(A) MessageType: "DDT"
(B) (Z) 1.1 SMG_ORG_VERS = "1.0"
(B) (Z) 1.2 CREATION_DATE = "2010-03-12T22:31:12.000"
(Z) (Z) 1.3 ORIGINATOR = "EMA"
(Z) (Z) 1.4 MESSAGE = "201113719185"

I haven't managed to find a satisfactory answer from google... Any ideas?
Re: What is this: " missing EOF at " error? [message #1028706 is a reply to message #1028671] Thu, 28 March 2013 16:33 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
Hi,

dont get it, your grammar says there is only one line

Model:
types+=Type*
;


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: What is this: " missing EOF at " error? [message #1028728 is a reply to message #1028706] Thu, 28 March 2013 16:57 Go to previous messageGo to next message
Lefteris Skoutaris is currently offline Lefteris SkoutarisFriend
Messages: 24
Registered: March 2013
Junior Member
Hello Christian and thank you for your reply.

First line is parsed by:

Type:
scl=SClass msg smn=MessageName '\r\n';

and the rest of the lines by:

File:
fst=Section '\r\n' nxt=File?;


If I remove the Type rule the parser works well as it manages to parse recursively all the lines of the file. E.g. Reads second line (=Section), then changes line (=\r\n) and then again the same etc.
However, when I add the Type rule it alerts me with the EOF error after parsing the first line.
So I thought if I add '\r\n' at the end of first line it would push the parser to start reading the second line and then entering the loop.

[Updated on: Thu, 28 March 2013 16:57]

Report message to a moderator

Re: What is this: " missing EOF at " error? [message #1028730 is a reply to message #1028728] Thu, 28 March 2013 16:58 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
Hi I dont see where you call the file rule.

--
Need training, onsite consulting or any other kind of help for Xtext?
Go visit http://xtext.itemis.com or send a mail to xtext at itemis dot de


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: What is this: " missing EOF at " error? [message #1028750 is a reply to message #1028730] Thu, 28 March 2013 17:33 Go to previous messageGo to next message
Lefteris Skoutaris is currently offline Lefteris SkoutarisFriend
Messages: 24
Registered: March 2013
Junior Member
Here:

File:
fst=Section '\r\n' nxt=File?;

Next section is read again, changes line and File is called again. Next Section is parsed, changes line and calls File again and so on.
Re: What is this: " missing EOF at " error? [message #1028758 is a reply to message #1028750] Thu, 28 March 2013 17:42 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
Yes but you don't call it from type which is the entry rule

--
Need training, onsite consulting or any other kind of help for Xtext?
Go visit http://xtext.itemis.com or send a mail to xtext at itemis dot de


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: What is this: " missing EOF at " error? [message #1028793 is a reply to message #1028758] Thu, 28 March 2013 18:46 Go to previous messageGo to next message
Lefteris Skoutaris is currently offline Lefteris SkoutarisFriend
Messages: 24
Registered: March 2013
Junior Member
Oh ok let me get this because im new in the field.

What you say is that the parser, parses the first line Type rule and stops there? It does not continue parsing the File rule?

I should call the File rule somewhere after the '\r\n' in the first line?
Re: What is this: " missing EOF at " error? [message #1028809 is a reply to message #1028793] Thu, 28 March 2013 19:16 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
Yes the first rule is the starting rule. every other rules have to be called directly or indirectly from there.
btw the xtext editor highlights uncalled rules gray


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: What is this: " missing EOF at " error? [message #1029190 is a reply to message #1028809] Fri, 29 March 2013 09:29 Go to previous message
Lefteris Skoutaris is currently offline Lefteris SkoutarisFriend
Messages: 24
Registered: March 2013
Junior Member
I now realize where this EOF is coming from. I will apply some modifications and see where it takes me.
I noticed the highlighting but I thought it was the other way around. Pretty useful info.

Btw, do you know of any good guide existing for practicing on writing grammars? Have you learned by the xtext user guide? I find it hard to follow. Would be appreciated if you can propose some useful links.

Thank you Christian for the precious help!



Previous Topic:Static Initializers
Next Topic:Update to Xtext 2.4 and Xtend 2.4
Goto Forum:
  


Current Time: Sat Apr 20 01:06:41 GMT 2024

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

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

Back to the top