dcsimg
confused about writing a rule
0 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Bharat_Khatri
Posted On:   Friday, August 13, 2004 11:37 AM

I am writing the grammer for a language for use with antlr. I have a to write a rule like the following: example of a compound statement statement : (named_statement)=>named_statement | compound_statement | assignment_statement; named_statement : IDENT COLON statement; assignment_statement : IDENT ASSIGN value SEMI; // value is dont care here compound_statement : "BEGIN" (statement)* (IDENT COLON)* "END"; Actually, a compund statement may have a label for each of its individual statements(through named statements), and may have one for the whole group of statements (which is indicat   More>>


I am writing the grammer for a language for use with antlr. I have a to write a rule like the following:





example of a compound statement



statement : (named_statement)=>named_statement | compound_statement | assignment_statement;




named_statement : IDENT COLON statement;



assignment_statement : IDENT ASSIGN value SEMI; // value is dont care here



compound_statement : "BEGIN" (statement)* (IDENT COLON)* "END";




Actually, a compund statement may have a label for each of its individual statements(through named statements), and may have one for the whole group of statements (which is indicated at the end of the compound statement definition by (IDENT colon)*. This rule throws a non-determinism exception, which is obvious since IDENT and COLON occur in both a statement (named) and the label of the compound statement itself. I've tried several ways but none worked. Any help in this matter will be appreciated.



Thanks

   <<Less
About | Sitemap | Contact