Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » [Newbie Q.] Grammar Failing: Element: -UNKNOWN-(Element: -UNKNOWN-; Reported by: XtextGenerator)
[Newbie Q.] Grammar Failing: Element: -UNKNOWN- [message #1818401] Sat, 14 December 2019 13:28 Go to next message
Soulaymen Chouri is currently offline Soulaymen ChouriFriend
Messages: 2
Registered: December 2019
Junior Member
Hello everyone!

First of all, I would like to thank the amazing eclipse foundation for such an amazing tool. I have been trying to build a language for years, never felt like having the right tool to build something robust and productive.

I have started reworking on my old language using Xtext, just after finding out about this awesome tool!

Though I am having some trouble with the grammar, I am certain that I am misunderstanding something. Here is my grammar: (attached)

If I compile it, I get the following error: (attached)

However, if I change the rule
VarDeclExpr returns Expression :
	'let' name=ID (':' type=Type)? '=' initialValue=Expression 'in' '{' innerBody=Expression '}'
;


to something like
VarDeclExpr returns Expression :
	'var' name=ID (':' type=Type)? '=' initialValue=Expression 'in' '{' innerBody=Expression '}'
;


It works. I understand that at somepoint the parser wont know which rule to consider, a VarDeclExpr or VarDeclStatement., but there the 'in ...' after, so please any tip/advice would be appreciated!

I don't think I am having a left-recursive rule, since the IDE does not complain about my syntax even though it does not compile.

I am also still newbie about the Java Internals of the generated stuff, I still haven't got into it, and I did not modify anything.

Thanks!
  • Attachment: Mana.xtext
    (Size: 3.29KB, Downloaded 34 times)
  • Attachment: log.txt
    (Size: 12.97KB, Downloaded 50 times)
Re: [Newbie Q.] Grammar Failing: Element: -UNKNOWN- [message #1818479 is a reply to message #1818401] Tue, 17 December 2019 07:34 Go to previous messageGo to next message
Uli Merkel is currently offline Uli MerkelFriend
Messages: 250
Registered: June 2013
Senior Member
looks like you use the keyword let in 2 different situations.
As your grammar has as well:

ClassAtrribute:
'let' (scope='local')? name=ID ':' type=Type;
Re: [Newbie Q.] Grammar Failing: Element: -UNKNOWN- [message #1818527 is a reply to message #1818479] Wed, 18 December 2019 16:00 Go to previous message
Soulaymen Chouri is currently offline Soulaymen ChouriFriend
Messages: 2
Registered: December 2019
Junior Member
Hi!

Thank you for your reponse!

I actually solved it as I was waiting for the thread to appear on the forum. In any case, yes that was the issue! I thought the parser would understand the rule because of the extra 'in' token, that sets apart from the other ones. Guess that didn't work, I ended up doing something like ML
val x: u8 = 8 * let val y = 3 in y * 2
Previous Topic:Dynamic content assist proposals order
Next Topic:Code coverage of generated Java code
Goto Forum:
  


Current Time: Thu Mar 28 22:53:42 GMT 2024

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

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

Back to the top