Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 24 additions & 2 deletions perly.c
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,15 @@ yysymprint(pTHX_ PerlIO * const yyoutput, int yytype, const YYSTYPE * const yyva
}


/* common prefixes of token names to strip when displaying in compact form
*/
static const char *name_prefixes[] = {
"PERLY_",
"KW_",
"bare_statement_",
NULL,
};

/* yy_stack_print()
* print the top 8 items on the parse stack.
*/
Expand All @@ -150,8 +159,21 @@ yy_stack_print (pTHX_ const yy_parser *parser)
PerlIO_printf(Perl_debug_log, " %8d", ps->state);

PerlIO_printf(Perl_debug_log, "\ntoken:");
for (ps = min; ps <= parser->ps; ps++)
PerlIO_printf(Perl_debug_log, " %8.8s", ps->name);
for (ps = min; ps <= parser->ps; ps++) {
const char *name = ps->name;
const char **p = name_prefixes;
/* strip some common prefixes off the name to better display
* truncated names */
for (; *p; p++) {
const char *prefix = *p;
STRLEN l = strlen(prefix);
if (strnEQ(name, prefix, l)) {
name += l;
break;
}
}
PerlIO_printf(Perl_debug_log, " %8.8s", name);
}

PerlIO_printf(Perl_debug_log, "\nvalue:");
for (ps = min; ps <= parser->ps; ps++) {
Expand Down
Loading