Xtext - Recursive grammar [message #1066988] |
Fri, 05 July 2013 11:00 |
chris yo Messages: 146 Registered: February 2013 |
Senior Member |
|
|
How can I use a recursive grammar?
I have the following code:
model:
defs += CFG_objects
;
CFG_objects:
statement=ID name=ID '{'
(par+=CFG_pars)*
'}' (':' comment=STRING)? ';'
;
CFG_pars:
condition=ID val=ID
('{' (pars+=CFG_pars) '}')?
(':' comment=STRING)? ';'
;
It throws me an error with this:
switch answer
{
case good : do_nothing ;
}: store answer;
What is wrong with my grammar? How can I implement a recursive grammar rule? I was expecting the above example to work.
[Updated on: Fri, 05 July 2013 11:01] Report message to a moderator
|
|
|
|
Re: Xtext - Recursive grammar [message #1067246 is a reply to message #1066991] |
Mon, 08 July 2013 03:39 |
chris yo Messages: 146 Registered: February 2013 |
Senior Member |
|
|
Hello,
I have changed the code and my configuration. But I am still getting an error.
model:
defs += CFG_objects
;
CFG_objects:
statement=ID name=ID '{'
(pars+=CFG_pars)*
'}' (':' comment=STRING1)? ';'
;
CFG_pars:
condition=ID val=ID
('{' (pars+=CFG_pars)* '}')?
(':' comment=STRING1)? ';'
;
terminal STRING1: '"' -> '"';
switch answer
{
case good : "do nothing" ;
TYPE bad;
}: "store answer";
The error I am getting is:
ERROR:mismatched input 'TYPE' expecting '}'
ERROR:extraneous input ';' expecting RULE_ID
[Updated on: Mon, 08 July 2013 03:40] Report message to a moderator
|
|
|
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.03269 seconds