diff options
Diffstat (limited to 'support/splint/cweb/lo.w')
-rw-r--r-- | support/splint/cweb/lo.w | 100 |
1 files changed, 43 insertions, 57 deletions
diff --git a/support/splint/cweb/lo.w b/support/splint/cweb/lo.w index 68ef1b6595..c2461787a9 100644 --- a/support/splint/cweb/lo.w +++ b/support/splint/cweb/lo.w @@ -1,4 +1,4 @@ -@q Copyright 2012-2020 Alexander Shibakov@> +@q Copyright 2012-2024 Alexander Shibakov@> @q Copyright 2002-2014 Free Software Foundation, Inc.@> @q This file is part of SPLinT@> @@ -18,6 +18,7 @@ @**The scanner for \ifx\bison\UNDEFINED\.{bison}\else\bison\fi\ syntax. \ifx\bison\UNDEFINED \input limbo.sty + \input yystype.sty \input grabstates.sty \immediate\openout\stlist=lo_states.h \fi @@ -95,7 +96,7 @@ output it in the form of a header file for the `real' lexer output @ {\it A \Cee-like comment in directives/rules}. @<Grammar lexer states@>= -@G +@G(fs1) %x SC_YACC_COMMENT @g @@ -106,22 +107,26 @@ output it in the form of a header file for the `real' lexer output %\tracerulestrue %\traceactionstrue %\tracebadcharstrue +%\traceparseresultstrue +%\traceparserstatestrue %\prodstyle{\%\%}% -\traceparserstatesfalse -\tracestacksfalse -\tracerulesfalse -\traceactionsfalse -\tracebadcharsfalse -\yyflexdebugfalse @<Grammar lexer states@>= -@G +@G(fs1) %x SC_ESCAPED_STRING SC_ESCAPED_CHARACTER @g @ {\it A identifier was just read in directives/rules. Special state to capture the sequence `\.{identifier:}'}. +\traceparserstatesfalse +\tracestacksfalse +\tracerulesfalse +\traceactionsfalse +\tracebadcharsfalse +\yyflexdebugfalse +\traceparseresultsfalse +\traceparserstatesfalse @<Grammar lexer states@>= -@G +@G(fs1) %x SC_AFTER_IDENTIFIER @g @@ -131,7 +136,7 @@ disallow \prodstyle{NUL}, as this simplifies our implementation. We match angle brackets in nested pairs: several languages use them for generics/template types}. @<Grammar lexer states@>= -@G +@G(fs1) %x SC_TAG @g @@ -150,25 +155,25 @@ Four types of user code: \aterm predicate (code between \.{\%?\{} and \.{\}} in middle section); }% @<Grammar lexer states@>= -@G +@G(fs1) %x SC_PROLOGUE SC_BRACED_CODE SC_EPILOGUE SC_PREDICATE @g @ {\it \Cee\ and \Ceepp\ comments in code}. @<Grammar lexer states@>= -@G +@G(fs1) %x SC_COMMENT SC_LINE_COMMENT @g @ {\it Strings and characters in code}. @<Grammar lexer states@>= -@G +@G(fs1) %x SC_STRING SC_CHARACTER @g @ Bracketed identifiers support. @<Grammar lexer states@>= -@G +@G(fs1) %x SC_BRACKETED_ID SC_RETURN_BRACKETED_ID @g @@ -179,9 +184,9 @@ Four types of user code: @ The code for the generated scanner is highly dependent on the options supplied. Most of the options below are essential for the scheme -adopted in this package to work. +adopted in this package to work.\gtextidx{\flex\ options example}{flex options example}{\flexidxdomain}% @<Grammar lexer options@>= -@G +@G(fs1) %option bison-bridge %option noyywrap nounput noinput reentrant %option noyy_top_state @@ -194,7 +199,6 @@ adopted in this package to work. Here is a full list of regular expressions recognized by the \bison\ scanner. @<Grammar token regular expressions@>= @<Scan grammar white space@>@; - @<Scan \flex\ directives and options@>@; @<Scan \bison\ directives@>@; @<Do not support zero characters@>@; @<Scan after an identifier, check whether a colon is next@>@; @@ -340,23 +344,11 @@ returns a pair of pointers as the value. } @g -@ Some additional constructs needed to typeset simple \flex\ -declarations. This is not part of the original \bison\ scanner. -@<Scan \flex\ directives and options@>= -@G(fs2) -<INITIAL> -{ - "%option" {@> @[TeX_( "/yylexreturnptr{FLEX_OPTION}" );@]@=} - "%x" {@> @[TeX_( "/yylexreturnptr{FLEX_STATE_X}" );@]@=} - "%s" {@> @[TeX_( "/yylexreturnptr{FLEX_STATE_S}" );@]@=} -} -@g - @ We present the `bad character' code first, before going into the details of the character matching by the rest of the lexer. @<Process a bad character@>= - @[TeX_( "/edef/next{/nx/csname lexspecial[/the/yytextpure]/nx/endcsname}" );@]@; - @[TeX_( "/expandafter/expandafter/expandafter/ifx/next/relax" );@]@; + @[TeX_( "/expandafter/let/expandafter/next/csname lexspecial[/the/yytextpure]/endcsname" );@]@; + @[TeX_( "/ifx/next/relax" );@]@; @[TeX_( " /iftracebadchars" );@]@; @[TeX_( " /yyfatal{invalid character(s): /the/yytext}" );@]@; @[TeX_( " /fi" );@]@; @@ -436,13 +428,12 @@ later, after the context is known. @ @<Process the bracketed part of an identifier@>= @[TeX_( "/ifx/bracketedidstr/empty" );@]@; @[TeX_( " /bracketedidcontextstate/YYSTART /yyBEGIN{SC_BRACKETED_ID}" );@]@; - @[TeX_( " /let/next=/yylexnext" );@]@; + @[TeX_( " /yybreak/yylexnext" );@]@; @[TeX_( "/else" );@]@; @[TeX_( " /ROLLBACKCURRENTTOKEN" );@]@; @[TeX_( " /yyBEGIN{SC_RETURN_BRACKETED_ID}" );@]@; - @[TeX_( " /def/next{/yylexreturn{ID}}" );@]@; - @[TeX_( "/fi" );@]@; - @[TeX_( "/next" );@]@; + @[TeX_( " /yybreak{/yylexreturn{ID}}" );@]@; + @[TeX_( "/yycontinue" );@]@; @ @<Process a colon after an identifier@>= @[TeX_( "/ifx/bracketedidstr/empty" );@]@; @@ -485,27 +476,25 @@ later, after the context is known. @[TeX_( "/ifx/bracketedidstr/empty" );@]@; @[TeX_( " /edef/bracketedidstr{{/the/yytextpure}{/the/yytext}" );@]@; @[TeX_( " {/the/yyfmark}{/the/yysmark}}" );@]@; - @[TeX_( " /let/next=/yylexnext" );@]@; + @[TeX_( " /yybreak/yylexnext" );@]@; @[TeX_( "/else" );@]@; - @[TeX_( " /def/next{/yywarn{unexpected identifier " );@]@; + @[TeX_( " /yybreak{/yywarn{unexpected identifier " );@]@; @[TeX_( " in bracketed name: /the/yytext}}" );@]@; - @[TeX_( "/fi" );@]@; - @[TeX_( "/next" );@]@; + @[TeX_( "/yycontinue" );@]@; @ @<Finish processing bracketed identifier@>= @[TeX_( "/yyBEGINr/bracketedidcontextstate" );@]@; @[TeX_( "/ifx/bracketedidstr/empty" );@]@; - @[TeX_( " /def/next{/yywarn{an identifier expected}}" );@]@; + @[TeX_( " /yybreak{/yywarn{an identifier expected}}" );@]@; @[TeX_( "/else" );@]@; @[TeX_( " /ifnum/bracketedidcontextstate=/yylexstate{INITIAL}/relax" );@]@; @[TeX_( " /expandafter/yylval/expandafter{/bracketedidstr}" );@]@; @[TeX_( " /let/bracketedidstr=/empty" );@]@; - @[TeX_( " /def/next{/yylexreturn{BRACKETED_ID}}" );@]@; + @[TeX_( " /yybreak@@{/yylexreturn{BRACKETED_ID}}" );@]@; @[TeX_( " /else" );@]@; - @[TeX_( " /let/next=/yylexnext" );@]@; + @[TeX_( " /yybreak@@/yylexnext" );@]@; @[TeX_( " /fi" );@]@; - @[TeX_( "/fi" );@]@; - @[TeX_( "/next" );@]@; + @[TeX_( "/yycontinue" );@]@; @ @<Complain about improper identifier characters@>= @[TeX_( "/yyfatal{invalid character(s) in bracketed name: /the/yytext}" );@]@; @@ -621,11 +610,10 @@ The initial quote is already eaten}. @[TeX_( " {/the/yyfmark}{/the/yysmark}}}/next" );@]@; @[TeX_( " /STRINGFREE" );@]@; @[TeX_( " /yyBEGIN{INITIAL}" );@]@; - @[TeX_( " /def/next{/yylexreturn{TAG}}" );@]@; + @[TeX_( " /yybreak{/yylexreturn{TAG}}" );@]@; @[TeX_( "/else" );@]@; - @[TeX_( " /STRINGGROW/let/next=/yylexnext" );@]@; - @[TeX_( "/fi" );@]@; - @[TeX_( "/next" );@]@; + @[TeX_( " /STRINGGROW/yybreak/yylexnext" );@]@; + @[TeX_( "/yycontinue" );@]@; @ This is a slightly different rule from the original scanner. We do not perform |yyleng| computations, so it makes sense to raise the nesting level one by one. @@ -722,13 +710,12 @@ braced code. @[TeX_( "/ifnum/lonesting</z@@" );@]@; @[TeX_( " /STRINGFINISH" );@]@; @[TeX_( " /edef/next{/yylval{{/the/laststring}{/the/yyfmark}{/the/yysmark}}}/next" );@]@; - @[TeX_( " /def/next{/yylexreturn{BRACED_CODE}}" );@]@; @[TeX_( " /yyBEGIN{INITIAL}" );@]@; + @[TeX_( " /yybreak{/yylexreturn{BRACED_CODE}}" );@]@; @[TeX_( "/else" );@]@; @[TeX_( " /STRINGGROW" );@]@; - @[TeX_( " /let/next=/yylexnext" );@]@; - @[TeX_( "/fi" );@]@; - @[TeX_( "/next" );@]@; + @[TeX_( " /yybreak/yylexnext" );@]@; + @[TeX_( "/yycontinue" );@]@; @ @<Add closing brace to a predicate@>= @[TeX_( "/advance/lonesting/m@@ne" );@]@; @@ -736,12 +723,11 @@ braced code. @[TeX_( " /STRINGFINISH" );@]@; @[TeX_( " /edef/next{/yylval{{/the/laststring}{/the/yyfmark}{/the/yysmark}}}/next" );@]@; @[TeX_( " /yyBEGIN{INITIAL}" );@]@; - @[TeX_( " /def/next{/yylexreturn{BRACED_PREDICATE}}" );@]@; + @[TeX_( " /yybreak{/yylexreturn{BRACED_PREDICATE}}" );@]@; @[TeX_( "/else" );@]@; @[TeX_( " /STRINGGROW" );@]@; - @[TeX_( " /let/next=/yylexnext" );@]@; - @[TeX_( "/fi" );@]@; - @[TeX_( "/next" );@]@; + @[TeX_( " /yybreak/yylexnext" );@]@; + @[TeX_( "/yycontinue" );@]@; @ {\it Scanning some prologue: from \.{\%\{} (already scanned) to \.{\%\}}}. @<Scan prologue@>= |