summaryrefslogtreecommitdiff
path: root/support/splint/examples/ld
diff options
context:
space:
mode:
Diffstat (limited to 'support/splint/examples/ld')
-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
14 files changed, 1016 insertions, 459 deletions
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@@{/}{{}$/${}}