Commit 686eb7d5 by Alok Priyadarshi

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 889f9d71
......@@ -288,6 +288,11 @@ int reserved_word(yyscan_t yyscanner) {
return 0;
}
void yyerror(YYLTYPE* lloc, TParseContext* context, const char* reason) {
context->error(*lloc, reason, yyget_text(context->scanner));
context->recover();
}
int glslang_initialize(TParseContext* context) {
yyscan_t scanner = NULL;
if (yylex_init_extra(context, &scanner))
......
......@@ -85,7 +85,7 @@ WHICH GENERATES THE GLSL ES PARSER (glslang_tab.cpp AND glslang_tab.h).
%{
extern int yylex(YYSTYPE* yylval, YYLTYPE* yylloc, void* yyscanner);
static 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) \
do { \
......@@ -2004,11 +2004,6 @@ function_definition
%%
void yyerror(YYLTYPE* yylloc, TParseContext* context, const char* reason) {
context->error(*yylloc, reason, "");
context->recover();
}
int glslang_parse(TParseContext* context) {
return yyparse(context);
}
......@@ -2897,6 +2897,11 @@ int reserved_word(yyscan_t yyscanner) {
return 0;
}
void yyerror(YYLTYPE* lloc, TParseContext* context, const char* reason) {
context->error(*lloc, reason, yyget_text(context->scanner));
context->recover();
}
int glslang_initialize(TParseContext* context) {
yyscan_t scanner = NULL;
if (yylex_init_extra(context,&scanner))
......
......@@ -307,7 +307,7 @@ int yyparse ();
extern int yylex(YYSTYPE* yylval, YYLTYPE* yylloc, void* yyscanner);
static 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) \
do { \
......@@ -4872,11 +4872,6 @@ yyreturn:
void yyerror(YYLTYPE* yylloc, TParseContext* context, const char* reason) {
context->error(*yylloc, reason, "");
context->recover();
}
int glslang_parse(TParseContext* 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