glr: display line numbers in traces

Suggested by Lars Maier.

* data/skeletons/glr.c: Also display rule locations when rules are
deferred, and rejected.
This commit is contained in:
Akim Demaille
2019-10-11 07:06:39 +02:00
parent 0c56c195e0
commit 2c20ae9b41
3 changed files with 9 additions and 7 deletions

3
THANKS
View File

@@ -95,8 +95,9 @@ Kees Zeelenberg kzlg@users.sourceforge.net
Keith Browne kbrowne@legato.com Keith Browne kbrowne@legato.com
Ken Moffat zarniwhoop@ntlworld.com Ken Moffat zarniwhoop@ntlworld.com
Kiyoshi Kanazawa yoi_no_myoujou@yahoo.co.jp Kiyoshi Kanazawa yoi_no_myoujou@yahoo.co.jp
Laurent Mascherpa laurent.mascherpa@epita.fr Lars Maier lars.maier@tefax.net
László Várady laszlo.varady93@gmail.com László Várady laszlo.varady93@gmail.com
Laurent Mascherpa laurent.mascherpa@epita.fr
Lie Yan lie.yan@kaust.edu.sa Lie Yan lie.yan@kaust.edu.sa
Magnus Fromreide magfr@lysator.liu.se Magnus Fromreide magfr@lysator.liu.se
Marc Autret autret_m@epita.fr Marc Autret autret_m@epita.fr

View File

@@ -1442,8 +1442,9 @@ yyglrReduce (yyGLRStack* yystackp, ptrdiff_t yyk, yyRuleNum yyrule,
YYRESULTTAG yyflag = yydoAction (yystackp, yyk, yyrule, &yysval]b4_locuser_args([&yyloc])[); YYRESULTTAG yyflag = yydoAction (yystackp, yyk, yyrule, &yysval]b4_locuser_args([&yyloc])[);
if (yyflag == yyerr && yystackp->yysplitPoint != YY_NULLPTR) if (yyflag == yyerr && yystackp->yysplitPoint != YY_NULLPTR)
{ {
YYDPRINTF ((stderr, "Parse on stack %ld rejected by rule #%d.\n", YYDPRINTF ((stderr,
(long) yyk, yyrule - 1)); "Parse on stack %ld rejected by rule %d (line %d).\n",
(long) yyk, yyrule - 1, yyrline[yyrule - 1]));
} }
if (yyflag != yyok) if (yyflag != yyok)
return yyflag; return yyflag;
@@ -1469,9 +1470,9 @@ yyglrReduce (yyGLRStack* yystackp, ptrdiff_t yyk, yyRuleNum yyrule,
yyupdateSplit (yystackp, yys); yyupdateSplit (yystackp, yys);
yynewLRState = yyLRgotoState (yys->yylrState, yylhsNonterm (yyrule)); yynewLRState = yyLRgotoState (yys->yylrState, yylhsNonterm (yyrule));
YYDPRINTF ((stderr, YYDPRINTF ((stderr,
"Reduced stack %ld by rule #%d; action deferred. " "Reduced stack %ld by rule %d (line %d); action deferred. "
"Now in state %d.\n", "Now in state %d.\n",
(long) yyk, yyrule - 1, yynewLRState)); (long) yyk, yyrule - 1, yyrline[yyrule - 1], yynewLRState));
for (yyi = 0; yyi < yystackp->yytops.yysize; yyi += 1) for (yyi = 0; yyi < yystackp->yytops.yysize; yyi += 1)
if (yyi != yyk && yystackp->yytops.yystates[yyi] != YY_NULLPTR) if (yyi != yyk && yystackp->yytops.yystates[yyi] != YY_NULLPTR)
{ {

View File

@@ -1711,10 +1711,10 @@ Reading a token: Now at end of input.
Stack 0 Entering state 7 Stack 0 Entering state 7
Now at end of input. Now at end of input.
Splitting off stack 1 from 0. Splitting off stack 1 from 0.
Reduced stack 1 by rule #2; action deferred. Now in state 2. Reduced stack 1 by rule 2 (line 24); action deferred. Now in state 2.
Stack 1 Entering state 2 Stack 1 Entering state 2
Now at end of input. Now at end of input.
Reduced stack 0 by rule #1; action deferred. Now in state 2. Reduced stack 0 by rule 1 (line 24); action deferred. Now in state 2.
Merging stack 0 into stack 1. Merging stack 0 into stack 1.
Stack 1 Entering state 2 Stack 1 Entering state 2
Now at end of input. Now at end of input.