summaryrefslogtreecommitdiff
path: root/support/splint/tex/yydebug.sty
blob: 0d763aecfaafae981adef709a5ed044ce96d48b6 (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
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
% 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/>.

% handy debugging shortcuts

\def\yydebugsetup{% initialize debugging (note that arbitrary commands 
                  % can be also inserted by \insertraw{...}
    \expandafter\def\expandafter\multicharswitch % allow execution of any code in the middle of input
        \expandafter{\multicharswitch\yydebugbegin\yydebugend{\the\yybyte}}%
}

\def\yydebuggenericstart{% generic command executed in the middle of input
    \yydebugmost % turn on tracing
    \yyinput % ... and continue
}

\def\yydebuggenericfinish{% stop debugging
    \yydebugnone % turn off tracing
    \yyinput % ... and continue
}

\let\yydebugbegin\yydebuggeneric
\let\yydebugend\yydebuggenericfinish

\newif\ifcdebug % a temporary conditional

\def\yydebugall{% turn all debugging options on
    \yydebugmost
    \checktabletrue
    \saveparseoutputtrue
}

\def\yydebugparse{%
    \tracelookaheadtrue
    \traceparseresultstrue
    \traceparserstatestrue
    \tracerulestrue
    \tracestackstrue
    \tracediscardedinputtrue
}

\def\reporttokendisplay{% to make this skippable in bootstrap mode
    \ifdisplaytokenraw\ferrmessage{tokens are typeset as is^^J}\fi
}

\def\yydebugmost{% do not save or display the tables
    \ifbootstrapmode
        \ferrmessage{*** bootstrap mode is on ***^^J^^J}%
    \else
        \reporttokendisplay
        \checktrimtrue
        \parseverbosetrue
        \checktrailingstashtrue
    \fi
    \ifbracketedvisible\ferrmessage{Symbolic term names are visible^^J}\fi
    \iftermindex\else\ferrmessage{Indexing is turned off^^J}\fi
    \ifshowlastaction\else\ferrmessage{Last action will not be shown}\fi
    \ifxreflocal\else\ferrmessage{Cross references are generated in noweb style}\fi
    \ifx\optimization\UNDEFINED
    \else
        \ferrmessage{Optimization level set at \number\optimization^^J}%
    \fi

    \tracingonline=3
    \showboxbreadth=10000
    \showboxdepth=10000
%
    \yydebugparse
    \traceactioncodetrue
    \traceactionstrue
    \tracebadcharstrue
    \tracebadnamestrue
    \tracedfatrue
    \traceflexbufferstrue
    \tracenamestrue
    \tracestatestrue
    \traceswitchlabelstrue
    \tracetexpptrue
    \tracetokennamestrue
    \yyflexdebugtrue
    \yyinputdebugtrue
    \yytracereplacementstrue
    \traceprettytokenstrue
}

\def\yydebugnone{% turn all debugging options off
    \checktablefalse
    \ifbootstrapmode
    \else
        \checktrimfalse
        \parseverbosefalse
    \fi
    \saveparseoutputfalse
    \traceactioncodefalse
    \traceactionsfalse
    \tracebadcharsfalse
    \tracebadnamesfalse
    \tracedfafalse
    \tracediscardedinputfalse
    \traceflexbuffersfalse
    \tracelookaheadfalse
    \tracenamesfalse
    \traceparseresultsfalse
    \traceparserstatesfalse
    \tracerulesfalse
    \tracestacksfalse
    \tracestatesfalse
    \traceswitchlabelsfalse
    \tracetexppfalse
    \tracetokennamesfalse
    \yyflexdebugfalse
    \yyinputdebugfalse
    \yytracereplacementsfalse
    \cdebugfalse
}

% miscellaneous shortcuts

\def\shownethe#1{%
    {%
        \edef\next{\the#1}%
        \ifx\next\empty
        \else
            \showthe#1%
        \fi
    }%
}

\def\showem#1#2#3{\toksa{#1}\toksb{#2}\toksc{#3}{\newlinechar=`^^J%
    \errmessage{%
        arg. 1: \the\toksa^^J%
        arg. 2: \the\toksb^^J%
        arg. 3: \the\toksc%
}}}