summaryrefslogtreecommitdiff
path: root/support/splint/cweb/np.w
blob: a4216ee0581c2ba98c68c00fdc199fddd04de0b4 (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
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
@q Copyright 2012-2024, Alexander Shibakov@>
@q This file is part of SPLinT@>

@q SPLinT is free software: you can redistribute it and/or modify@>
@q it under the terms of the GNU General Public License as published by@>
@q the Free Software Foundation, either version 3 of the License, or@>
@q (at your option) any later version.@>

@q SPLinT is distributed in the hope that it will be useful,@>
@q but WITHOUT ANY WARRANTY; without even the implied warranty of@>
@q MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the@>
@q GNU General Public License for more details.@>

@q You should have received a copy of the GNU General Public License@>
@q along with SPLinT.  If not, see <http://www.gnu.org/licenses/>.@>

@** The name parser. What follows is an example parser for the term
name processing. This approach (i.e. using a `full blown' parser/scanner
combination) is probably not the best way to implement such machinery
but its main purpose is to demonstrate a way to create a separate
parser for local purposes. The name parser is what allows one to
automatically typeset term names such as \.{example1}
and \.{\%option\_name} as \prodstyle{example1} and \prodstyle{\%option_name}.
@q The reference to \prodstyle{example1} above serves a dual role of correcting@>
@q an owerfull \vbox in the index.@>
% We include the macros here since this file is intended to be
% included by the documentation `aggregator' so putting bare \TeX\
% at the beginning of the file runs the risk of producing and error
% of having \TeX\ material inside a \Cee\ section.
\let\currentparsernamespace\parsernamespace
    \let\parsernamespace\smallnamespace
    \let\hostparsernamespace\smallnamespace
    \input stokenset.sty
\let\parsernamespace\currentparsernamespace
@(small_parser.yy@>=
@G Switch to generic mode.
%{@> @<Name parser \Cee\ preamble@> @=%}
 @> @<Bison options@> @= 
%union {@> @<Union of parser types@> @=}
%{@> @<Name parser \Cee\ postamble@> @=%}
 @> @<Token and types ...@> @= 
%%
 @> @<Parser productions@> @= 
%%
@g

@ @<Bison options@>=
@G
%token-table
%debug
%start full_name
@g

@ @<Token and types declarations@>=
@G
%token PERCENT_IDENTIFIER
%token IDENTIFIER
%token OPTIONAL NO_ATTR EXTENDED LT RT
%token INTEGER
%token WILDCARD C_ESCCHAR
%token META_IDENTIFIER
@g

@ @<Parser productions@>=
@G
full_name:
  identifier_string suffixes.opt  {@> @<Compose the full name@> @=}
| META_IDENTIFIER                 {@> @<Turn a \prodstylens{META_IDENTIFIER}{\smallnamespace} into a full name@> @=}
| quoted_name suffixes.opt        {@> @<Compose the full name@> @=}
;

identifier_string:
   PERCENT_IDENTIFIER             {@> @<Attach option name@> @=}  
|  IDENTIFIER                     {@> @<Start with an identifier@> @=}
|  '<' IDENTIFIER '>'             {@> @<Start with a tag@> @=}
|  '\'' WILDCARD '\''             {@> @<Start with a quoted string@> @=}
|  '\'' C_ESCCHAR '\''            {@> @<Start with an escaped character@> @=}
|  '\'' '>' '\''                  {@> @<Start with a \prodstyle{'>'} string@> @=}
|  '\'' '<' '\''                  {@> @<Start with a \prodstyle{'<'} string@> @=}
|  '\'' '.' '\''                  {@> @<Start with a \prodstyle{'.'} string@> @=}
|  '\'' '_' '\''                  {@> @<Start with an \prodstyle{'\_'} string@> @=}
|  '\'' '-' '\''                  {@> @<Start with a \prodstyle{'-'} string@> @=}
|  '\'' '$' '\''                  {@> @<Start with a \prodstyle{'\$'} string@> @=}
|  '$'                            {@> @<Prepare a \bison\ stack name@> @=}
|  qualifier                      {@> @<Turn a qualifier into an identifier@> @=}
|  identifier_string IDENTIFIER   {@> @<Attach an identifier@> @=}
|  identifier_string qualifier    {@> @<Attach qualifier to a name@> @=}
|  identifier_string INTEGER      {@> @<Attach an integer@> @=}
;

quoted_name:
   '\"' PERCENT_IDENTIFIER '\"'   {@> @<Process quoted option@> @=}  
|  '\"' IDENTIFIER '\"'           {@> @<Process quoted name@> @=}
;
suffixes.opt:
                                  {@> TeX_( "/yy0{}" ); @=}
|  '.'                            {@> TeX_( "/yy0{/nx/dotsp/nx/sfxnone}" ); @=}
|  '.' suffixes                   {@> @<Attach suffixes@> @=}
|  '.' qualified_suffixes         {@> @<Attach qualified suffixes@> @=}
;

suffixes:
   IDENTIFIER                     {@> @<Start with a named suffix@> @=}
|  INTEGER                        {@> @<Start with a numeric suffix@> @=}
|  suffixes '.'                   {@> @<Add a dot separator@> @=}
|  suffixes IDENTIFIER            {@> @<Attach a named suffix@> @=}
|  suffixes INTEGER               {@> @<Attach integer suffix@> @=}
|  qualifier '.'                  {@> TeX_( "/yy0{/nx/sfxn/the/yy(1)/nx/dotsp}" ); @=}
|  suffixes qualifier '.'         {@> TeX_( "/yy0{/the/yy(1)/nx/sfxn/the/yy(2)/nx/dotsp}" ); @=}
;

qualified_suffixes:
  suffixes qualifier              {@> @<Attach a qualifier@> @=}
| qualifier                       {@> @<Start suffixes with a qualifier@> @=}
;

@t}\vb{\inline\flatten}{@>
qualifier:
  OPTIONAL                        {@> TeX_( "/yy0{/the/yy(1)}" ); @=}
| NO_ATTR                         {@> TeX_( "/yy0{/the/yy(1)}" ); @=}
| EXTENDED                        {@> TeX_( "/yy0{/the/yy(1)}" ); @=}
| LT                              {@> TeX_( "/yy0{/the/yy(1)}" ); @=}
| RT                              {@> TeX_( "/yy0{/the/yy(1)}" ); @=}
;
@g

@ @<Compose the full name@>=
  @[TeX_( "/yy0{/the/yy(1)/the/yy(2)}/namechars/yyval" );@]@;

@ @<Turn a \prodstylens{META_IDENTIFIER}{\smallnamespace} into a full name@>=
  @[TeX_( "/getfirst{/yy(1)}/to/toksa" );@]@;
  @[TeX_( "/getsecond{/yy(1)}/to/toksb" );@]@;
  @[TeX_( "/yy0{/nx/idstr{/the/toksa}{/the/toksb}}/namechars/yyval" );@]@;

@ @<Attach option name@>=
  @[TeX_( "/getfirst{/yy(1)}/to/toksa" );@]@;
  @[TeX_( "/getsecond{/yy(1)}/to/toksb" );@]@;
  @[TeX_( "/yy0{/nx/optstr{/the/toksa}{/the/toksb}}" );@]@;

@ @<Start with an identifier@>=
  @[TeX_( "/getfirst{/yy(1)}/to/toksa" );@]@;
  @[TeX_( "/getsecond{/yy(1)}/to/toksb" );@]@;
  @[TeX_( "/yy0{/nx/idstr{/the/toksa}{/the/toksb}}" );@]@;

@ Tags are recognized as a separate syntax element although no special
processing is performed by the name parser or the associated macros.
@<Start with a tag@>=
  @[TeX_( "/getfirst{/yy(2)}/to/toksa" );@]@;
  @[TeX_( "/getsecond{/yy(2)}/to/toksb" );@]@;
  @[TeX_( "/yy0{/nx/idstr{</the/toksa>}{</the/toksb>}}" );@]@;

@ @<Start with a quoted string@>=
  @[TeX_( "/getfirst{/yy(2)}/to/toksa" );@]@;
  @[TeX_( "/getsecond{/yy(2)}/to/toksb" );@]@;
  @[TeX_( "/sansfirst/toksb" );@]@;
  @[TeX_( "/yy0{/nx/chstr{/the/toksb}{/the/toksb}/nx/visflag{/nx/termvstring}{}}" );@]@;

@ @<Start with an escaped character@>=
  @[TeX_( "/getsecond{/yy(2)}/to/toksb" );@]@;
  @[TeX_( "/yy0{/nx/chstr{/the/toksb}{/the/toksb}/nx/visflag{/nx/termvstring}{}}" );@]@;

@ @<Start with a \prodstyle{'<'} string@>=
  @[TeX_( "/yy0{/nx/chstr{<}{<}/nx/visflag{/nx/termvstring}{}}" );@]@;

@ @<Start with a \prodstyle{'>'} string@>=
  @[TeX_( "/yy0{/nx/chstr{/greaterthan}{/greaterthan}/nx/visflag{/nx/termvstring}{}}" );@]@;

@ @<Start with an \prodstyle{'\_'} string@>=
  @[TeX_( "/yy0{/nx/chstr{/uscoreletter}{/uscoreletter}/nx/visflag{/nx/termvstring}{}}" );@]@;

@ @<Start with a \prodstyle{'-'} string@>=
  @[TeX_( "/yy0{/nx/chstr{-}{-}/nx/visflag{/nx/termvstring}{}}" );@]@;

@ @<Start with a \prodstyle{'\$'} string@>=
  @[TeX_( "/yy0{/nx/chstr{/safemath}{/safemath}/nx/visflag{/nx/termvstring}{}}" );@]@;

@ @<Start with a \prodstyle{'.'} string@>=
  @[TeX_( "/yy0{/nx/chstr{.}{.}/nx/visflag{/nx/termvstring}{}}" );@]@;

@ @<Prepare a \bison\ stack name@>=
  @[TeX_( "/yy0{/nx/bidstr{/nx/$}{/safemath}}" );@]@;

@ @<Turn a qualifier into an identifier@>=
  @<Start with an identifier@>@;

@ @<Attach an identifier@>=
  @[TeX_( "/getsecond{/yy(1)}/to/toksa" );@]@;
  @[TeX_( "/appendr/toksa{/space}" );@]@;  
  @[TeX_( "/getfirst{/yy(2)}/to/toksb" );@]@;
  @[TeX_( "/concat/toksa/toksb" );@]@;
  @[TeX_( "/getthird{/yy(1)}/to/toksb" );@]@;
  @[TeX_( "/appendr/toksb{/space}" );@]@;  
  @[TeX_( "/getsecond{/yy(2)}/to/toksc" );@]@;
  @[TeX_( "/concat/toksb/toksc" );@]@;
  @[TeX_( "/yy0{/nx/idstr{/the/toksa}{/the/toksb}}" );@]@;

@ @<Attach qualifier to a name@>=
  @<Attach an identifier@>

@ An integer at the end of an identifier (such as |id1|) is
interpreted as a suffix (similar to the way \MF\ treats identifiers,
and \mft\ typesets them,\footnote{This allows, for example, names like
|$[term0]| while leaving |$[char2int]| in its `natural' form.} as \prodstyle{id1}) to
mitigate a well-intentioned but surprisingly inconvenient feature of
\CTANGLE, namely outputting something like \.{id.1} as \.{id\ .1} in an
attempt to make sure that integers do not interfere with structure
dereferences. For this to produce meaningful results, a stricter
interpretation of \prodstyle{IDENTIFIER} syntax is required,
represented by the \flexrenstyle{id\_strict} syntax
\locallink{id_strict definition}below\endlink.
@<Attach an integer@>=
  @[TeX_( "/yy0{/the/yy(1)/nx/dotsp/nx/sfxi/the/yy(2)}" );@]@;
                               
@ @<Process quoted name@>=
  @[TeX_( "/getfirst{/yy(2)}/to/toksa" );@]@;
  @[TeX_( "/getsecond{/yy(2)}/to/toksb" );@]@;
  @[TeX_( "/yy0{/nx/idstr{/the/toksa}{/the/toksb}/nx/visflag{/nx/termvstring}{}}" );@]@;

@ @<Process quoted option@>=
  @[TeX_( "/getfirst{/yy(2)}/to/toksa" );@]@;
  @[TeX_( "/getsecond{/yy(2)}/to/toksb" );@]@;
  @[TeX_( "/yy0{/nx/optstr{/the/toksa}{/the/toksb}/nx/visflag{/nx/termvstring}{}}" );@]@;

@ @<Attach suffixes@>=
  @[TeX_( "/yy0{/nx/dotsp/the/yy(2)}" );@]@;

@ @<Attach qualified suffixes@>=
  @<Attach suffixes@>@;

@ @<Start with a named suffix@>=
  @[TeX_( "/yy0{/nx/sfxn/the/yy(1)}" );@]@;

@ @<Start with a numeric suffix@>=
  @[TeX_( "/yy0{/nx/sfxi/the/yy(1)}" );@]@;

@ @<Add a dot separator@>=
  @[TeX_( "/yy0{/the/yy(1)/nx/dotsp}" );@]@;

@ @<Attach integer suffix@>=
  @[TeX_( "/yy0{/the/yy(1)/nx/sfxi/the/yy(2)}" );@]@;

@ @<Attach a named suffix@>=
  @[TeX_( "/yy0{/the/yy(1)/nx/sfxn/the/yy(2)}" );@]@;

@ @<Attach a qualifier@>=
  @[TeX_( "/yy0{/the/yy(1)/nx/qual/the/yy(2)}" );@]@;

@ @<Start suffixes with a qualifier@>=
  @[TeX_( "/yy0{/nx/qual/the/yy(1)}" );@]@;

@ \Cee\ preamble. In this case, there are no `real' actions that our
grammar performs, only \TeX\ output, so this section is empty.

@<Name parser \Cee\ preamble@>=

@ \Cee\ postamble. It is tricky to insert function definitions that use \bison's internal types,
as they have to be inserted in a place that is aware of the internal definitions but before said 
definitions are used.

@<Name parser \Cee\ postamble@>=

@ Union of types.

@<Union of parser types@>=

@** The name scanner.
The scanner for lexing term names is admittedly {\em ad hoc\/} and
rather redundant. A minor reason for this is to provide some
flexibility for name typesetting. Another reason is to let the
existing code serve as a template for similar procedures in other
projects. At the same time, it must be pointed out that this scanner
is executed multiple times for every \bison\ section, so its
efficiency directly affects the speed at which the parser operates.
@(small_lexer.ll@>=
@G
 @> @<Lexer definitions@> @= 
%{@> @<Lexer \Cee\ preamble@> @=%}
 @> @<Lexer options@> @= 
%%
 @> @<Regular expressions@> @= 
%%
@O
void define_all_states( void ) {
    @<Collect all state definitions@>@;
}
@o
@g

@ \namedspot{id_strict definition}The tokens consumed by the name parser must
represent a relatively fine classification of various identifier substrings to be able to
detect various suffixes.
@<Lexer definitions@>=
  @<Lexer states@>@;
@G(fs1)
letter    [_abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ]
c-escchar \\[fnrtv]
wc        ([^\\\'\"$.<>]{-}[_abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0-9]|\\.)
id        {letter}({letter}|[-0-9])*
id_strict {letter}(({letter}|[-0-9])*{letter})?
meta_id   "*"{id_strict}"*"?
int       [0-9]+
@g

@ @<Collect all state definitions@>=
#define _register_name( name ) @[Define_State( #name, name )@]
/* nothing for now */
#undef _register_name

@ Strings and characters in directives/rules.
@<Lexer states@>=
@G(fs1)
%x SC_ESCAPED_STRING SC_ESCAPED_CHARACTER
@g

@ @<Lexer \Cee\ preamble@>=

#include <stdint.h>
#include <stdbool.h>

@ @<Lexer options@>=
@G(fs1)
%option bison-bridge
%option noyywrap nounput noinput reentrant 
%option noyy_top_state
%option debug
%option stack
%option outfile="small_lexer.c"
@g

@ @<Regular expressions@>=
  @<Scan white space@>@;
  @<Scan identifiers@>@;

@ White space skipping. 
@<Scan white space@>=
@G(fs2)
[ \f\n\t\v]                        {@> @[TeX_( "/yylexnext" );@]@=}
@g

@ This collection of regular expressions might seem redundant, and in
its present state, it certainly is. However, if later on the
typesetting style for some of the keywords would need to be adjusted,
such changes would be easy to implement, since the template is already
here.
@<Scan identifiers@>=
@G(fs2)
"%binary"                          {@> @[TeX_( "/yylexreturnval{PERCENT_IDENTIFIER}" );@]@=}
"%code"                            {@> @[TeX_( "/yylexreturnval{PERCENT_IDENTIFIER}" );@]@=}
"%debug"                           {@> @[TeX_( "/yylexreturnval{PERCENT_IDENTIFIER}" );@]@=}
"%default-prec"                    {@> @[TeX_( "/yylexreturnval{PERCENT_IDENTIFIER}" );@]@=}
"%define"                          {@> @[TeX_( "/yylexreturnval{PERCENT_IDENTIFIER}" );@]@=}
"%defines"                         {@> @[TeX_( "/yylexreturnval{PERCENT_IDENTIFIER}" );@]@=}
"%destructor"                      {@> @[TeX_( "/yylexreturnval{PERCENT_IDENTIFIER}" );@]@=}
"%dprec"                           {@> @[TeX_( "/yylexreturnval{PERCENT_IDENTIFIER}" );@]@=}
"%empty"                           {@> @[TeX_( "/yylexreturnval{PERCENT_IDENTIFIER}" );@]@=}
"%error-verbose"                   {@> @[TeX_( "/yylexreturnval{PERCENT_IDENTIFIER}" );@]@=}
"%expect"                          {@> @[TeX_( "/yylexreturnval{PERCENT_IDENTIFIER}" );@]@=}
"%expect-rr"                       {@> @[TeX_( "/yylexreturnval{PERCENT_IDENTIFIER}" );@]@=}
"%file-prefix"                     {@> @[TeX_( "/yylexreturnval{PERCENT_IDENTIFIER}" );@]@=}
"%fixed-output-files"              {@> @[TeX_( "/yylexreturnval{PERCENT_IDENTIFIER}" );@]@=}
"%initial-action"                  {@> @[TeX_( "/yylexreturnval{PERCENT_IDENTIFIER}" );@]@=}
"%glr-parser"                      {@> @[TeX_( "/yylexreturnval{PERCENT_IDENTIFIER}" );@]@=}
"%language"                        {@> @[TeX_( "/yylexreturnval{PERCENT_IDENTIFIER}" );@]@=}
"%left"                            {@> @[TeX_( "/yylexreturnval{PERCENT_IDENTIFIER}" );@]@=}
"%lex-param"                       {@> @[TeX_( "/yylexreturnval{PERCENT_IDENTIFIER}" );@]@=}
"%locations"                       {@> @[TeX_( "/yylexreturnval{PERCENT_IDENTIFIER}" );@]@=}
"%merge"                           {@> @[TeX_( "/yylexreturnval{PERCENT_IDENTIFIER}" );@]@=}
"%name-prefix"                     {@> @[TeX_( "/yylexreturnval{PERCENT_IDENTIFIER}" );@]@=}
"%no-default-prec"                 {@> @[TeX_( "/yylexreturnval{PERCENT_IDENTIFIER}" );@]@=}
"%no-lines"                        {@> @[TeX_( "/yylexreturnval{PERCENT_IDENTIFIER}" );@]@=}
"%nonassoc"                        {@> @[TeX_( "/yylexreturnval{PERCENT_IDENTIFIER}" );@]@=}
"%nondeterministic-parser"         {@> @[TeX_( "/yylexreturnval{PERCENT_IDENTIFIER}" );@]@=}
"%nterm"                           {@> @[TeX_( "/yylexreturnval{PERCENT_IDENTIFIER}" );@]@=}
"%output"                          {@> @[TeX_( "/yylexreturnval{PERCENT_IDENTIFIER}" );@]@=}
"%param"                           {@> @[TeX_( "/yylexreturnval{PERCENT_IDENTIFIER}" );@]@=}
"%parse-param"                     {@> @[TeX_( "/yylexreturnval{PERCENT_IDENTIFIER}" );@]@=}
"%prec"                            {@> @[TeX_( "/yylexreturnval{PERCENT_IDENTIFIER}" );@]@=}
"%precedence"                      {@> @[TeX_( "/yylexreturnval{PERCENT_IDENTIFIER}" );@]@=}
"%printer"                         {@> @[TeX_( "/yylexreturnval{PERCENT_IDENTIFIER}" );@]@=}
"%pure-parser"                     {@> @[TeX_( "/yylexreturnval{PERCENT_IDENTIFIER}" );@]@=}
"%require"                         {@> @[TeX_( "/yylexreturnval{PERCENT_IDENTIFIER}" );@]@=}
"%right"                           {@> @[TeX_( "/yylexreturnval{PERCENT_IDENTIFIER}" );@]@=}
"%skeleton"                        {@> @[TeX_( "/yylexreturnval{PERCENT_IDENTIFIER}" );@]@=}
"%start"                           {@> @[TeX_( "/yylexreturnval{PERCENT_IDENTIFIER}" );@]@=}
"%term"                            {@> @[TeX_( "/yylexreturnval{PERCENT_IDENTIFIER}" );@]@=}
"%token"                           {@> @[TeX_( "/yylexreturnval{PERCENT_IDENTIFIER}" );@]@=}
"%token-table"                     {@> @[TeX_( "/yylexreturnval{PERCENT_IDENTIFIER}" );@]@=}
"%type"                            {@> @[TeX_( "/yylexreturnval{PERCENT_IDENTIFIER}" );@]@=}
"%union"                           {@> @[TeX_( "/yylexreturnval{PERCENT_IDENTIFIER}" );@]@=}
"%verbose"                         {@> @[TeX_( "/yylexreturnval{PERCENT_IDENTIFIER}" );@]@=}
"%yacc"                            {@> @[TeX_( "/yylexreturnval{PERCENT_IDENTIFIER}" );@]@=}
"%default"[-_]"prec"               {@> @[TeX_( "/yylexreturnval{PERCENT_IDENTIFIER}" );@]@=}
"%error"[-_]"verbose"              {@> @[TeX_( "/yylexreturnval{PERCENT_IDENTIFIER}" );@]@=}
"%expect"[-_]"rr"                  {@> @[TeX_( "/yylexreturnval{PERCENT_IDENTIFIER}" );@]@=}
"%fixed"[-_]"output"[-_]"files"    {@> @[TeX_( "/yylexreturnval{PERCENT_IDENTIFIER}" );@]@=}
"%name"[-_]"prefix"                {@> @[TeX_( "/yylexreturnval{PERCENT_IDENTIFIER}" );@]@=}
"%no"[-_]"default"[-_]"prec"       {@> @[TeX_( "/yylexreturnval{PERCENT_IDENTIFIER}" );@]@=}
"%no"[-_]"lines"                   {@> @[TeX_( "/yylexreturnval{PERCENT_IDENTIFIER}" );@]@=}
"%pure"[-_]"parser"                {@> @[TeX_( "/yylexreturnval{PERCENT_IDENTIFIER}" );@]@=}
"%token"[-_]"table"                {@> @[TeX_( "/yylexreturnval{PERCENT_IDENTIFIER}" );@]@=}
"%"({letter}|[0-9]|[-_]|"%"|[<>])+ {@> @[TeX_( "/yylexreturnval{PERCENT_IDENTIFIER}" );@]@=}
@t}\vb{\insertraw{\inscomment{\it suffixes}}}{@>
"opt"                              {@> @[TeX_( "/yylexreturnval{OPTIONAL}" );@]@=}
"na"                               {@> @[TeX_( "/yylexreturnval{NO_ATTR}" );@]@=}
"ext"                              {@> @[TeX_( "/yylexreturnval{EXTENDED}" );@]@=}
"l"                                {@> @[TeX_( "/yylexreturnval{LT}" );@]@=}
"r"                                {@> @[TeX_( "/yylexreturnval{RT}" );@]@=}
@t}\vb{\insertraw{\inscomment{\it delimeters}}}{@>
[<>$._\'\"]                        {@> @[TeX_( "/yylexreturnchar" );@]@=}
{c-escchar}                        {@> @[TeX_( "/yylexreturnval{C_ESCCHAR}" );@]@=}
{wc}                               {@> @[TeX_( "/yylexreturnval{WILDCARD}" );@]@=}
@t}\vb{\insertraw{\inscomment{\it identifiers and other names}}}{@>
{id_strict}                        {@> @[@<Prepare to process an identifier@>@]@=}
{meta_id}                          {@> @[@<Prepare to process a meta-identifier@>@]@=}
{int}                              {@> @[TeX_( "/yylexreturnval{INTEGER}" );@]@=}
@t}\vb{\insertraw{\inscomment{\it everything else}}}{@>
.                                  {@> @[@<React to a bad character@>@]@=}
@g

@ @<Prepare to process an identifier@>=
 @[TeX_( "/yylexreturnval{IDENTIFIER}" );@]@;

@ @<Prepare to process a meta-identifier@>=
 @[TeX_( "/yylexreturnval{META_IDENTIFIER}" );@]@;

@ @<React to a bad character@>=
 @[TeX_( "/iftracebadchars" );@]@;
 @[TeX_( "    /yyfatal{invalid character(s): /the/yytext}" );@]@;
 @[TeX_( "/fi" );@]@;