[Newbie Q.] Grammar Failing: Element: -UNKNOWN- [message #1818401] |
Sat, 14 December 2019 08:28  |
Eclipse User |
|
|
|
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 57 times)
Attachment: log.txt
(Size: 12.97KB, Downloaded 73 times)
|
|
|
|
Re: [Newbie Q.] Grammar Failing: Element: -UNKNOWN- [message #1818527 is a reply to message #1818479] |
Wed, 18 December 2019 11:00  |
Eclipse User |
|
|
|
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
|
|
|
Powered by
FUDForum. Page generated in 0.03720 seconds