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
|
% 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/>.
% token equivalence table does not exist, switch to a bootstrap parser
\ifx\tokendeffile\UNDEFINED
\else
\immediate\openout\tokendefs=\tokendeffile
\fi
\genericparser
name: bootstrap,
ptables: \bstrapparser,
ltables: cweb/ltab.tex,
tokens: {},
asetup: \bootstraplexersetup,
dsetup: \newlexerstateextra\newparserstateextra,
rsetup: {},
optimization: \optimizeall;%
\tobootstrapparser % this saves the current state
% stage two macros: parsing
% note that the bootstrap parser has no way of telling if the \%token declarations
% belong to the current parser or not (for example, the \flex\ parser has its own
% declarations); it is thus important to make sure that the \%token declarations in
% the file visible to the parser belong to a single parser (so the file read by the
% bootstrap parser does not have declarations sections for a a parser other than
% \bison's.
\def\preparsebootstrap{%
\let\postparse\postparsebootstrap
\tobootstrapparser % this is not currently required since there are no namespace switching macros
% in the \TeX\ portion of the text; it is left here in case such macros are used in the future
\basicparserinit
\bisonparserinit
\bisonparserdatainit
\yyparse
}
\def\postparsebootstrap{%
\ifyyparsefail % do nothing if parsing failed
\yybreak{}%
\else % Stage three, process the parsed table
\yybreak{\initbootstrap\the\table}%
\yycontinue
}
\fillpstack{b}{%
\preparsebootstrap
\relax
}
% sections with no parser tag are assumed to be bison sections
\fillpstack{}{%
\preparsebootstrap
\relax
}
% ignore in text production examples (there is no way 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{}
\input yydebug.sty
|