summaryrefslogtreecommitdiff
path: root/support/splint/cweb/so.w
diff options
context:
space:
mode:
Diffstat (limited to 'support/splint/cweb/so.w')
-rw-r--r--support/splint/cweb/so.w133
1 files changed, 85 insertions, 48 deletions
diff --git a/support/splint/cweb/so.w b/support/splint/cweb/so.w
index d7a7696b8c..944f2cb82f 100644
--- a/support/splint/cweb/so.w
+++ b/support/splint/cweb/so.w
@@ -32,6 +32,7 @@
@**The lexer for \ifx\flex\UNDEFINED\.{flex}\else\flex\ \fi syntax.
\ifx\flex\UNDEFINED
\input limbo.sty
+ \input yystype.sty
\input grabstates.sty
\immediate\openout\stlist=fil_states.h
\fi
@@ -43,16 +44,31 @@ to replace them with ordinary patterns and use |yyless()| in the actions.
@G
%{@> @<Preamble for \flex\ lexer@> @=%}
@> @<Options for \flex\ input lexer@> @=
- @> @<Additional options for \flex\ input lexer@> @=
+ @> @<Output file for \flex\ input lexer@> @=
@> @<State definitions for \flex\ input lexer@> @=
@> @<Definitions for \flex\ input lexer@> @=
%%
@> @<Postamble for \flex\ input lexer@> @=
+ @> @<Common patterns for \flex\ lexer@> @=
@> @<Patterns for \flex\ lexer@> @=
%%
@> @<Auxilary code for \flex\ lexer@> @=
@g
+@ Bootstrap lexer.
+@(ssfs.ll@>=
+@G
+%{@> @<Preamble for \flex\ lexer@> @=%}
+ @> @<Options for \flex\ input lexer@> @=
+ @> @<Output file for the bootstrap \flex\ lexer@> @=
+ @> @<Definitions for \flex\ input lexer@> @=
+%%
+ @> @<Common patterns for \flex\ lexer@> @=
+ @> @<Catchall rule for the bootstrap lexer@> @=
+%%
+ @> @<Auxilary code for the bootstrap \flex\ lexer@> @=
+@g
+
@ @<Preamble for \flex\ lexer@>=
@ There are a few options that are necessary to ensure that the lexer
@@ -60,27 +76,31 @@ 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
+@G(fs1)
%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
+
+@ @<Output file for \flex\ input lexer@>=
+@G(fs1)
%option outfile="fil.c"
@g
+@ @<Output file for the bootstrap \flex\ lexer@>=
+@G(fs1)
+%option outfile="ssfs.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
+@G(fs1)
%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
@@ -132,7 +152,7 @@ M4QEND "]]"
@*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@>=
+@<Common patterns for \flex\ lexer@>=
@G(fs2)
<INITIAL>{
^{WS} {@> @[TeX_( "/flindented@@codetrue/yyBEGIN{CODEBLOCK}/yylexnext" );@]@=}
@@ -211,7 +231,7 @@ The code below treats \prodstyle{\%pointer} and \prodstyle{\%array} the same way
<LINEDIR>{
\n {@> @[TeX_( "/yypopstate/yylexnext" );@]@=}
- [[:digit:]]+ {@> @[TeX_( "/fllinenum=/number/yytext/yylexnext" );@]@=}
+ [[:digit:]]+ {@> @[TeX_( "/fllinenum=/number/the/yytext/yylexnext" );@]@=}
\"[^"\n]*\" {@> @[TeX_( "/yylexnext" );@] /* ignore the file name in the line directives */ @=}
. {@> @[TeX_( "/yylexnext" );@] /* ignore spurious characters */ @=}
}
@@ -257,10 +277,10 @@ The code below treats \prodstyle{\%pointer} and \prodstyle{\%array} the same way
@ @<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_( " /yybreak{/flinc@@linenum/yyBEGIN{INITIAL}/yylexreturn{RE_DEF}}" );@]@;
@[TeX_( "/else" );@]@;
- @[TeX_( " /def/next{/yyfatal{incomplete name definition}}" );@]@;
- @[TeX_( "/fi/next" );@]@;
+ @[TeX_( " /yybreak{/yyfatal{incomplete name definition}}" );@]@;
+ @[TeX_( "/yycontinue" );@]@;
@ @<Patterns for \flex\ lexer@>=
@G(fs2)
@@ -390,7 +410,6 @@ The code below treats \prodstyle{\%pointer} and \prodstyle{\%array} the same way
<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>{
@@ -407,7 +426,6 @@ The code below treats \prodstyle{\%pointer} and \prodstyle{\%array} the same way
}
@ All the code inside is ignored.
-\saveparseoutputfalse
@<Consume the brace and increment the brace level@>=
@[TeX_( "/flinc/flbracelevel/yyless{2}/yylexnext" );@]@;
@@ -416,13 +434,16 @@ The code below treats \prodstyle{\%pointer} and \prodstyle{\%array} the same way
@ @<Begin section 2, prepare to reread, or ignore braced code@>=
@[TeX_( "/ifnum/flbracelevel>/z@@" );@]@;
- @[TeX_( " /let/next/yylexnext" );@]@;
+ @[TeX_( " /yybreak/yylexnext" );@]@;
@[TeX_( "/else" );@]@;
- @[TeX_( " /def/next{/yysetbol{/@@ne}/yyBEGIN{SECT2}/yyless{0}/yylexnext}" );@]@;
- @[TeX_( "/fi/next" );@]@;
+ @[TeX_( " /yybreak{/yysetbol{/@@ne}/yyBEGIN{SECT2}/yyless{0}/yylexnext}" );@]@;
+ @[TeX_( "/yycontinue" );@]@;
@ 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\
+A special symbol ($\odot$\gtextidx{$\odot$ separator, \flex}{0. separator, flex}{\flexidxdomain})
+has been 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
@@ -477,14 +498,14 @@ These corrections can also be delayed. For the details, an interested reader may
@ @<Process a repeat pattern@>=
@[TeX_( "/yyless{1}/yyBEGIN{NUM}" );@]@;
@[TeX_( "/iffllex@@compat" );@]@;
- @[TeX_( " /def/next{/yylexreturn{BEGIN_REPEAT_POSIX}}" );@]@;
+ @[TeX_( " /yybreak{/yylexreturn{BEGIN_REPEAT_POSIX}}" );@]@;
@[TeX_( "/else" );@]@;
@[TeX_( " /ifflposix@@compat" );@]@;
- @[TeX_( " /def/next{/yylexreturn{BEGIN_REPEAT_POSIX}}" );@]@;
+ @[TeX_( " /yybreak@@{/yylexreturn{BEGIN_REPEAT_POSIX}}" );@]@;
@[TeX_( " /else" );@]@;
- @[TeX_( " /def/next{/yylexreturn{BEGIN_REPEAT_FLEX}}" );@]@;
+ @[TeX_( " /yybreak@@{/yylexreturn{BEGIN_REPEAT_FLEX}}" );@]@;
@[TeX_( " /fi" );@]@;
- @[TeX_( "/fi/next" );@]@;
+ @[TeX_( "/yycontinue" );@]@;
@ @<Process braced code in the middle of section 2@>=
@[TeX_( "/def/flbracelevel{1}" );@]@;
@@ -492,17 +513,17 @@ These corrections can also be delayed. For the details, an interested reader may
@[TeX_( "/ifflin@@rule" );@]@;
@[TeX_( " /fldoing@@rule@@actiontrue" );@]@;
@[TeX_( " /flin@@rulefalse" );@]@;
- @[TeX_( " /def/next{/yylexreturnxchar/n}" );@]@;
+ @[TeX_( " /yybreak{/yylexreturnxchar/n}" );@]@;
@[TeX_( "/else" );@]@;
- @[TeX_( " /let/next/yylexnext" );@]@;
- @[TeX_( "/fi/next" );@]@;
+ @[TeX_( " /yybreak/yylexnext" );@]@;
+ @[TeX_( "/yycontinue" );@]@;
@ 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_( " /yybreak/yylexnext" );@]@;
@[TeX_( "/else" );@]@;
@[TeX_( " /flinc@@linenum" );@]@;
@[TeX_( " /fldoing@@rule@@actiontrue" );@]@;
@@ -510,8 +531,8 @@ is treated as an ordinary (empty) action.
@[TeX_( " /flcontinued@@actiontrue" );@]@;
@[TeX_( " /unput{/n}" );@]@;
@[TeX_( " /yyBEGIN{ACTION}" );@]@;
- @[TeX_( " /edef/next{/nx/yylexreturnxchar/n}" );@]@;
- @[TeX_( "/fi/next" );@]@;
+ @[TeX_( " /yybreak{/yylexreturnxchar/n}" );@]@;
+ @[TeX_( "/yycontinue" );@]@;
@ @<Process a comment inside a pattern@>=
@[TeX_( "/ifflsf@@skip@@ws" );@]@;
@@ -525,7 +546,7 @@ is treated as an ordinary (empty) action.
@ @<Decide whether to start an action or skip whitespace inside a rule@>=
@[TeX_( "/ifflsf@@skip@@ws" );@]@;
- @[TeX_( " /let/next/yylexnext" );@]@;
+ @[TeX_( " /yybreak/yylexnext" );@]@;
@[TeX_( "/else" );@]@;
@[TeX_( " /def/flbracelevel{0}" );@]@;
@[TeX_( " /flcontinued@@actionfalse" );@]@;
@@ -533,16 +554,16 @@ is treated as an ordinary (empty) action.
@[TeX_( " /ifflin@@rule" );@]@;
@[TeX_( " /fldoing@@rule@@actiontrue" );@]@;
@[TeX_( " /flin@@rulefalse" );@]@;
- @[TeX_( " /def/next{/yylexreturnxchar/n}" );@]@;
+ @[TeX_( " /yybreak@@{/yylexreturnxchar/n}" );@]@;
@[TeX_( " /else" );@]@;
- @[TeX_( " /let/next/yylexnext" );@]@;
+ @[TeX_( " /yybreak@@/yylexnext" );@]@;
@[TeX_( " /fi" );@]@;
- @[TeX_( "/fi/next" );@]@;
+ @[TeX_( "/yycontinue" );@]@;
@ @<Finish the line and/or action@>=
@[TeX_( "/ifflsf@@skip@@ws" );@]@;
@[TeX_( " /flinc@@linenum" );@]@;
- @[TeX_( " /let/next/yylexnext" );@]@;
+ @[TeX_( " /yybreak/yylexnext" );@]@;
@[TeX_( "/else" );@]@;
@[TeX_( " /def/flbracelevel{0}" );@]@;
@[TeX_( " /flcontinued@@actionfalse" );@]@;
@@ -551,11 +572,11 @@ is treated as an ordinary (empty) action.
@[TeX_( " /ifflin@@rule" );@]@;
@[TeX_( " /fldoing@@rule@@actiontrue" );@]@;
@[TeX_( " /flin@@rulefalse" );@]@;
- @[TeX_( " /def/next{/yylexreturnxchar/n}" );@]@;
+ @[TeX_( " /yybreak@@{/yylexreturnxchar/n}" );@]@;
@[TeX_( " /else" );@]@;
- @[TeX_( " /let/next/yylexnext" );@]@;
+ @[TeX_( " /yybreak@@/yylexnext" );@]@;
@[TeX_( " /fi" );@]@;
- @[TeX_( "/fi/next" );@]@;
+ @[TeX_( "/yycontinue" );@]@;
@ @<Start section 3@>=
@[TeX_( "/def/flsectnum{3}" );@]@;
@@ -596,26 +617,26 @@ The braces and the possible trailing whitespace will be dealt with by the typese
@ @<Determine if this is extended syntax or return a parenthesis@>=
@[TeX_( "/iffllex@@compat" );@]@;
- @[TeX_( " /def/next{/yyless{1}/flsf@@push/yylexreturnraw(}" );@]@;
+ @[TeX_( " /yybreak{/yyless{1}/flsf@@push/yylexreturnraw(}" );@]@;
@[TeX_( "/else" );@]@;
@[TeX_( " /ifflposix@@compat" );@]@;
- @[TeX_( " /def/next{/yyless{1}/flsf@@push/yylexreturnraw(}" );@]@;
+ @[TeX_( " /yybreak@@{/yyless{1}/flsf@@push/yylexreturnraw(}" );@]@;
@[TeX_( " /else" );@]@;
- @[TeX_( " /def/next{/yypushstate{EXTENDED_COMMENT}}" );@]@;
+ @[TeX_( " /yybreak@@{/yypushstate{EXTENDED_COMMENT}}" );@]@;
@[TeX_( " /fi" );@]@;
- @[TeX_( "/fi/next" );@]@;
+ @[TeX_( "/yycontinue" );@]@;
@ @<Determine if this is a parametric group or return a parenthesis@>=
@[TeX_( "/flsf@@push" );@]@;
@[TeX_( "/iffllex@@compat" );@]@;
- @[TeX_( " /def/next{/yyless{1}}" );@]@;
+ @[TeX_( " /yybreak{/yyless{1}}" );@]@;
@[TeX_( "/else" );@]@;
@[TeX_( " /ifflposix@@compat" );@]@;
- @[TeX_( " /def/next{/yyless{1}}" );@]@;
+ @[TeX_( " /yybreak@@{/yyless{1}}" );@]@;
@[TeX_( " /else" );@]@;
- @[TeX_( " /def/next{/yyBEGIN{GROUP_WITH_PARAMS}}" );@]@;
+ @[TeX_( " /yybreak@@{/yyBEGIN{GROUP_WITH_PARAMS}}" );@]@;
@[TeX_( " /fi" );@]@;
- @[TeX_( "/fi/next" );@]@;
+ @[TeX_( "/yycontinue" );@]@;
@[TeX_( "/yylexreturnraw(" );@]@;
@ @<Patterns for \flex\ lexer@>=
@@ -708,14 +729,14 @@ The braces and the possible trailing whitespace will be dealt with by the typese
@ @<Finish the repeat pattern@>=
@[TeX_( "/yyBEGIN{SECT2}" );@]@;
@[TeX_( "/iffllex@@compat" );@]@;
- @[TeX_( " /def/next{/yylexreturn{END_REPEAT_POSIX}}" );@]@;
+ @[TeX_( " /yybreak{/yylexreturn{END_REPEAT_POSIX}}" );@]@;
@[TeX_( "/else" );@]@;
@[TeX_( " /ifflposix@@compat" );@]@;
- @[TeX_( " /def/next{/yylexreturn{END_REPEAT_POSIX}}" );@]@;
+ @[TeX_( " /yybreak@@{/yylexreturn{END_REPEAT_POSIX}}" );@]@;
@[TeX_( " /else" );@]@;
- @[TeX_( " /def/next{/yylexreturn{END_REPEAT_FLEX}}" );@]@;
+ @[TeX_( " /yybreak@@{/yylexreturn{END_REPEAT_FLEX}}" );@]@;
@[TeX_( " /fi" );@]@;
- @[TeX_( "/fi/next" );@]@;
+ @[TeX_( "/yycontinue" );@]@;
@ @<Patterns for \flex\ lexer@>=
@@ -833,3 +854,19 @@ void define_all_states( void ) {
#include "fil_states.h"
#undef _register_name
+@ @<Catchall rule for the bootstrap lexer@>=
+@G(fs2)
+<*>. {@> @[TeX_( "/yyerrterminate" );@] @=}
+
+@ The drive expects this function to be defined but the bootstrap
+lexer has no need for it. We leave it in to appease the compiler.
+@<Auxilary code for the bootstrap \flex\ lexer@>=
+void define_all_states( void ) {
+ @<Collect state definitions for the bootstrap \flex\ lexer@>@;
+}
+
+@ @<Collect state definitions for the bootstrap \flex\ lexer@>=
+#define _register_name( name ) @[Define_State( #name, name )@]
+ /* The \flexsnstyle{INITIAL} state is generated automatically */
+#undef _register_name
+