summaryrefslogtreecommitdiff
path: root/support/splint/examples/symbols/symbols.w
diff options
context:
space:
mode:
Diffstat (limited to 'support/splint/examples/symbols/symbols.w')
-rw-r--r--support/splint/examples/symbols/symbols.w46
1 files changed, 26 insertions, 20 deletions
diff --git a/support/splint/examples/symbols/symbols.w b/support/splint/examples/symbols/symbols.w
index dc58adc0bd..f680b1bffc 100644
--- a/support/splint/examples/symbols/symbols.w
+++ b/support/splint/examples/symbols/symbols.w
@@ -1,4 +1,4 @@
-% Copyright 2012-2020, Alexander Shibakov
+% Copyright 2012-2024, Alexander Shibakov
% This file is part of SPLinT
%
% SPLinT is free software: you can redistribute it and/or modify
@@ -13,7 +13,6 @@
%
% You should have received a copy of the GNU General Public License
% along with SPLinT. If not, see <http://www.gnu.org/licenses/>.
-\newwrite\gindex
% the namespace choices below are a bit random as this is a demo only
@@ -21,11 +20,6 @@
\def\optimization{5}
\input yy.sty
\modenormal
-\input noweb.sty
- \xreflocaltrue
- \readlxrefs
- \newwrite\xrefstream
- \immediate\openout\xrefstream=\jobname.xxr
\input dcols.sty
\input symmap.sty
\let\parsernamespace\flexnamespace
@@ -70,7 +64,8 @@
\input symfm.sty
\input slimbo.sty
-\setupfootnotes
+\topskip=9pt
+\initauxstream
@** Introduction.
The manual supplied with \splint\ presents an outline of the main
@@ -243,7 +238,7 @@ the value of \.{\\gaglue} set by a copy of one of the productions.
\insertraw{\let\stashnext\stashnextwithspace}%
line_breaking_and_symbols:
GEN\stashed{|stash!=0|}ERIC '(' expression',' \ ss another es')' \
- \insertraw{\let\stashnext\stashnextwithnothingnx}%
+ \insertraw{\let\stashnext\stashnextwithnothing}%
` inline_\stashed{look: $\rightarrow\,$}c \{ \stashed{\X{$\infty$}:See this example to deduce $\ldots$\X\6}\stashed{|b == a - c|} \}
` more_inline_c \{ \stashed{|func(int a, char b);|} \}
%
@@ -285,7 +280,7 @@ symbol_tricks:
\input symtricks.sty
\noindent The stash chunks, inserted by \.{\\stashed\{}{\it random input\/}\.{\}} are invisible to the parser.
As an example, the stash producing the action in the first rule below (|stash!=0|) was
-inserted in the middle of the first term (\prodstyle{GENERIC}). The space (\.{ }) is a special case.
+inserted in the middle of the first term (\prodstyle{GENERIC}). The space (\.{\ }) is a special case.
\medskip
\beginprod
line_breaking_and_symbols:
@@ -305,7 +300,7 @@ Here is the same set of productions with stash producing a space in the middle o
\insertraw{\let\stashnext\stashnextwithspace}%
line_breaking_and_symbols:
GEN\stashed{|stash!=0|}ERIC '(' expression',' \ ss another es')' \
- \insertraw{\let\stashnext\stashnextwithnothingnx}%
+ \insertraw{\let\stashnext\stashnextwithnothing}%
` inline_\stashed{look: $\rightarrow\,$}c \{ \stashed{\X{$\infty$}:See this example to deduce $\ldots$\X\6}\stashed{|b == a - c|} \}
` more_inline_c \{ \stashed{|func(int a, char b);|} \}
%
@@ -316,7 +311,7 @@ line_breaking_and_symbols:
{\it \flexrestyle{\^\\\\[\\"\\'?\\\\]}}. Portions of \flex\ files may be typeset with the help of
\.{\\beginflex}$\ldots$\.{\\endflex} macros. Just as in the case of \bison\ productions, care must be taken to
escape some symbols that have special meaning to \TeX. The ones that {\it must be\/} escaped when used inside
-regular expressions are `\.{\{}', `\.{\}}', `\.{\\}', and~`\.{\%}'. Others, such as `\.{\^}', `\.{\_}', `\.{\$}', `\.{\#}',
+regular expressions are `\.{\{}', `\.{\}}', `\.{\\}', `\.{\ }' (see more below), and~`\.{\%}'. Others, such as `\.{\^}', `\.{\_}', `\.{\$}', `\.{\#}',
and~`\.{\&}' do not require any special treatment (although they continue to perform their special functions
inside \.{\\stashed} blocks). As a note of caution, `$\ldots$\.{\\\\]}' results
in `$\ldots$\flexrestyle{\\]}' and not
@@ -331,6 +326,9 @@ this character is nearly inaccessible in the \TeX\ mode of \CTANGLE, which resul
`\.{\\`}' instead. If the example is not part of a \CWEB\ input (for example it is included from its own \TeX\ file similar to
\.{symtricks.sty} above) then
one can use the `\.{\yl}' character as intended. However, even inside a `pure \TeX\ file' to get `\.{`}', one must still type `\.{\\`}'.
+Finally, it is worth remembering that a space (\.{\ }) would terminate a regular expression (and produce a syntax error) inside
+\.{\\flexrestyle}. This is part of the regular \flex\ syntax and not a \splint\ specific limitation. To make a space character
+a part of a regular expression it must be escaped.
Many of the points made above may become more transparent after examining the source of the example following this sentence.
\medskip
\cdebugtrue
@@ -371,6 +369,20 @@ LEXOPT [porkacne]
M4QSTART "[["
M4QEND "]]"
+@ Lexer specific options can be typeset as well. Any portion specific to \Cee\ can be relegated
+to \CWEB\ as can be seen below. Adjusting the typesetting of various \Cee\ terms works as expected
+(see the source for this example).
+@s scan_state int
+@<Lexer options@>=
+@G(fs1)
+%option bison-bridge
+%option noyywrap noinput reentrant nounput
+%option header-file="lexer.h"
+%option prefix="main_c"
+%option extra-type="@>struct scan_state *@="
+%option stack
+@g
+
@ The first three lines of the previous section successfully parse as section~2 input.
\parseverbosetrue
@<As section 2@>=
@@ -425,7 +437,8 @@ NOT_WS [^[:blank:]\r\n]
@q of index entries depends on the placement of this inclusion @>
@i alphas.hx
-@** Index. Various identifiers in \bison\ productions and \flex\ sections are put in the index, along with
+@** Index. \global\let\secrangedisplay\empty% do not show the current section range anymore
+Various identifiers in \bison\ productions and \flex\ sections are put in the index, along with
the identifiers from the \Cee\ portions of the \CWEB\ input. The
mechanism used to typeset these identifiers is different from the one
employed by the \CWEB's indexing macros. While the \.{\\I} macros in
@@ -434,16 +447,9 @@ only outputs the context in which the identifier was encountered. By
redefining the macros that interpret this context to typeset the
index, several useful effects can be achieved\footnote{One pretty common use is to redefine
macros that take parameters to take none.}.
-\unsetfootnotes
-\input gindex.sty
\def\otherlangindexseparator{% the index is too short
\toksg{}%
\vskip.5\baselineskip
\centerline{B{\sc ISON}, F{\sc LEX, AND} \TeX\ {\sc INDICES}}%
\vskip.5\baselineskip
}
-\closeout\gindex
-\termindexfalse % do not attach indexing entries to the terms in the index, or the section list
-\let\inx\inxmod
-\let\fin\finmod
-\def\topofcontents{\null\vskip-3\baselineskip\centerline{C{\sc ONTENTS} (\sc\uppercase\expandafter{\title})}\medskip}