Pretty much. Part of what the single_identifier action does is copy
yytext into a std::string, and then it's that std::string that I use
from then on.
Actually, just now I changed that IDENTIFIER inside the
field_declaration section to single_identifier, and now it works! Why
would that make a difference?
-Brad
Chris verBurg wrote:
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 <bradda...@comcast.net
<mailto:bradda...@comcast.net>> 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 <bradda...@comcast.net
<mailto:bradda...@comcast.net> <mailto:bradda...@comcast.net
<mailto:bradda...@comcast.net>>> 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?
_______________________________________________
help-bison@gnu.org <mailto:help-bison@gnu.org>
<mailto:help-bison@gnu.org <mailto:help-bison@gnu.org>>
http://lists.gnu.org/mailman/listinfo/help-bison
_______________________________________________
help-bison@gnu.org http://lists.gnu.org/mailman/listinfo/help-bison