Here is a snippet from my grammer that parses a C++-like language.

field_declaration:
   modifiers_opt type IDENTIFIER SEMICOLON
   {
       /* stuff */
   }
   ;

method_header:
   modifiers_opt type single_identifier single_identifier LPAREN RPAREN
   {
       /* stuff */
   }
   | modifiers_opt VOID single_identifier LPAREN RPAREN
   {
       /* stuff */
   }
   ;

single_identifier:
   IDENTIFIER { /* stuff with yytext */ }
   ;

field_declaration and method_header are similar enough that Bison has to look for the following LPAREN (right?). The problem I'm having is that yytext inside single_identifier is a '(' instead of the name of the method. So if I try to parse this line:

int MyMethod()

my parser thinks the method is called "(" instead of "MyMethod". Am I right that this is a lookahead issue? If it is, how do I fix it?


_______________________________________________
help-bison@gnu.org http://lists.gnu.org/mailman/listinfo/help-bison

Reply via email to