X-Git-Url: https://git.m6w6.name/?p=m6w6%2Fext-psi;a=blobdiff_plain;f=src%2Fparser_proc_grammar.y;h=7a3cf55f7dbef3bef88b8751abc3f5727619e832;hp=c076abd0e5a630f1db8c78e2fd5fd5d10a144a8c;hb=cd0567b4052ee24259bc6b8a9858af9d26f3de48;hpb=aa338e1f515a21d83284c83d780d2dc075192c4d diff --git a/src/parser_proc_grammar.y b/src/parser_proc_grammar.y index c076abd..7a3cf55 100644 --- a/src/parser_proc_grammar.y +++ b/src/parser_proc_grammar.y @@ -1,5 +1,9 @@ %code top { -#include "php_psi_stdinc.h" +#ifdef HAVE_CONFIG_H +# include "config.h" +#else +# include "php_config.h" +#endif } %code { @@ -2321,15 +2325,26 @@ static void psi_parser_proc_error(struct psi_parser *P, struct psi_plist *tokens psi_plist_get(tokens, last, &T); if (T) { - int i = (last >= 5) ? last - 5 : 0; + size_t i = (last >= 5) ? last - 5 : 0; 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);