X-Git-Url: http://git.openwrt.org/?a=blobdiff_plain;f=parser.y;h=f77779bc72ca8f7a9597c4fdc15f6c2956a6d069;hb=479ca5def5b6bd5c79de488806299064346e2339;hp=9c06c07c4a90a1eeed05a9a072727576db6e346d;hpb=f3830138661374ca10fe6a0b6f2f4b949dea3e5c;p=project%2Fjsonpath.git diff --git a/parser.y b/parser.y index 9c06c07..f77779b 100644 --- a/parser.y +++ b/parser.y @@ -39,35 +39,13 @@ } %syntax_error { - int n = sizeof(tokennames) / sizeof(tokennames[0]); - int l = strlen("Expecting "); - int c = 0; int i; - for (i = 0; i < n; i++) - { + for (i = 0; i < sizeof(tokennames) / sizeof(tokennames[0]); i++) if (yy_find_shift_action(yypParser, (YYCODETYPE)i) < YYNSTATE + YYNRULE) - l += strlen(tokennames[i]) + 4; - } - - s->error = malloc(l); - - if (s->error) - { - s->erroff = s->off; - strcpy(s->error, "Expecting "); - - for (i = 0; i < n; i++) - { - if (yy_find_shift_action(yypParser, (YYCODETYPE)i) < YYNSTATE + YYNRULE) - { - if (c++) - strcat(s->error, " or "); - - strcat(s->error, tokennames[i]); - } - } - } + s->error_code |= (1 << i); + + s->error_pos = s->off; }