summaryrefslogtreecommitdiff
path: root/support/splint/cweb/np.w
diff options
context:
space:
mode:
Diffstat (limited to 'support/splint/cweb/np.w')
-rw-r--r--support/splint/cweb/np.w34
1 files changed, 21 insertions, 13 deletions
diff --git a/support/splint/cweb/np.w b/support/splint/cweb/np.w
index 58379649a5..a4216ee058 100644
--- a/support/splint/cweb/np.w
+++ b/support/splint/cweb/np.w
@@ -1,4 +1,4 @@
-@q Copyright 2012-2020, Alexander Shibakov@>
+@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@>
@@ -18,7 +18,11 @@
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.
+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
@@ -61,7 +65,7 @@ parser for local purposes.
@G
full_name:
identifier_string suffixes.opt {@> @<Compose the full name@> @=}
-| META_IDENTIFIER {@> @<Turn a \prodstylens{META\_IDENTIFIER}{\smallnamespace} into a full name@> @=}
+| META_IDENTIFIER {@> @<Turn a \prodstylens{META_IDENTIFIER}{\smallnamespace} into a full name@> @=}
| quoted_name suffixes.opt {@> @<Compose the full name@> @=}
;
@@ -123,7 +127,7 @@ qualifier:
@ @<Compose the full name@>=
@[TeX_( "/yy0{/the/yy(1)/the/yy(2)}/namechars/yyval" );@]@;
-@ @<Turn a \prodstylens{META\_IDENTIFIER}{\smallnamespace} into a full name@>=
+@ @<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" );@]@;
@@ -138,7 +142,9 @@ qualifier:
@[TeX_( "/getsecond{/yy(1)}/to/toksb" );@]@;
@[TeX_( "/yy0{/nx/idstr{/the/toksa}{/the/toksb}}" );@]@;
-@ @<Start with a tag@>=
+@ 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>}}" );@]@;
@@ -193,14 +199,15 @@ qualifier:
@ 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.}) to
+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 \.{id\_strict} syntax below.
+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)}" );@]@;
@@ -251,8 +258,6 @@ 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.
@@ -281,7 +286,10 @@ void define_all_states( void ) {
@o
@g
-@ @<Lexer definitions@>=
+@ \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]
@@ -300,7 +308,7 @@ int [0-9]+
@ Strings and characters in directives/rules.
@<Lexer states@>=
-@G
+@G(fs1)
%x SC_ESCAPED_STRING SC_ESCAPED_CHARACTER
@g
@@ -310,7 +318,7 @@ int [0-9]+
#include <stdbool.h>
@ @<Lexer options@>=
-@G
+@G(fs1)
%option bison-bridge
%option noyywrap nounput noinput reentrant
%option noyy_top_state