help-bison
[Top][All Lists]
Advanced

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

lookahead and yytext


From: Brad
Subject: lookahead and yytext
Date: Mon, 08 Mar 2010 19:21:50 -0600
User-agent: Thunderbird 2.0.0.23 (Windows/20090812)

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?




reply via email to

[Prev in Thread] Current Thread [Next in Thread]