Commit 0b67bfbf by Alok Priyadarshi Committed by Jamie Madill

Print token string into the syntax error message.

Bison calls yyerror("syntax error") when it cannot match any grammar rule. We used to append current token string to the error message, which got broken in r2202. This patch restores the original behavior. BUG=442 R=kbr@chromium.org Review URL: https://codereview.appspot.com/12876043
parent 8156b6be
...@@ -487,6 +487,11 @@ int floatsuffix_check(TParseContext* context) ...@@ -487,6 +487,11 @@ int floatsuffix_check(TParseContext* context)
return(FLOATCONSTANT); return(FLOATCONSTANT);
} }
void yyerror(YYLTYPE* lloc, TParseContext* context, const char* reason) {
context->error(*lloc, reason, yyget_text(context->scanner));
context->recover();
}
int glslang_initialize(TParseContext* context) { int glslang_initialize(TParseContext* context) {
yyscan_t scanner = NULL; yyscan_t scanner = NULL;
if (yylex_init_extra(context, &scanner)) if (yylex_init_extra(context, &scanner))
......
...@@ -86,7 +86,7 @@ WHICH GENERATES THE GLSL ES PARSER (glslang_tab.cpp AND glslang_tab.h). ...@@ -86,7 +86,7 @@ WHICH GENERATES THE GLSL ES PARSER (glslang_tab.cpp AND glslang_tab.h).
} }
%{ %{
extern int yylex(YYSTYPE* yylval_param, YYLTYPE* yylloc, void* yyscanner); extern int yylex(YYSTYPE* yylval, YYLTYPE* yylloc, void* yyscanner);
extern void yyerror(YYLTYPE* yylloc, TParseContext* context, const char* reason); extern void yyerror(YYLTYPE* yylloc, TParseContext* context, const char* reason);
#define YYLLOC_DEFAULT(Current, Rhs, N) \ #define YYLLOC_DEFAULT(Current, Rhs, N) \
...@@ -1922,11 +1922,6 @@ function_definition ...@@ -1922,11 +1922,6 @@ function_definition
%% %%
void yyerror(YYLTYPE* yylloc, TParseContext* context, const char* reason) {
context->error(*yylloc, reason, "");
context->recover();
}
int glslang_parse(TParseContext* context) { int glslang_parse(TParseContext* context) {
return yyparse(context); return yyparse(context);
} }
...@@ -3289,6 +3289,11 @@ int floatsuffix_check(TParseContext* context) ...@@ -3289,6 +3289,11 @@ int floatsuffix_check(TParseContext* context)
return(FLOATCONSTANT); return(FLOATCONSTANT);
} }
void yyerror(YYLTYPE* lloc, TParseContext* context, const char* reason) {
context->error(*lloc, reason, yyget_text(context->scanner));
context->recover();
}
int glslang_initialize(TParseContext* context) { int glslang_initialize(TParseContext* context) {
yyscan_t scanner = NULL; yyscan_t scanner = NULL;
if (yylex_init_extra(context,&scanner)) if (yylex_init_extra(context,&scanner))
......
...@@ -342,7 +342,7 @@ int yyparse (); ...@@ -342,7 +342,7 @@ int yyparse ();
/* Copy the second part of user declarations. */ /* Copy the second part of user declarations. */
extern int yylex(YYSTYPE* yylval_param, YYLTYPE* yylloc, void* yyscanner); extern int yylex(YYSTYPE* yylval, YYLTYPE* yylloc, void* yyscanner);
extern void yyerror(YYLTYPE* yylloc, TParseContext* context, const char* reason); extern void yyerror(YYLTYPE* yylloc, TParseContext* context, const char* reason);
#define YYLLOC_DEFAULT(Current, Rhs, N) \ #define YYLLOC_DEFAULT(Current, Rhs, N) \
...@@ -5234,11 +5234,6 @@ yyreturn: ...@@ -5234,11 +5234,6 @@ yyreturn:
void yyerror(YYLTYPE* yylloc, TParseContext* context, const char* reason) {
context->error(*yylloc, reason, "");
context->recover();
}
int glslang_parse(TParseContext* context) { int glslang_parse(TParseContext* context) {
return yyparse(context); return yyparse(context);
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment