summaryrefslogtreecommitdiff
path: root/support/splint/tex/yyfaststack.sty
diff options
context:
space:
mode:
Diffstat (limited to 'support/splint/tex/yyfaststack.sty')
-rw-r--r--support/splint/tex/yyfaststack.sty94
1 files changed, 42 insertions, 52 deletions
diff --git a/support/splint/tex/yyfaststack.sty b/support/splint/tex/yyfaststack.sty
index 9bf46b3d1e..832ef8cfce 100644
--- a/support/splint/tex/yyfaststack.sty
+++ b/support/splint/tex/yyfaststack.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
@@ -61,7 +61,7 @@
0\expandafter\noexpand\csname \expandafter\eatone\string#1[#2]\parsernamespace\endcsname
}
-\def\movestackpointer#1\by#2{%
+\def\movestackpointer#1\by#2{% this assumes that #1 is a control sequence
\expandafter\advance\csname \expandafter\eatone\string#1<count>\endcsname#2%
}
@@ -88,6 +88,11 @@
\expandafter\expandafter\expandafter\edef\gettopofstackcs#2{#1}%
}
+\long\def\yypushg#1\on#2{% global push with expand: do not use this for anything other than index macros
+ \expandafter\global\romannumeral0\movestackpointer#2\by\@ne
+ \expandafter\expandafter\expandafter\xdef\gettopofstackcs#2{#1}%
+}
+
% push register contents on a stack: #1 is a register, #2 is a stack
\def\yypushr#1\on#2{%
@@ -176,6 +181,34 @@
\expandafter\yyreadvst@ck\expandafter{\number\xincrement{#2}}{#1}{#3}%
}
+% macros to read the stack from top to bottom (i.e.~in `reverse' order)
+\def\yyreadustack#1{% we do not compute anything unless the postprocessor
+ % detected an implicit rule
+ \ifnum\number\yycomputeilength{\number\yyn}>\z@
+ \yybreak{\expandafter\yyr@@@ust@@k\expandafter{\number\toptoks}{1}{#1}}%
+ \else
+ \yybreak{}%
+ \yycontinue
+}
+
+\def\yyr@@@ust@@k#1#2#3{%
+ \yyr@@dust@@k{#2}{#1}{#3}%
+}
+
+\def\yyreadust@ck#1#2#3{%
+ \expandafter\toksdef\csname$$$'#2\endcsname=#1\relax %
+ \expandafter\yypop\expandafter#3\expandafter\into\csname$$$'#2\endcsname%$
+ \ifnum\number\yycomputeilength{\number\yyn}>#2 %
+ \yybreak{\expandafter\yyr@@dust@@k\expandafter{\number\xincrement{#2}}{#1}{#3}}%
+ \else
+ \yybreak\relax
+ \yycontinue
+}
+
+\def\yyr@@dust@@k#1#2#3{%
+ \expandafter\yyreadust@ck\expandafter{\number\xincrement{#2}}{#1}{#3}%
+}
+
% end of replacement macros
\def\yypeekvstack#1\upto#2{% assume that #2 > 0
@@ -183,6 +216,11 @@
\movestackpointer#1\by#2\relax
}
+\def\yypeekustack#1{%
+ \yyreadustack#1%
+ \movestackpointer#1\by\number\yycomputeilength{\number\yyn}\relax
+}
+
% macros for reading the state stack (needed if using bison version 3.0 and above)
\def\yyreadsstack#1\upto#2\withprefix#3{% assume that #2 > 0
@@ -238,7 +276,7 @@
\def\yn#1#{%
\ifnum#1<\@ne
- \yybreak{\putyyval}%
+ \yybreak{\yyvalx}%
\else
\yybreak{\p@tyyassignment{#1}}%
\yycontinue
@@ -259,7 +297,7 @@
}%
}
-% \bb macro implementation
+% new \bb macro implementation
\def\p@twwassignment#1{%
\expandafter\advance\csname yyvsa<count>\endcsname-#1\relax
@@ -280,8 +318,6 @@
#2\yystringempty{#3}{#1}{#3{#1}}%
}
-\def\putyyval#1{\edef\next{\yyval{#1}}\next}
-
% dysplaying stack contents (\yyparse specific)
\def\showstack#1{%
@@ -338,49 +374,3 @@
\def\appendtoyytname{\appendtoyy@generic{#1}}%
\def\appendtoyytnamelast{\appendtoyy@genericlast{#1}}%
}
-
-% list macros
-
-\def\listx#1{% #1 is the list name
- \expandafter\ifx\csname #1[\the\csname#1<count>\endcsname]\endcsname\relax
- \csname#1<count>\endcsname\z@
- \yybreak\relax
- \else
- \yybreak{\csname #1[\the\csname#1<count>\endcsname]\endcsname
- \expandafter\advance\csname#1<count>\endcsname\@ne
- \listx{#1}}%
- \yycontinue
-}
-
-\def\newlist#1{%
- \toksa{\csname newcount\endcsname}%
- \expandafter\the\expandafter\toksa\csname#1<count>\endcsname
-}
-
-\def\initlistx#1{%
- \csname#1<count>\endcsname\z@
- \expandafter\let\csname #10\endcsname\relax
-}
-
-\def\resetlistx#1{%
- \csname#1<count>\endcsname\z@
-}
-
-\def\listxlastindex#1{%
- \the\csname#1<count>\endcsname
-}
-
-\def\addtolist#1#2{%
- \expandafter\def\csname#1[\the\csname#1<count>\endcsname]\endcsname{#2}%
- \expandafter\advance\csname#1<count>\endcsname\@ne
-}
-
-\def\addxtolist#1#2{%
- \expandafter\edef\csname#1[\the\csname#1<count>\endcsname]\endcsname{#2}%
- \expandafter\advance\csname#1<count>\endcsname\@ne
-}
-
-\def\finishlist#1{%
- \expandafter\advance\csname#1<count>\endcsname\@ne
- \expandafter\let\csname#1[\the\csname#1<count>\endcsname]\endcsname\relax
-}