summaryrefslogtreecommitdiff
path: root/support/splint/tex/grabstates.sty
blob: 1024d99432609c96d7bc1d4b3c59db12a7f66abc (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
% Copyright 2012-2020, Alexander Shibakov
% This file is part of SPLinT
%
% SPLinT is free software: you can redistribute it and/or modify
% it under the terms of the GNU General Public License as published by
% the Free Software Foundation, either version 3 of the License, or
% (at your option) any later version.
%
% SPLinT is distributed in the hope that it will be useful,
% but WITHOUT ANY WARRANTY; without even the implied warranty of
% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
% GNU General Public License for more details.
%
% You should have received a copy of the GNU General Public License
% along with SPLinT.  If not, see <http://www.gnu.org/licenses/>.

\def\optimization{5}

\input yycommon.sty % general routines for stack and array access
\input yymisc.sty   % helper macros (stack manipulation, table processing, value stack pointers)
                    % parser initialization, optimization
\input yyinput.sty  % input functions
\input yyparse.sty  % parser machinery
\input flex.sty     % lexer functions
\input yyfaststack.sty % sped up stack access functions
\input yyunion.sty

\def\yycomplain#1{\immediate\write16{#1}} % lexer errors

% modify the input routine to recognize \yyendgame; the somewhat verbose end of
% the section is necessary to gracefully handle parser failures: the \endparse
% control sequence must appear outside of any \vb block for \cleanupparse
% to do its job; the \yyinput reads \vb blocks in pairs so the closing \vb{} is
% necessary and is removed by \removefinalvb (see limbo.sty and brack.pl for
% details).

\expandafter\def\expandafter\multicharswitch\expandafter
{\multicharswitch\yyendgame{\yyinput\yyeof\yyeof\endparseinput\removefinalvb}}

\genericparser 
    name: grabstates, 
    ptables: cweb/byytab.tex, 
    ltables: cweb/lstab.tex, 
    tokens: {}, 
    asetup: \let\setflexstates\relax, 
    dsetup: {}, 
    rsetup: {},
    optimization: \optimizeall;%

\let\parsernamespace\grabstatesnamespace
\let\yylexreturn\yylexreturnregular

% stage two parsing macros

\let\nx\noexpand

\def\preparsegrabstates{%
    \let\postparse\postparsegrabstates
    \basicparserinit
    \yyparse
}

\def\postparsegrabstates{%
    \ifyyparsefail % do nothing if parsing failed
        \yybreak{}%
    \else % Stage three, process the parsed table
        \yybreak{%
            \restorecslist{bootstrap}\yyunion % TODO: this will not work in fs1 sections
            \the\table\relax
        }%
    \yycontinue
}

\fillpstack{b}{%
    \preparsegrabstates
    \relax
}

\fillpstack{fs1}{%
    \preparsegrabstates
    \relax
}

% ignore in text production examples (there is no way or need to parse them anyway)

\long\def\beginprod#1\endprod{}

\let\begincprod\beginprod

\def\nameproc#1\with#2{%
    #2{}{}{}{}{}% pretend the name is empty
}

\def\frexproc#1\with#2{%
    #2{}{}{}% pretend the regex is empty
}

\def\prodstyle#1{}

\newwrite\stlist