Are you strcpy'ing off the value of yytext before getting it from $3?

-Chris


On Mon, Mar 8, 2010 at 6:10 PM, Brad <[email protected]> wrote:

> Doh, sorry about that. The extra single_identifier was left over from when
> I was trying to debug the problem. The original grammar that has the yytext
> issue didn't have the extra single_identifier. Ignore it.
>
> -Brad
>
> Chris verBurg wrote:
>
>> Hey Brad,
>>
>> Do you mean to have "single_identifier" listed twice for the first
>> method_header grammar?  That's the only thing I can think of that would
>> cause this problem.  Honestly I wouldn't think it would get past the lexer,
>> since "(" should have been returned as a LPAREN instead of a
>> single_identifier.
>>
>> -Chris
>>
>>
>> On Mon, Mar 8, 2010 at 5:21 PM, Brad <[email protected] <mailto:
>> [email protected]>> wrote:
>>
>>    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?
>>
>>
>>    _______________________________________________
>>    [email protected] <mailto:[email protected]>
>>
>>    http://lists.gnu.org/mailman/listinfo/help-bison
>>
>>
>>
>
_______________________________________________
[email protected] http://lists.gnu.org/mailman/listinfo/help-bison

Reply via email to