summaryrefslogtreecommitdiff
path: root/support/splint/tex/grabstates.sty
blob: 6fa805168afa56ff2972dcf7b3bf973e2305a606 (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
% Copyright 2012-2015, 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)
\input yyinput.sty  % input functions
\input yyparse.sty  % parser machinery
\input flex.sty     % lexer functions
\input yyfaststack.sty % sped up stack access functions
\input yyboth.sty   % parser initialization, optimization
\input yyunion.sty

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

\let\parsernamespace\mainnamespace
\let\yylexreturn\yylexreturnregular

% main section macro

\let\nx\noexpand

\expandafter\def\csname parserstack[b]\endcsname#1#2{%
    \basicparserinit\yyparse#1\yyeof\yyeof\endparseinput\endparse
    \ifyyparsefail % do nothing if parsing failed
        \yybreak{}%
    \else % Stage three, process the parsed table
        \yybreak{%
            \restorecslist{bootstrap}\yyunion
            \the\table\relax
        }%
    \yycontinue
}

\expandafter\def\csname parserstack[]\endcsname#1#2{%
    \basicparserinit\yyparse#1\yyeof\yyeof\endparseinput\endparse
    \ifyyparsefail % do nothing if parsing failed
        \yybreak{}%
    \else % Stage three, process the parsed table
        \yybreak{%
            \restorecslist{bootstrap}\yyunion
            \the\table\relax
        }%
    \yycontinue
}

\newwrite\stlist