Syntax error, unexpected TOKEN, expecting $end
Win flex-bison is a port Flex & Bison tools to the Windows platform
Brought to you by:
lexxmark
Hello Alex,
I've got another question.
I have defined my grammar in the lex file:
%%
[0-9]+\.[0-9] {
yylval.fval = atof(yytext);
return T_FLOAT;
}
\n {
std::cout << "Found a linebreak" << std::endl;
}
%%
My token handling in the .y file (I use verbose error ouput with '%error-verbose'):
%union {
int ival;
float fval;
char *sval;
}
// Define the tokens with their data type.
%token <fval> T_FLOAT
%token <sval> T_STRING
%%
group_float:
T_FLOAT
{
std::cout << " A float was found:" << $1 << std::endl;
}
;
group_string:
T_STRING
{
std::cout << "A string was found: " << $1 << std::endl;
}
;
%%
After compiling and pressing 'Debug' I receive an error with the following description:
> Parse error! syntax error, unexpected T_FLOAT, expecting $end
My input file:
1.2
5.6
The output on the console can be seen in the attachment.
Can you tell me why the parser does not go to the next token it receives (the second float value) after it prints the linebreak?
Thanks
Sebastian
Anonymous
Actually I'm not familiar with flex/bison syntax.
Try to find solution or ask your question on stackoverflow, googling really helped me when I digged in flex/bison stuff several years ago.
View and moderate all "tickets Discussion" comments posted by this user
Mark all as spam, and block user from posting to "Tickets"
Hi Alex, I found an explanation for this behaviour here:
http://www.4answered.com/questions/view/1a4f2a0/Expecting-end-after-first-input
One has to write a complete context free grammar, then the result is as desired!
Thank for your advices,
Sebastian
Last edit: Anonymous 2018-10-12
Diff:
Diff:
Diff:
Diff:
1
1
1
1
1
1
1
1
1
1
1