error in Productions section of a file.sablecc.3

27 views
Skip to first unread message

MarK One

unread,
Feb 15, 2018, 2:11:30 PM2/15/18
to SableCC
Hi guys
I'm able to specify the following production in a file.sablecc3:

stmt_list      =  simple_stmt (semicolon simple_stmt)* semicolon
                   | simple_stmt (semicolon simple_stmt)*
                   ;

The problem is that, when the first parenthesis '(' is reached the parser expects a ';'
I think because is not supported the possibility to use the star symbol '*' on more than one element of the production; so
how can i fix this problem?

Michael B. Mast

unread,
Feb 15, 2018, 2:33:27 PM2/15/18
to sab...@googlegroups.com

You need to use recursion.  Something like this:

stmt_list = simple_stmt semicolon

                  | stmt_list;

--
You received this message because you are subscribed to the Google Groups "SableCC" group.
To unsubscribe from this group and stop receiving emails from it, send an email to sablecc+u...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages