summaryrefslogtreecommitdiff
path: root/support/splint/examples
diff options
context:
space:
mode:
Diffstat (limited to 'support/splint/examples')
-rw-r--r--support/splint/examples/count/count.sty16
-rw-r--r--support/splint/examples/expression/Makefile30
-rw-r--r--support/splint/examples/expression/etoks.sty16
-rw-r--r--support/splint/examples/expression/expression.sty36
-rw-r--r--support/splint/examples/expression/expression.w34
-rw-r--r--support/splint/examples/ld/Makefile72
-rw-r--r--support/splint/examples/ld/ldexample.hw77
-rw-r--r--support/splint/examples/ld/ldgram.w202
-rw-r--r--support/splint/examples/ld/ldgramo.w4
-rw-r--r--support/splint/examples/ld/ldint.sty27
-rw-r--r--support/splint/examples/ld/ldlex.w73
-rw-r--r--support/splint/examples/ld/ldlexo.w40
-rw-r--r--support/splint/examples/ld/ldman.w345
-rw-r--r--support/splint/examples/ld/ldnp.w71
-rw-r--r--support/splint/examples/ld/ldnump.w4
-rw-r--r--support/splint/examples/ld/ldtexlex.sty75
-rw-r--r--support/splint/examples/ld/ldunion.sty355
-rw-r--r--support/splint/examples/ld/lstokenset.sty17
-rw-r--r--support/splint/examples/ld/ltokenset.sty113
-rw-r--r--support/splint/examples/symbols/Makefile40
-rw-r--r--support/splint/examples/symbols/slimbo.sty16
-rw-r--r--support/splint/examples/symbols/symbols.w292
-rw-r--r--support/splint/examples/symbols/symfm.sty64
-rw-r--r--support/splint/examples/symbols/symmap.sty71
-rw-r--r--support/splint/examples/symbols/symtoks.sty16
-rw-r--r--support/splint/examples/symbols/symtricks.sty23
-rw-r--r--support/splint/examples/types/Makefile30
-rw-r--r--support/splint/examples/types/basic.sty4
-rw-r--r--support/splint/examples/types/test.sty7
-rw-r--r--support/splint/examples/types/tree.sty2
-rw-r--r--support/splint/examples/xxpression/Makefile53
-rw-r--r--support/splint/examples/xxpression/xtoks.sty17
-rw-r--r--support/splint/examples/xxpression/xxpression.sty23
-rw-r--r--support/splint/examples/xxpression/xxpression.w52
-rw-r--r--support/splint/examples/xxpression/xymmap.sty10
35 files changed, 1742 insertions, 585 deletions
diff --git a/support/splint/examples/count/count.sty b/support/splint/examples/count/count.sty
index bb8998e64f..d9fed05f94 100644
--- a/support/splint/examples/count/count.sty
+++ b/support/splint/examples/count/count.sty
@@ -1,3 +1,19 @@
+% Copyright 2012-2020, Alexander Shibakov
+% This file is part of SPLinT
+%
+% SPLinT is free software: you can redistribute it and/or modify
+% it under the terms of the GNU General Public License as published by
+% the Free Software Foundation, either version 3 of the License, or
+% (at your option) any later version.
+%
+% SPLinT is distributed in the hope that it will be useful,
+% but WITHOUT ANY WARRANTY; without even the implied warranty of
+% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+% GNU General Public License for more details.
+%
+% You should have received a copy of the GNU General Public License
+% along with SPLinT. If not, see <http://www.gnu.org/licenses/>.
+
% the sequences in this file have the eventual goal of implementing macros that count and compare token sequences
% (as either parameters or contents of token registers) in expandable manner.
% currently, a new sequence is prepared first, consisting of `markers'
diff --git a/support/splint/examples/expression/Makefile b/support/splint/examples/expression/Makefile
index 0e2f33c2ba..6f306939b6 100644
--- a/support/splint/examples/expression/Makefile
+++ b/support/splint/examples/expression/Makefile
@@ -1,11 +1,25 @@
+# Copyright 2012-2020, Alexander Shibakov
+# This file is part of SPLinT
+#
+# SPLinT is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# SPLinT is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with SPLinT. If not, see <http://www.gnu.org/licenses/>.
+
# this Makefile uses a flat directory structure for demonstration
# purposes; the main directory (../..) contains a slightly more
# modular organization.
-SPLINT_ROOT = $(shell pwd)/../..
-
-include ${SPLINT_ROOT}/makefile.inc
-include ${SPLINT_ROOT}/makefile.loc
+include ../../makefile.inc
+include ${SPLINT_ROOT}makefile.loc
# rules specific to this example
@@ -18,13 +32,13 @@ step1: expp.y expl.l
step2: ptabout ltabout
step3: ltab.tex ptab.tex
-ptabout: ${SPLINT_ROOT}/cweb/mkeparser.c ${PARSER}.c
- ${CC} -DPARSER_FILE=\"../examples/expression/$(lastword $^)\" -DYYPARSE_PARAMETERS= -o $@ $<
+ptabout: ${SPLINT_ROOT}cweb/mkeparser.c ${PARSER}.c
+ ${CC} ${BISON_STATE} -DPARSER_FILE=\"../examples/expression/$(lastword $^)\" -DYYPARSE_PARAMETERS= -o $@ $<
ptab.tex: ptabout
$< --optimize-actions $@
-ltabout: ${SPLINT_ROOT}/cweb/mkscanner.c ${LEXER}.c
+ltabout: ${SPLINT_ROOT}cweb/mkscanner.c ${LEXER}.c
${CC} -DLEXER_FILE=\"../examples/expression/$(lastword $^)\" -o $@ $<
ltab.tex: ltabout
@@ -40,7 +54,7 @@ test.tex ${PARSER}.yy ${LEXER}.ll: expression.x
expression.tex: expression.x
@${CWEAVE} $<
-expression.pdf: expression.tex ${SPLINT_XPTABLES} ${SPLINT_XLTABLES} ${SPLINT_ROOT}/cweb/bo.tok etoks.sty
+expression.pdf: expression.tex ${SPLINT_XPTABLES} ${SPLINT_XLTABLES} ${SPLINT_ROOT}cweb/bo.tok ${SPLINT_ROOT}cweb/fo.tok etoks.sty
@${PDFTEX} $<
test: test.tex ptab.tex ltab.tex
diff --git a/support/splint/examples/expression/etoks.sty b/support/splint/examples/expression/etoks.sty
index 7326245338..706ad35818 100644
--- a/support/splint/examples/expression/etoks.sty
+++ b/support/splint/examples/expression/etoks.sty
@@ -1,3 +1,19 @@
+% Copyright 2012-2020, Alexander Shibakov
+% This file is part of SPLinT
+%
+% SPLinT is free software: you can redistribute it and/or modify
+% it under the terms of the GNU General Public License as published by
+% the Free Software Foundation, either version 3 of the License, or
+% (at your option) any later version.
+%
+% SPLinT is distributed in the hope that it will be useful,
+% but WITHOUT ANY WARRANTY; without even the implied warranty of
+% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+% GNU General Public License for more details.
+%
+% You should have received a copy of the GNU General Public License
+% along with SPLinT. If not, see <http://www.gnu.org/licenses/>.
+
\prettywordpair{IDENTIFIER}{{$\langle$\rm identifier$\rangle$}}
\prettywordpair{INTEGER}{{\bf int}}
\prettywordpair{BOGUS}{{\tt Oh, @\%\$\&*!}}
diff --git a/support/splint/examples/expression/expression.sty b/support/splint/examples/expression/expression.sty
index 9f9195aafb..ac0d8ba7e5 100644
--- a/support/splint/examples/expression/expression.sty
+++ b/support/splint/examples/expression/expression.sty
@@ -1,25 +1,47 @@
-\def\optimization{5}
+% Copyright 2012-2020, Alexander Shibakov
+% This file is part of SPLinT
+%
+% SPLinT is free software: you can redistribute it and/or modify
+% it under the terms of the GNU General Public License as published by
+% the Free Software Foundation, either version 3 of the License, or
+% (at your option) any later version.
+%
+% SPLinT is distributed in the hope that it will be useful,
+% but WITHOUT ANY WARRANTY; without even the implied warranty of
+% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+% GNU General Public License for more details.
+%
+% You should have received a copy of the GNU General Public License
+% along with SPLinT. If not, see <http://www.gnu.org/licenses/>.
+% this example uses the unoptimized version of the stack for testing purposes;
+% it does not affect the performance much; if the optimized stack is desired,
+% the optimization related code below can be uncommented
+
+%\def\optimization{5}
+
+\input trt1.sty % \TeX\ `runtime': temporary register definitions
\input yycommon.sty % general routines for stack and array access
\input yymisc.sty % helper macros (stack manipulation, table processing, value stack pointers)
+ % parser initialization, optimization
\input yyinput.sty % input functions
\input yyparse.sty % parser machinery
\input flex.sty % lexer functions
-\input yyfaststack.sty % sped up stack access functions
-\input yyboth.sty % parser initializatio, optimization
+%\input yyfaststack.sty % sped up stack access functions
\let\yylexreturn\yylexreturnregular
\let\setflexstates\relax
\let\parsernamespace\empty
\genericparser
- name: main,
+ name: emain,
ptables: ptab.tex,
ltables: ltab.tex,
tokens: {},
asetup: {},
dsetup: {},
rsetup: {},
- optimization: \optimizeall;%
-
-\tomainparser
+ optimization: %\optimizeall
+ ;
+
+\toemainparser
diff --git a/support/splint/examples/expression/expression.w b/support/splint/examples/expression/expression.w
index c775741184..9e96ea44d0 100644
--- a/support/splint/examples/expression/expression.w
+++ b/support/splint/examples/expression/expression.w
@@ -1,4 +1,4 @@
-@q Copyright 2012-2014, Alexander Shibakov@>
+@q Copyright 2012-2020, Alexander Shibakov@>
@q This file is part of SPLinT@>
@q SPLinT is free software: you can redistribute it and/or modify@>
@@ -16,8 +16,9 @@
\input limbo.sty
\def\optimization{5}
\input yy.sty
+\modenormal
-@** Parser file. This an example parser for expressions. It takes
+@** Parser file. This is an example parser for expressions. It takes
advantage of some of the features of \splint\ generated parsers,
although anything that takes more than a straightforward setup is
omitted.
@@ -25,11 +26,11 @@ omitted.
The top-level structure of the input file presents no surprises and is
presented below.
\let\currentparsernamespace\parsernamespace
- \let\parsernamespace\smallnamespace
- \let\hostparsernamespace\smallnamespace
+ \def\parsernamespace{[edisplay]}
+ \def\hostparsernamespace{[edisplay]}
\input etoks.sty
\let\parsernamespace\currentparsernamespace
-\def\texnspace{[other]}
+\def\texnspace{[other]}% no pretty printing of \TeX
@s TeX_ TeX
@(expp.yy@>=
@@ -160,7 +161,7 @@ appropriate values.
%%
@ @<Lexer definitions@>=
-@G
+@G(fs1)
letter [_abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ]
id {letter}({letter}|[-0-9])*
int [0-9]+
@@ -188,30 +189,13 @@ int [0-9]+
@<Scan identifiers@>@;
@ White space skipping.
-\traceparserstatestrue
-\tracestackstrue
-\tracerulestrue
-\traceactionstrue
-\tracelookaheadtrue
-\traceparseresultstrue
-\tracebadcharstrue
-\yyflexdebugtrue
-%
-\traceparserstatesfalse
-\tracestacksfalse
-\tracerulesfalse
-\traceactionsfalse
-\tracelookaheadfalse
-\traceparseresultsfalse
-\tracebadcharsfalse
-\yyflexdebugfalse
@<Scan white space@>=
-@G
+@G(fs2)
[ \f\n\t\v] {@> @[TeX_( "/yylexnext" );@]@=}
@g
@ @<Scan identifiers@>=
-@G
+@G(fs2)
{id} {@> @[TeX_( "/yylexreturnval{IDENTIFIER}" );@]@=}
{int} {@> @[TeX_( "/yylexreturnval{INTEGER}" );@]@=}
[+*()] {@> @[TeX_( "/yylexreturnchar" );@]@=}
diff --git a/support/splint/examples/ld/Makefile b/support/splint/examples/ld/Makefile
index a23f191b9c..24bf4a7a9f 100644
--- a/support/splint/examples/ld/Makefile
+++ b/support/splint/examples/ld/Makefile
@@ -1,30 +1,44 @@
+# Copyright 2012-2020, Alexander Shibakov
+# This file is part of SPLinT
+#
+# SPLinT is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# SPLinT is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with SPLinT. If not, see <http://www.gnu.org/licenses/>.
+
# this Makefile uses a flat directory structure for demonstration
# purposes; the main directory (../..) contains a slightly more
# modular organization.
-SPLINT_ROOT = $(shell pwd)/../..
-
PARSER = ldp
LEXER = ldl
MANUAL = ldman
-LD_CORE_PREREQS = ${SPLINT_XTEXSTYLES} ${SPLINT_XPTABLES} ${SPLINT_XLTABLES} ${SPLINT_ROOT}/cweb/bo.tok
-LD_DOC_PREREQS = %.tex %.sty ${PARSER}.tok ldunion.sty ldint.sty ldfrontmatter.sty ${LD_CORE_PREREQS} ptab.tex ltab.tex ld_small_tab.tex
-LD_DOC_PREREQS += ld_small_dfa.tex ltokenset.sty lstokenset.sty
+LD_CORE_PREREQS = ${SPLINT_XTEXSTYLES} ${SPLINT_XPTABLES} ${SPLINT_XLTABLES} ${SPLINT_ROOT}cweb/bo.tok ${SPLINT_ROOT}cweb/fo.tok
+LD_DOC_PREREQS = %.tex %.sty ${PARSER}.tok ldunion.sty ldtexlex.sty ldint.sty ldfrontmatter.sty ${LD_CORE_PREREQS}
+LD_DOC_PREREQS += ptab.tex ltab.tex ld_small_tab.tex ld_small_dfa.tex ltokenset.sty lstokenset.sty
LD_DOC_PREREQS_XREF = ${LD_DOC_PREREQS} %.scn %.idx
-include ${SPLINT_ROOT}/makefile.inc
-include ${SPLINT_ROOT}/makefile.loc
+include ../../makefile.inc
+include ${SPLINT_ROOT}makefile.loc
# rules specific to this example
-ptabout: ${SPLINT_ROOT}/cweb/mkeparser.c ${PARSER}.c
- ${CC} -DPARSER_FILE=\"../examples/ld/$(lastword $^)\" -DYYPARSE_PARAMETERS= -o $@ $<
+ptabout: ${SPLINT_ROOT}cweb/mkeparser.c ${PARSER}.c
+ ${CC} ${BISON_STATE} -DPARSER_FILE=\"../examples/ld/$(lastword $^)\" -DYYPARSE_PARAMETERS= -o $@ $<
ptab.tex: ptabout
$< --optimize-actions --optimize-tables $@
-ltabout: ${SPLINT_ROOT}/cweb/mkscanner.c ldl_states.h ${LEXER}.c
+ltabout: ${SPLINT_ROOT}cweb/mkscanner.c ldl_states.h ${LEXER}.c
${CC} -DLEXER_FILE=\"../examples/ld/$(lastword $^)\" -o $@ $<
ltab.tex: ltabout
@@ -44,10 +58,10 @@ ${MANUAL}.stx: ${MANUAL}.x ldgram.x ldlex.x ldlexo.x ldgramo.x ldnp.x
# term name parser for ld grammar
-ldsmallp_out: ${SPLINT_ROOT}/cweb/mkeparser.c ld_small_parser.c
+ldsmallp_out: ${SPLINT_ROOT}cweb/mkeparser.c ld_small_parser.c
${CC} ${BISON_STATE} -DPARSER_FILE=\"../examples/ld/$(lastword $^)\" -DYYPARSE_PARAMETERS= -o $@ $<
-ldsmalll_out: ${SPLINT_ROOT}/cweb/mkscanner.c ld_small_lexer.c
+ldsmalll_out: ${SPLINT_ROOT}cweb/mkscanner.c ld_small_lexer.c
${CC} -DLEXER_FILE=\"../examples/ld/$(lastword $^)\" -o $@ $<
ld_small_tab.tex: ldsmallp_out
@@ -62,10 +76,10 @@ ld_small_lexer.ll: ldnp.x
# numeric parser for ld grammar
-ldnump_out: ${SPLINT_ROOT}/cweb/mkeparser.c ld_num_parser.c
+ldnump_out: ${SPLINT_ROOT}cweb/mkeparser.c ld_num_parser.c
${CC} ${BISON_STATE} -DPARSER_FILE=\"../examples/ld/$(lastword $^)\" -DYYPARSE_PARAMETERS= -o $@ $<
-ldnuml_out: ${SPLINT_ROOT}/cweb/mkscanner.c ld_num_lexer.c
+ldnuml_out: ${SPLINT_ROOT}cweb/mkscanner.c ld_num_lexer.c
${CC} -DLEXER_FILE=\"../examples/ld/$(lastword $^)\" -o $@ $<
ld_num_tab.tex: ldnump_out
@@ -78,8 +92,17 @@ ld_num_parser.yy \
ld_num_lexer.ll: ldnump.x
@${CTANGLE} $<
-${MANUAL}.tex: ${MANUAL}.x ldgram.x ldlex.x ldlexo.x ldgramo.x ldnp.x
- ${CWEAVE} $<
+ldexample_%.hx: ldexample.hw
+ echo $(patsubst ldexample_%.hx, "@G(%)", $@) >> $(patsubst %.hx, %.hy, $@)
+ cat $< >> $(patsubst %.hx, %.hy, $@)
+ echo "@g" >> $(patsubst %.hx, %.hy, $@)
+ ${BRACK} $(patsubst %.hx, %.hy, $@) $@
+
+alphas.hx:
+ ${MISCCW} --alpha-list --alpha-length=1 $@
+
+${MANUAL}.tex: ${MANUAL}.x ldgram.x ldlex.x ldlexo.x ldgramo.x ldnp.x ldexample_l.hx ldexample_b.hx alphas.hx
+ -${CWEAVE} $<
${MANUAL}.sty: ${MANUAL}.stx
${UNLINE} $< $@
@@ -88,12 +111,16 @@ ${MANUAL}.gdx: %.gdx: ${LD_DOC_PREREQS_XREF} ${PARSER}.tok
@echo "Making the bison and TeX indices ..."
${TEX} $*.tex
-${MANUAL}.pdf: %.pdf: ${LD_DOC_PREREQS_XREF} %.gdy
- ${PDFTEX} $< && touch $*.gdy && touch $*.pdf
+%.gdy: %.gdx
+
+${MANUAL}.gdy: %.gdy: %.gdx
+ ${BINDX} --fine $^ $@
-#${PARSER}.tok \
-#ldl_states.h: ${MANUAL}.tex ${MANUAL}.sty ${LD_CORE_PREREQS}
-# ${TEX} ${MODEBOOTSTRAP} \\input $<
+${MANUAL}.xxr: %.xxr: %.tex
+ ${PDFTEX} $*.tex
+
+${MANUAL}.pdf: %.pdf: ${LD_DOC_PREREQS_XREF} %.gdy %.xxr
+ ${PDFTEX} $< && touch $*.gdy && touch $*.pdf
${PARSER}.tok: ldgram.tex ${MANUAL}.sty ${LD_CORE_PREREQS}
${TEX} ${MODEBOOTSTRAP} \\input $<
@@ -103,7 +130,7 @@ ldl_states.h: ldlex.tex ${MANUAL}.sty ${LD_CORE_PREREQS}
ldgram.tex ldlex.tex: \
%.tex: %.x
- ${CWEAVE} -x $<
+ -${CWEAVE} -x $<
docs: ${MANUAL}.pdf
@@ -115,4 +142,3 @@ clean: clean_core
distclean: clean
cd ${SPLINT_ROOT} && ${MAKE} clean
-
diff --git a/support/splint/examples/ld/ldexample.hw b/support/splint/examples/ld/ldexample.hw
new file mode 100644
index 0000000000..a5cab97d2a
--- /dev/null
+++ b/support/splint/examples/ld/ldexample.hw
@@ -0,0 +1,77 @@
+INCLUDE file.ld
+
+MEMORY
+{
+ @> @<Some random portion of \ld\ code@> @=
+ RAM (xrw) : ORIGIN = 0x20000000, LENGTH = 20K
+ FLASH (rx) : ORIGIN = 0x8000000, LENGTH = 128K
+ ASH (rx) : ORIGIN = 8001000, LENGTH = 128K
+ @> @<Some random portion of \ld\ code@> @=
+ CLASH (rx) : ORIGIN = 700000, LENGTH = 128K
+ ASH (rx) : ORIGIN = $8000000, LENGTH = 128K
+ CLASH (rx) : ORIGIN = 700000B, LENGTH = 128K
+ INCLUDE file.mem
+ @> @<Some random portion of \ld\ code@> @=
+
+}
+
+_estack = 0x20005000;
+_bstack = a > 0 ? NEXT(11) : 0x19;
+ @> @<Some random portion of \ld\ code@> @=
+PROVIDE( var1 = . );
+PROVIDE_HIDDEN( var2 = . );
+ @> @<Some random portion of \ld\ code@> @=
+HIDDEN( var3 = . );
+ENTRY(_entry);
+
+SECTIONS
+{
+ @> @<Some random portion of \ld\ code@> @=
+ .isr_vector ALIGN(8) (NOLOAD): AT(.) ALIGN(.) ALIGN_WITH_INPUT SUBALIGN(8) SPECIAL
+ {
+ . = ALIGN(4);
+ KEEP(*(.isr_vector))
+ . = ALIGN(4);
+ } > FLASH AT > RAM : FLASH : RAM : OTHER = . + 8
+ @> @<Some random portion of \ld\ code@> @=
+ .text :
+ {
+ /* skip this comment */;
+ . = ALIGN(4);
+ *(.text)
+ *(.text.*)
+ *(.rodata)
+ *(.rodata*)
+ *(.glue_7)
+ *(.glue_7t)
+ . = ALIGN(4);
+ _etext = . + 8;
+ _sidata = _etext;
+ PROVIDE( var1 = . );
+ PROVIDE_HIDDEN( var2 = . );
+ HIDDEN( var3 = . );
+ } >FLASH AT > RAM
+
+ @> @<Some random portion of \ld\ code@> @=
+ .data : AT ( _sidata )
+ {
+ . = ALIGN(4);
+ _sdata = . ;
+ *(.data)
+ *(.data.*)
+ . = ALIGN(4);
+ _edata = . ;
+ } >RAM
+
+ .bss :
+ {
+ . = ALIGN(4);
+ _sbss = .;
+ *(.bss)
+ *(COMMON)
+ . = ALIGN(4);
+ _ebss = . ;
+ } >RAM
+ @> @<Some random portion of \ld\ code@> @=
+
+}
diff --git a/support/splint/examples/ld/ldgram.w b/support/splint/examples/ld/ldgram.w
index 4fb9a9a876..5e7ff73a03 100644
--- a/support/splint/examples/ld/ldgram.w
+++ b/support/splint/examples/ld/ldgram.w
@@ -1,4 +1,4 @@
-@q Copyright 2012-2015 Alexander Shibakov@>
+@q Copyright 2012-2020 Alexander Shibakov@>
@q Copyright 2002-2014 Free Software Foundation, Inc.@>
@q This file is part of SPLinT@>
@@ -16,10 +16,10 @@
@q along with SPLinT. If not, see <http://www.gnu.org/licenses/>.@>
@** The parser.
-\ifx\parsernamespace\UNDEFINED
+\ifbootstrapmode
\def\tokendeffile{ldp.tok}%
\input ldman.sty
- \input limbo.sty
+ \modebootstrap
\input dcols.sty
\setupfootnotes
\def\MRI{}
@@ -334,20 +334,23 @@ script commands.
@G
script_file:
{@>@[TeX_( "/ldlex@@both" );@]@=}
- ifile_list {@>@[TeX_( "/getsecond{/yy(2)}/to/ldcmds/ldlex@@popstate" );@]@=}
+ ifile_list {@>@[TeX_( "/getfifth{/yy(2)}/to/ldcmds/ldlex@@popstate" );@]@=}
;
ifile_list:
ifile_list ifile_p1 {@>@<Add the next command@>@=}
- | {@>@[TeX_( "/yy0{{}{}}" );@]@=}
+ | {@>@[TeX_( "/yy0{/nx/ldinsertcweb{}{}{}{}}" );@]@=}
;
@g
@ @<Add the next command@>=
- @[TeX_( "/getfirst{/yy(1)}/to/toksa/getsecond{/yy(1)}/to/toksb" );@]@;
- @[TeX_( "/getfirst{/yy(2)}/to/toksc/getsecond{/yy(2)}/to/toksd" );@]@;
- @[TeXb( "/yytoksempty{/toksb}{/yy0{/the/yy(2)}}" );@]@;
- @[TeXao( "{/yy0{{/the/toksc}{/the/toksb/noexpand/ldcommandseparator{/the/toksa}{/the/toksc}/the/toksd}}}" );@]@;
+ @[TeX_( "/getsecond{/yy(1)}/to/toksa/getthird{/yy(1)}/to/toksb" );@]@;
+ @[TeX_( "/getfourth{/yy(1)}/to/toksc/getfifth{/yy(1)}/to/toksd" );@]@;
+ @[TeX_( "/getsecond{/yy(2)}/to/tokse/getthird{/yy(2)}/to/toksf" );@]@;
+ @[TeX_( "/getfourth{/yy(2)}/to/toksg/getfifth{/yy(2)}/to/toksh" );@]@;
+ @[TeXb( "/yytoksempty{/toksh}{/yy0{/the/yy(1)}}{/yytoksempty{/toksd}{/yy0{/the/yy(2)}}" );@]@;
+ @[TeXf( " {/yy0{/nx/ldinsertcweb{/the/toksa}{/the/toksb}{/the/toksg}{/the/toksd" );@]@;
+ @[TeXfo( " /nx/ldcommandseparator{/the/tokse}{/the/toksf}{/the/toksc}{/the/toksg}/the/toksh}}}}" );@]@;
@*1 Script internals.
There are a number of different commands. For typesetting purposes,
@@ -377,16 +380,16 @@ the rule that adds the fragment to the script file.
@<\GNU\ \ld\ script rules@>=
@G
ifile_p1:
- memory {@>@[TeX_( "/yy0{{mem}{/the/yy(1)}}" );@]@=}
- | sections {@>@[TeX_( "/yy0{{sect}{/the/yy(1)}}" );@]@=}
+ memory {@>@<Carry on@>@=}
+ | sections {@>@<Carry on@>@=}
| phdrs
| startup
| high_level_library
| low_level_library
| floating_point_support
- | statement_anywhere {@>@[TeX_( "/yy0{{stmt}{/noexpand/ldstatement{/the/yy(1)}}}" );@]@=}
+ | statement_anywhere {@>@<Carry on@>@=}
| version
- | ';' {@>@[TeX_( "/yy0{{none}{}}" );@]@=}
+ | ';' {@>@[TeX_( "/yy0{/nx/ldinsertcweb/the/yy(1){none}{}}" );@]@=}
| TARGET_K '(' NAME ')' {}
| SEARCH_DIR '(' filename ')' {}
| OUTPUT '(' filename ')' {}
@@ -401,7 +404,7 @@ ifile_p1:
'(' input_list ')' {}
| MAP '(' filename ')' {}
| INCLUDE filename {@>@<Peek at a file@>@=}
- ifile_list END {@>@<Add an \prodstyle{INCLUDE} statement@>@=}
+ ifile_list END {@>@<Close the file@>@=}
| NOCROSSREFS '('
nocrossref_list ')' {}
| EXTERN '(' extern_name_list ')'
@@ -427,30 +430,39 @@ input_list:
;
sections:
- SECTIONS '{' sec_or_group_p1 '}' {@>@[TeX_( "/yy0{/noexpand/ldsections{/the/yy(3)}}" );@]@=}
+ SECTIONS '{' sec_or_group_p1 '}' {@>@<Form the \prodstyle{SECTIONS} group@>@=}
;
sec_or_group_p1:
- sec_or_group_p1 section {@>@<Add the next section@>@=}
- | sec_or_group_p1 statement_anywhere {@>@<Add the next statement@>@=}
+ sec_or_group_p1 section {@>@<Add the next section chunk@>@=}
+ | sec_or_group_p1 statement_anywhere {@>@<Add the next section chunk@>@=}
| {@>@[TeX_( "/yy0{}" );@]@=}
;
statement_anywhere:
- ENTRY '(' NAME ')' {}
- | assignment end {@>@<Carry on@>@=}
+ ENTRY '(' NAME ')' {@>@<Form an \prodstyle{ENTRY} statement@>@=}
+ | assignment end {@>@<Form a statement@>@=}
| ASSERT_K {@>@[TeX_( "/ldlex@@expression" );@]@=}
'(' exp ',' NAME ')' {@>@[TeX_( "/ldlex@@popstate" );@]@=}
;
@g
-@ @<Add the next section@>=
- @[TeXb( "/yytoksempty{/yy(1)}{/yy0{/the/yy(2)}}" );@]@;
- @[TeXao( "{/yy0{/the/yy(1)/noexpand/ldsectionseparator/the/yy(2)}}" );@]@;
+@ @<Form the \prodstyle{SECTIONS} group@>=
+ @[TeX_( "/yy0{/nx/ldinsertcweb/the/yy(1){sect}{/nx/ldsections{/the/yy(3)/nx/ldsectionstash/the/yy(4)}}}" );@]
-@ @<Add the next statement@>=
- @[TeXb( "/yytoksempty{/yy(1)}{/yy0{/the/yy(2)}}" );@]@;
- @[TeXao( "{/yy0{/the/yy(1)/noexpand/ldsectionseparator/ldstatement{/the/yy(2)}}}" );@]@;
+@ @<Add the next section chunk@>=
+ @[TeX_( "/getsecond{/yy(2)}/to/tokse/getthird{/yy(2)}/to/toksf" );@]@;
+ @[TeX_( "/getfourth{/yy(2)}/to/toksg/getfifth{/yy(2)}/to/toksh" );@]@;
+ @[TeXb( "/yytoksempty{/yy(1)}{/yy0{/nx/ldsectionstash{/the/tokse}{/the/toksf}/the/toksh}}" );@]@;
+ @[TeXfo( " {/yy0{/the/yy(1)/nx/ldsectionseparator{/the/tokse}{/the/toksf}/the/toksh}}" );@]@;
+
+@ @<Form an \prodstyle{ENTRY} statement@>=
+ @[TeX_( "/yy0{/nx/ldinsertcweb/the/yy(1){stmt}{/nx/ldstatement{/nx/ldentry{/nx/ldregexp{/the/yy(3)}}}}}" );@]
+
+@ @<Form a statement@>=
+ @[TeXb( "/getsecond{/yy(1)}/to/toksa/getthird{/yy(1)}/to/toksb" ); @]@;
+ @[TeXf( "/getfourth{/yy(1)}/to/toksc/getfifth{/yy(1)}/to/toksd" );@]@;
+ @[TeXfo( "/yy0{/nx/ldinsertcweb{/the/toksa}{/the/toksb}{stmt}{/nx/ldstatement{/the/toksd}}}" );@]
@ This is the default action performed by the parser when the parser
writer does not supply one. For a minor gain in efficiency, this
@@ -463,28 +475,25 @@ definition can be made empty.
@[TeX_( "/ldfile@@open@@command@@file{/yy(2)}" );@]@;
@ @<Close the file@>=
- @[TeX_( "/yy0{/noexpand/ldinclude{/the/yy(2)}}/ldlex@@popstate" );@]@;
-
-@ @<Add an \prodstyle{INCLUDE} statement@>=
- @[TeX_( "/yy0{{inc}{/noexpand/ldinclude{/the/yy(2)}}}/ldlex@@popstate" );@]@;
+ @[TeX_( "/yy0{/nx/ldinsertcweb/the/yy(1){inc}{/nx/ldinclude{/the/yy(2)}}}/ldlex@@popstate" );@]@;
@ \tracebadcharstrue
-{\it The \prodstyle{'*'} and \prodstyle{'?'} cases are there because the lexer returns them as
+{\it \setrulecontext{wildcard_name}The \prodstyle{'*'} and \prodstyle{'?'} cases are there because the lexer returns them as
separate tokens rather than as \prodstyle{NAME}.}
\tracebadcharsfalse
@<Grammar rules@>=
@G
wildcard_name:
- NAME {@>@<Carry on@>@=}
- | '*' {@>@[TeX_( "/yy0{{*}{*}}" );@]@=}
- | '?' {@>@[TeX_( "/yy0{{?}{?}}" );@]@=}
+ NAME {@>@<Create a wildcard name@>@=}
+ | '*' {@>@[TeX_( "/yy0{/nx/ldinsertcweb/the/yy(1){wld}{/nx/ldregop{{*}{*}/the/yy(1)}}}" );@]@=}
+ | '?' {@>@[TeX_( "/yy0{/nx/ldinsertcweb/the/yy(1){wld}{/nx/ldregop{{?}{?}/the/yy(1)}}}" );@]@=}
;
@g
@ @<Grammar rules@>=
@G
wildcard_spec:
- wildcard_name {}
+ wildcard_name {@>@<Carry on@>@=}
| EXCLUDE_FILE '(' exclude_name_list ')' wildcard_name
{}
| SORT_BY_NAME '(' wildcard_name ')' {}
@@ -525,8 +534,8 @@ exclude_name_list:
;
file_NAME_list:
- file_NAME_list opt_comma wildcard_spec {@>@[TeX_( "/yy0{/the/yy(1)/noexpand/ldspace/noexpand/ldregexp{/the/yy(2)}}" );@]@=}
- | wildcard_spec {@>@[TeX_( "/yy0{/noexpand/ldregexp{/the/yy(1)}}" );@]@=}
+ file_NAME_list opt_comma wildcard_spec {@>@<Add a wildcard spec to a list of files@>@=}
+ | wildcard_spec {@>@<Start a file list with a wildcard spec@>@=}
;
input_section_spec_no_keep:
@@ -534,51 +543,83 @@ input_section_spec_no_keep:
| sect_flags NAME {}
| '[' file_NAME_list ']' {}
| sect_flags '[' file_NAME_list ']' {}
- | wildcard_spec '(' file_NAME_list ')' {@>@[TeX_( "/yy0{/noexpand/ldregexp{/the/yy(1)}(/the/yy(3))}" );@]@=}
+ | wildcard_spec '(' file_NAME_list ')' {@>@<Add a plain section spec@>@=}
| sect_flags wildcard_spec '(' file_NAME_list ')'
{}
;
@g
+@ @<Create a wildcard name@>=
+ @[TeXf( "/getthird{/yy(1)}/to/toksa/getfourth{/yy(1)}/to/toksb" );@]@;
+ @[TeX_( "/yy0{/nx/ldinsertcweb{/the/toksa}{/the/toksb}{wld}{/nx/ldregexp{/the/yy(1)}}}" );@]
+
+@ @<Add a wildcard spec to a list of files@>=
+ @[TeX_( "/getsecond{/yy(1)}/to/toksa/getthird{/yy(1)}/to/toksb" );@]@;
+ @[TeX_( "/getfourth{/yy(1)}/to/toksc/getfifth{/yy(1)}/to/toksd" );@]@;
+ @[TeX_( "/getsecond{/yy(2)}/to/tokse/getthird{/yy(2)}/to/toksf" );@]@;
+ @[TeX_( "/getfourth{/yy(2)}/to/toksg/getfifth{/yy(2)}/to/toksh" );@]@;
+ @[TeX_( "/yy0{/nx/ldinsertcweb{/the/toksa}{/the/toksb}{flst}{/the/toksd/nx/ldspace/the/toksh}}" );@]
+
+@ @<Start a file list with a wildcard spec@>=
+ @<Carry on@>@;
+
+@ @<Add a plain section spec@>=
+ @[TeX_( "/getsecond{/yy(1)}/to/toksa/getthird{/yy(1)}/to/toksb" );@]@;
+ @[TeX_( "/getfourth{/yy(1)}/to/toksc/getfifth{/yy(1)}/to/toksd" );@]@;
+ @[TeX_( "/getfifth{/yy(3)}/to/toksh" );@]@;
+ @[TeX_( "/yy0{/nx/ldinsertcweb{/the/toksa}{/the/toksb}{sspec}{/the/toksd(/the/toksh)}}" );@]
+
@ @<Grammar rules@>=
@G
input_section_spec:
input_section_spec_no_keep {@>@<Carry on@>@=}
| KEEP '(' {}
- input_section_spec_no_keep ')' {@>@[TeX_( "/yy0{/mathop{/hbox{/noexpand/ttl keep}(/the/yy(4))}}" );@]@=}
+ input_section_spec_no_keep ')' {@>@<Add a \prodstyle{KEEP} statement@>@=}
;
statement:
- assignment end
+ assignment end {@>@<Form a statement@>@=}
| CREATE_OBJECT_SYMBOLS {}
- | ';' {@>@[TeX_( "/yy0{}" );@]@=}
+ | ';' {@>@[TeX_( "/yy0{/nx/ldinsertcweb/the/yy(1){stmt}{}}" );@]@=}
| CONSTRUCTORS {}
| SORT_BY_NAME '(' CONSTRUCTORS ')' {}
- | input_section_spec
+ | input_section_spec {@>@<Form an input section spec@>@=}
| length '(' mustbe_exp ')' {}
| FILL '(' fill_exp ')' {}
| ASSERT_K {@>@[TeX_( "/ldlex@@expression" );@]@=}
'(' exp ',' NAME ')' end {@>@[TeX_( "/ldlex@@popstate" );@]@=}
| INCLUDE filename {@>@<Peek at a file@>@=}
- statement_list_opt END {@>@<Close the file@>@=}
+ statement_list_opt END {@>@<Close the file@>@>@=}
;
statement_list:
statement_list statement {@>@<Attach a statement to a statement list@>@=}
- | statement {@>@<Start a statement list with a statement@>@=}
+ | statement {@>@<Carry on@>@=}
;
statement_list_opt:
- {@>@[TeX_( "/yy0{}" );@]@=}
+ {@>@[TeX_( "/yy0{/nx/insertcweb{}{}{stmt}{}}" );@]@=}
| statement_list {@>@<Carry on@>@=}
;
@g
-@ @<Attach a statement to a statement list@>=
- @[TeX_( "/yy0{/the/yy(1)/yytoksempty{/yy(2)}{}{/yytoksempty{/yy(1)}{}{/noexpand/ldor}{/the/yy(2)}}}" );@]
+@ @<Form an input section spec@>=
+ @[TeXb( "/getsecond{/yy(1)}/to/toksa/getthird{/yy(1)}/to/toksb" ); @]@;
+ @[TeXf( "/getfourth{/yy(1)}/to/toksc/getfifth{/yy(1)}/to/toksd" );@]@;
+ @[TeXfo( "/yy0{/nx/ldinsertcweb{/the/toksa}{/the/toksb}{stmt}{/nx/ldsecspec{/the/toksd}}}" );@]
-@ @<Start a statement list with a statement@>=
- @[TeX_( "/yy0{/yytoksempty{/yy(1)}{}{{/the/yy(1)}}}" );@]
+@ @<Add a \prodstyle{KEEP} statement@>=
+ @[TeX_( "/getfifth{/yy(4)}/to/toksa" );@]@;
+ @[TeX_( "/yy0{/nx/ldinsertcweb/the/yy(1){stmt}{/nx/ldkeep{/the/toksa}}}" );@]
+
+@ @<Attach a statement to a statement list@>=
+ @[TeX_( "/getsecond{/yy(1)}/to/toksa/getthird{/yy(1)}/to/toksb" );@]@;
+ @[TeX_( "/getfourth{/yy(1)}/to/toksc/getfifth{/yy(1)}/to/toksd" );@]@;
+ @[TeX_( "/getsecond{/yy(2)}/to/tokse/getthird{/yy(2)}/to/toksf" );@]@;
+ @[TeX_( "/getfourth{/yy(2)}/to/toksg/getfifth{/yy(2)}/to/toksh" );@]@;
+ @[TeXb( "/yytoksempty{/toksd}{/yy0{/the/yy(2)}}" );@]@;
+ @[TeXf( " {/yy0{/nx/ldinsertcweb{/the/toksa}{/the/toksb}{/the/toksg}{/the/toksd" );@]@;
+ @[TeXfo( " /yytoksempty{/toksh}{}{/yytoksempty{/toksd}{}{/nx/ldor}/the/toksh}}}}" );@]@;
@ @<Grammar rules@>=
@G
@@ -627,22 +668,33 @@ opt_comma: ',' |
assignment:
NAME '=' mustbe_exp {@>@<Process simple assignment@>@=}
| NAME assign_op mustbe_exp {@>@<Process compound assignment@>@=}
- | HIDDEN '(' NAME '=' mustbe_exp ')' {}
- | PROVIDE '(' NAME '=' mustbe_exp ')' {}
- | PROVIDE_HIDDEN '(' NAME '=' mustbe_exp ')' {}
+ | HIDDEN '(' NAME '=' mustbe_exp ')' {@>@<Process a \prodstyle{HIDDEN} assignment@>@=}
+ | PROVIDE '(' NAME '=' mustbe_exp ')' {@>@<Process a \prodstyle{PROVIDE} assignment@>@=}
+ | PROVIDE_HIDDEN '(' NAME '=' mustbe_exp ')' {@>@<Process a \prodstyle{PROVIDE\_HIDDEN} assignment@>@=}
;
@g
@ @<Process simple assignment@>=
- @[TeX_( "/yy0{/noexpand/ldassignment{/noexpand/ldregexp{/the/yy(1)}}{/K}{/the/yy(3)}}" );@]
+ @[TeXb( "/getthird{/yy(1)}/to/toksa/getfourth{/yy(1)}/to/toksb" );@]@;
+ @[TeXfo( "/yy0{/nx/ldinsertcweb{/the/toksa}{/the/toksb}{asgnm}{/nx/ldassignment{/nx/ldregexp{/the/yy(1)}}{/K}{/the/yy(3)}}}" );@]
@ @<Process compound assignment@>=
- @[TeX_( "/yy0{/noexpand/ldassignment{/noexpand/ldregexp{/the/yy(1)}}{/the/yy(2)}{/the/yy(3)}}" );@]
+ @[TeXb( "/getthird{/yy(1)}/to/toksa/getfourth{/yy(1)}/to/toksb" );@]@;
+ @[TeXfo( "/yy0{/nx/ldinsertcweb{/the/toksa}{/the/toksb}{asgnm}{/nx/ldassignment{/nx/ldregexp{/the/yy(1)}}{/the/yy(2)}{/the/yy(3)}}}" );@]
+
+@ @<Process a \prodstyle{HIDDEN} assignment@>=
+ @[TeX_( "/yy0{/nx/ldinsertcweb/the/yy(1){hiddn}{/nx/ldhidden{/nx/ldregexp{/the/yy(3)}}{/the/yy(5)}}}" );@]
+
+@ @<Process a \prodstyle{PROVIDE} assignment@>=
+ @[TeX_( "/yy0{/nx/ldinsertcweb/the/yy(1){prvde}{/nx/ldprovide{/nx/ldregexp{/the/yy(3)}}{/the/yy(5)}}}" );@]
+
+@ @<Process a \prodstyle{PROVIDE\_HIDDEN} assignment@>=
+ @[TeX_( "/yy0{/nx/ldinsertcweb/the/yy(1){prhid}{/nx/ldprovidehid{/nx/ldregexp{/the/yy(3)}}{/the/yy(5)}}}" );@]
@ @<Grammar rules@>=
@G
memory:
- MEMORY '{' memory_spec_list_opt '}' {@>@[TeX_( "/yy0{/noexpand/ldmemory{/the/yy(3)}}" );@]@=}
+ MEMORY '{' memory_spec_list_opt '}' {@>@<Form the \prodstyle{MEMORY} group@>@=}
;
memory_spec_list_opt:
@@ -651,8 +703,8 @@ memory_spec_list_opt:
;
memory_spec_list:
- memory_spec_list opt_comma memory_spec {@>@[TeX_( "/yy0{/the/yy(1)/the/yy(3)}" );@]@=}
- | memory_spec {@>@[TeX_( "/yy0{/the/yy(1)}" );@]@=}
+ memory_spec_list opt_comma memory_spec {@>@<Add a memory spec@>@=}
+ | memory_spec {@>@<Start a list of memory specs@>@=}
;
@@ -661,12 +713,30 @@ memory_spec:
attributes_opt ':'
origin_spec
@t}\vb{\breakline}{@>
- opt_comma length_spec {@>@[TeX_( "/yy0{/noexpand/ldmemoryspec{/the/yy(1)}{/the/yy(3)}{/the/yy(5)}{/the/yy(7)}}" );@]@=}
+ opt_comma length_spec {@>@<Declare a named memory region@>@=}
| INCLUDE filename {@>@<Peek at a file@>@=}
memory_spec_list_opt END {@>@<Close the file@>@=}
;
@g
+@ @<Form the \prodstyle{MEMORY} group@>=
+ @[TeX_( "/yy0{/nx/ldinsertcweb/the/yy(1){mem}{/nx/ldmemory{/the/yy(3)/nx/ldmemspecstash/the/yy(4)}}}" );@]
+
+@ @<Start a list of memory specs@>=
+ @[TeXb( "/getsecond{/yy(1)}/to/toksa/getthird{/yy(1)}/to/toksb" ); @]@;
+ @[TeXf( "/getfifth{/yy(1)}/to/toksc" );@]@;
+ @[TeXfo( "/yy0{/nx/ldmemspecstash{/the/toksa}{/the/toksb}/the/toksc}" );@]@;
+
+@ @<Add a memory spec@>=
+ @[TeXb( "/getsecond{/yy(3)}/to/toksa/getthird{/yy(3)}/to/toksb" ); @]@;
+ @[TeXf( "/getfifth{/yy(3)}/to/toksc" );@]@;
+ @[TeXfo( "/yy0{/the/yy(1)/nx/ldmemspecseparator{/the/toksa}{/the/toksb}/the/toksc}" );@]@;
+
+@ @<Declare a named memory region@>=
+ @[TeXb( "/getthird{/yy(1)}/to/toksa/getfourth{/yy(1)}/to/toksb" );@]@;
+ @[TeXf( "/yy0{/nx/ldinsertcweb{/the/toksa}{/the/toksb}{mreg}" );@]@;
+ @[TeXfo( " {/nx/ldmemoryspec{/the/yy(1)}{/the/yy(3)}{/the/yy(5)}{/the/yy(7)}}}" );@]
+
@ @<Grammar rules@>=
@G
origin_spec:
@@ -735,7 +805,7 @@ mustbe_exp:
;
@g
-@*1 {\ifheader\ninepoint\fi\prodstyle{SECTIONS}} and expressions.
+@*1 {\ifheader\ninepoint\fi\prodstylens{SECTIONS}{\ldnamespace}} and expressions.
The linker supports an extensive range of expressions. The precedence
mechanism provided by \bison\ is used to present the composition of
expressions out of simpler chunks and basic building blocks tied
@@ -790,7 +860,7 @@ exp :
| DATA_SEGMENT_END '(' exp ')' {}
| SEGMENT_START '(' NAME ',' exp ')' {}
| BLOCK '(' exp ')' {}
- | NAME {@>@[TeX_( "/yy0{/noexpand/ldregexp{/the/yy(1)}}" );@]@=}
+ | NAME {@>@[TeX_( "/yy0{/nx/ldregexp{/the/yy(1)}}" );@]@=}
| MAX_K '(' exp ',' exp ')' {}
| MIN_K '(' exp ',' exp ')' {}
| ASSERT_K '(' exp ',' NAME ')' {}
@@ -802,8 +872,8 @@ exp :
@ @<Process a primitive conditional@>=
@q TeX_( "/yy0{/hbox{/nx/ttl let }/nx/xi(0)=/the/yy(5): /nx/xi(/nx/CM0)=/the/yy(3)/hbox{ /nx/ttl do }/xi(/the/yy(1))}" );@>
-@[TeX_( "/yy0{/hbox{/nx/ttl do }/xi(/the/yy(1))/hbox{ /nx/ttl where }" );@>
-@[TeX_( " {/let/nx/{/nx/bigbracedel/nx/xi(x)=/nx/cases{/the/yy(5)& if /inmath{x=0}/cr/the/yy(3)& if /inmath{x/nx/not=0}}}}" );@]
+@[TeXb( "/yy0{/hbox{/nx/ttl do }/xi(/the/yy(1))/hbox{ /nx/ttl where }" );@]@;
+@[TeXfo( " {/let/nx/{/nx/bigbracedel/nx/xi(x)=/nx/cases{/the/yy(5)& if /inmath{x=0}/cr/the/yy(3)& if /inmath{x/nx/not=0}}}}" );@]@;
@ @<Grammar rules@>=
@G
@@ -880,7 +950,7 @@ section:
opt_comma {@>@<Record an overlay section@>@=}
| GROUP {@>@[TeX_( "/ldlex@@expression" );@]@=}
opt_exp_with_type {@>@[TeX_( "/ldlex@@popstate" );@]@=}
- '{' sec_or_group_p1 '}'
+ '{' sec_or_group_p1 '}' {}
| INCLUDE filename {@>@<Peek at a file@>@=}
sec_or_group_p1 END
{@>@<Close the file@>@=}
@@ -888,10 +958,12 @@ section:
@g
@ @<Record a named section@>=
- @[TeXb( "/yy0{/nx/ldnamedsection{/the/yy(1)}{/the/yy(3)}{/the/yy(4)}" );@]@;
+ @[TeXb( "/getthird{/yy(1)}/to/toksa/getfourth{/yy(1)}/to/toksb" );@]@;
+ @[TeXf( "/getfifth{/yy(12)}/to/toksc" );@]@;/* \prodstylens{statement\_list\_opt}{\ldnamespace} contents */
+ @[TeXf( "/yy0{/nx/ldinsertcweb{/the/toksa}{/the/toksb}{osect}{/nx/ldnamedsection{/the/yy(1)}{/the/yy(3)}{/the/yy(4)}" );@]@;
@[TeXf( " {{/the/yy(5)}{/the/yy(6)}{/the/yy(7)}}" );@]@;/* alignment */
- @[TeXf( " {/the/yy(9)}{/the/yy(12)}" );@]@;
- @[TeXfo( " {{/the/yy(15)}{/the/yy(16)}{/the/yy(17)}{/the/yy(18)}}}" );@]@; /*memory specifiers */
+ @[TeXf( " {/the/yy(9)}{/the/toksc}" );@]@;
+ @[TeXfo( " {{/the/yy(15)}{/the/yy(16)}{/the/yy(17)}{/the/yy(18)}}}}" );@]@; /*memory specifiers */
@ @<Record an overlay section@>=
diff --git a/support/splint/examples/ld/ldgramo.w b/support/splint/examples/ld/ldgramo.w
index 3069bb71eb..46d46f9a1f 100644
--- a/support/splint/examples/ld/ldgramo.w
+++ b/support/splint/examples/ld/ldgramo.w
@@ -1,4 +1,4 @@
-@q Copyright 2015 Alexander Shibakov@>
+@q Copyright 2020 Alexander Shibakov@>
@q Copyright 2002-2015 Free Software Foundation, Inc.@>
@q This file is part of SPLinT@>
@@ -504,7 +504,7 @@ statement_anywhere:
@g
@ \tracebadcharstrue
-The \prodstyle{'*'} and \prodstyle{'?'} cases are there because the lexer returns them as
+The {\setrulecontext{wildcardname}\prodstyle{'*'}} and \prodstyle{'?'} cases are there because the lexer returns them as
separate tokens rather than as \prodstyle{NAME}.
\tracebadcharsfalse
@<Original \ld\ grammar rules@>=
diff --git a/support/splint/examples/ld/ldint.sty b/support/splint/examples/ld/ldint.sty
index 478bdef17d..83f3068dc5 100644
--- a/support/splint/examples/ld/ldint.sty
+++ b/support/splint/examples/ld/ldint.sty
@@ -1,4 +1,4 @@
-% Copyright 2012-2015, Alexander Shibakov
+% Copyright 2012-2020, Alexander Shibakov
% This file is part of SPLinT
%
% SPLinT is free software: you can redistribute it and/or modify
@@ -175,7 +175,7 @@
}
\def\ldsciinteger#1{%
- \ifcase\intprefix{#1}
+ \ifcase\intprefix{#1}%
% decimal number (no prefix)
\lddecsplitws{#1}{}%
\or % hex number (0X)
@@ -203,11 +203,23 @@
}
\def\displayinteger#1#2#3#4#5#6#7#8{%
- {\def\ldintsep{$\,$}\hbox{\tt#7#8${}_{#1}\yystringempty{#2}{}{\,\hbox{\tt#2}}$}}%
+ {\def\ldintsep{$\,$}\hbox{\rm#7#8\rlap{${}_{#1}$}$\yystringempty{#2}{}{\lddisplayintsuffix{#2}}$}}%
}
+\def\lddisplayintsuffix#1{%
+ \expandafter\ifx\csname ldspecialsuffixdisplay#1\endcsname\relax
+ \,\hbox{\tt#1}%
+ \else
+ \csname ldspecialsuffixdisplay#1\endcsname
+ \fi
+}
+
+\def\ldspecialsuffixdisplayK{{}\cdot2^{10}}
+
+\def\ldspecialsuffixdisplayK{\,\hbox{\rm Kb}}
+
\def\displayintegerws#1#2#3#4#5#6#7{%
- {\def\ldintsep{$\,$}\hbox{\tt#6#7${}_{\yystringempty{#1}{}{\csname ldradix#1\endcsname}}$}}%
+ {\def\ldintsep{$\,$}\hbox{\rm#6#7\rlap{${}_{\yystringempty{#1}{}{\csname ldradix#1\endcsname}}$}}}%
}
% typeseting examples in text
@@ -234,6 +246,7 @@
\let\acharswitch\texcharadjust
\let\onecharswitch\texcsadjust
\let\yyinputgroup\yyinputldgroup
+ \expandafter\hidecs\expandafter{\ldunion} % inhibit expansion so that fewer \noexpand are necessary
\toldparser
\ldparserinit
\yyparse#1\yyeof\yyeof\endparseinput\endparse
@@ -242,9 +255,13 @@
\else % Stage three, process the parsed table
\yybreak{%
{%
+ \restorecslist{ld-parser:restash}\ldunion % extract the stash and mark lhs of assignments
+ \setprodtable % use \bison's parser typesetting definitions
+ \the\ldcmds
\restorecslist{ld-display}\ldunion
+ \setprodtable % use \bison's parser typesetting definitions
+ \restorecs{ld-display}{\anint\bint\hexint} % ... except for integer typesetting
\the\ldcmds
-% \par
\the\lddisplay
}%
}%
diff --git a/support/splint/examples/ld/ldlex.w b/support/splint/examples/ld/ldlex.w
index 9d1c256e62..2312fd1027 100644
--- a/support/splint/examples/ld/ldlex.w
+++ b/support/splint/examples/ld/ldlex.w
@@ -1,4 +1,4 @@
-@q Copyright 2012-2015 Alexander Shibakov@>
+@q Copyright 2012-2020 Alexander Shibakov@>
@q Copyright 2002-2014 Free Software Foundation, Inc.@>
@q This file is part of SPLinT@>
@@ -16,9 +16,9 @@
@q along with SPLinT. If not, see <http://www.gnu.org/licenses/>.@>
@** The lexer.
-\ifx\parsernamespace\UNDEFINED
+\ifbootstrapmode
\input ldman.sty
- \input limbo.sty
+ \modebootstrap
\input dcols.sty
\setupfootnotes
\def\MRI{}
@@ -65,13 +65,13 @@ void define_all_states( void ) {
#include "ldl_states.h"
#undef _register_name
-@ \yyskipparsetrue The character classes used by the scanner as well as
+@ The character classes used by the scanner as well as
lexer state declarations have been put in the definitions section of
the input file. No attempt has been made to clean up the definitions
of the character classes.
@<\ld\ lexer definitions@>=
@<\ld\ lexer states@>@;
-@G
+@G(fs1)
CMDFILENAMECHAR [_a-zA-Z0-9\/\.\\_\+\$\:\[\]\\\,\=\&\!\<\>\-\~]
CMDFILENAMECHAR1 [_a-zA-Z0-9\/\.\\_\+\$\:\[\]\\\,\=\&\!\<\>\~]
FILENAMECHAR1 [_a-zA-Z\/\.\\\$\_\~]
@@ -93,7 +93,6 @@ very rarely used explicitly. Keeping all the state declarations in the
same section simplifies the job of the
\locallink{bootstrapstates}bootstrap parser\endlink, as well.
\ifbootstrapmode\immediate\openout\stlist=ldl_states.h\fi
-\yyskipparsefalse
@<\ld\ lexer states@>=
@G
%s SCRIPT
@@ -109,8 +108,8 @@ same section simplifies the job of the
@*1 Macros for lexer functions.
The \locallink{pingpong}state switching\endlink\ `ping-pong' between the lexer and the parser aside,
the \ld\ lexer is very traditional. One implementation choice
-deserving some attenion is the treatment of comments by the lexer. The
-difficulty of implementing \Cee\ style comment lexing using regular
+deserving some attention is the treatment of comments. The
+difficulty of implementing \Cee\ style comment scanning using regular
expressions is well-known so an often used alternative is a
special function that simply skips to the end of the comment. This is
exactly what the \ld\ lexer does with an aptly named |comment()|
@@ -119,7 +118,7 @@ the same purpose. For the curious, here is a \flex\ style regular
expression defining \Cee\ comments\footnote{Taken from W.~McKeeman's site
at
\url{http://www.cs.dartmouth.edu/~mckeeman/cs118/assignments/comment.html}
-and adopted to \flex\ syntax.}:
+and adapted to \flex\ syntax.}:
$$
\hbox{\.{"/*" ("/"\yl[\^*/]\yl"*"+[\^*/])* "*"+ "/"}}
$$
@@ -136,7 +135,7 @@ setup of the lexer and enters a `|while| loop' in the input
routine. This macro is a reasonable approximation of the functionality
provided by |comment()|.
@<Additional macros for the \ld\ lexer/parser@>=
-@G
+@G(t)
\def\ldcomment{%
\let\oldyyreturn\yyreturn
\let\oldyylextail\yylextail
@@ -147,7 +146,7 @@ provided by |comment()|.
@ The rest of the |while| loop merely waits for the \.{*/} combination.
@<Additional macros for the \ld\ lexer/parser@>=
-@G
+@G(t)
\def\ldcommentskipchars{%
\ifnum\yycp@@=`*
\yybreak{\let\yyreturn\ldcommentseekslash\yyinput}%
@@ -174,7 +173,7 @@ provided by |comment()|.
@ Once the end of the comment has been found, resume lexing the input
stream.
@<Additional macros for the \ld\ lexer/parser@>=
-@G
+@G(t)
\def\ldcommentfinish{%
\let\yyreturn\oldyyreturn
\let\yylextail\oldyylextail
@@ -195,7 +194,7 @@ an `optimized' lexer the restriction is even weaker, namely,
\.{\\yylextail} merely has to be absent in the portion of the action
following \.{\\ldcomment}).
@<Additional macros for the \ld\ lexer/parser@>=
-@G
+@G(t)
\def\ldcomment#1\yylextail{%
\let\oldyyreturn\yyreturn
\def\yylexcontinuation{#1\yylextail}%
@@ -224,7 +223,7 @@ appropriate end of file marker for the lexer (a double
has to be cleaned up from the input stream (the lexer is designed to
leave it intact). The macros below are designed to handle this assignment.
@<Additional macros for the \ld\ lexer/parser@>=
-@G
+@G(t)
\def\ldcleanyyeof#1\yylextail{%
\let\oldyyinput\yyinput
\def\yyinput\yyeof\yyeof{\let\yyinput\oldyyinput#1\yylextail}%
@@ -240,11 +239,11 @@ sections that follow.
Variable names and algebraic operations come first.
@<\ld\ token regular expressions@>=
-@G
+@G(fs2)
<BOTH,SCRIPT,EXPRESSION,VERS_START,VERS_NODE,VERS_SCRIPT>"/*" {@> @[TeX_( "/ldcomment/yylexnext" );@]@=}
<DEFSYMEXP>"-" {@> @[TeX_( "/yylexreturnchar" );@]@=}
<DEFSYMEXP>"+" {@> @[TeX_( "/yylexreturnchar" );@]@=}
-<DEFSYMEXP>{FILENAMECHAR1}{SYMBOLCHARN}* {@> @[TeX_( "/yylexreturnval{NAME}" );@]@=}
+<DEFSYMEXP>{FILENAMECHAR1}{SYMBOLCHARN}* {@> @[TeX_( "/yylexreturnsym{NAME}" );@]@=}
<DEFSYMEXP>"=" {@> @[TeX_( "/yylexreturnchar" );@]@=}
<MRI,EXPRESSION>"$"([0-9A-Fa-f])+ {@> @<Return an absolute hex constant@> @=}
<MRI,EXPRESSION>([0-9A-Fa-f])+(H|h|X|x|B|b|O|o|D|d) {@> @<Return a constant in a specific radix@>@=}
@@ -294,7 +293,7 @@ Variable names and algebraic operations come first.
inside script files. File name syntax is listed as well, along with
miscellanea such as whitespace and version symbols.
@<\ld\ token regular expressions@>=
-@G
+@G(fs2)
<BOTH,SCRIPT>"MEMORY" {@> @[TeX_( "/yylexreturnptr{MEMORY}" );@]@=}
<BOTH,SCRIPT>"REGION_ALIAS" {@> @[TeX_( "/yylexreturnptr{REGION_ALIAS}" );@]@=}
<BOTH,SCRIPT>"LD_FEATURE" {@> @[TeX_( "/yylexreturnptr{LD_FEATURE}" );@]@=}
@@ -420,11 +419,11 @@ miscellanea such as whitespace and version symbols.
<MRI>"list".* {@> @[TeX_( "/yylexreturnptr{LIST}" );@]@=}
<MRI>"sect" {@> @[TeX_( "/yylexreturnptr{SECT}" );@]@=}
<EXPRESSION,BOTH,SCRIPT,MRI>"absolute" {@> @[TeX_( "/yylexreturnptr{ABSOLUTE}" );@]@=}
-<MRI>{FILENAMECHAR1}{NOCFILENAMECHAR}* {@> @[TeX_( "/yylexreturnval{NAME}" );@]@=}
-<BOTH>{FILENAMECHAR1}{FILENAMECHAR}* {@> @[TeX_( "/yylexreturnval{NAME}" );@]@=}
-<BOTH>"-l"{FILENAMECHAR}+ {@> @[TeX_( "/yylexreturnval{NAME}" );@]@=}
-<EXPRESSION>{FILENAMECHAR1}{NOCFILENAMECHAR}* {@> @[TeX_( "/yylexreturnval{NAME}" );@]@=}
-<EXPRESSION>"-l"{NOCFILENAMECHAR}+ {@> @[TeX_( "/yylexreturnval{NAME}" );@]@=}
+<MRI>{FILENAMECHAR1}{NOCFILENAMECHAR}* {@> @[TeX_( "/yylexreturnsym{NAME}" );@]@=}
+<BOTH>{FILENAMECHAR1}{FILENAMECHAR}* {@> @[TeX_( "/yylexreturnsym{NAME}" );@]@=}
+<BOTH>"-l"{FILENAMECHAR}+ {@> @[TeX_( "/yylexreturnsym{NAME}" );@]@=}
+<EXPRESSION>{FILENAMECHAR1}{NOCFILENAMECHAR}* {@> @[TeX_( "/yylexreturnsym{NAME}" );@]@=}
+<EXPRESSION>"-l"{NOCFILENAMECHAR}+ {@> @[TeX_( "/yylexreturnsym{NAME}" );@]@=}
<SCRIPT>{WILDCHAR}* {@> @[@<Skip a possible comment and return a \prodstyle{NAME}@>@]@=}
<EXPRESSION,BOTH,SCRIPT,VERS_NODE>"\""[^\"]*"\"" {@> @[@<Return the \prodstyle{NAME} inside quotes@>@]@=}
<BOTH,SCRIPT,EXPRESSION>"\n" {@> @[TeX_( "/yylexnext" );@]@=}
@@ -457,7 +456,7 @@ macros are looking for a \.{\$} suffix while the contents of
@[TeX_( "/yylexreturn{INT}" );@]@;
@ @<Additional macros for the \ld\ lexer/parser@>=
-@G
+@G(t)
@=\def\matchcomment@@#1/*#2\yyeof#3#4{%@>@;
\yystringempty{#1}{#3}{#4}%
}
@@ -480,28 +479,28 @@ try again.}
@<Skip a possible comment and return a \prodstyle{NAME}@>=
@[TeX_( "/matchcomment/yytextpure" );@]@;
@[TeX_( " {/yyless/tw@@/ldcomment}" );@]/*matched the beginning of a comment*/@;
- @[TeX_( " {/yylexreturnval{NAME}}" );@]@;
+ @[TeX_( " {/yylexreturnsym{NAME}}" );@]@;
@ {\it No matter the state, quotes give what's inside.}
@<Return the \prodstyle{NAME} inside quotes@>=
- @[TeX_( "/ldstripquotes/yylexreturnval{NAME}" );@]@;
+ @[TeX_( "/ldstripquotes/yylexreturnsym{NAME}" );@]@;
@ @<Additional macros for the \ld\ lexer/parser@>=
-@G
+@G(t)
\newcount\versnodenesting
\newcount\includestackptr
@g
@ Some syntax specific to version scripts.
@<\ld\ token regular expressions@>=
-@G
+@G(fs2)
<VERS_SCRIPT>"{" {@> @[TeX_( "/yyBEGIN{VERS_NODE}/versnodenesting=/z@@/yylexreturnchar" );@]@=}
<VERS_SCRIPT>"}" {@> @[TeX_( "/yylexreturnchar" );@]@=}
<VERS_NODE>"{" {@> @[TeX_( "/advance/versnodenesting/@@ne /yylexreturnchar" );@]@=}
-<VERS_NODE>"}" {@> @[TeX_( "/advance/versnodenesting/m@@ne" );@]@;
- @> @[TeX_( "/ifnum/versnodenesting</z@@" );@]@;
- @> @[TeX_( " /yyBEGIN{VERS_SCRIPT}" );@]@;
- @> @[TeX_( "/fi" );@]@;
+<VERS_NODE>"}" {@> @[TeX_( "/advance/versnodenesting/m@@ne" );@]@=
+ @> @[TeX_( "/ifnum/versnodenesting</z@@" );@]@=
+ @> @[TeX_( " /yyBEGIN{VERS_SCRIPT}" );@]@=
+ @> @[TeX_( "/fi" );@]@=
@> @[TeX_( "/yylexreturnchar" );@]@=}
<VERS_START,VERS_NODE,VERS_SCRIPT>[\n] {@> @[TeX_( "/yylexnext" );@]@=}
<VERS_START,VERS_NODE,VERS_SCRIPT>#.* {@> @[TeX_( "/yylexnext" );@]@=}
@@ -509,12 +508,8 @@ try again.}
<<EOF>> {@> @[@<Process the end of (possibly included) file@>@]@=}
-<SCRIPT,MRI,VERS_START,VERS_SCRIPT,VERS_NODE>. {@> @[TeX_( "/yycomplain{bad character `/the/yytext'" );@]
- @> @[TeX_( " in script}" );@]
- @> @[TeX_( "/yyerrterminate" );@]@=}
-<EXPRESSION,DEFSYMEXP,BOTH>. {@> @[TeX_( "/yycomplain{bad character `/the/yytext'" );@]
- @> @[TeX_( " in expression}" );@]@=
- @> @[TeX_( "/yyerrterminate" );@]@=}
+<SCRIPT,MRI,VERS_START,VERS_SCRIPT,VERS_NODE>. {@> @[TeX_( "/yyfatal{bad character `/the/yytext' in script}" );@]@=}
+<EXPRESSION,DEFSYMEXP,BOTH>. {@> @[TeX_( "/yyfatal{bad character `/the/yytext' in expression}" );@]@=}
@g
@ @<Process the end of (possibly included) file@>=
@@ -529,7 +524,7 @@ try again.}
\namedspot{stateswitchers}Here are the long promised auxiliary
macros for switching lexer states and handling file input.
@<Additional macros for the \ld\ lexer/parser@>=
-@G
+@G(t)
\def\ldlex@@script{\yypushstate{SCRIPT}}
\def\ldlex@@mri@@script{\yypushstate{MRI}}
\def\ldlex@@version@@script{\yypushstate{VERS_START}}
@@ -541,7 +536,7 @@ macros for switching lexer states and handling file input.
\def\ldfile@@open@@command@@file#1{%
\advance\includestackptr\@@ne
- \appendl\yytextseen{\noexpand\yyeof\noexpand\yyeof}%
+ \appendlnx\yytext@@seen{\yyeof\yyeof}%
\yytextbackuptrue
}
diff --git a/support/splint/examples/ld/ldlexo.w b/support/splint/examples/ld/ldlexo.w
index 6b62d2fd77..a1c5d62bb0 100644
--- a/support/splint/examples/ld/ldlexo.w
+++ b/support/splint/examples/ld/ldlexo.w
@@ -1,4 +1,4 @@
-@q Copyright 2015 Alexander Shibakov@>
+@q Copyright 2015-2020 Alexander Shibakov@>
@q Copyright 2002-2015 Free Software Foundation, Inc.@>
@q This file is part of SPLinT@>
@@ -89,14 +89,14 @@ int yywrap (void) { return 1; }/* Some versions of \flex\ want this. */
#endif
@ @<Ignored options@>=
-@G
+@G(fs1)
%a 4000
%o 5000
@g
@ {\it Some convenient abbreviations for regular expressions.}%
-\ifbootstrapmode\else\yyskipparsetrue\fi@<Original \ld\ macros@>=
-@G
+@<Original \ld\ macros@>=
+@G(fs1)
CMDFILENAMECHAR [_a-zA-Z0-9\/\.\\_\+\$\:\[\]\\\,\=\&\!\<\>\-\~]
CMDFILENAMECHAR1 [_a-zA-Z0-9\/\.\\_\+\$\:\[\]\\\,\=\&\!\<\>\~]
FILENAMECHAR1 [_a-zA-Z\/\.\\\$\_\~]
@@ -163,8 +163,8 @@ States:
}
@ @<Original \ld\ regular expressions@>=
+@G(fs2)
@=<BOTH,SCRIPT,EXPRESSION,VERS_START,VERS_NODE,VERS_SCRIPT>"/*" {@> comment ();@+@=}@>@;
-@G
<DEFSYMEXP>"-" {@>@[RTOKEN('-');@]@=}
<DEFSYMEXP>"+" {@>@[RTOKEN('+');@]@=}
<DEFSYMEXP>{FILENAMECHAR1}{SYMBOLCHARN}* {@>@[yylval.name = xstrdup (yytext);@+return NAME;@]@=}
@@ -177,8 +177,8 @@ States:
return INT;
@o
}
-
-<MRI,EXPRESSION>([0-9A-Fa-f])+(H|h|X|x|B|b|O|o|D|d) {
+@t}\vb{\insertraw{\insrulealign{\rulealigntemplate}{\cr\egroup\egroup}}}{@>
+<MRI,EXPRESSION>@>@t}\vb{\insertraw{\insparensalign{&}{}}}{@>@=([0-9A-Fa-f])+@>@t}\vb{\insertraw{\insparensalign{\rlap{$\odot$}\cr&}{}}}{@>@=(H|h|X|x|B|b|O|o|D|d) {
@O
int ibase ;
switch (yytext[yyleng - 1]) {
@@ -205,8 +205,8 @@ States:
return INT;
@o
}
-
-<SCRIPT,DEFSYMEXP,MRI,BOTH,EXPRESSION>((("$"|0[xX])([0-9A-Fa-f])+)|(([0-9])+))(M|K|m|k)? {
+@t}\vb{\insertraw{\insrulealign{\rulealigntemplate}{\cr\egroup\egroup}}}{@>
+<SCRIPT,DEFSYMEXP,MRI,BOTH,EXPRESSION>((("$"|0[xX])([0-9A-Fa-f])+)|(([0-9])+@>@t}\vb{\insertraw{\insparensalign{\rlap{$\odot$}\cr&}{}}}{@>@=)@>@t}\vb{\insertraw{\insparensalign{&}{}}}{@>@=)(M|K|m|k)? {
@O
char *s = yytext;
int ibase = 0;
@@ -364,8 +364,8 @@ States:
<EXPRESSION,BOTH,SCRIPT>"CONSTANT" {@>@[RTOKEN(CONSTANT);@]@=}
<MRI>"#".*\n? {@>@[++ lineno; @]@=}
<MRI>"\n" {@> @[++lineno;@+RTOKEN(NEWLINE);@]@=}
-<MRI>"*".* {}/* \MRI\ comment line */
-<MRI>";".* {}/* \MRI\ comment line */
+<MRI>"*".* {@> /* \MRI\ comment line */ @=}
+<MRI>";".* {@> /* \MRI\ comment line */ @=}
<MRI>"END" {@>@[RTOKEN(ENDWORD); @]@=}
<MRI>"ALIGNMOD" {@>@[RTOKEN(ALIGNMOD);@]@=}
<MRI>"ALIGN" {@>@[RTOKEN(ALIGN_K);@]@=}
@@ -380,7 +380,7 @@ States:
<MRI>"FORMAT" {@>@[RTOKEN(FORMAT); @]@=}
<MRI>"CASE" {@>@[RTOKEN(CASE); @]@=}
<MRI>"START" {@>@[RTOKEN(START); @]@=}
-<MRI>"LIST".* {@>@[RTOKEN(LIST); @]@=}/* \prodstyle{LIST} and ignore to end of line */
+<MRI>"LIST".* {@>@[RTOKEN(LIST);@]/* \prodstyle{LIST} and ignore to end of line */@=}
<MRI>"SECT" {@>@[RTOKEN(SECT); @]@=}
<EXPRESSION,BOTH,SCRIPT,MRI>"ABSOLUTE" {@>@[RTOKEN(ABSOLUTE); @]@=}
<MRI>"end" {@>@[RTOKEN(ENDWORD); @]@=}
@@ -398,7 +398,7 @@ States:
<MRI>"case" {@>@[RTOKEN(CASE); @]@=}
<MRI>"extern" {@>@[RTOKEN(EXTERN); @]@=}
<MRI>"start" {@>@[RTOKEN(START); @]@=}
-<MRI>"list".* {@>@[RTOKEN(LIST); @]@=}/* \prodstyle{LIST} and ignore to end of line */
+<MRI>"list".* {@>@[RTOKEN(LIST);@]/* \prodstyle{LIST} and ignore to end of line */@=}
<MRI>"sect" {@>@[RTOKEN(SECT); @]@=}
<EXPRESSION,BOTH,SCRIPT,MRI>"absolute" {@>@[RTOKEN(ABSOLUTE); @]@=}
@@ -435,10 +435,10 @@ States:
}
<SCRIPT>{WILDCHAR}* {
@O
- /* Annoyingly, this pattern can match comments, and we have
- longest match issues to consider. So if the first two
- characters are a comment opening, put the input back and
- try again. */
+ @t}\C{Annoyingly, this pattern can match comments,}\6{@>
+ @t}\C{and we have longest match issues to consider.}\6{@>
+ @t}\C{So if the first two characters are a comment}\6{@>
+ @t}\C{opening, put the input back and try again.}\6{@>
if (yytext[0] == '/' && yytext[1] == '*')
{
yyless (2);
@@ -506,10 +506,10 @@ States:
}
<VERS_START,VERS_NODE,VERS_SCRIPT>[\n] {@>@[lineno++;@]@=}
-<VERS_START,VERS_NODE,VERS_SCRIPT>#.* {}/* Eat up comments */
-<VERS_START,VERS_NODE,VERS_SCRIPT>[ \t\r]+ {}/* Eat up whitespace */
+<VERS_START,VERS_NODE,VERS_SCRIPT>#.* {@>@[;@]/* Eat up comments */@=}
+<VERS_START,VERS_NODE,VERS_SCRIPT>[ \t\r]+ {@>@[;@]/* Eat up whitespace */@=}
-<<EOF>> {
+<<EOF>> {@>@=
@O
include_stack_ptr--;
if (include_stack_ptr == 0)
diff --git a/support/splint/examples/ld/ldman.w b/support/splint/examples/ld/ldman.w
index c9551d1b3e..b6eb733dbd 100644
--- a/support/splint/examples/ld/ldman.w
+++ b/support/splint/examples/ld/ldman.w
@@ -1,4 +1,4 @@
-% Copyright 2012-2015, Alexander Shibakov
+% Copyright 2012-2020, Alexander Shibakov
% Copyright 2002-2014 Free Software Foundation, Inc.
% This file is part of SPLinT
%
@@ -15,18 +15,22 @@
% You should have received a copy of the GNU General Public License
% along with SPLinT. If not, see <http://www.gnu.org/licenses/>.
@s TeX_ TeX
-\input limbo.sty
-\input ldfrontmatter.sty
\def\MRI{{\sc MRI}}
\def\optimization{5}
\input ldman.sty
+\modenormal
+\input ldfrontmatter.sty
+\input noweb.sty
+ \xreflocaltrue
+ \readlxrefs % read the reference file if exists before any sections appear
+ \newwrite\xrefstream % references for noweb like style of sectioning.
+ \immediate\openout\xrefstream=\jobname.xxr
% multi-column output
\input dcols.sty
\let\oldN\N
-\let\N\textN
+\let\N\chapterN
\let\M\textM
-\def\ld{\.{ld}}
\showlastactiontrue
\immediate\openout\gindex=\jobname.gdx
@@ -48,28 +52,34 @@ supporting \TeX\ macros that make both the parser and this
documentation possible. The \TeX\ macros presented here are collected
in \.{ldman.sty} which is later included in the \TeX\ file produced by \CWEAVE.
@<Set up the generic parser machinery@>=
-@G
+@G(t)
\ifx\optimization\UNDEFINED %/* this trick is based on the premise that \.{\\UNDEFINED} */
\def\optimization{0} %/* is never defined nor created with \.{\\csname$\ldots$\\endcsname} */
\fi
\let\nx\noexpand %/* convenient */
+\input limbo.sty %/* general setup macros */
\input yycommon.sty %/* general routines for stack and array access */
-\input yymisc.sty %/* helper macros (stack manipulation, table processing, value stack pointers) */
+\input yymisc.sty %/* helper macros (stack manipulation, table processing, value stack pointers */
+ %/* parser initialization, optimization) */
\input yyinput.sty %/* input functions */
\input yyparse.sty %/* parser machinery */
\input flex.sty %/* lexer functions */
-\input yyboth.sty %/* parser initialization, optimization */
\ifnum\optimization>\tw@
\input yyfaststack.sty
+\else
+ \let\stashnext\stashnextwithnothing
\fi
\input yystype.sty %/* scanner auxiliary types and functions */
\input yyunion.sty %/* parser data structures */
\input yxunion.sty %/* extended parser data structures */
-@=\input ldunion.sty %@>/* \ld\ parser data structures */@+
+\expandafter\def %/* adjust the \.{\\yyinput} to recognize \.{\\yyendgame} */
+ \expandafter\multicharswitch\expandafter
+ {\multicharswitch\yyendgame{\yyinput\yyeof\yyeof\endparseinput\removefinalvb}}
+\input ldunion.sty %@>/* \ld\ parser data structures */@+
@g
@*1 Bootstrapping.
@@ -141,7 +151,7 @@ a robust token output function which simply ignores the token values
the lexer is not aware of (it should not be necessary in our case
since we are using full featured lexer and parser).
@<Define the bootstrapping mode@>=
-@G
+@G(t)
\newwrite\tokendefs %/* token list */
\newwrite\stlist %/* \flex\ state list */
\newwrite\gindex %/* index entries */
@@ -155,12 +165,13 @@ since we are using full featured lexer and parser).
%\let\yylexreturn\yylexreturnregular /* should also work */
}%
\input yybootstrap.sty%
+ \input yytexlex.sty%
}
@g
@*1 Namespaces and modes.
Every parser/lexer pair (as well as some other macros) operates
-within a dedicated {\it namespace\/}. This simply means that the macros
+within a set of dedicated {\it namespaces\/}. This simply means that the macros
that output token values, switch lexer states and access various
tables `tack on' the string of characters representing the current
namespace to the `low level' control sequence name that performs the
@@ -171,23 +182,66 @@ generic name in the case of an `unoptimized' parser or lexer. The
optimized parser or lexer handles the namespace referencing internally.
The mode setup macros for this manual define several separate
-namespaces. The \.{[main]} namespace is established for the parser
-that does the typesetting of the grammar. Every time a term name is
+namespaces:
+{%
+\def\aterm#1{\item{\sqebullet}{\ttl #1}: \ignorespaces}%
+\setbox0=\hbox{\sqebullet\enspace}
+\parindent=0pt
+\advance\parindent by \wd0
+\smallskip
+\aterm{main}the \.{[main]} namespace is established for the parser
+that does the typesetting of the grammar.
+
+\aterm{ld}every time a term name is
processed, the token names are looked up in the \.{[ld]}
namespace. The same namespace is used by the parser that typesets \ld\
script examples in the manual (i.e.~the parser described here). This
is done to provide visual consistency between the description of the
-parser and its output. The \.{[small]} namespace is used by the term
+parser and its output.
+
+\aterm{small{ \rm and} ldsmall}the \.{[small]}namespace is used by the term
name parser itself. Since we use a customized version of the name parser, we
dedicate a separate namespace for this purpose, \.{[ldsmall]}.
-The parser based on a subset of the full \bison\
+
+\aterm{prologue}the parser based on a subset of the full \bison\
grammar describing prologue declarations uses the \.{[prologue]}
-namespace. The \.{[index]} namespace is used for typesetting the
+namespace.
+
+\aterm{index}the \.{[index]} namespace is used for typesetting the
index entries and is not necessarily associated with any parser or
-lexer.
+lexer. Somewhat confusingly, the macros that typeset \TeX\ entries, use
+\.{index} (without the brackets) as a pseudonamespace to display \TeX\
+terms in the index (due to the design of these typesetting macros, many
+of them take parameters, which can lead to chaos in the index). These
+two namespaces are not related but due to `hystorical' reasons (and the
+poorly thought out \TeX\ typesetting macro design) the \.{index} name has
+been retained. In addition, \.{index:visual} is used to adjust the sort order
+of \TeX\ terms (similar to the way \.{\\prettywordpairwvis} macro does).
+
+
+\aterm{flexre{\rm, }flexone{, \rm and} flextwo}the parsers for
+\flex\ input use the \.{[flexre]}, \.{[flexone]}, and~\.{[flextwo]} namespaces for
+their operation. Another convention is to use the \.{\\flexpseudonamespace}
+to typeset \flex\ state names, and the \.{\\flexpseudorenamespace} for typesetting
+the names of \flex\ regular
+expressions. Currently, \.{\\flexpseudo...} namespaces are set equal to
+their non-\.{pseudo} versions by default. This setting may be changed
+whenever several parsers are used in the same document and tokens with
+the same names must be typeset in different styles.
+All \flex\ namespaces, as well as~\.{[main]}, \.{[small]},
+and~\.{[ldsmall]} are defined by the \.{\\genericparser}
+macros.
+
+\aterm{cwebclink}finally, the \.{[cwebclink]} namespace is used for
+typesetting the variables {\it inside\/} \ld\ scripts. This way, the
+symbols exported by the linker may be typeset in a style similar to
+\Cee\ variables, if desired (as they play very similar roles).
+
+}
@<Begin namespace setup@>=
-@G
+@G(t)
\def\indexpseudonamespace{[index]}
+\def\cwebclinknamespace{[cwebclink]}
\let\parsernamespace\empty
@g
@@ -201,15 +255,18 @@ initializing the \bison\ parser (accomplished by inputting
\.{yyinit.sty}), followed by handling the token typesetting for the
\ld\ grammar.
@<Define the normal mode@>=
-@G
+@G(t)
\newtoks\ldcmds
\def\modenormal{%
- \def\drvname{bo}%
\def\appendr##1##2{\edef\appnext{##1{\the##1##2}}\appnext}%
\def\appendl##1##2{\edef\appnext{##1{##2\the##1}}\appnext}%
\input yyinit.sty%
+ \input yytexlex.sty% /* \TeX\ typesetting macros */
+ \input ldtexlex.sty% /* \TeX\ typesetting specific to \ld */
\let\hostparsernamespace\ldnamespace /* the namespace where tokens are looked up for typesetting purposes */
+ @>@[@<Initialize \ld\ parsers@>@]
+ @>@[@<Modified name parser for \ld\ grammar@>@]
}
@g
@@ -220,7 +277,7 @@ the ability of the parser to switch lexer states. Thus, the parser can
switch the lexer state before the lexer is invoked for the first time
wreaking havoc on the lexer state stack.
@<Define the normal mode@>=
-@G
+@G(t)
\def\ldparserinit{%
\basicparserinit
\includestackptr=\@@ne
@@ -233,38 +290,45 @@ wreaking havoc on the lexer state stack.
@ This is the \ld\ parser invocation routine. It is coded according to
a straightforward sequence initialize-invoke-execute-or-fall back.
@<Define the normal mode@>=
-@G
-\expandafter\def\csname parserstack[l]\endcsname#1#2{%
- \toldparser\ldparserinit\yyparse#1\yyeof\yyeof\endparseinput\endparse
- \ifyyparsefail % /* revert to generic macros if parsing failed */
- \yybreak{\message{parsing failed ...}#2}%
- \else % /* stage three, process the parsed table */
- \yybreak{%
- \message{commands: \the\ldcmds}%
- {%
- \restorecslist{ld-display}\ldunion
- \the\ldcmds
- \par
- \vskip-\baselineskip
- \the\lddisplay
- }%
- }%
- \yycontinue
+@G(t)
+\def\preparseld{%
+ \let\postparse\postparseld
+ \expandafter\hidecs\expandafter{\ldunion}% /* inhibit expansion so that fewer \.{\\noexpand}s are necessary */
+ \toldparser
+ \ldparserinit
+ \yyparse
}
-@g
-
-@ @<Initialize the active mode@>=
-@G
-\ifx\modeactive\UNDEFINED
- \def\modeactive{\modenormal}
-\fi
-\modeactive
+\def\postparseld{%
+ \ifsaveparseoutput
+ {\newlinechar=`^^J\immediate\write\exampletable{^^J\harmlesscomment
+ parsed table: \the\ldcmds^^J^^J\harmlesscomment
+ stashed stream:^^J\the\yystash^^J^^J\harmlesscomment
+ format stream: ^^J\the\yyformat}%
+ }%
+ \fi
+ \ifchecktable
+ \errmessage{parsed table: \the\ldcmds^^J^^J%
+ stashed stream: \the\yystash^^J^^J%
+ format stream: \the\yyformat}%
+ \fi
+ \restorecslist{ld-parser:restash}\ldunion % /* mark variables, preprocess stash */
+ \setprodtable
+ \the\ldcmds
+ \restorecslist{ld-display}\ldunion
+ \setprodtable /* use the \bison's parser typesetting definitions */
+ \restorecs{ld-display}{\anint\bint\hexint} % /* $\ldots$ except for integer typesetting */
+ \the\ldcmds
+ \par
+ \vskip-\baselineskip
+ \the\lddisplay
+}
-\ifbootstrapmode\else
- @>@[@<Initialize \ld\ parsers@>@]@;
- @>@[@<Modified name parser for \ld\ grammar@>@]@;
-\fi
+\fillpstack{l}{%
+ \preparseld
+ {\preparsefallback{++}}% /* skip this section if parsing failed, put \.{++} on the screen */
+ \relax % /* this \.{\\relax} serves as a `guard' for the braces */
+}
@g
@ Unless they are being bootstrapped, the \ld\ parser and its
@@ -280,7 +344,7 @@ In the original \bison-\flex\ interface, token names are
defined as straightforward macros (a poor choice as will be seen
shortly) which can sometimes clash with the standard \Cee\ macros.
This is why \ld\ lexer returns \prodstyle{ASSERT} as
-\prodstyle{ASSERT_K}. The name parser treats \.{K} as a suffix to
+\prodstyle{ASSERT\_K}. The name parser treats \.{K} as a suffix to
supply a visual reminder of this flaw. Note that the `suffixless' part
of these tokens (such as \prodstyle{ASSERT}) is never declared and
thus has to be entered in \.{ltokenset.sty} by hand.
@@ -291,7 +355,7 @@ fixed appearance (for example, \prodstyle{NAME}) are typeset in a
style that indicates their origin. The details can be found by
examining \.{ltokenset.sty}.
@<Initialize \ld\ parsers@>=
-@G
+@G(t)
\genericparser
name: ld,
ptables: ptab.tex,
@@ -300,7 +364,7 @@ examining \.{ltokenset.sty}.
asetup: {},
dsetup: {},
rsetup: {},
- optimization: {};%
+ optimization: {};% /* the parser and lexer are optimized when output */
\genericprettytokens
namespace: ld,
tokens: ldp.tok,
@@ -316,7 +380,6 @@ of this documentation.
@<Define the bootstrapping mode@>@;
@<Define the normal mode@>@;
@<Additional macros for the \ld\ lexer/parser@>@;
-@<Initialize the active mode@>@;
@i ldgram.x
@i ldlex.x
@@ -342,156 +405,14 @@ need for a `parser stack' as in the case of the \bison\
parser. If one must be able to display still smaller segments of \ld\
code, using `hidden context' tricks (discussed elsewhere) seems to be
a better approach.
-\iffalse
-\traceparserstatestrue
-\tracestackstrue
-\tracerulestrue
-\traceactionstrue
-\tracelookaheadtrue
-\traceparseresultstrue
-\tracebadcharstrue
-\yyflexdebugtrue
-\tracestatestrue
-\fi
%
@<Example \ld\ script@>=
-@G(l)
-INCLUDE file.ld
-
-MEMORY
-{
- RAM (xrw) : ORIGIN = 0x20000000, LENGTH = 20K
- FLASH (rx) : ORIGIN = 0x8000000, LENGTH = 128K
- ASH (rx) : ORIGIN = 8000000, LENGTH = 128K
- CLASH (rx) : ORIGIN = 700000, LENGTH = 128K
- ASH (rx) : ORIGIN = $8000000, LENGTH = 128K
- CLASH (rx) : ORIGIN = 700000B, LENGTH = 128K
- INCLUDE file.mem
-}
-
-_estack = 0x20005000;
-_bstack = a > 0 ? NEXT(11) : 0x19;
-
-SECTIONS
-{
- .isr_vector ALIGN(8) (NOLOAD): AT(.) ALIGN(.) ALIGN_WITH_INPUT SUBALIGN(8) SPECIAL
- {
- . = ALIGN(4);
- KEEP(*(.isr_vector))
- . = ALIGN(4);
- } > FLASH AT > RAM : FLASH : RAM : OTHER = . + 8
-
- .text :
- {
- /* skip this comment */;
- . = ALIGN(4);
- *(.text)
- *(.text.*)
- *(.rodata)
- *(.rodata*)
- *(.glue_7)
- *(.glue_7t)
- . = ALIGN(4);
- _etext = . + 8;
- _sidata = _etext;
- } >FLASH AT > RAM
-
- .data : AT ( _sidata )
- {
- . = ALIGN(4);
- _sdata = . ;
- *(.data)
- *(.data.*)
- . = ALIGN(4);
- _edata = . ;
- } >RAM
-
- .bss :
- {
- . = ALIGN(4);
- _sbss = .;
- *(.bss)
- *(COMMON)
- . = ALIGN(4);
- _ebss = . ;
- } >RAM
-}
-@g
+@i ldexample_l.hx
@ @<The same example of an \ld\ script@>=
-@G(b)
-INCLUDE file.ld
-
-MEMORY
-{
- RAM (xrw) : ORIGIN = 0x20000000, LENGTH = 20K
- FLASH (rx) : ORIGIN = 0x8000000, LENGTH = 128K
- ASH (rx) : ORIGIN = 8000000, LENGTH = 128K
- CLASH (rx) : ORIGIN = 700000, LENGTH = 128K
- ASH (rx) : ORIGIN = $8000000, LENGTH = 128K
- CLASH (rx) : ORIGIN = 700000B, LENGTH = 128K
- INCLUDE file.mem
-}
+@i ldexample_b.hx
-_estack = 0x20005000;
-_bstack = a > 0 ? NEXT(11) : 0x19;
-
-SECTIONS
-{
- .isr_vector ALIGN(8) (NOLOAD): AT(.) ALIGN(.) ALIGN_WITH_INPUT SUBALIGN(8) SPECIAL
- {
- . = ALIGN(4);
- KEEP(*(.isr_vector))
- . = ALIGN(4);
- } > FLASH AT > RAM : FLASH : RAM : OTHER = . + 8
-
- .text :
- {
- /* skip this comment */;
- . = ALIGN(4);
- *(.text)
- *(.text.*)
- *(.rodata)
- *(.rodata*)
- *(.glue_7)
- *(.glue_7t)
- . = ALIGN(4);
- _etext = . + 8;
- _sidata = _etext;
- } >FLASH AT > RAM
-
- .data : AT ( _sidata )
- {
- . = ALIGN(4);
- _sdata = . ;
- *(.data)
- *(.data.*)
- . = ALIGN(4);
- _edata = . ;
- } >RAM
-
- .bss :
- {
- . = ALIGN(4);
- _sbss = .;
- *(.bss)
- *(COMMON)
- . = ALIGN(4);
- _ebss = . ;
- } >RAM
-}
-@g
-
-@
-\traceparserstatesfalse
-\tracestacksfalse
-\tracerulesfalse
-\traceactionsfalse
-\tracelookaheadfalse
-\traceparseresultsfalse
-\tracebadcharsfalse
-\yyflexdebugfalse
-\tracestatesfalse
+@ @<Some random portion of \ld\ code@>=
@i ldnp.x
@@ -516,12 +437,17 @@ to take advantage of \TeX\ formatting and introduce some visual
cues. The convention of using {\it italics\/} for the original
comments has been reversed: the italicized comments are the ones
introduced by the author, {\it not\/} the original
-creators of \ld.
+creators of \ld.%\checktabletrue\saveparseoutputtrue
@i ldgramo.x
@i ldlexo.x
+@q Include the list of index section markers; this is a hack to get around @>
+@q the lack of control over the generation of \CWEB's index; the correct order @>
+@q of index entries depends on the placement of this inclusion @>
+@i alphas.hx
-@** Index. This section lists the variable names and (in some cases)
+@** Index. \checktablefalse\saveparseoutputtrue
+This section lists the variable names and (in some cases)
the keywords used inside the `language sections' of the \CWEB\
source. It takes advantage of the built-in facility of \CWEB\ to supply
references for both definitions (set in {\it
@@ -551,19 +477,12 @@ $$
index entries, as well, mimicking \CWEB's behavior for the
{\it inline \Cee\/} (\.{\yl}$\ldots$\.{\yl}). Such entries are labeled
with $^\circ$, to provide a reminder of their origin.
-\def\otherlangindexseparator{%
- \par
- \vskip.5\baselineskip
- \centerline{B{\sc ISON}, LD, {\sc AND} \TeX\ {\sc INDICES}}%
- \vskip.5\baselineskip
- \par
-}
-\let\currentparsernamespace\parsernamespace
- \let\parsernamespace\indexpseudonamespace
- \prettywordpair{emptyrhs}{$\circ$ {\rm(empty rhs)}}%
- \prettywordpair{inline_action}{$\diamond$ {\rm(inline action)}}%
-\let\parsernamespace\currentparsernamespace
+\unsetfootnotes
+\def\next{\expandafter\eatone\string}
+\edef\unindexable{{\next\the}{\next\nx}{\next\yy}{\next\yylexnext}{\next\else}{\next\fi}{\next\yyBEGIN}{\next\next}}
+\input gindex.sty
\closeout\gindex
+\termindexfalse
\let\inx\inxmod
\let\fin\finmod
\let\oldMRL\MRL
diff --git a/support/splint/examples/ld/ldnp.w b/support/splint/examples/ld/ldnp.w
index f92d0dfc8c..0a99d864fd 100644
--- a/support/splint/examples/ld/ldnp.w
+++ b/support/splint/examples/ld/ldnp.w
@@ -1,4 +1,4 @@
-@q Copyright 2012-2015, Alexander Shibakov@>
+@q Copyright 2012-2020, Alexander Shibakov@>
@q This file is part of SPLinT@>
@q SPLinT is free software: you can redistribute it and/or modify@>
@@ -40,7 +40,7 @@ initialization is done by the macros below. After the initialization
has been completed, the switch command is replaced by the one that
activates the new name parser.
@<Modified name parser for \ld\ grammar@>=
-@G
+@G(t)
\genericparser
name: ldsmall,
ptables: ld_small_tab.tex,
@@ -48,10 +48,12 @@ activates the new name parser.
tokens: {},
asetup: {},
dsetup: {},
- rsetup: {\noexpand\savefullstateextra},
+ rsetup: \let\returnexplicitspace\ignoreexplicitspace, % ignore spaces in names
optimization: {};%
\let\otosmallparser\tosmallparser % /* save the old name parser */
\let\tosmallparser\toldsmallparser
+\expandafter\let\csname to\stripbrackets\cwebclinknamespace parser\endcsname\tosmallparser %
+/* make the name parser handle the typesetting of \Cee\ variables */
@g
@ @<Bison options@>=
@@ -70,6 +72,7 @@ activates the new name parser.
%token INTEGER
%token EXTENDED
%token WILDCARD
+%token META_IDENTIFIER
@g
@*1 The name parser productions. These macros do a bit more than we
@@ -80,26 +83,39 @@ order to be able to refer to, say, \flex\ options in text. The inline
action in one of the rules for \prodstyle{identifier\_string} was
added to adjust the number and the position of the terms so that the
appropriate action can be reused later for
-\prodstyle{qualified\_identifier\_string}.
+\prodstyle{qualified\_identifier\_string}.
+%\tracebadnamestrue
+%\tracenamestrue
+%\traceparserstatestrue
+%\tracestackstrue
+%\tracerulestrue
+%\traceactionstrue
+%\tracelookaheadtrue
+%\traceparseresultstrue
+%\tracebadcharstrue
+%\yyflexdebugtrue
@<Parser productions@>=
@G
full_name:
identifier_string suffixes.opt {@> @<Compose the full name@> @=}
| qualifier '_' identifier_string suffixes.opt {@> @<Compose a qualified name@> @=}
+| META_IDENTIFIER {@> @<Turn a \prodstylens{META\_IDENTIFIER}{\ldsmallnamespace} into a full name@> @=}
+| '\'' {@> @<Make \prodstyle{'} into a name@> @=}
;
identifier_string:
PERCENT_IDENTIFIER {@> @<Attach option name@> @=}
| IDENTIFIER {@> @<Start with an identifier@> @=}
| '\'' WILDCARD '\'' {@> @<Start with a quoted string@> @=}
+| '\'' '_' '\'' {@> @<Start with a \prodstyle{'\_'} string@> @=}
| '\'' '.' '\'' {@> @<Start with a \prodstyle{'.'} string@> @=}
-| '\'' '_' '\'' {@> @<Start with an \prodstyle{'\_'} string@> @=}
@t}\vb{\flatten}{@>
| incomplete_identifier_string {} IDENTIFIER {@> @<Attach an identifier@> @=}
;
@t}\vb{\resetf}{@>
incomplete_identifier_string:
- identifier_string '_' {@> TeX_( "/yy0{/the/yy(1)}" ); @=}
+ '_' {@> TeX_( "/yy0{/nx/idstr{}{}}" );@=}
+| identifier_string '_' {@> TeX_( "/yy0{/the/yy(1)}" ); @=}
| qualified_identifier_string '_' {@> TeX_( "/yy0{/the/yy(1)}" ); @=}
;
@@ -144,7 +160,16 @@ qualifier:
@[TeX_( "/yy0{/the/yy(1)/the/yy(2)}/namechars/yyval" );@]@;
@ @<Compose a qualified name@>=
- @[TeX_( "/yy0{/the/yy(3)/the/yy(4)/nx/dotsp/nx/qual/the/yy(1)}/namechars/yyval" );@]@;
+ @[TeX_( "/getfirst{/yy(1)}/to/toksa/getsecond{/yy(1)}/to/toksb" );@]@;
+ @[TeX_( "/yy0{/the/yy(3)/the/yy(4)/nx/dotsp/nx/qual{/the/toksa/nx/_}{/the/toksb/uscoreletter}}/namechars/yyval" );@]@;
+
+@ @<Turn a \prodstylens{META\_IDENTIFIER}{\ldsmallnamespace} 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" );@]@;
+
+@ @<Make \prodstyle{'} into a name@>=
+ @[TeX_( "/yy0{/nx/chstr{'}{'}}/namechars/yyval" );@]@;
@ @<Attach option name@>=
@[TeX_( "/getfirst{/yy(1)}/to/toksa" );@]@;
@@ -164,13 +189,13 @@ qualifier:
@ @<Start with a quoted string@>=
@[TeX_( "/getfirst{/yy(2)}/to/toksa" );@]@;
@[TeX_( "/getsecond{/yy(2)}/to/toksb" );@]@;
- @[TeX_( "/yy0{/nx/chstr{/the/toksa}{/the/toksb}}" );@]@;
+ @[TeX_( "/yy0{/nx/visflag{/nx/termvstring}{}/nx/chstr{/the/toksa}{/the/toksb}}" );@]@;
-@ @<Start with a \prodstyle{'.'} string@>=
- @[TeX_( "/yy0{/nx/chstr{.}{.}}" );@]@;
+@ @<Start with a \prodstyle{'\_'} string@>=
+ @[TeX_( "/yy0{/nx/visflag{/nx/termvstring}{}/nx/chstr{/nx/_}{_}}" );@]@;
-@ @<Start with an \prodstyle{'\_'} string@>=
- @[TeX_( "/yy0{/nx/chstr{/uscoreletter}{/uscoreletter}}" );@]@;
+@ @<Start with a \prodstyle{'.'} string@>=
+ @[TeX_( "/yy0{/nx/visflag{/nx/termvstring}{}/nx/chstr{.}{.}}" );@]@;
@ @<Turn a qualifier into an identifier@>=
@<Start with an identifier@>@;
@@ -193,10 +218,12 @@ qualifier:
@[TeX_( "/yy0{/nx/dotsp/nx/sfxi/the/yy(1)}" );@]@;
@ @<Attach a subscripted integer@>=
- @[TeX_( "/yy0{/nx/dotsp/nx/sfxi/the/yy(2)}" );@]@;
+ @[TeX_( "/getfirst{/yy(2)}/to/toksa/getsecond{/yy(2)}/to/toksb" );@]@;
+ @[TeX_( "/yy0{/nx/dotsp/nx/sfxi{/nx/_/the/toksa}{/uscoreletter/the/toksb}}" );@]@;
@ @<Attach a subscripted qualifier@>=
- @[TeX_( "/yy0{/nx/dotsp/nx/qual/the/yy(2)}" );@]@;
+ @[TeX_( "/getfirst{/yy(2)}/to/toksa/getsecond{/yy(2)}/to/toksb" );@]@;
+ @[TeX_( "/yy0{/nx/dotsp/nx/qual{/nx/_/the/toksa}{/uscoreletter/the/toksb}}" );@]@;
@ @<Attach suffixes@>=
@[TeX_( "/yy0{/nx/dotsp/the/yy(2)}" );@]@;
@@ -262,10 +289,13 @@ void define_all_states( void ) {
@ @<Lexer definitions@>=
@<Lexer states@>@;
-@G
+@G(fs1)
aletter [a-zA-Z]
-wc ([^\\\']{-}[a-zA-Z0-9]|\\.)
+letter (_|{aletter})
+wc ([^\\\'\"]{-}[_a-zA-Z0-9]|\\.)
id ({aletter}|{aletter}({aletter}|[0-9])*{aletter})
+id_strict {letter}(({letter}|[-0-9])*{letter})?
+meta_id "*"{id_strict}"*"?
int [0-9]+
@g
@@ -321,9 +351,8 @@ int [0-9]+
\tracebadcharsfalse
\yyflexdebugfalse
%
-\yyskipparsetrue
@<Scan white space@>=
-@G
+@G(fs2)
[ \f\n\t\v] {@> @[TeX_( "/yylexnext" );@]@=}
@g
@@ -333,7 +362,7 @@ 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.
@<Scan identifiers@>=
-@G
+@G(fs2)
"%"({aletter}|[0-9]|[-_]|"%"|[<>])+ {@> @[TeX_( "/yylexreturnval{PERCENT_IDENTIFIER}" );@]@=}
"opt" {@> @[TeX_( "/yylexreturnval{OPTIONAL}" );@]@=}
@@ -344,6 +373,7 @@ here.
{wc} {@> @[TeX_( "/yylexreturnval{WILDCARD}" );@]@=}
{id} {@> @[@<Prepare to process an identifier@>@]@=}
+{meta_id} {@> @[@<Prepare to process a meta-identifier@>@]@=}
{int} {@> @[TeX_( "/yylexreturnval{INTEGER}" );@]@=}
"\"" {@> @[TeX_( "/yylexnext" );@]@=}
@@ -353,6 +383,9 @@ here.
@ @<Prepare to process an identifier@>=
@[TeX_( "/yylexreturnval{IDENTIFIER}" );@]@;
+@ @<Prepare to process a meta-identifier@>=
+ @[TeX_( "/yylexreturnval{META_IDENTIFIER}" );@]@;
+
@ \let\hostparsernamespace\ldnamespace\yyskipparsefalse A simple routine to detect
trivial scanning problems.
@<React to a bad character@>=
diff --git a/support/splint/examples/ld/ldnump.w b/support/splint/examples/ld/ldnump.w
index 5d4d45f724..813628c68c 100644
--- a/support/splint/examples/ld/ldnump.w
+++ b/support/splint/examples/ld/ldnump.w
@@ -1,4 +1,4 @@
-@q Copyright 2012-2015, Alexander Shibakov@>
+@q Copyright 2012-2020, Alexander Shibakov@>
@q This file is part of SPLinT@>
@q SPLinT is free software: you can redistribute it and/or modify@>
@@ -54,7 +54,7 @@ activates the new name parser.
tokens: {},
asetup: {},
dsetup: {},
- rsetup: {\noexpand\savefullstateextra},
+ rsetup: {},
optimization: {};%
@g
diff --git a/support/splint/examples/ld/ldtexlex.sty b/support/splint/examples/ld/ldtexlex.sty
new file mode 100644
index 0000000000..01b8873540
--- /dev/null
+++ b/support/splint/examples/ld/ldtexlex.sty
@@ -0,0 +1,75 @@
+% Copyright 2012-2020, Alexander Shibakov
+% This file is part of SPLinT
+%
+% SPLinT is free software: you can redistribute it and/or modify
+% it under the terms of the GNU General Public License as published by
+% the Free Software Foundation, either version 3 of the License, or
+% (at your option) any later version.
+%
+% SPLinT is distributed in the hope that it will be useful,
+% but WITHOUT ANY WARRANTY; without even the implied warranty of
+% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+% GNU General Public License for more details.
+%
+% You should have received a copy of the GNU General Public License
+% along with SPLinT. If not, see <http://www.gnu.org/licenses/>.
+
+% additional definitions for typesetting \TeX\ control sequences
+
+\def\defz#1#{%
+ \d@fz{#1}%
+}
+
+\def\d@fz#1#2{%
+ \defx#1{#2}{texline}%
+ \d@@z#1{#2}{index}%
+}
+
+\def\d@@z#1#2#{%
+ \expandafter\def
+ \expandafter
+ \alltexsymbols
+ \expandafter{\alltexsymbols#1}%
+ \defy#1%
+}
+
+\def\defzop#1{%
+ \defz#1{$#1$}%
+}
+
+\defzop\CM
+\defzop\AND
+\defzop\OR
+\defzop\XOR
+\defzop\V
+\defzop\W
+\defzop\leq
+\defzop\geq
+\defzop\ll
+\defzop\gg
+\defzop\times
+\defzop\div
+\defz\/{${}/{}$}
+\defzop\R
+\defzop\xi
+\defzop\Xorxeq
+\defzop\K
+
+
+\defx\CM{=not}{index:visual}
+\defx\AND{&&}{index:visual}
+\defx\OR{||}{index:visual}
+\defx\XOR{|||}{index:visual}
+%\defx\V{V}{index:visual}
+%\defx\W{W}{index:visual}
+\defx\leq{<=}{index:visual}
+\defx\geq{>=}{index:visual}
+\defx\ll{<<}{index:visual}
+\defx\gg{>>}{index:visual}
+\defx\times{=times}{index:visual}
+\defx\div{\%}{index:visual}
+\defx\/{/}{index:visual}
+\defx\R{not^}{index:visual}
+%\defx\xi{xi}{index:visual}
+\defx\Xorxeq{=|||}{index:visual}
+\defx\K{=}{index:visual}
diff --git a/support/splint/examples/ld/ldunion.sty b/support/splint/examples/ld/ldunion.sty
index b2c3837e57..710d4e1725 100644
--- a/support/splint/examples/ld/ldunion.sty
+++ b/support/splint/examples/ld/ldunion.sty
@@ -1,4 +1,4 @@
-% Copyright 2012-2015, Alexander Shibakov
+% Copyright 2012-2020, Alexander Shibakov
% This file is part of SPLinT
%
% SPLinT is free software: you can redistribute it and/or modify
@@ -21,6 +21,7 @@
\def\yyuniontag{\ldunion}
\def\parserstrictnamespace{ld-parser-strict}
\def\parserprototypesnamespace{ld-parser-strict:headers}
+\def\parserdebugnamespace{ld-parser-debug}
\def\ldunion{\currentyyunionnamespace}
\def\currentyyunionnamespace{ld-generic}
@@ -33,28 +34,40 @@
% ld commands
-\defp\ldregexp#1{} % name pattern :: \ldregexp{name}
+\defp\ldregexp#1{} % name pattern :: \ldregexp{{name}{name11}{fptr}{sptr}}
+\defp\ldregop#1{} % name pattern :: \ldregop{name}
\defp\ldspace{} % space separator :: \ldspace
\defp\ldattributes#1{} % attributes :: \ldattributes{name}
\defp\ldattributesneg#1{} % complemented attributes :: \ldattributesneg{name}
\defp\ldfilename#1{} % file name :: \ldfilename{name}
-\defp\ldcommandseparator#1#2{} % command separator
+\defp\ldcommandseparator#1#2#3#4{} % command separator :: \ldcommandseparator{fptr}{sptr}{prev command}{next command}
\defp\ldassignment#1#2#3{} % assignment :: \ldassignment{lhs}{op}{rhs}
+\defp\ldhidden#1#2{} % hidden :: \ldhidden{lhs}{rhs}
+\defp\ldprovide#1#2{} % provide :: \ldprovide{lhs}{rhs}
+\defp\ldprovidehid#1#2{} % provide hidden :: \ldprovidehid{lhs}{rhs}
+\defp\ldkeep#1{} % keep :: \ldkeep{list}
+\defp\ldentry#1{} % entry :: \ldentry{name}
\defp\ldinclude#1{} % file inclusion :: \ldinclude{file name}
\defp\ldmemory#1{} % memory specification :: \ldmemory{memory spcification}
\defp\ldfill#1{} % fill expression :: \ldfill{expression}
\defp\ldmemoryspec#1#2#3#4{} % memory item :: \ldmemoryspec{name}{attributes}{origin}{length}
+\defp\ldmemspecstash#1#2{} % memory spec stash :: \ldmemspecstash{fptr}{sptr}
+\defp\ldmemspecseparator#1#2{} % memory spec separator :: \ldmemspecseparator{fptr}{sptr}
\defp\ldoriginspec#1{} % origin :: \ldoriginspec{expression}
\defp\ldlengthspec#1{} % length :: \ldlengthspec{expression}
\defp\ldsections#1{} % ld sections :: \ldsections{sections}
-\defp\ldsectionseparator{} % section separator
+\defp\ldsectionseparator#1#2{} % section separator :: \ldsectionseparator{fptr}{sptr}
\defp\ldtype#1{} % section type :: \ldtype{type}
-\defp\ldstatement#1{} % stray statement :: \ldstatement{statement}
+\defp\ldstatement#1{} % statement :: \ldstatement{statement}
+\defp\ldsecspec#1{} % section spec :: \ldsecspec{section spec}
+\defp\ldinsertcweb#1#2#3#4{} % insert accumulated \CWEB\ material :: \ldinsertcweb
+ % {fptr}{sptr}{command}{parsed segment} : never defined
\defp\ldnamedsection#1#2#3#4#5#6#7{} % named section :: \ldnamedsection{name}
% {{expression}{type}}{at}
% {{}{}{}:alignment}
% {constraint}{statements}
% {{}{}{}{}:placement}
+\defp\ldsectionstash#1#2{} % sections spec stash :: \ldsectionstash{fptr}{sptr}
\savecslist{ld-parser-prototypes}\ldunion
@@ -64,6 +77,8 @@
\newtoks\lddisplay
+\restorecslist{ld-parser-strict}\ldunion
+
\defc\ldinclude{%
\toksa={&##\cr\ttl include\ &}#1%
\concat\toksa\toksc
@@ -77,8 +92,8 @@
\restorecslist{ld-parser:memory-spec}\ldunion
\toksa{}#1%
\toksc{%
- \hfil##\qquad&##\hfil&\qquad##\hfil\quad&\hfil##&\quad\hfil##\cr
- \ttl memory&\hfil&\ttl attributes&\ttl origin&\ttl length\cr
+ \hfil##\qquad&##\hfil&\qquad##\hfil\quad&\hfil##&\qquad\hfil##\cr
+ \ttl memory&\hfil&\ttl attributes&\ttl starts at&\ttl length\cr
\noalign{\smallskip}%
}%
\edef\next{\lddisplay{\the\lddisplay\halign{\the\toksc\the\toksa}}}\next
@@ -97,23 +112,72 @@
\restorecslist{local-namespace}{\ldunion}%
}
-\def\ldextractname#1#2{%
- \edef\next{\toksc{\gidxentry{\termttstring}{#2}{\ntt #2}}}\next
+\def\ldextractname#1#2#3#4{%
+ \edef\next{\toksc{\gidxentry{\termttstring}{#2}{}{\ntt #2}}}\next
+}
+
+\def\ldextractmemname#1#2#3#4{%
+ {%
+ \expandafter\let\expandafter\tosmallparser\csname to\stripbrackets\cwebclinknamespace parser\endcsname
+ \let\optstrextra\optstrextraesc
+ \def\hostparsernamespace{[none]}%
+ \nameproc{#2}\with\parsebin
+ \edef\next{\toksc{\gidxentry{\termvstring}{#2}{}{\let\idxfont\nx\empty\ntt\the\toksa}}}%
+ \expandafter
+ }\next%
+
}
% the grammar of ld scripts is very uniform so the separator form
-% below is more than adequate; if a more sophisticated spacing
+% below should be more than adequate; if a more sophisticated spacing
% strategy is required, one may consult the design of
% \separatorswitcheq and \separatorswitchneq in yyunion.sty
-\defc\ldcommandseparator{\yyifsamestring{#1}{#2}{}{\appendr\lddisplay{\noexpand\medskip}}}
+\defc\ldcommandseparator{%
+ \restorecs{table-render}{\strm}%
+ \expandafter\ifx\csname ldstashentry[#2]\endcsname\relax
+ \yyifsamestring{#3}{#4}{}{\appendrnx\lddisplay{\medskip}}%
+ \else
+ \expandafter\expandafter\expandafter\yystashlocal\expandafter\expandafter\expandafter{\csname ldstashentry[#2]\endcsname}%
+ \edef\next{\toksc{\toksa{}\the\yystashlocal
+ \noexpand\ldmakestashbox{}}}\next
+ \appendrnx\lddisplay{\smallskip\noindent}%
+ \concat\lddisplay\toksc
+ \appendrnx\lddisplay{\smallskip}%
+ \fi
+}
+
+\defc\ldcommandseparator{% new version; TODO: remove the duplicates after the macros have been tested
+ \expandafter\ifx\csname ldstashentry[#2]\endcsname\relax
+ \yyifsamestring{#3}{#4}{}{\appendrnx\lddisplay{\medskip}}%
+ \else
+ \expandafter\expandafter\expandafter\yystashlocal\expandafter\expandafter\expandafter{\csname ldstashentry[#2]\endcsname}%
+ \appendrnx\lddisplay{\smallskip\noindent}%
+ \appendr \lddisplay{\toksa{\the\yystashlocal}}%
+ \appendrnx\lddisplay{\ldmakestashbox{}\smallskip}%
+ \fi
+}
\defc\ldstatement{\toksc{\hbox{$#1$}}\concat\lddisplay\toksc}
+\let\ldsecspec\ldstatement
+
\defc\ldassignment{%
#1#2#3%
}
+\defc\ldhidden{%
+ \mathop{\hbox{\ssf hidden}}\hbox{$\langle\,$}#1\K#2\hbox{$\,\rangle$}%
+}
+
+\defc\ldprovide{%
+ \mathop{\hbox{\ssf provide}}\hbox{$\langle\,$}#1\K#2\hbox{$\,\rangle$}%
+}
+
+\defc\ldprovidehid{%
+ \mathop{\hbox{\ssf provide$_{h}$}}\hbox{$\langle\,$}#1\K#2\hbox{$\,\rangle$}%
+}
+
\defc\anint{%
\uppercase{\ldsciinteger{#1}}%
}
@@ -130,14 +194,61 @@
\ldreg@xp#1%
}
-\def\ldreg@xp#1#2{%
- \hbox{\let\termindex\writeidxentry\edef\next{\toksc{\gidxentry{\termttstring}{#2}}}\next\the\toksc\ntt@#2}%
+\def\ldreg@xp#1#2#3#4{%
+ \expandafter\ifx\csname ldvarname[#2]\endcsname\relax
+ {%
+ \let\termindex\writeidxentry
+ \let\hostparsernamespace\cwebclinknamespace% process the variable names as in \CWEB
+ \edef\next{\toksc{\gidxentry{\termttstring}{#1}{}}}\next\the\toksc
+ \hbox{\ntt@#1}%
+ \expandafter
+ }\the\toksc
+ \else
+ \yyifsamestring{#2}{.}{% special . name
+ {%
+ \let\termindex\writeidxentry
+ \let\hostparsernamespace\cwebclinknamespace% for consistency
+ \edef\next{\toksc{\gidxentry{\termexception}{.origin&}{.}}}\next
+ \hbox{\csname\prettynamecs\hostparsernamespace{.origin&}\endcsname{}}%
+ \expandafter
+ }\the\toksc
+ }{%
+ {%
+ \let\termindex\writeidxentry
+ \let\hostparsernamespace\cwebclinknamespace% process the variable names as in \CWEB
+ \edef\next{\toksc{\gidxentry{\termhostidstring}{#1}{}}}\next
+ \hbox{%
+ \expandafter\let\expandafter\tosmallparser\csname to\stripbrackets\cwebclinknamespace parser\endcsname
+ \let\optstrextra\optstrextraesc
+ \nameproc{#2}\with\parsebin
+ \it\the\toksa
+ }%
+ \expandafter
+ }\the\toksc
+ }%
+ \fi
+}
+
+\defc\ldregop{%
+ \ldreg@p#1%
+}
+
+\def\ldreg@p#1#2#3#4{%
+ \hbox{\ntt@#1}%
}
\defc\ldfill{%
#1%
}
+\defc\ldentry{% this command survives till the table time
+ \hbox{\ttl entry{\rm: }} #1%
+}
+
+\defc\ldkeep{%
+ \mathop{\hbox{\ssf keep}}(#1)%
+}
+
\defc\ldfilename{\ldextractname#1}
\savecslist{ld-display}\ldunion
@@ -149,9 +260,9 @@
\defc\ldmemoryspec{%
\toksb{\hfil&}%
\let\termindex\writeidxhentry
- \ldextractname#1\concat\toksb\toksc
+ \ldextractmemname#1\concat\toksb\toksc
\let\termindex\eatone
- \appendr\toksb{&}%
+ \appendrnx\toksb{&}%
\toksc{}#2\concat\toksb\toksc
\toksc{}#3\concat\toksb\toksc
\toksc{}#4\concat\toksb\toksc
@@ -160,7 +271,7 @@
}
\defc\ldattributes{%
- \ldextractname#1\appendr\toksc{&}%
+ \ldextractname#1\appendrnx\toksc{&}%
}
\defc\ldlengthspec{%
@@ -179,7 +290,43 @@
\concat\toksa\toksc
}
-\restorecs{ld-display}{\anint\ldfilename}
+\defc\ldmemspecseparator{% TODO: remove after testing is complete
+ \restorecs{table-render}{\strm}%
+ \expandafter\ifx\csname ldstashentry[#2]\endcsname\relax
+ \else
+ \expandafter\expandafter\expandafter\yystashlocal\expandafter\expandafter\expandafter{\csname ldstashentry[#2]\endcsname}%
+ \edef\next{\toksc{&\noexpand\multispan4\toksa{}\the\yystashlocal
+ \noexpand\ldmakestashbox{\cdotfill}\noexpand\quad\cr}}\next\concat\toksa\toksc
+ \fi
+}
+
+\defc\ldmemspecseparator{%
+ \expandafter\ifx\csname ldstashentry[#2]\endcsname\relax
+ \else
+ \expandafter\expandafter\expandafter\yystashlocal\expandafter\expandafter\expandafter{\csname ldstashentry[#2]\endcsname}%
+ \appendr\toksa{&\nx\multispan4\toksa{\the\yystashlocal}\nx\ldmakestashbox{\nx\cdotfill}\nx\quad\cr}%
+ \fi
+}
+
+\defc\ldmemspecstash{%
+ \restorecs{table-render}{\strm}%
+ \expandafter\ifx\csname ldstashentry[#2]\endcsname\relax
+ \else
+ \expandafter\expandafter\expandafter\yystashlocal\expandafter\expandafter\expandafter{\csname ldstashentry[#2]\endcsname}%
+ \edef\next{\toksc{&\noexpand\multispan4\toksa{}\the\yystashlocal
+ \noexpand\ldmakestashbox{\cdotfill}\noexpand\quad\cr}}\next\concat\toksa\toksc
+ \fi
+}
+
+\defc\ldmemspecstash{%
+ \expandafter\ifx\csname ldstashentry[#2]\endcsname\relax
+ \else
+ \expandafter\expandafter\expandafter\yystashlocal\expandafter\expandafter\expandafter{\csname ldstashentry[#2]\endcsname}%
+ \appendr\toksa{&\nx\multispan4\toksa{\the\yystashlocal}\nx\ldmakestashbox{\nx\cdotfill}\nx\quad\cr}%
+ \fi
+}
+
+\restorecs{ld-display}{\ldfilename\ldentry}
\toyyunion{ld-parser:memory-spec}
% sections commands
@@ -206,19 +353,19 @@
\toksb\expandafter{\sections@header&}% section header
\ldextractname#1% section name
\concat\toksb\toksc
- \appendr\toksb{&}%
+ \appendrnx\toksb{&}%
\ldexpwithtype#2% location and type
\concat\toksb\toksc
- \appendr\toksb{&}%
+ \appendrnx\toksb{&}%
\yystringempty{#3}{\ldpushalignment#4}{\toksc{{\ttl at }$#3$}}% alignment
\concat\toksb\toksc
- \appendr\toksb{&}%
+ \appendrnx\toksb{&}%
\yystringempty{#5}{\ldpushplacement#7}{\toksc{{\ttl #5}}}% constraint
\concat\toksb\toksc
- \appendr\toksb{&}%
+ \appendrnx\toksb{&}%
\ldstartpheaders#7% possible pheaders
\concat\toksb\toksc
- \appendr\toksb{\cr}%
+ \appendrnx\toksb{\cr}%
\def\sections@header{}%
\else
\toksb\expandafter{&}% section header
@@ -238,19 +385,19 @@
\toksc\expandafter{\expandafter\qquad\expandafter$\the\toksc{}$}%
}%
\concat\toksb\toksc
- \appendr\toksb{&}%
+ \appendrnx\toksb{&}%
% \ldexpwithtype#2% location and type
% \concat\toksa\toksc
- \appendr\toksb{&}%
+ \appendrnx\toksb{&}%
\ldpushalignment#4% alignment
\concat\toksb\toksc
- \appendr\toksb{&}%
+ \appendrnx\toksb{&}%
\ldpushplacement#7% placement
\concat\toksb\toksc
- \appendr\toksb{&}%
+ \appendrnx\toksb{&}%
\ldpushpheaders#7% possible pheaders
\concat\toksb\toksc
- \appendr\toksb{\cr}%
+ \appendrnx\toksb{\cr}%
\def\sections@header{}%
\fi
\ifsectioncomplete
@@ -296,11 +443,11 @@
}{%
\ldextractname#1%
\toksd{{\ttl in }}%
- \appendl\toksc{\the\toksd}%
+ \concatl\toksd\toksc
}%
\yystringempty{#2}{% any AT > ?
}{%
- \yytoksempty\toksc{\toksc{{\ttl as }}}{\appendr\toksc{ {\noexpand\ttl as }}}%
+ \yytoksempty\toksc{\toksc{{\ttl as }}}{\appendrnx\toksc{ {\ttl as }}}%
\toksd=\toksc
\ldextractname#2%
\concat\toksd\toksc
@@ -336,7 +483,7 @@
\def\ldexpwithtype#1#2#3#4#5{% TODO
\yystringempty{#2}{\toksc{$}}{\toksc{$#2}}%$
- \yystringempty{#5}{\toksd{{}$}}{#5\appendr\toksd{]$}\appendl\toksd{[}}%
+ \yystringempty{#5}{\toksd{{}$}}{#5\appendlnx\toksd{[}\appendrnx\toksd{]$}}%
\concat\toksc\toksd
}
@@ -344,8 +491,152 @@
\toksd{\hbox{\ttl #1}}%
}
-\defc\ldstatement{}
+\defc\ldstatement{{#1}} % the braces form the group for a \toks assignment
+
+\let\ldsecspec\ldstatement
+
\defc\ldsectionseparator{\toksc{&\multispan5\cdotfill\quad\cr}\concat\toksa\toksc}
-\restorecs{ld-display}{\anint\ldregexp\ldassignment\ldfill}
+\def\ldboxstash#1{%
+ \ifchecktrim\errmessage{stash contents: \the\toksa}\fi
+ {\setbox0 \vbox{\the\toksa}\ifdim\ht0=\z@\aftergroup\toksa\else\aftergroup\eatone\fi}{}%
+ \yytoksempty\toksa{#1}{%
+ $\vtop{\activateinlinec\tabskip\z@\halign{\strut\ignorespaces##\hfil\cr\the\toksa\crcr}}$\hfill}}
+
+\def\ldmakestashbox#1{\cleanstash\stripstash\ldboxstash{#1}}
+
+\defc\ldsectionseparator{%
+ \restorecs{table-render}{\strm}%
+ \expandafter\ifx\csname ldstashentry[#2]\endcsname\relax
+ \else
+ \expandafter\expandafter\expandafter\yystashlocal\expandafter\expandafter\expandafter{\csname ldstashentry[#2]\endcsname}%
+ \edef\next{\toksc{&\noexpand\multispan5\toksa{}\the\yystashlocal
+ \noexpand\ldmakestashbox{\cdotfill}\noexpand\quad\cr}}\next\concat\toksa\toksc
+ \fi
+}
+
+\defc\ldsectionseparator{%
+ \expandafter\ifx\csname ldstashentry[#2]\endcsname\relax
+ \else
+ \expandafter\expandafter\expandafter\yystashlocal\expandafter\expandafter\expandafter{\csname ldstashentry[#2]\endcsname}%
+ \appendr\toksa{&\nx\multispan5\toksa{\the\yystashlocal}\nx\ldmakestashbox{\nx\cdotfill}\nx\quad\cr}%
+ \fi
+}
+
+\defc\ldsectionstash{%
+ \restorecs{table-render}{\strm}%
+ \expandafter\ifx\csname ldstashentry[#2]\endcsname\relax
+ \else
+ \expandafter\expandafter\expandafter\yystashlocal\expandafter\expandafter\expandafter{\csname ldstashentry[#2]\endcsname}%
+ \edef\next{\toksc{\sections@header&\noexpand\multispan5\toksa{}\the\yystashlocal
+ \noexpand\ldmakestashbox{\cdotfill}\noexpand\quad\cr}}\next\concat\toksa\toksc
+ \def\sections@header{}%
+ \fi
+}
+
+\defc\ldsectionstash{%
+ \expandafter\ifx\csname ldstashentry[#2]\endcsname\relax
+ \else
+ \expandafter\expandafter\expandafter\yystashlocal\expandafter\expandafter\expandafter{\csname ldstashentry[#2]\endcsname}%
+ \appendr\toksa{\sections@header&\nx\multispan5\toksa{\the\yystashlocal}\nx\ldmakestashbox{\nx\cdotfill}\nx\quad\cr}%
+ \let\sections@header\empty
+ \fi
+}
+
+\restorecs{ld-display}{\ldregexp\ldassignment\ldfill\ldinsertcweb\ldentry}
\toyyunion{ld-parser:sections}
+
+% preprocessing macros: collecing stash and marking variables
+
+\restorecslist{ld-parser-prototypes}\ldunion
+\restorecs{ld-parser-strict}{\insertcweb}
+
+\defc\ldmemory{#1} % memory specification :: \ldmemory{memory spcification}
+
+\defc\ldmemspecstash{%
+ \readstash{#2}%
+ \setbox0 \vbox{\toksa\expandafter{\the\yystashlocal}\cleanstash\stripstash\the\toksa}%
+ \ifdim\ht0=\z@
+ \expandafter\let\csname ldstashentry[#2]\endcsname\relax
+ \else
+ \expandafter\edef\csname ldstashentry[#2]\endcsname{\the\yystashlocal}%
+ \fi
+} % memory spec stash :: \ldmemspecstash{fptr}{sptr}
+
+\defc\ldmemspecseparator{%
+ \readstash{#2}%
+ \setbox0 \vbox{\toksa\expandafter{\the\yystashlocal}\cleanstash\stripstash\the\toksa}%
+ \ifdim\ht0=\z@
+ \expandafter\let\csname ldstashentry[#2]\endcsname\relax
+ \else
+ \expandafter\edef\csname ldstashentry[#2]\endcsname{\the\yystashlocal}%
+ \fi
+} % memory spec separator :: \ldmemspecseparator{fptr}{sptr}
+
+\defc\ldsections{#1} % ld sections :: \ldsections{sections}
+
+\defc\ldsectionseparator{%
+ \readstash{#2}%
+ \setbox0 \vbox{\toksa\expandafter{\the\yystashlocal}\cleanstash\stripstash\the\toksa}%
+ \ifdim\ht0=\z@
+ \expandafter\let\csname ldstashentry[#2]\endcsname\relax
+ \else
+ \expandafter\edef\csname ldstashentry[#2]\endcsname{\the\yystashlocal}%
+ \fi
+} % section separator :: \ldsectionseparator{fptr}{sptr}
+
+\defc\ldsectionstash{%
+ \readstash{#2}%
+ \setbox0 \vbox{\toksa\expandafter{\the\yystashlocal}\cleanstash\stripstash\the\toksa}%
+ \ifdim\ht0=\z@
+ \expandafter\let\csname ldstashentry[#2]\endcsname\relax
+ \else
+ \expandafter\edef\csname ldstashentry[#2]\endcsname{\the\yystashlocal}%
+ \fi
+} % sections spec stash :: \ldsectionstash{fptr}{sptr}
+
+\defc\ldcommandseparator{%
+ \readstash{#2}%
+ \setbox0 \vbox{\toksa\expandafter{\the\yystashlocal}\cleanstash\stripstash\the\toksa}%
+ \ifdim\ht0=\z@
+ \expandafter\let\csname ldstashentry[#2]\endcsname\relax
+ \else
+ \expandafter\edef\csname ldstashentry[#2]\endcsname{\the\yystashlocal}%
+ \fi
+} % command separator :: \ldcommandseparator{fptr}{sptr}{prev command}{next command}
+
+\defc\ldstatement{#1}
+
+\defc\ldnamedsection{\let\ldor\empty#6}
+
+\defc\ldassignment{%
+ {%
+ \let\ldregexp\markldname
+ #1%
+ }{\errmessage{Not an \\ldregexp!}}%
+}
+\defc\ldprovide{%
+ {%
+ \let\ldregexp\markldname
+ #1%
+ }{\errmessage{Not an \\ldregexp!}}%
+}
+
+\defc\ldentry{%
+ {%
+ \let\ldregexp\markldname
+ #1%
+ }{\errmessage{Not an \\ldregexp!}}%
+}
+
+\def\markldname#1{%
+ \markldn@me#1%
+}
+\def\markldn@me#1#2#3#4{%
+ \aftergroup\def\expandafter\aftergroup\csname ldvarname[#2]\endcsname
+}
+
+\let\ldhidden\ldprovide
+\let\ldprovidehid\ldprovide
+
+\toyyunion{ld-parser:restash}
diff --git a/support/splint/examples/ld/lstokenset.sty b/support/splint/examples/ld/lstokenset.sty
index 3ab3ae2d16..441bad2543 100644
--- a/support/splint/examples/ld/lstokenset.sty
+++ b/support/splint/examples/ld/lstokenset.sty
@@ -1,4 +1,4 @@
-% Copyright 2012-2015, Alexander Shibakov
+% Copyright 2012-2020, Alexander Shibakov
% This file is part of SPLinT
%
% SPLinT is free software: you can redistribute it and/or modify
@@ -14,10 +14,11 @@
% You should have received a copy of the GNU General Public License
% along with SPLinT. If not, see <http://www.gnu.org/licenses/>.
-\prettywordpair{OPTIONAL}{{\tt opt}}%
-\prettywordpair{SUFFIX}{{\tt suffix}}%
-\prettywordpair{EXTENDED}{{\tt ext}}%
-\prettywordpair{INTEGER}{{$[\,0\ldots9\,]\ast$}}%
-\prettywordpair{IDENTIFIER}{{$[\,\hbox{\tt a}\ldots\hbox{\tt Z}\,0\ldots9\,]\ast$}}%
-\prettywordpair{WILDCARD}{{{\tt *} {\rm or} {\tt ?}}}%
-\prettywordpair{PERCENT_IDENTIFIER}{{\tt\%$[\,\hbox{\tt a}\ldots\hbox{\tt Z}\,0\ldots9\,]\ast$}}%
+\prettywordpairwvis{OPTIONAL}{{\tt opt}}{opt}%
+\prettywordpairwvis{SUFFIX}{{\tt suffix}}{suffix}%
+\prettywordpairwvis{EXTENDED}{{\tt ext}}{ext}%
+\prettywordpairwvis{INTEGER}{{$[\,0\ldots9\,]\ast$}}{[0...9]*}%
+\prettywordpairwvis{IDENTIFIER}{{$[\,\hbox{\tt a}\ldots\hbox{\tt Z}\,0\ldots9\,]\ast$}}{[a...Z0...9]*}%
+\prettywordpairwvis{META_IDENTIFIER}{{\cyr\lqq{\rm meta identifier}\rqq}}{meta identifier}%
+\prettywordpairwvis{WILDCARD}{{{\tt *} {\rm or} {\tt ?}}}{* or ?}%
+\prettywordpairwvis{PERCENT_IDENTIFIER}{{\tt\%$[\,\hbox{\tt a}\ldots\hbox{\tt Z}\,0\ldots9\,]\ast$}}{\%[a...Z0...9]*}%
diff --git a/support/splint/examples/ld/ltokenset.sty b/support/splint/examples/ld/ltokenset.sty
index d5d0d9b1ee..846dead6c8 100644
--- a/support/splint/examples/ld/ltokenset.sty
+++ b/support/splint/examples/ld/ltokenset.sty
@@ -1,4 +1,4 @@
-% Copyright 2012-2015, Alexander Shibakov
+% Copyright 2012-2020, Alexander Shibakov
% This file is part of SPLinT
%
% SPLinT is free software: you can redistribute it and/or modify
@@ -14,13 +14,21 @@
% You should have received a copy of the GNU General Public License
% along with SPLinT. If not, see <http://www.gnu.org/licenses/>.
-\prettywordpair{comma}{{\tt,}}
-\prettywordpair{semicolon}{{\tt;}}
-\prettywordpair@@{file\_NAME\_list}{\ifinheader\itbold\else\it\fi file\_{\rm name}\_list}
-\prettywordpair@@{high\_level\_library\_NAME\_list}{\ifinheader\itbold\else\it\fi high\_level\_library\_{\rm name}\_list}
-\prettywordpair@@{low\_level\_library\_NAME\_list}{\ifinheader\itbold\else\it\fi low\_level\_library\_{\rm name}\_list}
+\let\currentparsernamespace\parsernamespace
+\let\parsernamespace\indexpseudonamespace % use the correct namespace
+\input yypretty.sty % input standard prettified tokens first
+ % so that we can change their appearance below
+\let\parsernamespace\cwebclinknamespace
+\prettywordpair{.origin&}{{$\cdot\cdot$}}% special . name in \ld\ scripts
+\let\parsernamespace\currentparsernamespace
+
+\prettywordpairwvis{comma}{{\tt,}}{,}
+\prettywordpairwvis{semicolon}{{\tt;}}{;}
+\prettywordpair@@{file\_NAME\_list}{{\ifinheader\itbold\else\it\fi file\_{\rm name}\_list}}
+\prettywordpair@@{high\_level\_library\_NAME\_list}{{\ifinheader\itbold\else\it\fi high\_level\_library\_{\rm name}\_list}}
+\prettywordpair@@{low\_level\_library\_NAME\_list}{{\ifinheader\itbold\else\it\fi low\_level\_library\_{\rm name}\_list}}
\prettywordpair@@{NAME}{{\rm name}}
-\prettywordpair@@{LNAME}{{\rm name$_{\rm L}$}}
+\prettywordpair@@wvis{LNAME}{{\rm name$_{\rm L}$}}{name_L}
\prettywordpair@@{END}{{\rm end}}
\prettywordpair@@{UNARY}{{\rm unary}}
\prettywordpair@@{VERSIONK}{{\tt VERSION}$_{\rm K}$}
@@ -30,23 +38,23 @@
\prettytoken{TARGET}
\prettytoken{ASSERT}
\prettytoken{INSERT}
-\prettywordpair@@{PLUSEQ}{{}$\MRL{+{\K}}${}}
-\prettywordpair@@{MINUSEQ}{{}$\MRL{-{\K}}${}}
-\prettywordpair@@{MULTEQ}{{}$\MRL{\times{\K}}${}}
-\prettywordpair@@{DIVEQ}{{}$\MRL{{\div}{\K}}${}}
-\prettywordpair@@{ANDEQ}{{}$\Xandxeq${}}
-\prettywordpair@@{OREQ}{{}$\Xorxeq${}}
-\prettywordpair@@{LSHIFTEQ}{{}$\MRL{\ll{\K}}${}}
-\prettywordpair@@{RSHIFTEQ}{{}$\MRL{\gg{\K}}${}}
-\prettywordpair@@{NE}{{}$\not=${}}
-\prettywordpair@@{LE}{{}$\leq${}}
-\prettywordpair@@{GE}{{}$\geq${}}
-\prettywordpair@@{EQ}{{}$=${}}
-\prettywordpair@@{OROR}{{}$\V${}}
-\prettywordpair@@{ANDAND}{{}$\W${}}
-\prettywordpair@@{LSHIFT}{{}$\ll${}}
-\prettywordpair@@{RSHIFT}{{}$\gg${}}
-\prettywordpair@@{=}{{}$\K${}}
+\prettywordpair@@wvis{PLUSEQ}{{}$\MRL{+{\K}}${}}{=+}
+\prettywordpair@@wvis{MINUSEQ}{{}$\MRL{-{\K}}${}}{=-}
+\prettywordpair@@wvis{MULTEQ}{{}$\MRL{\times{\K}}${}}{=*}
+\prettywordpair@@wvis{DIVEQ}{{}$\MRL{{\div}{\K}}${}}{=/}
+\prettywordpair@@wvis{ANDEQ}{{}$\Xandxeq${}}{=W}
+\prettywordpair@@wvis{OREQ}{{}$\Xorxeq${}}{=V}
+\prettywordpair@@wvis{LSHIFTEQ}{{}$\MRL{\ll{\K}}${}}{=<<}
+\prettywordpair@@wvis{RSHIFTEQ}{{}$\MRL{\gg{\K}}${}}{=>>}
+\prettywordpair@@wvis{NE}{{}$\not=${}}{= }
+\prettywordpair@@wvis{LE}{{}$\leq${}}{<=}
+\prettywordpair@@wvis{GE}{{}$\geq${}}{>=}
+\prettywordpair@@wvis{EQ}{{}$=${}}{=}
+\prettywordpair@@wvis{OROR}{{}$\V${}}{||}
+\prettywordpair@@wvis{ANDAND}{{}$\W${}}{&&}
+\prettywordpair@@wvis{LSHIFT}{{}$\ll${}}{<<}
+\prettywordpair@@wvis{RSHIFT}{{}$\gg${}}{>>}
+\prettywordpair@@wvis{=}{{}$\K${}}{=:}
\prettywordpair@@{+}{{}$+${}}
\prettywordpair@@{-}{{}$-${}}
\prettywordpair@@{!}{{}$\CM${}}
@@ -54,9 +62,16 @@
\prettywordpair@@{^}{{}$\XOR${}}
\prettywordpair@@{|}{{}$\OR${}}
\prettywordpair@@{&}{{}$\AND${}}
+\prettywordpair@@{\{}{{\ntt@\{}}% the purpose is to adjust the indexing
+\prettywordpair@@{\}}{{\ntt@\}}}% the purpose is to adjust the indexing
+
+% the switches below are sloppy, since the macros in the index
+% read a-z as letters (category 11) whereas the parser records them as
+% non-letters, it would be beter to use category 12 throughout (by,
+% for example passing the context as a stream of character codes
\def\gtsymswitch{%
- \raw exp *left *right\raw {%
+ exp \raw exp *left *right\raw {%
{}$>${}%
}
}
@@ -64,7 +79,7 @@
\def\gtsymswitchdefault{{\tt >}}
\def\ltsymswitch{%
- \raw exp *left *right\raw {%
+ exp \raw exp *left *right\raw {%
{}$<${}%
}
}
@@ -74,17 +89,53 @@
\setspecialcharsfrom\gtsymswitch
\setspecialcharsfrom\ltsymswitch
-\prettywordpair@@{>}{{%
+% the visual key switches below slightly abuse the properties of
+% \yyifsamestring, namely that it ignores the category code of the characters
+
+\prettywordpair@@wvis{>}{{%
\let\default\gtsymswitchdefault
\switchon{#1}\in\gtsymswitch
-}}
+}}{%
+ \yyifsamestring{exp}{#1}{> exp}{%
+ \yyifsamestring{*left}{#1}{> exp}{%
+ \yyifsamestring{*right}{#1}{> exp}{>}%
+ }%
+ }%
+}
-\prettywordpair@@{<}{{%
+\prettywordpair@@wvis{<}{{%
\let\default\ltsymswitchdefault
\switchon{#1}\in\ltsymswitch
-}}
+}}{%
+ \yyifsamestring{exp}{#1}{< exp}{%
+ \yyifsamestring{*left}{#1}{< exp}{%
+ \yyifsamestring{*right}{#1}{< exp}{<}%
+ }%
+ }%
+}
-\prettywordpair@@{*}{\yyifsamestring{exp}{#1}{{}$\times${}}{{\tt *}}}
+\def\astsymswitch{%
+ exp \raw exp *left *right\raw {%
+ {}$\times${}%
+ }
+}
+
+\def\astsymswitchdefault{{\tt *}}
+
+\setspecialcharsfrom\astsymswitch
+
+\prettywordpair@@wvis{*}{%
+ {%
+ \let\default\astsymswitchdefault
+ \switchon{#1}\in\astsymswitch
+ }%
+}{%
+ \yyifsamestring{exp}{#1}{* exp}{%
+ \yyifsamestring{*left}{#1}{* exp}{%
+ \yyifsamestring{*right}{#1}{* exp}{*}%
+ }%
+ }%
+}
\prettywordpair@@{/}{{}$/${}}
diff --git a/support/splint/examples/symbols/Makefile b/support/splint/examples/symbols/Makefile
index d22110baaf..964927bc9d 100644
--- a/support/splint/examples/symbols/Makefile
+++ b/support/splint/examples/symbols/Makefile
@@ -1,20 +1,38 @@
+# Copyright 2012-2020, Alexander Shibakov
+# This file is part of SPLinT
+#
+# SPLinT is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# SPLinT is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with SPLinT. If not, see <http://www.gnu.org/licenses/>.
+
# this Makefile uses a flat directory structure for demonstration
# purposes; the main directory (../..) follows a slightly more
# modular organization scheme.
-SPLINT_ROOT = $(shell pwd)/../..
-SYMBOLS_PREREQS = %.tex %.idx ${SPLINT_XTEXSTYLES} ${SPLINT_ROOT}/cweb/bo.tok symtoks.sty
-SYMBOLS_PREREQS += ${SPLINT_XPTABLES} ${SPLINT_XLTABLES} symmap.sty ${SPLINT_ROOT}/cweb/bg.y
+SYMBOLS_PREREQS = %.tex %.idx ${SPLINT_XTEXSTYLES} ${SPLINT_ROOT}cweb/bo.tok ${SPLINT_ROOT}cweb/fo.tok symtoks.sty
+SYMBOLS_PREREQS += ${SPLINT_XPTABLES} ${SPLINT_XLTABLES} symmap.sty symtricks.sty symfm.sty slimbo.sty
+SYMBOLS_PREREQS += ${SPLINT_ROOT}cweb/fil.l ${SPLINT_ROOT}cweb/bg.y ${SPLINT_ROOT}cweb/lo.l
-include ${SPLINT_ROOT}/makefile.inc
+include ../../makefile.inc
# rules specific to this example
+%.tex: %.x
+
%.tex: %.w
-%.tex %.idx: %.w
- ${CWEAVE} $<
+%.tex %.idx: %.x alphas.hx
+ -${CWEAVE} $<
%.gdx: ${SYMBOLS_PREREQS}
${TEX} $*.tex
@@ -22,6 +40,9 @@ include ${SPLINT_ROOT}/makefile.inc
%.pdf %.sns: ${SYMBOLS_PREREQS} %.gdy
${PDFTEX} $*.tex && touch $*.gdy && touch $*.pdf
+alphas.hx:
+ ${MISCCW} --alpha-list --alpha-length=1 $@
+
docs: symbols.pdf
clean: clean_core
@@ -32,6 +53,9 @@ mostlyclean: clean_temp
distclean: clean
cd ${SPLINT_ROOT} && ${MAKE} clean
-.PRECIOUS: symbols.gdy
+.PRECIOUS: ${SPLINT_ROOT}cweb/fo.tok ${SPLINT_ROOT}cweb/bo.tok ${SPLINT_ROOT}cweb/lo.l \
+ ${SPLINT_ROOT}cweb/fil.l ${SPLINT_ROOT}cweb/dyytab.tex ${SPLINT_ROOT}cweb/gyytab.tex \
+ ${SPLINT_ROOT}cweb/fyytab.tex symbols.gdy
-.INTERMEDIATE: symbols.gdx
+.INTERMEDIATE:
+#.INTERMEDIATE: symbols.gdx
diff --git a/support/splint/examples/symbols/slimbo.sty b/support/splint/examples/symbols/slimbo.sty
new file mode 100644
index 0000000000..48da360f55
--- /dev/null
+++ b/support/splint/examples/symbols/slimbo.sty
@@ -0,0 +1,16 @@
+% Copyright 2012-2020, Alexander Shibakov
+% This file is part of SPLinT
+%
+% SPLinT is free software: you can redistribute it and/or modify
+% it under the terms of the GNU General Public License as published by
+% the Free Software Foundation, either version 3 of the License, or
+% (at your option) any later version.
+%
+% SPLinT is distributed in the hope that it will be useful,
+% but WITHOUT ANY WARRANTY; without even the implied warranty of
+% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+% GNU General Public License for more details.
+%
+% You should have received a copy of the GNU General Public License
+% along with SPLinT. If not, see <http://www.gnu.org/licenses/>.
+
diff --git a/support/splint/examples/symbols/symbols.w b/support/splint/examples/symbols/symbols.w
index 47c210e4f8..dc58adc0bd 100644
--- a/support/splint/examples/symbols/symbols.w
+++ b/support/splint/examples/symbols/symbols.w
@@ -1,4 +1,4 @@
-% Copyright 2012-2014, Alexander Shibakov
+% Copyright 2012-2020, Alexander Shibakov
% This file is part of SPLinT
%
% SPLinT is free software: you can redistribute it and/or modify
@@ -15,17 +15,40 @@
% 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
+
\input limbo.sty
\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
+\let\hostparsernamespace\flexnamespace
+ \let\tokeneq\tokeneqpretty
+\let\optstrextra\optstrextraesc
+ %\input fo.tok
+ \input ftokenset.sty %
+\let\parsernamespace\flexpseudorenamespace
+\let\hostparsernamespace\flexpseudorenamespace
+\input fretokenset.sty % regular expression names
\def\symnamespace{[symbols]}
\let\currentnamespace\parsernamespace
\let\parsernamespace\symnamespace
- \input symtoks.sty %
+ \input symtoks.sty %
+ \let\tokeneq\tokeneqpretty
+ \let\optstrextra\optstrextraesc
+ \input fo.tok
+ \input ftokenset.sty
+\let\parsernamespace\indexpseudonamespace
+ \input yypretty.sty
\let\parsernamespace\currentnamespace
\let\hostparsernamespace\symnamespace % the namespace where tokens are looked up
% for typesetting purposes
@@ -38,17 +61,60 @@
}
\let\oldN\N
-\let\N\textN
\let\M\textM
+\let\N\chapterN
+
+\font\ttit=cmitt10
\defreserved{Y}{\.{Y}}
-@** Introduction. \setupfootnotes
+\input symfm.sty
+\input slimbo.sty
+\setupfootnotes
+
+@** Introduction.
+The manual supplied with \splint\ presents an outline of the main
+features of the package. Its main focus, however, is on the
+general parser design using the package. The two parsers that come
+with \splint, for pretty printing \bison\ and \flex\ are used as an
+illustration only. A full featured parser design of a parser for
+pretty printing linker scripts does not treat the \bison\ and \flex\
+parsers in any detail, either. Partially filling this gap is the main
+reason for this example\footnote{A secondary reason is to provide a testbed
+for typesetting experiments.}.
+
The same parser and lexer (with a slightly different input routine)
-are used to typeset examples of productions in text.
-Some of the features of this parser
-are collected below for future reference. One might keep this section
-handy when typesetting his own examples (for example, it is probably
+may be used to typeset \bison\ and \flex\ examples in text, as
+well. There are some subtle differences between doing it inside a
+straightforward \TeX\ file and a \CWEB\ section. The obvious one of
+these is the requirement to use \.{@@@@} whenever a single \.{@@} is
+called for in the \TeX\ input. See below for further examples.
+
+Typesetting grammar examples also calls for a wider range of
+typographic devices than the ones used for pretty printing \bison\
+(and \flex) code. Formatting and modifying the typesetting of \bison\
+productions and \flex\ scanner rules is given some consideration as
+well.
+
+While this example is rather short, it has enough variety to present
+the indexing features of the macros supplied with \splint in some
+detail.
+
+Finally, a few macros, hastily thrown together, show how \CWEB\ may be
+used to create the documentation with a `book feel', including the
+custom typesetting of chapter headers, sectioned index, etc. Not all
+of the features mentioned above may be desired for any one project but
+in case some of them are, these examples provide a convenient place to
+consult about the details of the implementaion for one's own use.
+
+%\let\N\textN
+
+@s TeX_ TeX
+
+@* Examples of \bison\ parser output.
+Some of the features specific to the use of the \bison\ parser for this purpose
+are explained below. One might find it useful to keep this section
+as a quick reference while typesetting his own examples (for example, it is probably
unintuitive that `\.{`}' produces `\.{\yl}' but there is simply no
way to use `\.{\yl}' as a character inside the \TeX\ section of \CWEB).
The first, rather eclectic and lengthy example demonstrates various
@@ -89,7 +155,7 @@ and_another:
\%token bogey1 bogey2 ;
\%type <some> TOKEN ANOTHER ;
\%start inputer;
-\stashed{\rm Example 1 of flushed code}\sflush{F}{flush this}
+\stashed{\rm Example 1 of flushed code (delayed till next \.{\\stashed} is encountered).}\sflush{F}{flush this}
\%default-prec;
\%no-default-prec;
\stashed{\rm Example 2 of flushed code}
@@ -112,9 +178,9 @@ and_another:
\beginprod
\%expect 0x137;
\%expect-rr 17;
-\%lex-param \{\stashed{|int number;|}\};
-\%define var.1 \{ \stashed{ |func3(8, "string"){n = m++;};| } \}
-\%union var.2 \{ \stashed{\rm |int a, b, c;|\6 |char a_char;|} \}
+\%lex-param \{\stashed{\rm|int number;|}\};
+\%define var.1 \{ \stashed{\rm |func3(8, "string"){n = m++;}| } \}
+\%union var.2 \{ \stashed{\rm |int a, b, c;|\6\rm |char a_char;|\C{font switching must be applied to every line (see the source)}} \}
\%\{ \stashed{\rm |int a, b, c;|\6 |char a_char;|} \%\}
\endprod
%
@@ -128,7 +194,8 @@ variations enabled by such context.
\nx\restorecolor
}%
\def\dset#1{%
- $\nx\underbrace{\hbox{#1}}_{{\nx\rm identifier:\ \the\toksc}}$%
+ $\nx\underbrace{\hbox{#1}}_{{\nx\rm id:\ \hbox{\sixrm\the\toksa}}}$% TODO: find a better way to switch
+ % the font family explicitly
}%
\def\esets#1{%
\nx\beginub#1%
@@ -139,6 +206,8 @@ variations enabled by such context.
\def\beginub#1\endub{%
$\underbrace{\hbox{#1}}_{\rm a\ group}$%
}
+\checktabletrue
+%\yyflexdebugtrue
\smallskip
\beginprod
\skipheader
@@ -150,11 +219,38 @@ ghost:
\formatlocal{\let\termmetastyle\esete}this\formatlocal{\restorecs{table-render}\termmetastyle}one\{\stashed{\rm|assign(x, y, z);|}\}
;
\endprod
+\checktablefalse
+\yyflexdebugfalse
+\medskip
+\noindent Next, an incomplete listing of the characters that can be
+typeset, as well as the way to typeset\footnote{Please note that we are discussing the issues of typesetting
+{\let\tt\tti\it examples of \bison\ input in text\/} at the moment; the parser reading the code from
+{\let\tt\tti\it the \Cee\ portion of the \CWEB\ input\/} typesets these symbols automaticaly.} them (only the `tricky' cases
+are listed). The use of `\.{`}' to typeset `\.{\yl}' deserves a special note---\CWEB's rules make it
+nearly impossible to use `\.{\yl}' in the \TeX\ portion of the program. One way to avoid using this
+relatively unnatural notation is to put the production example in a separate \TeX\ file as demonstrated
+by the \prodstyle{symbol\_tricks2} example below, included from \.{symtricks.sty}. The same example uses
+a few parser facilities to override the typesetting defaults of the standard production demo setup (such as using
+\.{\\insertraw} to reset the last action display).
+
+The uniform alignment across several productions below was accomplished with \.{\\setglobalalignrules} by using
+the value of \.{\\gaglue} set by a copy of one of the productions.
+\begingroup
+\setbox0\hbox{\ninepoint look: $\rightarrow\,$\X{$\infty$}:See this example to deduce $\ldots$\X}%
+\setbox0=\vbox{
\medskip
-\noindent Finally, an incomplete listing of the characters that can be
-typeset, as well as the way to typeset them. The use of `\.{`}' to
-typeset `\.{\yl}' deserves a special note---\CWEB's rules make it
-nearly impossible to use `\.{\yl}' in the \TeX\ portion of the program.
+\beginprod
+\insertraw{\let\stashnext\stashnextwithspace}%
+line_breaking_and_symbols:
+ GEN\stashed{|stash!=0|}ERIC '(' expression',' \ ss another es')' \
+ \insertraw{\let\stashnext\stashnextwithnothingnx}%
+ ` 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);|} \}
+%
+\endprod
+\expandafter
+}%
+\expandafter\setglobalalignrules\expandafter{\the\gaglue}%
\medskip
\tomainparser
\prettywordpair{GENERIC}{\_Generic}
@@ -185,9 +281,169 @@ symbol_tricks:
` ' ' \
;
\endprod
+\medskip
+\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.
+\medskip
+\beginprod
+line_breaking_and_symbols:
+ GEN\stashed{|stash!=0|}ERIC '(' expression',' \ ss another es')' \
+ ` 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);|} \}
+%
+\endprod
+\medskip
+\noindent The behavior or the input routine mentioned above is adjustable by redefining \.{\\stashnext}. These adjustments may
+be even made locally, for small portions of the input only, using \.{\\insertraw}.
+Here is the same set of productions with stash producing a space in the middle of \prodstyle{GENERIC} reverting to the usual,
+`invisible' behavior by the time \.{\\yyinput} reaches \prodstyle{inline\_c} (that has
+`\.{\\stashed\{}$\,$look: $\rightarrow\,$\.{\}}' inserted before~\prodstyle{\_c}):
+\medskip
+\beginprod
+\insertraw{\let\stashnext\stashnextwithspace}%
+line_breaking_and_symbols:
+ GEN\stashed{|stash!=0|}ERIC '(' expression',' \ ss another es')' \
+ \insertraw{\let\stashnext\stashnextwithnothingnx}%
+ ` 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);|} \}
+%
+\endprod
+\endgroup
+
+@* Examples of \flex\ parser output. Standalone regular expressions can be displayed using \.{\\flexrestyle}:
+{\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 `\.{\^}', `\.{\_}', `\.{\$}', `\.{\#}',
+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
+{%
+\let\flbraceccl\flbraceccldemo\savecs{flexparser-re}\flbraceccl
+`\flexrestyle{[\\\\]}'%
+} as might have been intended (i.e.~the bracket, \.{]} is treated as an ordinary character, and not as part of
+the syntax for a character class). This is because the escape character (\.{\\}) serves a special r\^ole in \flex\ so
+to get the desired effect one must type \.{\\\\\\\\]}. The use of `\.{\yl}' deserves a special mention. As was pointed out above,
+this character is nearly inaccessible in the \TeX\ mode of \CTANGLE, which resulted in the following workaround. To use
+`\.{\yl}' in the examples typeset inside the \TeX\ portion of the \CWEB\ input, one should type `\.{`}'. To use `\.{`}', type
+`\.{\\`}' 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 `\.{\\`}'.
+Many of the points made above may become more transparent after examining the source of the example following this sentence.
+\medskip
+\cdebugtrue
+\beginflex
+\stashed{\C{ Comments are possible with some effort }}
+<FAKE\stashed{\X{$x_m\ldots x_n$}:Names can have their own sections\X}>\{
+ ^\{WS\}([\ a-x#\\\\]`[\`0-9\\`])\\n\\r \{\stashed{|x=@t}2^y{@>|}\}
+ ^"/*"$ \{\stashed{|start_comment(@tWatch out for `\.{\yl}'!@>)|}\}
+\}
+\endflex
+\cdebugfalse
+\medskip
+\noindent While, technically speaking, \flex\ has a `parser stack' in the sense that in the event of an unsuccessful parsing pass
+with a `section 2' parser, a `section 1' parser may be attempted, this strategy often fails. As a short excerpt immediately
+following this section shows, `section 1' input may also pass for syntactically correct `section 2' \flex\ code (although with
+entirely wrong semantics). Thus a better `lazy' approach is to mark all \flex\ code as `section 1' instead.
+@<Definitions for \flex\ input lexer@>=
+@G(fs1)
+WS [[:blank:]]+
+OPTWS [[:blank:]]*
+NOT_WS [^[:blank:]\r\n]
+
+NL \r?\n
+
+NAME ([[:alpha:]_][[:alnum:]_-]*)
+NOT_NAME [^[:alpha:]_*\n]+
+
+SCNAME {NAME}
+
+ESCSEQ (\\([^\n]|[0-7]{1,3}|x[[:xdigit:]]{1,2}))
+
+FIRST_CCL_CHAR ([^\\\n]|{ESCSEQ})
+CCL_CHAR ([^\\\n\]]|{ESCSEQ})
+CCL_EXPR ("[:"^?[[:alpha:]]+":]")
+
+LEXOPT [porkacne]
+
+M4QSTART "[["
+M4QEND "]]"
+
+@ The first three lines of the previous section successfully parse as section~2 input.
+\parseverbosetrue
+@<As section 2@>=
+@G(fs2)
+WS [[:blank:]]+
+OPTWS [[:blank:]]*
+NOT_WS [^[:blank:]\r\n]
+@ @<Patterns for \flex\ lexer@>=
+@G(fs1)
+/* Comment before the section is put after the states list */
+<INITIAL@>@<Definitions for \flex\ input lexer@>@=>{
+ ^{WS} {@> @[TeX_( "/flindented@@codetrue/yyBEGIN{CODEBLOCK}/yylexnext" );@]@=}
+ ^"/*" {@> @[TeX_( "/yypushstate{COMMENT}/yylexnext" );@]@=}
+ ^#{OPTWS}line{WS} {@> @[TeX_( "/yypushstate{LINEDIR}/yylexnext" );@]@=}
+ ^"%s"{NAME}? {@> @[TeX_( "/yylexreturnptr{SCDECL}" );@]@=}
+ ^"%x"{NAME}? {@> @[TeX_( "/yylexreturnptr{XSCDECL}" );@]@=}
+ ^"%{".*{NL} {@> @<Start a \Cee\ code section@> @=}
+
+ ^"%top"[[:blank:]]*"{"[[:blank:]]*{NL} {@> @<Begin the \prodstyle{\%top} directive@> @=}
+ ^"%top".* {@> @[TeX_( "/yyfatal{malformed '/harmlesscomment top' directive}" );@] @=}
+
+ {WS} {@> @[;@]/* discard */ @=}
+
+ ^"%%".* {@> @<Start section 2@> @=}
+
+ ^"%pointer".*{NL} {@> @[TeX_( "/flinc@@linenum/yylexreturn{POINTER_OP}" );@]@=}
+ ^"%array".*{NL} {@> @[TeX_( "/flinc@@linenum/yylexreturn{ARRAY_OP}" );@]@=}
+
+ ^"%option" {@> @[TeX_( "/yyBEGIN{OPTION}/yylexreturn{OPTION_OP}" );@]@=}
+
+ ^"%"{LEXOPT}{OPTWS}[[:digit:]]*{OPTWS}{NL} {@> @[TeX_( "/flinc@@linenum/yyflexoptreturn{OPT_DEPRECATED}" );@]@=}
+ ^"%"{LEXOPT}{WS}.*{NL} {@> @[TeX_( "/flinc@@linenum/yyflexoptreturn{OPT_DEPRECATED}" );@]@=}
+
+ ^"%"[^porksexcan{}].* {@> @[TeX_( "/yyfatal{unrecognized '/harmlesscomment' directive: /the/yytext}" );@] @=}
+
+ ^{NAME} {@> @<Copy the name and start a definition@> @=}
+ {SCNAME} @> @[TeX_( "/RETURNNAME" );@] @=
+ ^{OPTWS}{NL} {@> @[TeX_( "/flinc@@linenum/yylexnext" );@]/* allows blank lines in section 1 */@=}
+ {OPTWS}{NL} {@> @[TeX_( "/flinc@@linenum/yylexnext" );@]/* maybe end of comment line */@=}
+}
+
+@ @<Start a \Cee\ code section@>=
+
+@ @<Copy the name and start a definition@>=
+
+@ @<Begin the \prodstyle{\%top} directive@>=
+
+@ @<Start section 2@>=
+@q Include the list of index section markers; this is a hack to get around @>
+@q the lack of control over the generation of \CWEB's index; the correct order @>
+@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
+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
+\.{cwebmac.tex} pass the actual typesetting commands to \TeX, \splint\
+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
-@** Index. Totally superfluous in this case.
+\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}
diff --git a/support/splint/examples/symbols/symfm.sty b/support/splint/examples/symbols/symfm.sty
new file mode 100644
index 0000000000..9cfeacbeaa
--- /dev/null
+++ b/support/splint/examples/symbols/symfm.sty
@@ -0,0 +1,64 @@
+% Copyright 2012-2020, Alexander Shibakov
+% This file is part of SPLinT
+%
+% SPLinT is free software: you can redistribute it and/or modify
+% it under the terms of the GNU General Public License as published by
+% the Free Software Foundation, either version 3 of the License, or
+% (at your option) any later version.
+%
+% SPLinT is distributed in the hope that it will be useful,
+% but WITHOUT ANY WARRANTY; without even the implied warranty of
+% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+% GNU General Public License for more details.
+%
+% You should have received a copy of the GNU General Public License
+% along with SPLinT. If not, see <http://www.gnu.org/licenses/>.
+
+\begingroup
+\footline{\hfill}\headline{\hfill}\vfill
+\newread\versionstream
+\immediate\openin\versionstream=VERSION
+\read\versionstream to \version
+\message{<\version>}%
+\def\undot#1.#2.#3{#1\kern-.3pc.\kern-.3pc#2\kern-.3pc.\kern-.3pc#3\ignorespaces}
+\chardef\amp=`\&
+\titletrue
+
+% a few more fonts: everybody has these.
+
+\font\euror=cmr10
+\font\eurow=cmr10
+\font\eurob=cmbr10
+\font\eurobtwelve=cmbr10 at 16pt
+{\font\cminch=cmr10 at 1in
+\font\cmhuge=cmr10 at 1in
+\def\strut{\vrule height 17pt depth 7pt width 0pt}%
+\noindent
+\hbox to \hsize{%
+ \valign{#\vfil\cr
+ \halign{%
+ \hfil\eurobtwelve\strut#\cr
+ \noalign{\hrule height 5pt\vskip0pt plus1pt}%
+ S\kern-.1pc\hfill P\hfill L\hfill I\hfill N\hfill T\cr
+ \noalign{\hrule height .9pt\vskip0pt plus1pt}%
+ reference\cr
+ \noalign{\hrule height 5pt\vskip0pt plus1pt}%
+ }\cr
+ \noalign{\hfill}%
+ \vbox{\hbox{\eurobtwelve v e r s i o n\ \cminch \expandafter\undot\version}}\cr
+ }%
+}%
+%
+\vfill
+\newdimen\tempdimen
+\def\hrfill#1{\leaders\hrule#1\hfill}
+\hbox to \hsize{\cmhuge S\hfil\kern-3.9pc Y\hfil\kern-3.3pc M\hfil\kern-3.3pc B\hfil\kern-3.5pc O\hfil\kern-3.7pc L\hfil\kern-3.5pc S}
+\vfill
+\hrule height .3pc
+\kern .2pc
+\hbox to \hsize{\leaders\hrule height 15pt\hfill\raise5pt\llap{\hbox to
+\hsize{\euror\colorwhite{$\;$Alex Shibakov\hfill\ifcase\month \or
+January \or February\or March\or April\or May\or June\or July\or August\or September\or
+October\or November \or December\fi\ \number\day, \number\year$\,$}}}}}\eject
+\endgroup
+\titletrue
diff --git a/support/splint/examples/symbols/symmap.sty b/support/splint/examples/symbols/symmap.sty
index 12261be656..450dd9a649 100644
--- a/support/splint/examples/symbols/symmap.sty
+++ b/support/splint/examples/symbols/symmap.sty
@@ -1,4 +1,4 @@
-% Copyright 2012-2014, Alexander Shibakov
+% Copyright 2012-2020, Alexander Shibakov
% This file is part of SPLinT
%
% SPLinT is free software: you can redistribute it and/or modify
@@ -54,17 +54,15 @@
\input cweb/gyytab.tex % this should be the parser that will be used later
% in this case it is just an example
\edef\tointermediateparser{%
- \noexpand\savefullstate % unnecessary
- \noexpand\savefullstateextra % unnecessary
\let\noexpand\parsernamespace\noexpand\inamespace % switch to the new namespace
\the\pinittoks % restore all the tables, tokens and constants, and stacks
\let\noexpand\getcurrentparser\noexpand\tointermediateparser
}%
- \settokens % this simply assign values to tokens where the name of each token is taken out of yytname ...
- \input \drvname.tok % this will set up token equivalences in the namespace above ...
- % those are the values gleaned during the bootstrapping stage.
- % in the general case, one needs to run a bootsrapping (or similar)
- % parser to extract the token information.
+ \settokens % this simply assigns values to tokens where the name of each token is taken out of yytname ...
+ \input bo.tok % this will set up token equivalences in the namespace above ...
+ % those are the values gleaned during the bootstrapping stage.
+ % in the general case, one needs to run a bootsrapping (or similar)
+ % parser to extract the token information.
\optimizeall % this is necessary for correct rule listing in the output stage:
% otherwise \fgetelemof will use the current value of the \yy... token registers which
% will hold the values of the full parser that is loaded next
@@ -72,7 +70,7 @@
\listrules % ... to be used while listing the rules
% note that we do not bother to set up a lexer for this parser (even though we already have one and the
% \optimizeall macro above will create a set of associative tables for it---this is merely an unwanted
- % sideffect); after the rules have been listed, the intemediate parser in no longer needed.
+ % sideffect); after the rules have been listed, the intemediate parser is no longer needed.
%\showthe\newsymswitch
\def\fullnamespace{[full]}% this is the parser that parses the bison grammar from a raw
% bison file; it can play a role of the bootstrap parser for
@@ -96,7 +94,7 @@
% part of the file, this can simply be disabled
\settokens
\setflexstates % the main lexer can be reused in this case; the states still need to be set up
- \input \drvname.tok % set up the tokens for the bison grammar parser
+ \input bo.tok % set up the tokens for the bison grammar parser
\newparserstate
\newlexerstate
\newlexerstateextra
@@ -104,8 +102,6 @@
\setnulstack{yyirulestack}%
%
\edef\tofullparser{%
- \noexpand\savefullstate
- \noexpand\savefullstateextra
\let\noexpand\parsernamespace\noexpand\fullnamespace % switch to the new namespace
\the\pinittoks % restore all the tables, tokens and constants, and stacks
\let\noexpand\getcurrentparser\noexpand\tofullparser
@@ -140,7 +136,7 @@
\fi
}%
% build the command to create the symbolic name switch
- \toksc{\tofullparser\parserinit
+ \toksc{\tofullparser\basicparserinit\bisonparserinit\bisonparserdatainit
\let\yyinputold\yyinput
\let\yyinput\yyinputtrivial % a demo of a stripped down, slightly faster input routine
\doascii{11}\expandafter\yyparse}%
@@ -161,4 +157,53 @@
{\newlinechar=`\^^J \immediate\write\symbolicswitch{\the\setsncommands\the\unsetsncommands}}%
\immediate\closeout\symbolicswitch
\tomainparser % go back to the main parser
+%
+% \flex\ parser test
+%
+ {%
+ \toflexreparser
+ \basicparserinit
+ \flexreparserinit
+ \flexreparserdatainit
+ \yyBEGIN{SECT2}%
+ \flin@ruletrue
+ % special status of `\yl' in \CWEB\ makes the following workaround necessary
+ % if the code is unsed inside a \CWEB\ file
+ %|@t}\expandafter\yyparse\space [a-b]*(c|d|e)?\yyeof\yyeof\endparseinput\endparse{@>|
+ \expandafter\yyparse\space [a-b]*(c|d|e)?\yyeof\yyeof\endparseinput\endparse
+ \ifyyparsefail\else
+ \ferrmessage{done processing flex}%
+ \fi
+ }%
+%
+ {%
+ \def\flnamespace{[flex]}
+ \let\parsernamespace\flnamespace
+ \toflexparser
+ \basicparserinit
+ %\flexparserinit
+ \flexparserdatainit
+ \yylessusedtrue % TODO: put it in the \genericparser command
+ \let\f@nishparse\finishparse
+ \def\finishparse{\endinput\message{end of input}\relax\let\cleanupcs\f@nishparse}%
+ \def\next{%
+ \catcode`\\=12
+ \catcode`\^^J=12
+ \catcode`\%=12
+ \catcode`\^^M=12
+ \catcode`\{=12
+ \catcode`\}=12
+ \catcode`\#=12
+ \catcode`\_=12
+ %\yydebugmost
+ \expandafter\yyparse\input cweb/lo.l \cleanupcs\yyeof\yyeof\endparseinput\endparse % note that the space after the file name is necessary
+ \ifyyparsefail
+ \errmessage{stopped}%
+ \fi
+ \yydebugnone
+ \basicparserinit
+ \expandafter\yyparse\input cweb/fil.l \cleanupcs\yyeof\yyeof\endparseinput\endparse
+ % note that the space after the file name is necessary
+ }\expandafter\next % to lock the \catcode of the brace
+ }%
\fi
diff --git a/support/splint/examples/symbols/symtoks.sty b/support/splint/examples/symbols/symtoks.sty
index 8d6cdc5596..3ab9b142c7 100644
--- a/support/splint/examples/symbols/symtoks.sty
+++ b/support/splint/examples/symbols/symtoks.sty
@@ -1,3 +1,19 @@
+% Copyright 2012-2020, Alexander Shibakov
+% This file is part of SPLinT
+%
+% SPLinT is free software: you can redistribute it and/or modify
+% it under the terms of the GNU General Public License as published by
+% the Free Software Foundation, either version 3 of the License, or
+% (at your option) any later version.
+%
+% SPLinT is distributed in the hope that it will be useful,
+% but WITHOUT ANY WARRANTY; without even the implied warranty of
+% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+% GNU General Public License for more details.
+%
+% You should have received a copy of the GNU General Public License
+% along with SPLinT. If not, see <http://www.gnu.org/licenses/>.
+
\prettywordpair{ANOTHER}{{\rm(}another\rm{)}}
\prettywordpair{TOKEN}{$\langle${\it token}$\rangle$}
\prettywordpair{GENERIC}{{\tt \_Generic}}
diff --git a/support/splint/examples/symbols/symtricks.sty b/support/splint/examples/symbols/symtricks.sty
new file mode 100644
index 0000000000..04bf5c5ac1
--- /dev/null
+++ b/support/splint/examples/symbols/symtricks.sty
@@ -0,0 +1,23 @@
+% Copyright 2012-2020, Alexander Shibakov
+% This file is part of SPLinT
+%
+% SPLinT is free software: you can redistribute it and/or modify
+% it under the terms of the GNU General Public License as published by
+% the Free Software Foundation, either version 3 of the License, or
+% (at your option) any later version.
+%
+% SPLinT is distributed in the hope that it will be useful,
+% but WITHOUT ANY WARRANTY; without even the implied warranty of
+% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+% GNU General Public License for more details.
+%
+% You should have received a copy of the GNU General Public License
+% along with SPLinT. If not, see <http://www.gnu.org/licenses/>.
+
+\beginprod
+\insertraw{\showlastactiontrue}\format{\inline\flatten}
+symbol_tricks2:
+ '|' | other \{\stashed{$\displaystyle e^{-1}=\lim\limits_{n\to\infty}\left({n\over n+1}\right)^n$}\}
+ ;
+\endprod
+\medskip
diff --git a/support/splint/examples/types/Makefile b/support/splint/examples/types/Makefile
new file mode 100644
index 0000000000..3dd52abeed
--- /dev/null
+++ b/support/splint/examples/types/Makefile
@@ -0,0 +1,30 @@
+# Copyright 2012-2020, Alexander Shibakov
+# This file is part of SPLinT
+#
+# SPLinT is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# SPLinT is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with SPLinT. If not, see <http://www.gnu.org/licenses/>.
+
+# this Makefile uses a flat directory structure for demonstration
+# purposes; the main directory (../..) follows a slightly more
+# modular organization scheme.
+
+# a rudimentary test for the tree evaluation macros and 'bignum'
+# arithmetic; mainly a debugging tool for simple parsers
+
+include ../../makefile.inc
+
+test:
+ ${TEX} test.sty
+
+
+clean: clean_core
diff --git a/support/splint/examples/types/basic.sty b/support/splint/examples/types/basic.sty
index 856faf2374..ba0decc237 100644
--- a/support/splint/examples/types/basic.sty
+++ b/support/splint/examples/types/basic.sty
@@ -1,4 +1,4 @@
-% Copyright 2012-2014, Alexander Shibakov
+% Copyright 2012-2020, Alexander Shibakov
% This file is part of SPLinT
%
% SPLinT is free software: you can redistribute it and/or modify
@@ -208,7 +208,7 @@
% \sdigit a b c which expands to the two digits of a + b + c
% where c \in \{0, 1\}.
% altogether there are 1200 sequences in use. this number can be
-% reduced to under 500 at the expence of more sophisticated
+% reduced to under 500 at the expense of more sophisticated
% conditionals:
% o in the case of \xdigit, a == 1 or b == 1 reduces \xdigit a b c to
% \sdigit a c 0 (for b == 1), whereas a == 0 or b == 0 makes
diff --git a/support/splint/examples/types/test.sty b/support/splint/examples/types/test.sty
index 8a7859d3d6..018b299c29 100644
--- a/support/splint/examples/types/test.sty
+++ b/support/splint/examples/types/test.sty
@@ -1,4 +1,4 @@
-% Copyright 2012-2014, Alexander Shibakov
+% Copyright 2012-2020, Alexander Shibakov
% This file is part of SPLinT
%
% SPLinT is free software: you can redistribute it and/or modify
@@ -16,8 +16,9 @@
% some examples of the `tree evaluator' and the `expandable arithmetic' macros
-\input ../../yycommon.sty
-\input ../../yymisc.sty
+\input ../../tex/yycommon.sty
+\input ../../tex/trt1.sty
+\input ../../tex/yymisc.sty
\input basic.sty
\input tree.sty
diff --git a/support/splint/examples/types/tree.sty b/support/splint/examples/types/tree.sty
index 46a4c94a97..68171e6a2d 100644
--- a/support/splint/examples/types/tree.sty
+++ b/support/splint/examples/types/tree.sty
@@ -1,4 +1,4 @@
-% Copyright 2012-2014, Alexander Shibakov
+% Copyright 2012-2020, Alexander Shibakov
% This file is part of SPLinT
%
% SPLinT is free software: you can redistribute it and/or modify
diff --git a/support/splint/examples/xxpression/Makefile b/support/splint/examples/xxpression/Makefile
index 4450e3126d..8d8b6877c6 100644
--- a/support/splint/examples/xxpression/Makefile
+++ b/support/splint/examples/xxpression/Makefile
@@ -1,12 +1,28 @@
+# Copyright 2012-2020, Alexander Shibakov
+# This file is part of SPLinT
+#
+# SPLinT is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# SPLinT is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with SPLinT. If not, see <http://www.gnu.org/licenses/>.
+
# this Makefile uses a flat directory structure for demonstration
# purposes; the main directory (../..) contains a slightly more
# modular organization.
-SPLINT_ROOT = $(shell pwd)/../..
-XXPRESSION_PREREQS = %.tex %.scn %.idx %.tok ${SPLINT_XPTABLES} ${SPLINT_XLTABLES} ${SPLINT_ROOT}/cweb/bo.tok xymmap.sty xtoks.sty
+XXPRESSION_PREREQS = %.tex %.scn %.idx %.tok ${SPLINT_XPTABLES} ${SPLINT_XLTABLES}
+XXPRESSION_PREREQS += ${SPLINT_ROOT}cweb/bo.tok ${SPLINT_ROOT}cweb/fo.tok xymmap.sty xtoks.sty
-include ${SPLINT_ROOT}/makefile.inc
-include ${SPLINT_ROOT}/makefile.loc
+include ../../makefile.inc
+include ${SPLINT_ROOT}makefile.loc
# rules specific to this example
@@ -20,13 +36,13 @@ step2: ptabout ltabout
step3: ltab.tex ptab.tex
step4: xymbols.sns
-ptabout: ${SPLINT_ROOT}/cweb/mkeparser.c ${PARSER}.c
+ptabout: ${SPLINT_ROOT}cweb/mkeparser.c ${PARSER}.c
${CC} -DPARSER_FILE=\"../examples/xxpression/$(lastword $^)\" -DYYPARSE_PARAMETERS= -o $@ $<
ptab.tex: ptabout
$< --optimize-actions $@
-ltabout: ${SPLINT_ROOT}/cweb/mkscanner.c ${LEXER}.c
+ltabout: ${SPLINT_ROOT}cweb/mkscanner.c ${LEXER}.c
${CC} -DLEXER_FILE=\"../examples/xxpression/$(lastword $^)\" -o $@ $<
ltab.tex: ltabout
@@ -36,28 +52,35 @@ ${LEXER}.c: ${LEXER}.l
${FLEX} -o $@ $<
test.tex xymbols.tex \
-${PARSER}.yy ${LEXER}.ll: xxpression.x
+${PARSER}.yy ${LEXER}.ll: xxpression.x alphas.hx
@${CTANGLE} $<
${UNLINE} test.txx test.tex
${UNLINE} xymbols.txx xymbols.tex
-xymbols.sns: xymbols.tex xxpression.tok ${SPLINT_ROOT}/cweb/bo.tok ${SPLINT_XPTABLES} ${SPLINT_XLTABLES} ptab.tex
+xymbols.sns: xymbols.tex xxpression.tok ${SPLINT_ROOT}cweb/bo.tok ${SPLINT_ROOT}cweb/fo.tok \
+ ${SPLINT_XPTABLES} ${SPLINT_XLTABLES} ptab.tex
${PDFTEX} $<
-xxpression.tex: xxpression.x
- ${CWEAVE} $<
+alphas.hx:
+ ${MISCCW} --alpha-list --alpha-length=1 $@
+
+xxpression.tex: xxpression.x alphas.hx
+ ${CWEAVE} $<
-xxpression.gdx: %.gdx: ${XXPRESSION_PREREQS}
+xxpression.gdx:%.gdx: ${XXPRESSION_PREREQS}
${TEX} $*.tex
-xxpression.pdf: %.pdf: ${XXPRESSION_PREREQS} %.gdy
+xxpression.pdf:%.pdf: ${XXPRESSION_PREREQS} %.gdy
${PDFTEX} $* && touch $*.gdy && touch $*.pdf
# if [ -f $*.gdx ] ; then ${BINDX} $*.gdx $*.gdy; fi
-xxpression.tok: xxpression.tex ${SPLINT_XPTABLES} ${SPLINT_XLTABLES} ${SPLINT_ROOT}/cweb/bo.tok
- ${PDFTEX} $< && touch xxpression.tok
+xxpression.tok: xxpression.tex ${SPLINT_XPTABLES} ${SPLINT_XLTABLES} ${SPLINT_ROOT}cweb/bo.tok
+ ${PDFTEX} $< && touch xxpression.tok
+
+${SPLINT_ROOT}cweb/%:
+ cd ${SPLINT_ROOT}cweb/ && ${MAKE} $(notdir $@)
-test: test.tex xymbols.sns xxpression.tok ptab.tex ltab.tex
+test: test.tex xymbols.sns xxpression.tok ptab.tex ltab.tex ${SPLINT_ROOT}cweb/fo.tok
tex test.tex
docs: xxpression.pdf
diff --git a/support/splint/examples/xxpression/xtoks.sty b/support/splint/examples/xxpression/xtoks.sty
index 2dc5abafb4..60e7dfa7a6 100644
--- a/support/splint/examples/xxpression/xtoks.sty
+++ b/support/splint/examples/xxpression/xtoks.sty
@@ -1,2 +1,19 @@
+% Copyright 2012-2020, Alexander Shibakov
+% This file is part of SPLinT
+%
+% SPLinT is free software: you can redistribute it and/or modify
+% it under the terms of the GNU General Public License as published by
+% the Free Software Foundation, either version 3 of the License, or
+% (at your option) any later version.
+%
+% SPLinT is distributed in the hope that it will be useful,
+% but WITHOUT ANY WARRANTY; without even the implied warranty of
+% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+% GNU General Public License for more details.
+%
+% You should have received a copy of the GNU General Public License
+% along with SPLinT. If not, see <http://www.gnu.org/licenses/>.
+
\prettywordpair{IDENTIFIER}{{$\langle$\rm identifier$\rangle$}}
\prettywordpair{INTEGER}{{\bf int}}
+\prettywordpair{$\ undefined}{{\tt\$undefined}}
diff --git a/support/splint/examples/xxpression/xxpression.sty b/support/splint/examples/xxpression/xxpression.sty
index 422901f6da..1b56c4dce3 100644
--- a/support/splint/examples/xxpression/xxpression.sty
+++ b/support/splint/examples/xxpression/xxpression.sty
@@ -1,12 +1,29 @@
+% Copyright 2012-2020, Alexander Shibakov
+% This file is part of SPLinT
+%
+% SPLinT is free software: you can redistribute it and/or modify
+% it under the terms of the GNU General Public License as published by
+% the Free Software Foundation, either version 3 of the License, or
+% (at your option) any later version.
+%
+% SPLinT is distributed in the hope that it will be useful,
+% but WITHOUT ANY WARRANTY; without even the implied warranty of
+% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+% GNU General Public License for more details.
+%
+% You should have received a copy of the GNU General Public License
+% along with SPLinT. If not, see <http://www.gnu.org/licenses/>.
+
\def\optimization{5}
+\input trt1.sty % \TeX\ `runtime': temporary register definitions
\input yycommon.sty % general routines for stack and array access
\input yymisc.sty % helper macros (stack manipulation, table processing, value stack pointers)
+ % parser initializatio, optimization
\input yyinput.sty % input functions
\input yyparse.sty % parser machinery
\input flex.sty % lexer functions
\input yyfaststack.sty % sped up stack access functions
-\input yyboth.sty % parser initializatio, optimization
\def\yycomplain#1{\immediate\write16{#1}} % lexer errors
@@ -15,7 +32,7 @@
\let\parsernamespace\empty
\genericparser
- name: main,
+ name: xmain,
ptables: ptab.tex,
ltables: ltab.tex,
tokens: xxpression.tok,
@@ -24,4 +41,4 @@
rsetup: {},
optimization: \optimizeall;%
-\tomainparser
+\toxmainparser
diff --git a/support/splint/examples/xxpression/xxpression.w b/support/splint/examples/xxpression/xxpression.w
index 00834b4436..bdf81b004d 100644
--- a/support/splint/examples/xxpression/xxpression.w
+++ b/support/splint/examples/xxpression/xxpression.w
@@ -1,4 +1,4 @@
-@q Copyright 2012-2014, Alexander Shibakov@>
+@q Copyright 2012-2020, Alexander Shibakov@>
@q This file is part of SPLinT@>
@q SPLinT is free software: you can redistribute it and/or modify@>
@@ -39,25 +39,25 @@
\newread\testeof
\immediate\openin\testeof=\jobname.tok
\ifeof\testeof % make the local token equivalence table
- \def\drvname{bo}
- \csname newwrite\endcsname\tokendefs
\let\nx\noexpand
+ \csname newwrite\endcsname\tokendefs
\edef\tokendeffile{\jobname.tok} % where to put the token equivalence table
\edef\bstrapparser{dyytab.tex}
\def\bootstraplexersetup{%
\let\yylexreturn\yylexreturnregular
\bootstrapmodetrue
- \input \drvname.tok % use token equivalence table to set the values of non-string tokens
- % this has to be added if a non-bootstrap parser is used to
- % extract token information (see the comments above)
+ \input bo.tok % use token equivalence table to set the values of non-string tokens
+ % this has to be added if a non-bootstrap parser is used to
+ % extract token information (see the comments above)
}
\toks0{%
+ \input trt1.sty %/* \TeX\ `runtime': temporary register definitions */
\input yycommon.sty % general routines for stack and array access
\input yymisc.sty % helper macros (stack manipulation, table processing, value stack pointers)
+ % parser initialization, optimization
\input yyinput.sty % input functions
\input yyparse.sty % parser machinery
\input flex.sty % lexer functions
- \input yyboth.sty % parser initialization, optimization
\input yyfaststack.sty
\input yystype.sty % scanner auxiliary types and functions
\input yyunion.sty % parser data structures
@@ -65,22 +65,29 @@
\let\parsernamespace\empty
% create token equivalence table (making, say, \tokenID the same as \csname token"identifier"\endcsname)
\input yybootstrap.sty
+ \input yytexlex.sty
+ \expandafter\def %/* adjust the \.{\\yyinput} to recognize \.{\\yyendgame} */
+ \expandafter\multicharswitch\expandafter
+ {\multicharswitch\yyendgame{\yyinput\yyeof\yyeof\endparseinput\removefinalvb}}%
}
\else
\toks0{%
\input yy.sty
+ \modenormal
\let\currentparsernamespace\parsernamespace
- \let\parsernamespace\smallnamespace
- \let\hostparsernamespace\smallnamespace
+ \def\parsernamespace{[xxdisplay]}% for \pretty... commands to works
+ \def\hostparsernamespace{[xxdisplay]}% for the \nameproc macro
\input xtoks.sty
- \let\parsernamespace\currentparsernamespace
+ \let\parsernamespace\currentparsernamespace % does not really matter
+ % the \hostparsernamespace stays `[xxdisplay]' which should cause the
+ % \nameproc macro to correct the typesetting of terminals accordingly
}
\fi
\immediate\closein\testeof
\the\toks0
@**Parser file. \setupfootnotes
-This an enhanced parser for expressions. It takes
+This is an enhanced parser for expressions. It takes
advantage of the `symbolic term name' mechanism and extends the basic
expression syntax.
@@ -130,7 +137,9 @@ parser impossible.
@ To continue the token name discussion, this parser uses internal
names only but the |yytname| array contains a string equivalent of
-\prodstyle{IDENTIFIER}. Thus, bootstrapping is necessary. The beginning
+\prodstyle{IDENTIFIER}. Thus, bootstrapping is necessary\footnote{This
+was done as a demonstration; changing the definition of
+\prodstyle{IDENTIFIER} would easily remove this requirement.}. The beginning
of this file contains a simple scheme for producing a token
equivalence table.
The typesetting of the tokens can be adjusted using \.{\\prettywordpair}
@@ -238,7 +247,7 @@ variable names that expand to appropriate values.
@g
@ @<Lexer definitions@>=
-@G
+@G(fs1)
letter [_abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ]
id {letter}({letter}|[-0-9])*
int [0-9]+
@@ -284,12 +293,12 @@ int [0-9]+
\tracebadcharsfalse
\yyflexdebugfalse
@<Scan white space@>=
-@G
+@G(fs2)
[ \f\n\t\v] {@> @[TeX_( "/yylexnext" );@]@=}
@g
@ @<Scan identifiers@>=
-@G
+@G(fs2)
{id} {@> @[TeX_( "/yylexreturnval{IDENTIFIER}" );@]@=}
{int} {@> @[TeX_( "/yylexreturnval{INTEGER}" );@]@=}
[-+*/()] {@> @[TeX_( "/yylexreturnchar" );@]@=}
@@ -309,7 +318,10 @@ any adjustments are needed.
@(xymbols.txx@>=
@G
\def\optimization{5} % this can be omitted
+\input cwebmac.tex
+\input limbo.sty
\input yy.sty
+\modenormal
\input xymmap.sty
\end
@g
@@ -332,6 +344,7 @@ scanner routines.
\tracebadcharstrue
\yyflexdebugtrue
\yyinputdebugtrue
+ \traceactioncodetrue
\fi
\newread\ssw
@@ -346,7 +359,6 @@ scanner routines.
\def\varone{10}
\def\expression{1 + 3 * ( 5 + 7 ) + varone - 10}
-
\basicparserinit\expandafter\yyparse \expression \yyeof\yyeof\endparseinput\endparse
{
@@ -356,8 +368,16 @@ scanner routines.
\bye
@g
+@q Include the list of index section markers; this is a hack to get around @>
+@q the lack of control over the generation of \CWEB's index; the correct order @>
+@q of index entries depends on the placement of this inclusion @>
+@i alphas.hx
@**Index.
+\unsetfootnotes
+\input gindex.sty
+\closeout\gindex
+\termindexfalse % do not attach indexing entries to the terms in the index, or the section list
\let\inx\inxmod
\let\fin\finmod
\immediate\closeout\exampletable
diff --git a/support/splint/examples/xxpression/xymmap.sty b/support/splint/examples/xxpression/xymmap.sty
index 3d36bae920..d38d23ca9b 100644
--- a/support/splint/examples/xxpression/xymmap.sty
+++ b/support/splint/examples/xxpression/xymmap.sty
@@ -1,4 +1,4 @@
-% Copyright 2012-2015, Alexander Shibakov
+% Copyright 2012-2020, Alexander Shibakov
% This file is part of SPLinT
%
% SPLinT is free software: you can redistribute it and/or modify
@@ -36,8 +36,6 @@
\pinittoks{}%
\input ptab.tex % this is the enhanced expression parser
\edef\tointermediateparser{%
- \noexpand\savefullstate % unnecessary
- \noexpand\savefullstateextra % unnecessary
\let\noexpand\parsernamespace\noexpand\inamespace % switch to the new namespace
\the\pinittoks % restore all the tables, tokens and constants, and stacks
\let\noexpand\getcurrentparser\noexpand\tointermediateparser
@@ -87,7 +85,7 @@
% part of the file, this can simply be disabled
\settokens
\setflexstates % the main lexer can be reused in this case; the states still need to be set up
-\input \drvname.tok % set up the tokens for the bison grammar parser
+\input bo.tok % set up the tokens for the bison grammar parser
\newparserstate
\newlexerstate
\newlexerstateextra
@@ -95,8 +93,6 @@
\setnulstack{yyirulestack}%
%
\edef\tofullparser{%
- \noexpand\savefullstate
- \noexpand\savefullstateextra
\let\noexpand\parsernamespace\noexpand\fullnamespace % switch to the new namespace
\the\pinittoks % restore all the tables, tokens and constants, and stacks
\let\noexpand\getcurrentparser\noexpand\tofullparser
@@ -131,7 +127,7 @@
\fi
}%
% build the command to create the symbolic name switch
-\toksc{\tofullparser\parserinit
+\toksc{\tofullparser\basicparserinit\bisonparserinit\bisonparserdatainit
\let\yyinputold\yyinput
\let\yyinput\yyinputtrivial % a demo of a stripped down, slightly faster input routine
\doascii{11}\expandafter\yyparse}%