diff options
author | Norbert Preining <norbert@preining.info> | 2020-10-12 03:04:00 +0000 |
---|---|---|
committer | Norbert Preining <norbert@preining.info> | 2020-10-12 03:04:00 +0000 |
commit | 0ce40abb18ec02ec6fd6bcc5f21612c88daa7578 (patch) | |
tree | 416289fe1448873fd8ca33051f50ad85bffa8aaa /support/splint/tex/yyparse.sty | |
parent | fdb18507cd80dc17f5a5256153d34668b4f4e61c (diff) |
CTAN sync 202010120303
Diffstat (limited to 'support/splint/tex/yyparse.sty')
-rw-r--r-- | support/splint/tex/yyparse.sty | 68 |
1 files changed, 53 insertions, 15 deletions
diff --git a/support/splint/tex/yyparse.sty b/support/splint/tex/yyparse.sty index ce5ab8b5e3..f6c6dadff8 100644 --- a/support/splint/tex/yyparse.sty +++ b/support/splint/tex/yyparse.sty @@ -1,4 +1,4 @@ -% Copyright 2012-2015, Alexander Shibakov +% Copyright 2012-2020, Alexander Shibakov % This file is part of SPLinT % % SPLinT is free software: you can redistribute it and/or modify @@ -37,14 +37,14 @@ \yypushr\yystate\on\yyssa {% \iftraceparserstates - \derrmessage{^^Jstate \the\yystate\iftracestacks, \fi}% + \ferrmessage{^^Jstate \the\yystate\iftracestacks, \fi}% \fi \iftracestacks \iftraceparserstates \else - \derrmessage{^^J}% + \ferrmessage{^^J}% \fi - \showstack\yyssa\derrmessage{state stack: \stackcs^^J}% + \showstack\yyssa\ferrmessage{state stack: \stackcs^^J}% \fi }% \yybreak\yybackup @@ -117,7 +117,7 @@ \yybreak@@@\yynewstate % new state will be shifted \else % ...if (yyn < 0) \iffalse % if (yytable_value_is_error(yyn)) - % \ifnum\yyn=\YYTABLEERROR\relax + % /* #define yytable_value_is_error(Yytable_value) YYID (0) */ \yybreak@@@@\yyerr \else \yyn=-\yyn @@ -137,7 +137,7 @@ \yyn=\fgetelemof{yydefact}\at\yystate\relax % yyn = yydefact[yystate] \iftraceactions - \derrmessage{default action^^J}% + \ferrmessage{default action^^J}% \fi \ifnum\yyn=\z@ \xskiptofi\yyerr @@ -149,16 +149,16 @@ \def\yyreduce{% \yylen=\fgetelemof{yyrtwo}\at\yyn\relax \iftracerules - \derrmessage{^^Jreducing (rule \the\yyn)}\printrule{\yyn}% + \ferrmessage{^^Jreducing (rule \the\yyn)}\printrule{\yyn}% \fi {% \iftracestacks \iftracerules \else - \derrmessage{^^J}% + \ferrmessage{^^J}% \fi \showstack\yyssa - \derrmessage{stack: \stackcs^^Jpopping \the\yylen^^J}% + \ferrmessage{stack: \stackcs^^Jpopping \the\yylen^^J}% \fi }% \yyilen=\fgetelemof{yyrthree}\at\yyn\relax @@ -218,14 +218,14 @@ \def\yypaccept{% \iftraceparseresults - \derrmessage{accepted^^J}% + \ferrmessage{accepted^^J}% \fi \finishparse } \def\yyerr{% \iftraceparseresults - \derrmessage{(parse) error^^J}% + \ferrmessage{(parse) error^^J}% \fi \cleanupparse } @@ -235,10 +235,12 @@ \let\yysymswitch\eatone \let\yysymcleanup\eatone +% parser specific output message: defines the current token name to output + \def\derrmessage#1{{% \newlinechar=`\^^J% \edef\tokname{\fgetelemof{yytname}\at\yytoken}% - \message{#1}% + \ferrmessage{#1}% }} % these macros reuse dedicated counters ... locally @@ -256,7 +258,7 @@ \else \edef\ruleline{\ruleline\space<empty>}% \fi - \message{ -->\ruleline}% + \ferrmessage{ -->\ruleline}% }} % print the rule without using yyprhs and yyrhs (necessary if using @@ -269,7 +271,7 @@ \else \edef\ruleline{\ruleline\space<empty>}% \fi - \message{ -->\ruleline}% + \ferrmessage{ -->\ruleline}% }} \def\appendtoruleline#1{% @@ -293,7 +295,7 @@ \long\def\cleanupparse#1\endparse{% \iftracediscardedinput - \immediate\write16{discarding the rest of the input}% + {\toksa{#1}\immediate\write16{discarding the rest of the input: \the\toksa}}% \fi \yyerror } @@ -317,3 +319,39 @@ % \yysymcleanup{\yyn}% removing symbol names from the namespace } + +% common parser initializations; note that some initializations (such as resetting the data +% and state stacks) are done at parser startup (see the definition of \yyparse) + +\def\basicparserinit{% + \yytext{}% + \yysubtext{}% + \yytext@{}% + \yytextpure{}% + \yytextseenpure{}% + \yytextseen{}% + \yytext@seen{}% + \yybyte{}% + \yyfbyte{}\yysbyte{}% + \yystash{}% + \yystashseen{}% + \yyformat{}% + \yyformatseen{}% + \yyfutureyytext{}% + \yyinitstack\astarray % flattened AST to (possibly) speed up the parser + \yyinitstack\yystatestack + \yyfmark=\z@ + \yysmark=\z@ + \yyfmarklast=\z@ + \yyfmark@accept=\z@ + \formatmarker=\z@ + \yysmarklast=\z@ + \yysmark@accept=\z@ + \stashmarker=\z@ + \yytextbackupfalse + \yyg@yyinit=\z@ + \yyg@yystart=\z@ + \YYATBOL=\@ne + \yyparsefailfalse + \YYEOBLASTMATCHtrue +} |