diff options
Diffstat (limited to 'support/splint/tex/yyparse.sty')
-rw-r--r-- | support/splint/tex/yyparse.sty | 78 |
1 files changed, 42 insertions, 36 deletions
diff --git a/support/splint/tex/yyparse.sty b/support/splint/tex/yyparse.sty index f6c6dadff8..3599692346 100644 --- a/support/splint/tex/yyparse.sty +++ b/support/splint/tex/yyparse.sty @@ -1,4 +1,4 @@ -% Copyright 2012-2020, Alexander Shibakov +% Copyright 2012-2024, Alexander Shibakov % This file is part of SPLinT % % SPLinT is free software: you can redistribute it and/or modify @@ -80,15 +80,15 @@ \newif\iftracelookahead \def\yyparsetail{% this is where the lexer returns - \ifnum\yychar>\YYEOF\relax % if (yychar > YYEOF) + \ifnum\yychar>\z@\relax % if (yychar > YYEOF) \yytoken=\fgetelemof{yytranslate}\at\yychar\relax \iftracelookahead \derrmessage{lookahead: \tokname, value: \the\yylval^^J}% \fi % yytoken = yytranslate[yychar] \else % else - \yychar=\YYEOF\relax % yychar = yytoken = YYEOF - \yytoken=\YYEOF\relax + \yychar=\z@\relax % yychar = yytoken = YYEOF + \yytoken=\YYSYMBOLxYYEOF\relax \fi% valid lookahead token \advance\yyn by\yytoken % yyn = yypact[yystate] + yytoken \ifnum\yyn<\z@ @@ -148,32 +148,7 @@ \def\yyreduce{% \yylen=\fgetelemof{yyrtwo}\at\yyn\relax - \iftracerules - \ferrmessage{^^Jreducing (rule \the\yyn)}\printrule{\yyn}% - \fi - {% - \iftracestacks - \iftracerules - \else - \ferrmessage{^^J}% - \fi - \showstack\yyssa - \ferrmessage{stack: \stackcs^^Jpopping \the\yylen^^J}% - \fi - }% - \yyilen=\fgetelemof{yyrthree}\at\yyn\relax - \ifnum\yyilen>\z@ % this is an inline rule - \ifnum\yylen>\z@ - \errmessage{an inline rule with a nontrivial left hand side: rule \the\yyn}% - \fi - \else - \yyilen\yylen - \fi - \ifnum\yyilen>\z@ - \yypeekvstack\yyvsa\upto\yyilen - \yyval\csname $$'1\endcsname % $$ = $1 - \fi - % + \preparevaluestack \yyaction % value % \yypopstack\yyvsa\by\yylen @@ -214,6 +189,36 @@ \yynewstate } +\def\preparevaluestack{% + \iftracerules + \ferrmessage{^^Jreducing (rule \the\yyn)}\printrule{\yyn}% + \fi + {% + \iftracestacks + \iftracerules + \else + \ferrmessage{^^J}% + \fi + \showstack\yyssa + \ferrmessage{stack: \stackcs^^Jpopping \the\yylen^^J}% + \fi + }% + \yyilen=\fgetelemof{yyrthree}\at\yyn\relax + \ifnum\yyilen>\z@ % this is an inline rule + \ifnum\yylen>\z@ + \errmessage{an inline rule with a nontrivial left hand side: rule \the\yyn}% + \fi + \else + \yyilen\yylen + \fi + \ifnum\yyilen>\z@ + \yypeekvstack\yyvsa\upto\yyilen % see yymisc.sty for the definition + \yyval\csname $$'1\endcsname % $$ = $1 + \else + \yypeekustack\yyvsa + \fi +} + \newif\iftraceparseresults \def\yypaccept{% @@ -223,6 +228,9 @@ \finishparse } +% most of the error processing mechanisms supplied by the `genuine' \bison\ parsers +% have been omitted for simplicity + \def\yyerr{% \iftraceparseresults \ferrmessage{(parse) error^^J}% @@ -332,13 +340,11 @@ \yytextseen{}% \yytext@seen{}% \yybyte{}% - \yyfbyte{}\yysbyte{}% - \yystash{}% - \yystashseen{}% - \yyformat{}% - \yyformatseen{}% + \initlist\yystash + \appendtolist\yystash{}% increment the list counter + \initlist\yyformat + \appendtolist\yyformat{}% increment the list counter \yyfutureyytext{}% - \yyinitstack\astarray % flattened AST to (possibly) speed up the parser \yyinitstack\yystatestack \yyfmark=\z@ \yysmark=\z@ |