X-Git-Url: https://git.m6w6.name/?p=m6w6%2Fext-psi;a=blobdiff_plain;f=src%2Fparser_proc_grammar.y;h=e0eca666d4e3b66c3b46865a589b50e87e17f7c1;hp=fc0b75210aad1c9bee15ec96aa19f11745804624;hb=44bd65fe60fb83fa4c3bbb0d4c679d2b70a096df;hpb=d2e0af1718294569a84c3c15616c74e4d55ea579 diff --git a/src/parser_proc_grammar.y b/src/parser_proc_grammar.y index fc0b752..e0eca66 100644 --- a/src/parser_proc_grammar.y +++ b/src/parser_proc_grammar.y @@ -1,4 +1,9 @@ %code top { +#ifdef HAVE_CONFIG_H +# include "config.h" +#else +# include "php_config.h" +#endif } %code { @@ -2291,7 +2296,7 @@ static int psi_parser_proc_lex(YYSTYPE *lvalp, struct psi_parser *P, struct psi_ #if PSI_DEBUG_LEX PSI_DEBUG_PRINT(P, "PSI: LEX index %4zu ", *index); #endif - if (psi_plist_get(tokens, (*index)++, &token)) { + if (psi_plist_get(tokens, (*index)++, &token) && token) { #if PSI_DEBUG_LEX PSI_DEBUG_DUMP(P, psi_token_dump, token); #endif @@ -2324,11 +2329,22 @@ static void psi_parser_proc_error(struct psi_parser *P, struct psi_plist *tokens P->error(PSI_DATA(P), T, PSI_WARNING, "PSI %s at col %u", msg, T->col); while (i <= last || T->type != PSI_T_EOS) { + const char *pos; + if (!psi_plist_get(tokens, i++, &T)) { break; } + + if (i < last + 1) { + pos = "preceding"; + } else if (i > last + 1) { + pos = "following"; + } else { + pos = "offending"; + } + P->error(PSI_DATA(P), T, PSI_WARNING, "PSI %s token '%s' at col %u", - ilast+1?"following":"offending", T->text->val, T->col); + pos, T ? T->text->val : "", T ? T->col : 0); } } else { P->error(PSI_DATA(P), NULL, PSI_WARNING, "PSI %s", msg);