[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: grammar switch statement



With an optional default_clause, you'll get a shift-reduce error because, if the default_clause is empty, a case_clause is ambiguous between a pre_case_clause and a post_case_clause.
Franz


russel.lindsay@centrelink.gov.au wrote:


Hi,


I have defined a switch statement in my grammar as follows (and it works):

switch =
   T.switch left_parenthese expression right_parenthese case_block;

case_block =
left_brace case_clause* right_brace
|{default} left_brace [pre]:case_clause* default_clause [post]:case_clause* right_brace;


case_clause =
   case expression colon statement*;

default_clause =
   default colon statement*;


however, if i change the case_block to following it does not work:


case_block =
left_brace [pre]:case_clause* default_clause? [post]:case_clause* right_brace;



Can anybody see what is wrong with the definition, or have i not provided enough information?


thankyou all,


russel |

Important: This e-mail is intended for the use of the addressee and may contain information that is confidential, commercially valuable or subject to legal or parliamentary privilege. If you are not the intended recipient you are notified that any review, re-transmission, disclosure, use or dissemination of this communication is strictly prohibited by several Commonwealth Acts of Parliament. If you have received this communication in error please notify the sender immediately and delete all copies of this transmission together with any attachments.
|