summaryrefslogtreecommitdiff
path: root/support/splint/cweb/so.w
blob: d7a7696b8c98d87c0a2fa09841485455ce8ddbb8 (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
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
@q  Copyright (c) 1990 The Regents of the University of California. @>
@q  All rights reserved. @>

@q  This code is derived from software contributed to Berkeley by @>
@q  Vern Paxson. @>

@q  The United States Government has rights in this work pursuant @>
@q  to contract no. DE-AC03-76SF00098 between the United States @>
@q  Department of Energy and the University of California. @>

@q  This file is part of SPLinT. @>

@q  Redistribution and use in source and binary forms, with or without @>
@q  modification, are permitted provided that the following conditions @>
@q  are met: @>

@q  1. Redistributions of source code must retain the above copyright @>
@q     notice, this list of conditions and the following disclaimer. @>
@q  2. Redistributions in binary form must reproduce the above copyright @>
@q     notice, this list of conditions and the following disclaimer in the @>
@q     documentation and/or other materials provided with the distribution. @>

@q  Neither the name of the University nor the names of its contributors @>
@q  may be used to endorse or promote products derived from this software @>
@q  without specific prior written permission. @>

@q  THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR @>
@q  IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED @>
@q  WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR @>
@q  PURPOSE. @>

@**The lexer for \ifx\flex\UNDEFINED\.{flex}\else\flex\ \fi syntax.
\ifx\flex\UNDEFINED
    \input limbo.sty
    \input grabstates.sty
    \immediate\openout\stlist=fil_states.h
\fi
The original lexer for \flex\ grammar relies on a few rules that use `trailing context'.
The lexing mechanism implemented by \splint\ cannot process such rules properly in general.
The rules used by \flex\ match fixed-length trailing context only, which makes it possible
to replace them with ordinary patterns and use |yyless()| in the actions.
@(fil.ll@>=
@G
%{@> @<Preamble for \flex\ lexer@> @=%}
 @> @<Options for \flex\ input lexer@> @= 
 @> @<Additional options for \flex\ input lexer@> @= 
 @> @<State definitions for \flex\ input lexer@> @= 
 @> @<Definitions for \flex\ input lexer@> @= 
%%
 @> @<Postamble for \flex\ input lexer@> @= 
 @> @<Patterns for \flex\ lexer@> @= 
%%
 @> @<Auxilary code for \flex\ lexer@> @= 
@g

@ @<Preamble for \flex\ lexer@>=

@ There are a few options that are necessary to ensure that the lexer
functions properly. Some of them (like \.{caseless}) directly
affect the behavior of the scanner, others (e.g.~\.{noyy\_top\_state})
prevent generation of unnecessary code.
@<Options for \flex\ input lexer@>=
@G
%option caseless nodefault stack noyy_top_state
%option nostdinit
@g

@ @<Additional options for \flex\ input lexer@>=
@G
%option bison-bridge
%option noyywrap nounput noinput reentrant 
%option debug
%option stack
%option outfile="fil.c"
@g

@*1 Regular expression and state definitions.
The lexer uses a large number of states to control its operation. Both
section~1 and section~2 rules rely on the scanner being in the
appropriate state. Otherwise (see \.{symbols.sty} example) the lexer
may parse the same fragment in a wrong context.
@<State definitions for \flex\ input lexer@>=
@G
%x SECT2 SECT2PROLOG SECT3 CODEBLOCK PICKUPDEF SC CARETISBOL NUM QUOTE
%x FIRSTCCL CCL ACTION RECOVER COMMENT ACTION_STRING PERCENT_BRACE_ACTION
%x OPTION LINEDIR CODEBLOCK_MATCH_BRACE
%x GROUP_WITH_PARAMS
%x GROUP_MINUS_PARAMS
%x EXTENDED_COMMENT
%x COMMENT_DISCARD

@ Somewhat counterintuitively, \flex\ definitions do not {\it always\/} have to be
fully formed regular expressions. For example, after
$$
\hbox to 3in{\flexrenstyle{BOGUS}\hfil\.{\^[a-}}
$$
one can form the following action:
$$
\hbox to 3in{\flexrenstyle{BOGUS}\.{t]}\hfil\.{;}}
$$
although without the `\.{\^}' in the definition of
`\flexrenstyle{BOGUS}' \flex\ would have put a `\.{)}' inside the
character class. We will assume such (rather counterproductive) tricks
are not used. If the definition is not a well-formed regular
expression the pretty printing will be suspended.
@<Definitions for \flex\ input lexer@>=
@G(fs1)
WS		[[:blank:]]+
OPTWS		[[:blank:]]*
NOT_WS		[^[:blank:]\r\n]

NL		\r?\n

NAME		([[:alpha:]_][[:alnum:]_-]*)
NOT_NAME	[^[:alpha:]_*\n]+

SCNAME		{NAME}

ESCSEQ		(\\([^\n]|[0-7]{1,3}|x[[:xdigit:]]{1,2}))

FIRST_CCL_CHAR	([^\\\n]|{ESCSEQ})
CCL_CHAR	([^\\\n\]]|{ESCSEQ})
CCL_EXPR	("[:"^?[[:alpha:]]+":]")

LEXOPT		[porkacne]

M4QSTART    "[["
M4QEND      "]]"

@ @<Postamble for \flex\ input lexer@>=

@*1 Regular expressions for \flex\ input scanner.
The code below treats \prodstyle{\%pointer} and \prodstyle{\%array} the same way it treats
\prodstyle{\%option} while typesetting.
@<Patterns for \flex\ lexer@>=
@G(fs2)
<INITIAL>{
        ^{WS}              {@> @[TeX_( "/flindented@@codetrue/yyBEGIN{CODEBLOCK}/yylexnext" );@]@=}
        ^"/*"              {@> @[TeX_( "/yypushstate{COMMENT}/yylexnext" );@]@=}
        ^#{OPTWS}line{WS}  {@> @[TeX_( "/yypushstate{LINEDIR}/yylexnext" );@]@=}
        ^"%s"{NAME}?       {@> @[TeX_( "/yylexreturnptr{SCDECL}" );@]@=}
        ^"%x"{NAME}?       {@> @[TeX_( "/yylexreturnptr{XSCDECL}" );@]@=}
        ^"%{".*{NL}        {@> @<Start a \Cee\ code section@> @=}
        
    ^"%top"[[:blank:]]*"{"[[:blank:]]*{NL}    {@> @<Begin the \prodstyle{\%top} directive@> @=}
    ^"%top".*              {@> @[TeX_( "/yyfatal{malformed '/harmlesscomment top' directive}" );@] @=}

        {WS}               {@> @[;@]/* discard */ @=}

        ^"%%".*            {@> @<Start section 2@> @=}

        ^"%pointer".*{NL}  {@> @[TeX_( "/flinc@@linenum/yylexreturn{POINTER_OP}" );@]@=}
        ^"%array".*{NL}    {@> @[TeX_( "/flinc@@linenum/yylexreturn{ARRAY_OP}" );@]@=}

        ^"%option"         {@> @[TeX_( "/yyBEGIN{OPTION}/yylexreturn{OPTION_OP}" );@]@=}

        ^"%"{LEXOPT}{OPTWS}[[:digit:]]*{OPTWS}{NL} {@> @[TeX_( "/flinc@@linenum/yyflexoptreturn{OPT_DEPRECATED}" );@]@=}
        ^"%"{LEXOPT}{WS}.*{NL}                     {@> @[TeX_( "/flinc@@linenum/yyflexoptreturn{OPT_DEPRECATED}" );@]@=}

        ^"%"[^porksexcan{}].*   {@> @[TeX_( "/yyfatal{unrecognized '/harmlesscomment' directive: /the/yytext}" );@] @=}

        ^{NAME}            {@> @<Copy the name and start a definition@> @=}
        {SCNAME}            @> @[TeX_( "/RETURNNAME" );@] @= 
        ^{OPTWS}{NL}       {@> @[TeX_( "/flinc@@linenum/yylexnext" );@]/* allows blank lines in section 1 */@=}
        {OPTWS}{NL}        {@> @[TeX_( "/flinc@@linenum/yylexnext" );@]/* maybe end of comment line */@=}
}

@ @<Start a \Cee\ code section@>=
    @[TeX_( "/flinc@@linenum" );@]@;
    @[TeX_( "/flindented@@codefalse/yyBEGIN{CODEBLOCK}" );@]@;
    @[TeX_( "/yylexnext" );@]@;

@ Ignore setting |brace_start_line| as it is only used internally to report errors.
@<Begin the \prodstyle{\%top} directive@>=
    @[TeX_( "/flinc@@linenum" );@]@;
    @[TeX_( "/def/flbrace@@depth{1}" );@]@;
    @[TeX_( "/yypushstate{CODEBLOCK_MATCH_BRACE}/yylexnext" );@]@;

@ @<Start section 2@>=
    @[TeX_( "/def/flsectnum{2}/def/flbracelevel{0}" );@]@;
    @[TeX_( "/yyBEGIN{SECT2PROLOG}/yylexreturnptr{SECTEND}" );@]@;

@ @<Copy the name and start a definition@>=
    @[TeX_( "/fldidadeffalse/yyBEGIN{PICKUPDEF}" );@]@;
    @[TeX_( "/yylexreturnsym{DEF_OP}" );@]@;

@ @<Patterns for \flex\ lexer@>=
@G(fs2)
<COMMENT>{
       "*/"     {@> @[TeX_( "/yypopstate/yylexnext" );@]@=}
        "*"     {@> @[TeX_( "/yylexnext" );@]@=}
 {M4QSTART}     {@> @[TeX_( "/yylexnext" );@]@=}
   {M4QEND}     {@> @[TeX_( "/yylexnext" );@]@=}
     [^*\n]     {@> @[TeX_( "/yylexnext" );@]@=}
       {NL}     {@> @[TeX_( "/flinc@@linenum/yylexnext" );@]@=}
}

/* This is the same as \flexsnstyle{COMMENT}, but is discarded rather than output. */
<COMMENT_DISCARD>{
       "*/"     {@> @[TeX_( "/yypopstate/yylexnext" );@]@=}
        "*"     {@> @[TeX_( "/yylexnext" );@]@=}
     [^*\n]     {@> @[TeX_( "/yylexnext" );@]@=}
       {NL}     {@> @[TeX_( "/flinc@@linenum/yylexnext" );@]@=}
}

<EXTENDED_COMMENT>{
        ")"     {@> @[TeX_( "/yypopstate/yylexnext" );@]@=}
   [^\n\)]+     {@> @[TeX_( "/yylexnext" );@]@=}
       {NL}     {@> @[TeX_( "/flinc@@linenum/yylexnext" );@]@=}
}

<LINEDIR>{
           \n   {@> @[TeX_( "/yypopstate/yylexnext" );@]@=}
 [[:digit:]]+   {@> @[TeX_( "/fllinenum=/number/yytext/yylexnext" );@]@=}
  \"[^"\n]*\"   {@> @[TeX_( "/yylexnext" );@] /* ignore the file name in the line directives */ @=}
        .       {@> @[TeX_( "/yylexnext" );@] /* ignore spurious characters */ @=}
}

<CODEBLOCK>{
  ^"%}".*{NL}   {@> @[TeX_( "/flinc@@linenum/yyBEGIN{INITIAL}/yylexnext" );@]@=}
   {M4QSTART}   {@> @[TeX_( "/yylexnext" );@]@=}
     {M4QEND}   {@> @[TeX_( "/yylexnext" );@]@=}
            .   {@> @[TeX_( "/yylexnext" );@]@=}
         {NL}   {@> @[TeX_( "/flinc@@linenum/ifflindented@@code/yyBEGIN{INITIAL}/fi/yylexnext" );@]@=}
}

<CODEBLOCK_MATCH_BRACE>{
    "}"         {@> @<Pop state if code braces match@> @=}
    "{"         {@> @[TeX_( "/flinc/flbrace@@depth/yylexnext" );@] @=}
    {NL}        {@> @[TeX_( "/flinc@@linenum/yylexnext" );@]@=}
    {M4QSTART}  {@> @[TeX_( "/yylexnext" );@]@=}
    {M4QEND}    {@> @[TeX_( "/yylexnext" );@]@=}
    [^{}\r\n]   {@> @[TeX_( "/yylexnext" );@]@=}
    <<EOF>>     {@> @[TeX_( "/yyfatal{Unmatched '/lbchar'}" );@] @=}
}

@ @<Pop state if code braces match@>=
    @[TeX_( "/fldec/flbrace@@depth" );@]@;
    @[TeX_( "/ifnum/flbrace@@depth=/z@@/relax" );@]@;
    @[TeX_( "    /yypopstate/yylexreturnxchar/n" );@]@;
    @[TeX_( "/else" );@]@;
    @[TeX_( "    /yylexnext" );@]@;
    @[TeX_( "/fi" );@]@;

@ @<Patterns for \flex\ lexer@>=
@G(fs2)
<PICKUPDEF>{
        {WS}      {@> @[TeX_( "/yylexnext" );@]@=}
 {NOT_WS}[^\r\n]* {@> @<Skip trailing whitespace, save the definition@> @=}
        {NL}      {@> @<Complain if not inside a definition, continue otherwise@> @=}
}

@ @<Skip trailing whitespace, save the definition@>=
    @[TeX_( "/edef/flnmdef{{/the/yytext}{/the/yytextpure}{/the/yyfmark}{/the/yysmark}}" );@]@;
    @[TeX_( "/fldidadeftrue/yylexnext" );@]@;

@ @<Complain if not inside a definition, continue otherwise@>=
    @[TeX_( "/iffldidadef" );@]@;
    @[TeX_( "    /yylval/expandafter{/flnmdef}" );@]@;
    @[TeX_( "    /def/next{/flinc@@linenum/yyBEGIN{INITIAL}/yylexreturn{RE_DEF}}" );@]@;
    @[TeX_( "/else" );@]@;
    @[TeX_( "    /def/next{/yyfatal{incomplete name definition}}" );@]@;
    @[TeX_( "/fi/next" );@]@;

@ @<Patterns for \flex\ lexer@>=
@G(fs2)
<OPTION>{
        {NL}            {@> @[TeX_( "/flinc@@linenum/yyBEGIN{INITIAL}/yylexnext" );@] @=}
        {WS}            {@> @[TeX_( "/floption@@sensetrue/yylexnext" );@] @=}

        "="             {@> @[TeX_( "/yylexreturnchar" );@]@=}

        no              {@> @<Toggle |option_sense|@> @=};

        7bit            {@> @[TeX_( "/yyflexoptreturn{OPT_OTHER}" );@]@=}
        8bit            {@> @[TeX_( "/yyflexoptreturn{OPT_OTHER}" );@]@=}

        align           {@> @[TeX_( "/yyflexoptreturn{OPT_OTHER}" );@]@=}
   always-interactive   {@> @[TeX_( "/yyflexoptreturn{OPT_OTHER}" );@]@=}

        array           {@> @[TeX_( "/yyflexoptreturn{OPT_OTHER}" );@]@=}
    ansi-definitions    {@> @[TeX_( "/yyflexoptreturn{OPT_OTHER}" );@]@=}
    ansi-prototypes     {@> @[TeX_( "/yyflexoptreturn{OPT_OTHER}" );@]@=}
        backup          {@> @[TeX_( "/yyflexoptreturn{OPT_OTHER}" );@]@=}
        batch           {@> @[TeX_( "/yyflexoptreturn{OPT_OTHER}" );@]@=}
    bison-bridge        {@> @[TeX_( "/yyflexoptreturn{OPT_OTHER}" );@]@=}
    bison-locations     {@> @[TeX_( "/yyflexoptreturn{OPT_OTHER}" );@]@=}

        "c++"           {@> @[TeX_( "/yyflexoptreturn{OPT_OTHER}" );@]@=}
 caseful|case-sensitive {@> @[TeX_( "/yyflexoptreturn{OPT_OTHER}" );@]@=}
 caseless|case-insensitive {@> @[TeX_( "/yyflexoptreturn{OPT_OTHER}" );@]@=}
        debug           {@> @[TeX_( "/yyflexoptreturn{OPT_OTHER}" );@]@=}
        default         {@> @[TeX_( "/yyflexoptreturn{OPT_OTHER}" );@]@=}
        ecs             {@> @[TeX_( "/yyflexoptreturn{OPT_OTHER}" );@]@=}
        fast            {@> @[TeX_( "/yyflexoptreturn{OPT_OTHER}" );@]@=}

        full            {@> @[TeX_( "/yyflexoptreturn{OPT_OTHER}" );@]@=}

        input           {@> @[TeX_( "/yyflexoptreturn{OPT_OTHER}" );@]@=}
        interactive     {@> @[TeX_( "/yyflexoptreturn{OPT_OTHER}" );@]@=}
        lex-compat      {@> @<Set |lex_compat|@> @=}
        posix-compat    {@> @<Set |posix_compat|@> @=}
        main            {@> @[TeX_( "/yyflexoptreturn{OPT_OTHER}" );@]@=}

        meta-ecs        {@> @[TeX_( "/yyflexoptreturn{OPT_OTHER}" );@]@=}
  never-interactive     {@> @[TeX_( "/yyflexoptreturn{OPT_OTHER}" );@]@=}

        perf-report     {@> @[TeX_( "/yyflexoptreturn{OPT_OTHER}" );@]@=}
        pointer         {@> @[TeX_( "/yyflexoptreturn{OPT_OTHER}" );@]@=}
        read            {@> @[TeX_( "/yyflexoptreturn{OPT_OTHER}" );@]@=}
    reentrant           {@> @[TeX_( "/yyflexoptreturn{OPT_OTHER}" );@]@=}
        reject          {@> @[TeX_( "/yyflexoptreturn{OPT_OTHER}" );@]@=}
        stack           {@> @[TeX_( "/yyflexoptreturn{OPT_OTHER}" );@]@=}
        stdinit         {@> @[TeX_( "/yyflexoptreturn{OPT_OTHER}" );@]@=}
        stdout          {@> @[TeX_( "/yyflexoptreturn{OPT_OTHER}" );@]@=}
    unistd              {@> @[TeX_( "/yyflexoptreturn{OPT_OTHER}" );@]@=}
        unput           {@> @[TeX_( "/yyflexoptreturn{OPT_OTHER}" );@]@=}
        verbose         {@> @[TeX_( "/yyflexoptreturn{OPT_OTHER}" );@]@=}
        warn            {@> @[TeX_( "/yyflexoptreturn{OPT_OTHER}" );@]@=}
        yylineno        {@> @[TeX_( "/yyflexoptreturn{OPT_OTHER}" );@]@=}
        yymore          {@> @[TeX_( "/yyflexoptreturn{OPT_OTHER}" );@]@=}
        yywrap          {@> @[TeX_( "/yyflexoptreturn{OPT_OTHER}" );@]@=}

        yy_push_state   {@> @[TeX_( "/yyflexoptreturn{OPT_OTHER}" );@]@=}
        yy_pop_state    {@> @[TeX_( "/yyflexoptreturn{OPT_OTHER}" );@]@=}
        yy_top_state    {@> @[TeX_( "/yyflexoptreturn{OPT_OTHER}" );@]@=}

        yy_scan_buffer  {@> @[TeX_( "/yyflexoptreturn{OPT_OTHER}" );@]@=}
        yy_scan_bytes   {@> @[TeX_( "/yyflexoptreturn{OPT_OTHER}" );@]@=}
        yy_scan_string  {@> @[TeX_( "/yyflexoptreturn{OPT_OTHER}" );@]@=}

        yyalloc         {@> @[TeX_( "/yyflexoptreturn{OPT_OTHER}" );@]@=}
        yyrealloc       {@> @[TeX_( "/yyflexoptreturn{OPT_OTHER}" );@]@=}
        yyfree          {@> @[TeX_( "/yyflexoptreturn{OPT_OTHER}" );@]@=}
        
        yyget_debug     {@> @[TeX_( "/yyflexoptreturn{OPT_OTHER}" );@]@=}
        yyset_debug     {@> @[TeX_( "/yyflexoptreturn{OPT_OTHER}" );@]@=}
        yyget_extra     {@> @[TeX_( "/yyflexoptreturn{OPT_OTHER}" );@]@=}
        yyset_extra     {@> @[TeX_( "/yyflexoptreturn{OPT_OTHER}" );@]@=}
        yyget_leng      {@> @[TeX_( "/yyflexoptreturn{OPT_OTHER}" );@]@=}
        yyget_text      {@> @[TeX_( "/yyflexoptreturn{OPT_OTHER}" );@]@=}
        yyget_lineno    {@> @[TeX_( "/yyflexoptreturn{OPT_OTHER}" );@]@=}
        yyset_lineno    {@> @[TeX_( "/yyflexoptreturn{OPT_OTHER}" );@]@=}
        yyget_in        {@> @[TeX_( "/yyflexoptreturn{OPT_OTHER}" );@]@=}
        yyset_in        {@> @[TeX_( "/yyflexoptreturn{OPT_OTHER}" );@]@=}
        yyget_out       {@> @[TeX_( "/yyflexoptreturn{OPT_OTHER}" );@]@=}
        yyset_out       {@> @[TeX_( "/yyflexoptreturn{OPT_OTHER}" );@]@=}
        yyget_lval      {@> @[TeX_( "/yyflexoptreturn{OPT_OTHER}" );@]@=}
        yyset_lval      {@> @[TeX_( "/yyflexoptreturn{OPT_OTHER}" );@]@=}
        yyget_lloc      {@> @[TeX_( "/yyflexoptreturn{OPT_OTHER}" );@]@=}
        yyset_lloc      {@> @[TeX_( "/yyflexoptreturn{OPT_OTHER}" );@]@=}

        extra-type      {@> @[TeX_( "/yylexreturn{OPT_EXTRA_TYPE}" );@]@=}
        outfile         {@> @[TeX_( "/yylexreturn{OPT_OUTFILE}" );@]@=}
        prefix          {@> @[TeX_( "/yylexreturn{OPT_PREFIX}" );@]@=}
        yyclass         {@> @[TeX_( "/yylexreturn{OPT_YYCLASS}" );@]@=}
        header(-file)?  {@> @[TeX_( "/yylexreturn{OPT_HEADER}" );@]@=}
        tables-file     {@> @[TeX_( "/yylexreturn{OPT_TABLES}" );@]@=}
        tables-verify   {@> @[TeX_( "/yyflexoptreturn{OPT_OTHER}" );@]@=}

        \"[^"\n]*\"     {@> @[TeX_( "/edef/flnmstr{{/the/yytext}{/the/yytextpure}}/yylexreturnsym{NAME}" );@]@=}

 (([a-mo-z]|n[a-np-z])[[:alpha:]\-+]*)|. {@> @[TeX_( "/yyfatal{unrecognized /%option: /the/yytext}" );@]@=}
}

@ @<Toggle |option_sense|@>=
    @[TeX_( "/iffloption@@sense" );@]@;
    @[TeX_( "    /floption@@sensefalse" );@]@;
    @[TeX_( "/else" );@]@;
    @[TeX_( "    /floption@@sensetrue" );@]@;   
    @[TeX_( "/fi/yylexnext" );@]@;

@ @<Set |lex_compat|@>=
    @[TeX_( "/iffloption@@sense" );@]@;
    @[TeX_( "    /fllex@@compattrue" );@]@;
    @[TeX_( "/else" );@]@;
    @[TeX_( "    /fllex@@compatfalse" );@]@;
    @[TeX_( "/fi/yyflexoptreturn{OPT_OTHER}" );@]@;

@ @<Set |posix_compat|@>=
    @[TeX_( "/iffloption@@sense" );@]@;
    @[TeX_( "    /flposix@@compattrue" );@]@;
    @[TeX_( "/else" );@]@;
    @[TeX_( "    /flposix@@compatfalse" );@]@;
    @[TeX_( "/fi/yyflexoptreturn{OPT_OTHER}" );@]@;

@ The \flexsnstyle{RECOVER} state is never used for typesetting and is only added for completeness.
@<Patterns for \flex\ lexer@>=
@G(fs2)
<RECOVER>.*{NL}      {@> @[TeX_( "/flinc@@linenum/yyBEGIN{INITIAL}/yylexnext" );@] @=}

@ Like \bison, \flex\ allows insertion of \Cee\ code in the middle of the input file.
\saveparseoutputtrue
@<Patterns for \flex\ lexer@>=
@G(fs2)
<SECT2PROLOG>{
        ^"%{".*      {@> @<Consume the brace and increment the brace level@> @=}
        ^"%}".*      {@> @<Consume the brace and decrement the brace level@> @=}

        ^{WS}.*      {@> @[TeX_( "/yylexnext" );@]@=}

        ^{NOT_WS}.*  {@> @<Begin section 2, prepare to reread, or ignore braced code@> @=}
        .            {@> @[TeX_( "/yylexnext" );@] @=}
        {NL}         {@> @[TeX_( "/flinc@@linenum/yylexnext" );@] @=}

        <<EOF>>      {@> @[TeX_( "/def/flsectnum{0}/yyterminate" );@] @=}
}

@ All the code inside is ignored.
\saveparseoutputfalse
@<Consume the brace and increment the brace level@>=
    @[TeX_( "/flinc/flbracelevel/yyless{2}/yylexnext" );@]@;

@ @<Consume the brace and decrement the brace level@>=
    @[TeX_( "/fldec/flbracelevel/yyless{2}/yylexnext" );@]@;

@ @<Begin section 2, prepare to reread, or ignore braced code@>=
    @[TeX_( "/ifnum/flbracelevel>/z@@" );@]@;
    @[TeX_( "    /let/next/yylexnext" );@]@;
    @[TeX_( "/else" );@]@;
    @[TeX_( "    /def/next{/yysetbol{/@@ne}/yyBEGIN{SECT2}/yyless{0}/yylexnext}" );@]@;
    @[TeX_( "/fi/next" );@]@;
    
@ A pattern below (for the character class processing) had to be broken into two lines.
A symbol ($\odot$@^$\odot$ separator, \flex@>) was inserted to indicate that a break had occured. The macros for \flex\
typesetting use a different mechanism from that of \bison\ macros and allow typographic
corrections to be applied to sections of the \flex\ code represented by various nonterminals.
These corrections can also be delayed. For the details, an interested reader may consult
\.{yyunion.sty}.
@<Patterns for \flex\ lexer@>=
@G(fs2)
<SECT2>{
        ^{OPTWS}{NL}    {@> @[TeX_( "/flinc@@linenum/yylexnext" );@] /* allow blank lines in section 2 */ @=}
        ^{OPTWS}"%{"    {@> @<Start braced code in section 2@> @=}
        ^{OPTWS}"<"     {@> @[TeX_( "/ifflsf@@skip@@ws/else/yyBEGIN{SC}/fi/yylexreturnraw<" );@] @=}
        ^{OPTWS}"^"     {@> @[TeX_( "/yylexreturnraw^" );@] @=}
        \"              {@> @[TeX_( "/yyBEGIN{QUOTE}/yylexreturnxchar/flquotechar" );@] @=}
        "{"[[:digit:]]  {@> @<Process a repeat pattern@> @=}
 "$"([[:blank:]]|{NL})  {@> @[TeX_( "/yyless{1}/yylexreturnraw/$" );@] @=}

        {WS}"%{"        {@> @<Process braced code in the middle of section 2@> @=}
        {WS}"|".*{NL}   {@> @<Process a deferred action@> @=}
        ^{WS}"/*"       {@> @<Process a comment inside a pattern@> @=}
        ^{WS}            @> ; /* allow indented rules */@= 
        {WS}            {@> @<Decide whether to start an action or skip whitespace inside a rule@> @=}

        {OPTWS}{NL}     {@> @<Finish the line and/or action@> @=}

        ^{OPTWS}"<<EOF>>"       |
        "<<EOF>>"       {@> @[TeX_( "/yylexreturnptr{EOF_OP}" );@] @=}

        ^"%%".*         {@> @<Start section 3@> @=}
@t}\vb{\insertraw{\insrulealign{\rulealigntemplate}{\cr\egroup\egroup}}}{@>
        "["@>@t}\vb{\insertraw{\insparensalign{&}{}}}{@>@=({FIRST_CCL_CHAR}|{CCL_EXPR})@>@t}\vb{\insertraw{\insparensalign{\rlap{$\odot$}\cr&}{}}}{@>@=({CCL_CHAR}|{CCL_EXPR})*  {@> @<Start processing a character class@> @=}

        "{-}"           {@> @[TeX_( "/yylexreturn{CCL_OP_DIFF}" );@] @=}
        "{+}"           {@> @[TeX_( "/yylexreturn{CCL_OP_UNION}" );@] @=}

        "{"{NAME}"}"[[:space:]]?  {@> @<Process a named expression after checking for whitespace at the end@> @=}

         "/*"           {@> @<Decide if this is a comment@> @=}
         "(?#"          {@> @<Determine if this is extended syntax or return a parenthesis@> @=}
         "(?"           {@> @<Determine if this is a parametric group or return a parenthesis@> @=}
         "("            {@> @[TeX_( "/flsf@@push/yylexreturnraw/(" );@] @=}
         ")"            {@> @[TeX_( "/flsf@@pop/yylexreturnraw/)" );@] @=}

        [/|*+?.(){}]    {@> @[TeX_( "/yylexreturnchar" );@] @=}
        .               {@> @[TeX_( "/RETURNCHAR" );@] @=}
}

@ @<Start braced code in section 2@>=
    @[TeX_( "/def/flbracelevel{1}" );@]@;
    @[TeX_( "/indented@@codefalse/doing@@codeblocktrue" );@]@;
    @[TeX_( "/yyBEGIN{PERCENT_BRACE_ACTION}" );@]@;
    @[TeX_( "/yylexnext" );@]@;

@ @<Process a repeat pattern@>=
    @[TeX_( "/yyless{1}/yyBEGIN{NUM}" );@]@;
    @[TeX_( "/iffllex@@compat" );@]@;
    @[TeX_( "    /def/next{/yylexreturn{BEGIN_REPEAT_POSIX}}" );@]@;
    @[TeX_( "/else" );@]@;
    @[TeX_( "    /ifflposix@@compat" );@]@;
    @[TeX_( "        /def/next{/yylexreturn{BEGIN_REPEAT_POSIX}}" );@]@;
    @[TeX_( "    /else" );@]@;
    @[TeX_( "        /def/next{/yylexreturn{BEGIN_REPEAT_FLEX}}" );@]@;
    @[TeX_( "    /fi" );@]@;
    @[TeX_( "/fi/next" );@]@;

@ @<Process braced code in the middle of section 2@>=
    @[TeX_( "/def/flbracelevel{1}" );@]@;
    @[TeX_( "/yyBEGIN{PERCENT_BRACE_ACTION}" );@]@;
    @[TeX_( "/ifflin@@rule" );@]@;
    @[TeX_( "    /fldoing@@rule@@actiontrue" );@]@;
    @[TeX_( "    /flin@@rulefalse" );@]@;
    @[TeX_( "    /def/next{/yylexreturnxchar/n}" );@]@;
    @[TeX_( "/else" );@]@;
    @[TeX_( "    /let/next/yylexnext" );@]@;
    @[TeX_( "/fi/next" );@]@;
                        
@ This action has been changed to accomodate the new grammar. The separator (\.{\yl})
is treated as an ordinary (empty) action.
@<Process a deferred action@>=
    @[TeX_( "/ifflsf@@skip@@ws" );@]@;/* whitespace ignored, still inside a pattern */
    @[TeX_( "    /yylessafter{|}" );@]@;
    @[TeX_( "    /let/next/yylexnext" );@]@;
    @[TeX_( "/else" );@]@;
    @[TeX_( "    /flinc@@linenum" );@]@;
    @[TeX_( "    /fldoing@@rule@@actiontrue" );@]@;
    @[TeX_( "    /flin@@rulefalse" );@]@;
    @[TeX_( "    /flcontinued@@actiontrue" );@]@;
    @[TeX_( "    /unput{/n}" );@]@;
    @[TeX_( "    /yyBEGIN{ACTION}" );@]@;
    @[TeX_( "    /edef/next{/nx/yylexreturnxchar/n}" );@]@;
    @[TeX_( "/fi/next" );@]@;

@ @<Process a comment inside a pattern@>=
    @[TeX_( "/ifflsf@@skip@@ws" );@]@;
    @[TeX_( "    /yypushstate{COMMENT_DISCARD}" );@]@;
    @[TeX_( "/else" );@]@;
    @[TeX_( "    /unput{//*}" );@]@;
    @[TeX_( "    /def/flbracelevel{0}" );@]@;
    @[TeX_( "    /flcontinued@@actionfalse" );@]@;
    @[TeX_( "    /yyBEGIN{ACTION}" );@]@;
    @[TeX_( "/fi/yylexnext" );@]@;

@ @<Decide whether to start an action or skip whitespace inside a rule@>=
    @[TeX_( "/ifflsf@@skip@@ws" );@]@;
    @[TeX_( "    /let/next/yylexnext" );@]@;
    @[TeX_( "/else" );@]@;
    @[TeX_( "    /def/flbracelevel{0}" );@]@;
    @[TeX_( "    /flcontinued@@actionfalse" );@]@;
    @[TeX_( "    /yyBEGIN{ACTION}" );@]@;
    @[TeX_( "    /ifflin@@rule" );@]@;
    @[TeX_( "        /fldoing@@rule@@actiontrue" );@]@;
    @[TeX_( "        /flin@@rulefalse" );@]@;
    @[TeX_( "        /def/next{/yylexreturnxchar/n}" );@]@;
    @[TeX_( "    /else" );@]@;
    @[TeX_( "        /let/next/yylexnext" );@]@;
    @[TeX_( "    /fi" );@]@;
    @[TeX_( "/fi/next" );@]@;

@ @<Finish the line and/or action@>=
    @[TeX_( "/ifflsf@@skip@@ws" );@]@;
    @[TeX_( "    /flinc@@linenum" );@]@;
    @[TeX_( "    /let/next/yylexnext" );@]@;
    @[TeX_( "/else" );@]@;
    @[TeX_( "    /def/flbracelevel{0}" );@]@;
    @[TeX_( "    /flcontinued@@actionfalse" );@]@;
    @[TeX_( "    /yyBEGIN{ACTION}" );@]@;
    @[TeX_( "    /unput{/n}" );@]@;
    @[TeX_( "    /ifflin@@rule" );@]@;
    @[TeX_( "        /fldoing@@rule@@actiontrue" );@]@;
    @[TeX_( "        /flin@@rulefalse" );@]@;
    @[TeX_( "        /def/next{/yylexreturnxchar/n}" );@]@;
    @[TeX_( "    /else" );@]@;
    @[TeX_( "        /let/next/yylexnext" );@]@;
    @[TeX_( "    /fi" );@]@;
    @[TeX_( "/fi/next" );@]@;

@ @<Start section 3@>=
    @[TeX_( "/def/flsectnum{3}" );@]@;
    @[TeX_( "/yyBEGIN{SECT3}" );@]@;
    @[TeX_( "/yyterminate" );@]@;

@ @<Start processing a character class@>=
    @[TeX_( "/edef/flnmstr{/the/yytext}" );@]@;
    @[TeX_( "/yyless{1}" );@]@;
    @[TeX_( "/yyBEGIN{FIRSTCCL}" );@]@;
    @[TeX_( "/yylexreturnraw[" );@]@;

@ Return a special \prodstyle{CHAR} and return the whitespace back into the input.
The braces and the possible trailing whitespace will be dealt with by the typesetting code.
@<Process a named expression after checking for whitespace at the end@>=
    @[TeX_( "/edef/flend@@ch{/the/yytextlastchar}" );@]@;
    @[TeX_( "/ifnum/flend@@ch=`/}/relax" );@]@;
    @[TeX_( "    /flend@@is@@wsfalse" );@]@;
    @[TeX_( "/else" );@]@;
    @[TeX_( "    /flend@@is@@wstrue" );@]@;
    @[TeX_( "/fi" );@]@;
    @[TeX_( "/toksa/expandafter{/astformat@@flnametok}" );@]@;
    @[TeX_( "/let/astformat@@flnametok/empty" );@]@;
    @[TeX_( "/edef/next{/yylval{{/nx/flnametok{/the/yytext}{/the/toksa}}{}{/the/yyfmark}{/the/yysmark}}}/next" );@]@;
    @[TeX_( "/ifflend@@is@@ws" );@]@;
    @[TeX_( "    /unput{ }" );@]@;
    @[TeX_( "/fi" );@]@;
    @[TeX_( "/yylexreturn{CHAR}" );@]@;

@ @<Decide if this is a comment@>=
    @[TeX_( "/ifflsf@@skip@@ws" );@]@;
    @[TeX_( "    /yypushstate{COMMENT_DISCARD}" );@]@;
    @[TeX_( "    /yylexnext" );@]@;
    @[TeX_( "/else" );@]@;
    @[TeX_( "    /yyless{1}" );@]@;
    @[TeX_( "    /yylexreturnraw//" );@]@;
    @[TeX_( "/fi" );@]@;

@ @<Determine if this is extended syntax or return a parenthesis@>=
    @[TeX_( "/iffllex@@compat" );@]@;
    @[TeX_( "    /def/next{/yyless{1}/flsf@@push/yylexreturnraw(}" );@]@;
    @[TeX_( "/else" );@]@;
    @[TeX_( "    /ifflposix@@compat" );@]@;
    @[TeX_( "        /def/next{/yyless{1}/flsf@@push/yylexreturnraw(}" );@]@;
    @[TeX_( "    /else" );@]@;
    @[TeX_( "        /def/next{/yypushstate{EXTENDED_COMMENT}}" );@]@;
    @[TeX_( "    /fi" );@]@;
    @[TeX_( "/fi/next" );@]@;

@ @<Determine if this is a parametric group or return a parenthesis@>=
    @[TeX_( "/flsf@@push" );@]@;
    @[TeX_( "/iffllex@@compat" );@]@;
    @[TeX_( "    /def/next{/yyless{1}}" );@]@;
    @[TeX_( "/else" );@]@;
    @[TeX_( "    /ifflposix@@compat" );@]@;
    @[TeX_( "        /def/next{/yyless{1}}" );@]@;
    @[TeX_( "    /else" );@]@;
    @[TeX_( "        /def/next{/yyBEGIN{GROUP_WITH_PARAMS}}" );@]@;
    @[TeX_( "    /fi" );@]@;
    @[TeX_( "/fi/next" );@]@;
    @[TeX_( "/yylexreturnraw(" );@]@;
                
@ @<Patterns for \flex\ lexer@>=
@G(fs2)
<SC>{
    {OPTWS}{NL}{OPTWS} {@> @[TeX_( "/flinc@@linenum" );@] /* allow blank lines and continuations */@+@=}@>
    [,*]               {@> @[TeX_( "/yylexreturnchar" );@] @=}@>
    ">"                {@> @[TeX_( "/yyBEGIN{SECT2}/yylexreturnchar" );@] @=}
    ">"^               {@> @[TeX_( "/yyBEGIN{CARETISBOL}/yyless{1}/yylexreturnraw>" );@] @=}
    {SCNAME}           {@> @[TeX_( "/RETURNNAME" );@] @=}
    .                  {@> @[TeX_( "/yyfatal{bad <start condition>: /the/yytext}" );@] @=}
}

<CARETISBOL>"^"        {@> @[TeX_( "/yyBEGIN{SECT2}/yylexreturnchar" );@] @=}

<QUOTE>{
        [^"\n]          {@> @[TeX_( "/RETURNCHAR" );@] @=}
        \"              {@> @[TeX_( "/yyBEGIN{SECT2}/yylexreturnxchar/flquotechar" );@] @=}

        {NL}            {@> @[TeX_( "/yyfatal{missing quote}" );@] @=}
}

<GROUP_WITH_PARAMS>{
    ":"                 {@> @[TeX_( "/yyBEGIN{SECT2}/yylexnext" );@] @=}
    "-"                 {@> @[TeX_( "/yyBEGIN{GROUP_MINUS_PARAMS}/yylexnext" );@] @=}
    i                   {@> @[TeX_( "/flsf@@case@@instrue/yylexnext" );@] @=}
    s                   {@> @[TeX_( "/flsf@@dot@@alltrue/yylexnext" );@] @=}
    x                   {@> @[TeX_( "/flsf@@skip@@wstrue/yylexnext" );@] @=}
}

<GROUP_MINUS_PARAMS>{
    ":"                 {@> @[TeX_( "/yyBEGIN{SECT2}/yylexnext" );@] @=}
    i                   {@> @[TeX_( "/flsf@@case@@insfalse/yylexnext" );@] @=}
    s                   {@> @[TeX_( "/flsf@@dot@@allfalse/yylexnext" );@] @=}
    x                   {@> @[TeX_( "/flsf@@skip@@wsfalse/yylexnext" );@] @=}
}

<FIRSTCCL>{
        "^"[^-\]\n]     {@> @[TeX_( "/yyBEGIN{CCL}/yyless{1}/yylexreturnraw^" );@] @=}
        "^"("-"|"]")    {@> @[TeX_( "/yyless{1}/yylexreturnraw^" );@] @=}
        .               {@> @[TeX_( "/yyBEGIN{CCL}/RETURNCHAR" );@] @=}
}

<CCL>{
        -[^\]\n]        {@> @[TeX_( "/yyless{1}/yylexreturnraw-" );@] @=}
        [^\]\n]         {@> @[TeX_( "/RETURNCHAR" );@] @=}
        "]"             {@> @[TeX_( "/yyBEGIN{SECT2}/yylexreturnchar" );@] @=}
        .|{NL}          {@> @[TeX_( "/yyfatal{bad character class}" );@] @=}
}

<FIRSTCCL,CCL>{
        "[:alnum:]"     {@> @[TeX_( "/xcclreturn{CCE_ALNUM}" );@] @=}
        "[:alpha:]"     {@> @[TeX_( "/xcclreturn{CCE_ALPHA}" );@] @=}
        "[:blank:]"     {@> @[TeX_( "/xcclreturn{CCE_BLANK}" );@] @=}
        "[:cntrl:]"     {@> @[TeX_( "/xcclreturn{CCE_CNTRL}" );@] @=}
        "[:digit:]"     {@> @[TeX_( "/xcclreturn{CCE_DIGIT}" );@] @=}
        "[:graph:]"     {@> @[TeX_( "/xcclreturn{CCE_GRAPH}" );@] @=}
        "[:lower:]"     {@> @[TeX_( "/xcclreturn{CCE_LOWER}" );@] @=}
        "[:print:]"     {@> @[TeX_( "/xcclreturn{CCE_PRINT}" );@] @=}
        "[:punct:]"     {@> @[TeX_( "/xcclreturn{CCE_PUNCT}" );@] @=}
        "[:space:]"     {@> @[TeX_( "/xcclreturn{CCE_SPACE}" );@] @=}
        "[:upper:]"     {@> @[TeX_( "/xcclreturn{CCE_UPPER}" );@] @=}
        "[:xdigit:]"    {@> @[TeX_( "/xcclreturn{CCE_XDIGIT}" );@] @=}

        "[:^alnum:]"    {@> @[TeX_( "/xcclreturn{CCE_NEG_ALNUM}" );@] @=}
        "[:^alpha:]"    {@> @[TeX_( "/xcclreturn{CCE_NEG_ALPHA}" );@] @=}
        "[:^blank:]"    {@> @[TeX_( "/xcclreturn{CCE_NEG_BLANK}" );@] @=}
        "[:^cntrl:]"    {@> @[TeX_( "/xcclreturn{CCE_NEG_CNTRL}" );@] @=}
        "[:^digit:]"    {@> @[TeX_( "/xcclreturn{CCE_NEG_DIGIT}" );@] @=}
        "[:^graph:]"    {@> @[TeX_( "/xcclreturn{CCE_NEG_GRAPH}" );@] @=}
        "[:^lower:]"    {@> @[TeX_( "/xcclreturn{CCE_NEG_LOWER}" );@] @=}
        "[:^print:]"    {@> @[TeX_( "/xcclreturn{CCE_NEG_PRINT}" );@] @=}
        "[:^punct:]"    {@> @[TeX_( "/xcclreturn{CCE_NEG_PUNCT}" );@] @=}
        "[:^space:]"    {@> @[TeX_( "/xcclreturn{CCE_NEG_SPACE}" );@] @=}
        "[:^upper:]"    {@> @[TeX_( "/xcclreturn{CCE_NEG_UPPER}" );@] @=}
        "[:^xdigit:]"   {@> @[TeX_( "/xcclreturn{CCE_NEG_XDIGIT}" );@] @=}
        {CCL_EXPR}      {@> @[TeX_( "/yyfatal{bad character class expression: /the/yytext}" );@] @=}
}

<NUM>{
        [[:digit:]]+    {@> @[TeX_( "/yylexreturnval{NUMBER}" );@] @=}

        ","             {@> @[TeX_( "/yylexreturnchar" );@] @=}
        "}"             {@> @<Finish the repeat pattern@> @=}
        .               {@> @[TeX_( "/yyfatal{bad character inside {}'s}" );@] @=}

        {NL}            {@> @[TeX_( "/yyfatal{missing /nx/}}" );@] @=}
}

@ @<Finish the repeat pattern@>=
    @[TeX_( "/yyBEGIN{SECT2}" );@]@;
    @[TeX_( "/iffllex@@compat" );@]@;
    @[TeX_( "    /def/next{/yylexreturn{END_REPEAT_POSIX}}" );@]@;
    @[TeX_( "/else" );@]@;
    @[TeX_( "    /ifflposix@@compat" );@]@;
    @[TeX_( "        /def/next{/yylexreturn{END_REPEAT_POSIX}}" );@]@;
    @[TeX_( "    /else" );@]@;
    @[TeX_( "        /def/next{/yylexreturn{END_REPEAT_FLEX}}" );@]@;
    @[TeX_( "    /fi" );@]@;
    @[TeX_( "/fi/next" );@]@;


@ @<Patterns for \flex\ lexer@>=
@G(fs2)
<PERCENT_BRACE_ACTION>{
  {OPTWS}"%}".*   {@> @[TeX_( "/def/flbracelevel{0}/yylexnext" );@] @=}

   <ACTION>"/*"   {@> @[TeX_( "/yypushstate{COMMENT}/yylexnext" );@] @=}

        <CODEBLOCK,ACTION>{
                "reject"        {@> @[TeX_( "/yylexnext" );@]@=}
                "yymore"        {@> @[TeX_( "/yylexnext" );@]@=}
        }

    {M4QSTART}    {@> @[TeX_( "/yylexnext" );@]@=}
      {M4QEND}    {@> @[TeX_( "/yylexnext" );@]@=}
             .    {@> @[TeX_( "/yylexnext" );@]@=}
          {NL}    {@> @<Process a newline inside a braced group@> @=}
}

@ This actions has been modified to output \prodstyle{'\\n'}.
@<Process a newline inside a braced group@>=
    @[TeX_( "/flinc@@linenum" );@]@;
    @[TeX_( "/ifnum/flbracelevel=/z@@" );@]@;
    @[TeX_( "    /iffldoing@@rule@@action" );@]@;
    @[TeX_( "        /yylexreturnxchar/n" );@]@;
    @[TeX_( "    /else" );@]@;
    @[TeX_( "        /yylexnext" );@]@;
    @[TeX_( "    /fi" );@]@;
    @[TeX_( "    /fldoing@@rule@@actionfalse" );@]@;
    @[TeX_( "    /fldoing@@codeblockfalse" );@]@;
    @[TeX_( "    /yyBEGIN{SECT2}" );@]@;
    @[TeX_( "/else" );@]@;
    @[TeX_( "    /iffldoing@@codeblock" );@]@;
    @[TeX_( "        /ifflindented@@code" );@]@;
    @[TeX_( "            /fldoing@@rule@@actionfalse" );@]@;
    @[TeX_( "            /fldoing@@codeblockfalse" );@]@;
    @[TeX_( "            /yyBEGIN{SECT2}" );@]@;
    @[TeX_( "        /fi" );@]@;
    @[TeX_( "    /fi" );@]@;
    @[TeX_( "    /yylexnext" );@]@;
    @[TeX_( "/fi" );@]@;

@ @<Patterns for \flex\ lexer@>=
@G(fs2)
/* |reject| and |yymore()| are checked for above, in \flexsnstyle{PERCENT\_BRACE\_ACTION} */
<ACTION>{
        "{"            {@> @[TeX_( "/flinc/flbracelevel/yylexnext" );@] @=}
        "}"            {@> @[TeX_( "/fldec/flbracelevel/yylexnext" );@] @=}
    {M4QSTART}         {@> @[TeX_( "/yylexnext" );@]@=}
    {M4QEND}           {@> @[TeX_( "/yylexnext" );@]@=}
 [^[:alpha:]_{}"'/\n\[\]]+ {@> @[TeX_( "/yylexnext" );@]@=}
    [\[\]]             {@> @[TeX_( "/yylexnext" );@]@=}
        {NAME}         {@> @[TeX_( "/yylexnext" );@]@=}
 "'"([^'\\\n]|\\.)*"'" {@> @[TeX_( "/yylexnext" );@]@=}
        \"             {@> @[TeX_( "/yyBEGIN{ACTION_STRING}/yylexnext" );@]@=}
        {NL}           {@> @<Process a newline inside an action@> @=}
        .              {@> @[TeX_( "/yylexnext" );@]@=}
}

@ This actions has been modified to output \prodstyle{'\\n'}.
@<Process a newline inside an action@>=
    @[TeX_( "/flinc@@linenum" );@]@;
    @[TeX_( "/ifnum/flbracelevel=/z@@" );@]@;
    @[TeX_( "    /iffldoing@@rule@@action" );@]@;
    @[TeX_( "        /yylexreturnxchar/n" );@]@;
    @[TeX_( "    /else" );@]@;
    @[TeX_( "        /yylexnext" );@]@;
    @[TeX_( "    /fi" );@]@;
    @[TeX_( "    /fldoing@@rule@@actionfalse" );@]@;
    @[TeX_( "    /yyBEGIN{SECT2}" );@]@;
    @[TeX_( "/fi" );@]@;

@ @<Patterns for \flex\ lexer@>=
@G(fs2)
<ACTION_STRING>{
 [^"\\\n]+ {@> @[TeX_( "/yylexnext" );@] @=}
       \\. {@> @[TeX_( "/yylexnext" );@] @=}
      {NL} {@> @[TeX_( "/flinc@@linenum/yyBEGIN{ACTION}/yylexnext" );@] @=}
        \" {@> @[TeX_( "/yyBEGIN{ACTION}/yylexnext" );@] @=}
         . {@> @[TeX_( "/yylexnext" );@] @=}
}

<COMMENT,COMMENT_DISCARD,ACTION,ACTION_STRING><<EOF>>   {@> @[TeX_( "/yyfatal{EOF encountered inside an action}" );@] @=}

<EXTENDED_COMMENT,GROUP_WITH_PARAMS,GROUP_MINUS_PARAMS><<EOF>>  {@> @[TeX_( "/yyfatal{EOF encountered inside pattern}" );@] @=}

<SECT2,QUOTE,FIRSTCCL,CCL>{ESCSEQ} {@> @<Process an escaped sequence@> @=}

@ @<Process an escaped sequence@>=
  @[TeX_( "/ifnum/YYSTART=/number/csname flexstate/parsernamespace FIRSTCCL/endcsname/relax" );@]@;
  @[TeX_( "    /yyBEGIN{CCL}" );@]@;
  @[TeX_( "/fi" );@]@;
  @[TeX_( "/RETURNCHAR" );@]@;

@ @<Patterns for \flex\ lexer@>=
@G(fs2)
<SECT3>{
      {M4QSTART} {@> @[TeX_( "/yylexnext" );@] @=}
        {M4QEND} {@> @[TeX_( "/yylexnext" );@] @=}
 [^\[\]\n]*(\n?) {@> @[TeX_( "/yylexnext" );@] @=}
          (.|\n) {@> @[TeX_( "/yylexnext" );@] @=}
         <<EOF>> {@> @[TeX_( "/def/flsectnum{0}/yyterminate" );@] @=}
}

<*>.|\n    {@> @[TeX_( "/yyfatal{bad character: /the/yytext}" );@] @=}

@ @<Auxilary code for \flex\ lexer@>=
void define_all_states( void ) {
  @<Collect state definitions for the \flex\ lexer@>@;
}

@ @<Collect state definitions for the \flex\ lexer@>=
#define _register_name( name ) @[Define_State( #name, name )@]
#include "fil_states.h"
#undef _register_name