summaryrefslogtreecommitdiff
path: root/support/splint/examples/ld/ldnp.w
diff options
context:
space:
mode:
Diffstat (limited to 'support/splint/examples/ld/ldnp.w')
-rw-r--r--support/splint/examples/ld/ldnp.w49
1 files changed, 22 insertions, 27 deletions
diff --git a/support/splint/examples/ld/ldnp.w b/support/splint/examples/ld/ldnp.w
index 0a99d864fd..9a7d86f097 100644
--- a/support/splint/examples/ld/ldnp.w
+++ b/support/splint/examples/ld/ldnp.w
@@ -1,4 +1,4 @@
-@q Copyright 2012-2020, Alexander Shibakov@>
+@q Copyright 2012-2022, Alexander Shibakov@>
@q This file is part of SPLinT@>
@q SPLinT is free software: you can redistribute it and/or modify@>
@@ -181,11 +181,6 @@ qualifier:
@[TeX_( "/getsecond{/yy(1)}/to/toksb" );@]@;
@[TeX_( "/yy0{/nx/idstr{/the/toksa}{/the/toksb}}" );@]@;
-@ @<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" );@]@;
@@ -197,9 +192,6 @@ qualifier:
@ @<Start with a \prodstyle{'.'} string@>=
@[TeX_( "/yy0{/nx/visflag{/nx/termvstring}{}/nx/chstr{.}{.}}" );@]@;
-@ @<Turn a qualifier into an identifier@>=
- @<Start with an identifier@>@;
-
@ @<Attach an identifier@>=
@[TeX_( "/getsecond{/yy(1)}/to/toksa" );@]@;
@[TeX_( "/appendr/toksa{/noexpand/_}" );@]@;
@@ -213,7 +205,6 @@ qualifier:
@ @<Attach qualifier to a name@>=
-
@ @<Attach an integer@>=
@[TeX_( "/yy0{/nx/dotsp/nx/sfxi/the/yy(1)}" );@]@;
@@ -262,14 +253,15 @@ as they have to be inserted in a place that is aware of the internal definitions
definitions are used.
@<Name parser \Cee\ postamble@>=
-#define YYPRINT(file, type, value) @[yyprint (file, type, value)@]
- static void yyprint (FILE *file, int type, YYSTYPE value){}
@ Union of types.
@<Union of parser types@>=
-@*1 The name scanner.
+@*1 The name scanner. The scanner for \ld\ name parser is essentially identical to that for the
+\bison\ and \flex\ name parser\footnote{And is just as much of an overkill. This should serve as a
+cautionary tale of how suboptimal but convenient choices tend to take root.}. The only exception
+is the scanning of suffixes.
%\checktabletrue
@(ld_small_lexer.ll@>=
@G
@@ -277,7 +269,7 @@ definitions are used.
%{@> @<Lexer \Cee\ preamble@> @=%}
@> @<Lexer options@> @=
%%
- @> @<Regular expressions@> @=
+ @> @<Regular expressions for the name parser@> @=
%%
@O
void define_all_states( void ) {
@@ -306,18 +298,16 @@ int [0-9]+
@ Strings and characters in directives/rules.
@<Lexer states@>=
-@G
+@G(fs1)
%x SC_ESCAPED_STRING SC_ESCAPED_CHARACTER
@g
@ @<Lexer \Cee\ preamble@>=
-
#include <stdint.h>
-#include <stdbool.h>
+#include <stdbool.h>@t}\yyskipparsefalse{@>
-@t}\yyskipparsefalse{@>
@ @<Lexer options@>=
-@G
+@G(fs1)
%option bison-bridge
%option noyywrap nounput noinput reentrant
%option noyy_top_state
@@ -326,11 +316,18 @@ int [0-9]+
%option outfile="ld_small_lexer.c"
@g
-@ @<Regular expressions@>=
+@ @<Regular expressions for the name parser@>=
@<Scan white space@>@;
@<Scan identifiers@>@;
-@ White space skipping.
+@ White space is skipped in names\footnote{How it finds its way {\em into\/} a name deserves
+some investigation for which we do not have the space here.}.
+Note that the input routine produced by \splint\ springs into action
+{\em after\/} the input passes through the scanning mechanism of \TeX\ which makes it very unlikely
+that any of the characters below in the definition of `whitespace' could make it to the scanner.
+They are left in, however, in case a custom input routine is used that produces such
+characters\footnote{Although, in this case, some special processing by the scanner
+would likely be required.}.
\traceparserstatestrue
\tracestackstrue
\tracerulestrue
@@ -356,11 +353,9 @@ int [0-9]+
[ \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.
+@ Suffixes specific to \ld\ name scanner are defined here, along with some other
+lexical elements. Most of these definitions mimic the ones for the \bison\ name
+scanner.
@<Scan identifiers@>=
@G(fs2)
"%"({aletter}|[0-9]|[-_]|"%"|[<>])+ {@> @[TeX_( "/yylexreturnval{PERCENT_IDENTIFIER}" );@]@=}
@@ -392,4 +387,4 @@ trivial scanning problems.
@[TeX_( "/iftracebadchars" );@]@;
@[TeX_( " /yycomplain{invalid character(s): /the/yytext}" );@]@;
@[TeX_( "/fi" );@]@;
- @[TeX_( "/yylexreturn{$undefined}" );@]@;
+ @[TeX_( "/yyerrterminate" );@]@;