summaryrefslogtreecommitdiff
path: root/support/splint/examples
diff options
context:
space:
mode:
Diffstat (limited to 'support/splint/examples')
-rw-r--r--support/splint/examples/count/count.sty2
-rw-r--r--support/splint/examples/expression/Makefile4
-rw-r--r--support/splint/examples/expression/etoks.sty2
-rw-r--r--support/splint/examples/expression/expression.sty2
-rw-r--r--support/splint/examples/expression/expression.w18
-rw-r--r--support/splint/examples/ld/Makefile47
-rw-r--r--support/splint/examples/ld/ldexample.hw16
-rw-r--r--support/splint/examples/ld/ldgram.w108
-rw-r--r--support/splint/examples/ld/ldgramo.w9
-rw-r--r--support/splint/examples/ld/ldint.sty9
-rw-r--r--support/splint/examples/ld/ldlex.w519
-rw-r--r--support/splint/examples/ld/ldlexo.w14
-rw-r--r--support/splint/examples/ld/ldman.w297
-rw-r--r--support/splint/examples/ld/ldnp.w49
-rw-r--r--support/splint/examples/ld/ldnump.w10
-rw-r--r--support/splint/examples/ld/ldtexlex.sty4
-rw-r--r--support/splint/examples/ld/ldunion.sty242
-rw-r--r--support/splint/examples/ld/lstokenset.sty2
-rw-r--r--support/splint/examples/ld/ltokenset.sty2
-rw-r--r--support/splint/examples/symbols/Makefile8
-rw-r--r--support/splint/examples/symbols/slimbo.sty2
-rw-r--r--support/splint/examples/symbols/symbols.w46
-rw-r--r--support/splint/examples/symbols/symfm.sty2
-rw-r--r--support/splint/examples/symbols/symmap.sty5
-rw-r--r--support/splint/examples/symbols/symtoks.sty2
-rw-r--r--support/splint/examples/symbols/symtricks.sty2
-rw-r--r--support/splint/examples/types/Makefile2
-rw-r--r--support/splint/examples/types/basic.sty2
-rw-r--r--support/splint/examples/types/test.sty2
-rw-r--r--support/splint/examples/types/tree.sty2
-rw-r--r--support/splint/examples/xxpression/Makefile8
-rw-r--r--support/splint/examples/xxpression/xtoks.sty3
-rw-r--r--support/splint/examples/xxpression/xxpression.sty2
-rw-r--r--support/splint/examples/xxpression/xxpression.w39
-rw-r--r--support/splint/examples/xxpression/xymmap.sty5
35 files changed, 845 insertions, 643 deletions
diff --git a/support/splint/examples/count/count.sty b/support/splint/examples/count/count.sty
index d9fed05f94..d697096141 100644
--- a/support/splint/examples/count/count.sty
+++ b/support/splint/examples/count/count.sty
@@ -1,4 +1,4 @@
-% Copyright 2012-2020, Alexander Shibakov
+% Copyright 2012-2022, Alexander Shibakov
% This file is part of SPLinT
%
% SPLinT is free software: you can redistribute it and/or modify
diff --git a/support/splint/examples/expression/Makefile b/support/splint/examples/expression/Makefile
index 6f306939b6..741e94664c 100644
--- a/support/splint/examples/expression/Makefile
+++ b/support/splint/examples/expression/Makefile
@@ -1,4 +1,4 @@
-# Copyright 2012-2020, Alexander Shibakov
+# Copyright 2012-2022, Alexander Shibakov
# This file is part of SPLinT
#
# SPLinT is free software: you can redistribute it and/or modify
@@ -54,7 +54,7 @@ test.tex ${PARSER}.yy ${LEXER}.ll: expression.x
expression.tex: expression.x
@${CWEAVE} $<
-expression.pdf: expression.tex ${SPLINT_XPTABLES} ${SPLINT_XLTABLES} ${SPLINT_ROOT}cweb/bo.tok ${SPLINT_ROOT}cweb/fo.tok etoks.sty
+expression.pdf: expression.tex ${SPLINT_XTABLES} etoks.sty
@${PDFTEX} $<
test: test.tex ptab.tex ltab.tex
diff --git a/support/splint/examples/expression/etoks.sty b/support/splint/examples/expression/etoks.sty
index 706ad35818..6df6c0d3be 100644
--- a/support/splint/examples/expression/etoks.sty
+++ b/support/splint/examples/expression/etoks.sty
@@ -1,4 +1,4 @@
-% Copyright 2012-2020, Alexander Shibakov
+% Copyright 2012-2022, Alexander Shibakov
% This file is part of SPLinT
%
% SPLinT is free software: you can redistribute it and/or modify
diff --git a/support/splint/examples/expression/expression.sty b/support/splint/examples/expression/expression.sty
index ac0d8ba7e5..8fe0970159 100644
--- a/support/splint/examples/expression/expression.sty
+++ b/support/splint/examples/expression/expression.sty
@@ -1,4 +1,4 @@
-% Copyright 2012-2020, Alexander Shibakov
+% Copyright 2012-2024, Alexander Shibakov
% This file is part of SPLinT
%
% SPLinT is free software: you can redistribute it and/or modify
diff --git a/support/splint/examples/expression/expression.w b/support/splint/examples/expression/expression.w
index 9e96ea44d0..1f6a2f6b61 100644
--- a/support/splint/examples/expression/expression.w
+++ b/support/splint/examples/expression/expression.w
@@ -1,4 +1,4 @@
-@q Copyright 2012-2020, Alexander Shibakov@>
+@q Copyright 2012-2024, Alexander Shibakov@>
@q This file is part of SPLinT@>
@q SPLinT is free software: you can redistribute it and/or modify@>
@@ -16,9 +16,12 @@
\input limbo.sty
\def\optimization{5}
\input yy.sty
+\input dcols.sty
\modenormal
+\initauxstream
-@** Parser file. This is an example parser for expressions. It takes
+@** Parser file.
+This is an example parser for expressions. It takes
advantage of some of the features of \splint\ generated parsers,
although anything that takes more than a straightforward setup is
omitted.
@@ -140,8 +143,6 @@ as they have to be inserted in a place that is aware of the internal definitions
definitions are used.
@<\.{expression} parser \Cee\ postamble@>=
-#define YYPRINT(file, type, value) @[yyprint (file, type, value)@]
- static void yyprint (FILE *file, int type, YYSTYPE value){}
@ Union of types. Empty as well.
@@ -175,7 +176,7 @@ int [0-9]+
void define_all_states( void ){}
@ @<Lexer options@>=
-@G
+@G(fs1)
%option bison-bridge
%option noyywrap nounput noinput reentrant
%option noyy_top_state
@@ -206,13 +207,14 @@ int [0-9]+
@[TeX_( "/iftracebadchars" );@]@;
@[TeX_( " /yycomplain{invalid character(s): /the/yytext}" );@]@;
@[TeX_( "/fi" );@]@;
- @[TeX_( "/yylexreturn{$undefined}" );@]@;
+ @[TeX_( "/yyerrterminate" );@]@;
@*Test file. The test file includes a handy list of debugging options
that can be activated to see the inner workings of the parser and
scanner routines.
@(test.txx@>=
@G
+\chardef\other=12 % needed for some macros to work
\input expression.sty
\iffalse
@@ -240,7 +242,7 @@ scanner routines.
\bye
@g
-@**Index.
-\immediate\closeout\exampletable
+@**Index.\global\let\secrangedisplay\empty% do not show the current section range anymore
+\global\topskip=9pt
\def\Tex{\TeX\ output}
\def\TeXx{\TeX\ output}
diff --git a/support/splint/examples/ld/Makefile b/support/splint/examples/ld/Makefile
index 24bf4a7a9f..8d876e55c9 100644
--- a/support/splint/examples/ld/Makefile
+++ b/support/splint/examples/ld/Makefile
@@ -1,4 +1,4 @@
-# Copyright 2012-2020, Alexander Shibakov
+# Copyright 2012-2024, Alexander Shibakov
# This file is part of SPLinT
#
# SPLinT is free software: you can redistribute it and/or modify
@@ -22,10 +22,11 @@ PARSER = ldp
LEXER = ldl
MANUAL = ldman
-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
+LD_CORE_PREREQS = ${SPLINT_XTEXSTYLES} ${SPLINT_XTABLES}
+LD_DOC_PREREQS_STATIC = ldunion.sty ldtexlex.sty ldint.sty ltokenset.sty lstokenset.sty
+LD_DOC_PREREQS_GEN = ldptab.tex ldltab.tex ld_small_tab.tex ld_small_dfa.tex ${PARSER}.tok ldsetup.sty
+LD_DOC_PREREQS_XREF = ${LD_CORE_PREREQS} %.sty ${LD_DOC_PREREQS_STATIC} %.tex ${LD_DOC_PREREQS_GEN} %.scn %.idx
+LD_DOC_PREREQS_XREF += ldfrontmatter.sty
include ../../makefile.inc
include ${SPLINT_ROOT}makefile.loc
@@ -35,13 +36,13 @@ include ${SPLINT_ROOT}makefile.loc
ptabout: ${SPLINT_ROOT}cweb/mkeparser.c ${PARSER}.c
${CC} ${BISON_STATE} -DPARSER_FILE=\"../examples/ld/$(lastword $^)\" -DYYPARSE_PARAMETERS= -o $@ $<
-ptab.tex: ptabout
+ldptab.tex: ptabout
$< --optimize-actions --optimize-tables $@
ltabout: ${SPLINT_ROOT}cweb/mkscanner.c ldl_states.h ${LEXER}.c
${CC} -DLEXER_FILE=\"../examples/ld/$(lastword $^)\" -o $@ $<
-ltab.tex: ltabout
+ldltab.tex: ltabout
$< --optimize-actions --optimize-tables $@
${LEXER}.c: ${LEXER}.l
@@ -53,7 +54,8 @@ ${PARSER}.yy : ldgram.x
${LEXER}.ll: ldlex.x
@${CTANGLE} $<
-${MANUAL}.stx: ${MANUAL}.x ldgram.x ldlex.x ldlexo.x ldgramo.x ldnp.x
+${MANUAL}.stx \
+ldsetup.stx: ${MANUAL}.x ldgram.x ldlex.x ldlexo.x ldgramo.x ldnp.x ldexample_l.hx ldexample_t.hx alphas.hx
@${CTANGLE} $<
# term name parser for ld grammar
@@ -101,11 +103,13 @@ ldexample_%.hx: ldexample.hw
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
+${MANUAL}.tex: ${MANUAL}.x ldgram.x ldlex.x ldlexo.x ldgramo.x ldnp.x ldexample_l.hx ldexample_t.hx alphas.hx
+ @echo "Preparing the ${MANUAL}.tex file ..."
-${CWEAVE} $<
-${MANUAL}.sty: ${MANUAL}.stx
- ${UNLINE} $< $@
+${MANUAL}.sty \
+ldsetup.sty:%.sty: %.stx
+ ${UNLINE} $< $@
${MANUAL}.gdx: %.gdx: ${LD_DOC_PREREQS_XREF} ${PARSER}.tok
@echo "Making the bison and TeX indices ..."
@@ -116,11 +120,8 @@ ${MANUAL}.gdx: %.gdx: ${LD_DOC_PREREQS_XREF} ${PARSER}.tok
${MANUAL}.gdy: %.gdy: %.gdx
${BINDX} --fine $^ $@
-${MANUAL}.xxr: %.xxr: %.tex
- ${PDFTEX} $*.tex
-
-${MANUAL}.pdf: %.pdf: ${LD_DOC_PREREQS_XREF} %.gdy %.xxr
- ${PDFTEX} $< && touch $*.gdy && touch $*.pdf
+${MANUAL}.pdf: %.pdf: ${LD_DOC_PREREQS_XREF} %.gdy %.aux
+ ${PDFTEX} $*.tex && touch $*.gdy && touch $*.pdf
${PARSER}.tok: ldgram.tex ${MANUAL}.sty ${LD_CORE_PREREQS}
${TEX} ${MODEBOOTSTRAP} \\input $<
@@ -130,15 +131,25 @@ ldl_states.h: ldlex.tex ${MANUAL}.sty ${LD_CORE_PREREQS}
ldgram.tex ldlex.tex: \
%.tex: %.x
- -${CWEAVE} -x $<
+ @echo "Building ldgram.tex and ldlex.tex."
+ -${CWEAVE} -x $*.x
docs: ${MANUAL}.pdf
+install: docs
+ @cp ${LD_DOC_PREREQS_STATIC} ${SPLINT_INSTALL_DIR}/tex/
+ @cp ${LD_DOC_PREREQS_GEN} ${SPLINT_INSTALL_DIR}/cweb/
+
+uninstall:
+ @rm -f $(patsubst %, ${SPLINT_INSTALL_DIR}/tex/%, ${LD_DOC_PREREQS_STATIC})
+ @rm -f $(patsubst %, ${SPLINT_INSTALL_DIR}/cweb/%, ${LD_DOC_PREREQS_GEN})
+
mostlyclean: clean_temp
-rm -f ptabout ltabout ldsmalll_out ldsmallp_out ldnump_out ldnuml_out ${MANUAL}.c
clean: clean_core
- -rm -f ptabout ltabout ldsmalll_out ldsmallp_out ldnump_out ldnuml_out *.stx ldman.sty
+ -rm -f ptabout ltabout ldsmalll_out ldsmallp_out ldnump_out ldnuml_out *.stx \
+ ldman.sty ldsetup.sty
distclean: clean
cd ${SPLINT_ROOT} && ${MAKE} clean
diff --git a/support/splint/examples/ld/ldexample.hw b/support/splint/examples/ld/ldexample.hw
index a5cab97d2a..d9cb732624 100644
--- a/support/splint/examples/ld/ldexample.hw
+++ b/support/splint/examples/ld/ldexample.hw
@@ -4,7 +4,7 @@ MEMORY
{
@> @<Some random portion of \ld\ code@> @=
RAM (xrw) : ORIGIN = 0x20000000, LENGTH = 20K
- FLASH (rx) : ORIGIN = 0x8000000, LENGTH = 128K
+ FLASH (rx!w) : ORIGIN = 0x8000000, LENGTH = 128K
ASH (rx) : ORIGIN = 8001000, LENGTH = 128K
@> @<Some random portion of \ld\ code@> @=
CLASH (rx) : ORIGIN = 700000, LENGTH = 128K
@@ -27,6 +27,7 @@ ENTRY(_entry);
SECTIONS
{
@> @<Some random portion of \ld\ code@> @=
+ . = ORIGIN(FLASH);
.isr_vector ALIGN(8) (NOLOAD): AT(.) ALIGN(.) ALIGN_WITH_INPUT SUBALIGN(8) SPECIAL
{
. = ALIGN(4);
@@ -73,5 +74,18 @@ SECTIONS
_ebss = . ;
} >RAM
@> @<Some random portion of \ld\ code@> @=
+ . = ALIGN(0x0001ABCD);
+ _ffbegin = .;
+ OVERLAY : NOCROSSREFS AT ( _ffabs ) {
+ .free_func0
+ {
+ *(.free_func0)
+ . = ALIGN(4);
+ }
+ .free_func1
+ {
+ *(.free_func1)
+ }
+ } >RAM
}
diff --git a/support/splint/examples/ld/ldgram.w b/support/splint/examples/ld/ldgram.w
index 5e7ff73a03..3671ee52ce 100644
--- a/support/splint/examples/ld/ldgram.w
+++ b/support/splint/examples/ld/ldgram.w
@@ -1,4 +1,4 @@
-@q Copyright 2012-2020 Alexander Shibakov@>
+@q Copyright 2012-2022 Alexander Shibakov@>
@q Copyright 2002-2014 Free Software Foundation, Inc.@>
@q This file is part of SPLinT@>
@@ -18,10 +18,12 @@
@** The parser.
\ifbootstrapmode
\def\tokendeffile{ldp.tok}%
- \input ldman.sty
+ \input ldman.sty
+ \def\bstrapparser{dyytab.tex}% only the full or preamble parser would know how to
+ % parse grammar sections that mix \prodstyle{\%token}
+ % declarations with other \bison\ syntax
+ \def\bstraptokens{bo.tok}% token equivalences for the full lexer
\modebootstrap
- \input dcols.sty
- \setupfootnotes
\def\MRI{}
\def\ld{}
\fi
@@ -76,8 +78,6 @@ is supplied by the \TeX\ macros in \.{ldman.sty}.
@ @<Union of grammar parser types@>=
@ @<\ld\ parser \Cee\ postamble@>=
-#define YYPRINT(file, type, value) yyprint (file, type, value)
- static void yyprint (FILE *file, int type, YYSTYPE value){}
@ @<\ld\ parser productions@>=
@<\GNU\ \ld\ script rules@>@;
@@ -129,13 +129,13 @@ by the \ld\ parser are put in a single list.
%left OROR ANDAND '|' '^' '&' EQ NE '<' '>' LE GE LSHIFT RSHIFT '+' '-' '*' '/' '%' '('
@g
-@*1 Grammar rules, an overview.
+@*1 Grammar rules, an overview.
The first natural step in transforming an existing parser into a
`parser stack' for pretty printing is to understand the `anatomy' of
the grammar. Not every grammar is suitable for such a transformation
and in almost every case, some modifications are needed. The
parser and lexer implementation for \ld\ is not terrible although it does
-have some idiosynchasies that could have been eliminated by a careful
+have some idiosynchrasies that could have been eliminated by a careful
grammar redesign. Instead of invasive rewriting of significant
portions of the grammar, the approach taken here merely omits some
rules and partitions the grammar into several subsets, each of which
@@ -143,7 +143,7 @@ is supposed to handle a well defined logical section of an \ld\ script
file.
One example of a trick used by the \ld\ parser that is not appropriate for a
-pretty printing grammar implements a way of handling the choice of the
+pretty printing grammar is the way the original parser handles the choice of the
format of an input file. After a command line option that selects the
input format has been read (or the format has been determined using
some other method), the first token output by the lexer branches the
@@ -219,12 +219,14 @@ defsym_expr:
@ {\it Syntax within an \MRI\ script file}\footnote{As explained at the
beginning of this chapter, the text in {\it italics\/} was taken from
-the original comments by \ld\ parser and lexer programmers.}. The parser for typesetting
+the original comments by the \ld\ parser and lexer programmers.}. The parser for typesetting
is only intended to process \GNU\ \ld\ scripts and does not concern
itself with any additional compatibility modes. For this reason, all
support for \MRI\ style scripts has been omitted. One use for the
section below is a small demonstration of the formatting tools that
change the output of the \bison\ parser.
+%\checktabletrue
+%\tracingliststrue
@<\MRI\ style script rules@>=
@G
@t}\vb{\inline\flatten}{@>
@@ -315,6 +317,8 @@ casesymlist:
@ {\it Parsed as expressions so that commas separate entries.} The
core of the parser consists of productions describing \GNU\ \ld\ linker
scripts. The first rule is common to both \MRI\ and \GNU\ formats.
+\checktablefalse
+\tracinglistsfalse
@<\GNU\ \ld\ script rules@>=
@G
extern_name_list:
@@ -435,7 +439,7 @@ sections:
sec_or_group_p1:
sec_or_group_p1 section {@>@<Add the next section chunk@>@=}
- | sec_or_group_p1 statement_anywhere {@>@<Add the next section chunk@>@=}
+ | sec_or_group_p1 statement_anywhere {@>@<Add the next section statement@>@=}
| {@>@[TeX_( "/yy0{}" );@]@=}
;
@@ -451,10 +455,20 @@ statement_anywhere:
@[TeX_( "/yy0{/nx/ldinsertcweb/the/yy(1){sect}{/nx/ldsections{/the/yy(3)/nx/ldsectionstash/the/yy(4)}}}" );@]
@ @<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}}" );@]@;
+ @[TeX_( "/yytoksempty{/yy(2)}{/yy0{/the/yy(1)}}{" );@]@;
+ @[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}}" );@]@;
+ @[TeXa( " {/yy0{/the/yy(1)/nx/ldsectionseparator{/the/tokse}{/the/toksf}/the/toksh}}" );@]@;
+ @[TeXfo( "}" );@]@;
+
+@ @<Add the next section statement@>=
+ @[TeX_( "/yytoksempty{/yy(2)}{/yy0{/the/yy(1)}}{" );@]@;
+ @[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}/nx/ldfreestmt{/the/toksh}}}" );@]@;
+ @[TeXa( " {/yy0{/the/yy(1)/nx/ldsectionseparator{/the/tokse}{/the/toksf}/nx/ldfreestmt{/the/toksh}}}" );@]@;
+ @[TeXfo( "}" );@]@;
@ @<Form an \prodstyle{ENTRY} statement@>=
@[TeX_( "/yy0{/nx/ldinsertcweb/the/yy(1){stmt}{/nx/ldstatement{/nx/ldentry{/nx/ldregexp{/the/yy(3)}}}}}" );@]
@@ -631,14 +645,14 @@ length:
| SHORT {}
| BYTE {}
;
-
+@t}\vb{\resetf\inline}{@>
fill_exp:
mustbe_exp {@>@<Carry on@>@=}
;
-
+@t}\vb{\flatten}{@>
fill_opt:
- '=' fill_exp {@>@[TeX_( "/yy0{/noexpand/ldfill{/the/yy(2)}}" );@]@=}
- | {@>@[TeX_( "/yy0{}" );@]@=}
+ {@>@[TeX_( "/yy0{}" );@]@=}
+ | '=' fill_exp {@>@[TeX_( "/yy0{/noexpand/ldfill{/the/yy(2)}}" );@]@=}
;
@t}\vb{\resetf}{@>
@@ -710,9 +724,7 @@ memory_spec_list:
memory_spec:
NAME {}
- attributes_opt ':'
- origin_spec
-@t}\vb{\breakline}{@>
+ attributes_opt ':' origin_spec
opt_comma length_spec {@>@<Declare a named memory region@>@=}
| INCLUDE filename {@>@<Peek at a file@>@=}
memory_spec_list_opt END {@>@<Close the file@>@=}
@@ -759,8 +771,8 @@ attributes_list:
;
attributes_string:
- NAME {@>@[TeX_( "/yy0{/noexpand/ldattributes{/the/yy(1)}}" );@]@=}
- | '!' NAME {@>@[TeX_( "/yy0{/noexpand/ldattributesneg{/the/yy(2)}}" );@]@=}
+ NAME {@>@[TeX_( "/yy0{/noexpand/ldattrstring/the/yy(1)}" );@]@=}
+ | '!' NAME {@>@[TeX_( "/yy0{/noexpand/ldattrstringneg/the/yy(2)}" );@]@=}
;
startup:
@@ -812,7 +824,7 @@ expressions out of simpler chunks and basic building blocks tied
together by algebraic operations.
@<Grammar rules@>=
@G
-exp :
+exp:
'-' exp %prec UNARY {@>@[TeX_( "/yy0{{-/the/yy(2)}}" );@]@=}
| '(' exp ')' {@>@[TeX_( "/yy0{(/the/yy(2))}" );@]@=}
| NEXT '(' exp ')' %prec UNARY {@>@[TeX_( "/yy0{/hbox{/nx/ssf next}(/the/yy(3))}" );@]@=}
@@ -844,28 +856,28 @@ exp :
@<Grammar rules@>=
@G
exp :
- DEFINED '(' NAME ')' {}
- | INT {}
+ DEFINED '(' NAME ')' {@>@[TeX_( "/def/ldfuncname{defined}" );@]@<Apply a function to a name@>@=}
+ | INT {@>@<Carry on@>@=}
| SIZEOF_HEADERS {}
- | ALIGNOF '(' NAME ')' {}
- | SIZEOF '(' NAME ')' {}
- | ADDR '(' NAME ')' {}
- | LOADADDR '(' NAME ')' {}
- | CONSTANT '(' NAME ')' {}
- | ABSOLUTE '(' exp ')' {}
+ | ALIGNOF '(' NAME ')' {@>@[TeX_( "/def/ldfuncname{alignof}" );@]@<Apply a function to a name@>@=}
+ | SIZEOF '(' NAME ')' {@>@[TeX_( "/def/ldfuncname{sizeof}" );@]@<Apply a function to a name@>@=}
+ | ADDR '(' NAME ')' {@>@[TeX_( "/def/ldfuncname{addr}" );@]@<Apply a function to a name@>@=}
+ | LOADADDR '(' NAME ')' {@>@[TeX_( "/def/ldfuncname{loadaddr}" );@]@<Apply a function to a name@>@=}
+ | CONSTANT '(' NAME ')' {@>@[TeX_( "/def/ldfuncname{constant}" );@]@<Apply a function to a name@>@=}
+ | ABSOLUTE '(' exp ')' {@>@[TeX_( "/yy0{/nx/mathop{/hbox{/nx/ssf absolute}}(/the/yy(3))}" );@]@=}
| ALIGN_K '(' exp ')' {@>@[TeX_( "/yy0{/nx/mathop{/hbox{/nx/ssf align}}(/the/yy(3))}" );@]@=}
| ALIGN_K '(' exp ',' exp ')' {}
| DATA_SEGMENT_ALIGN '(' exp ',' exp ')' {}
| DATA_SEGMENT_RELRO_END '(' exp ',' exp ')' {}
| DATA_SEGMENT_END '(' exp ')' {}
| SEGMENT_START '(' NAME ',' exp ')' {}
- | BLOCK '(' exp ')' {}
+ | BLOCK '(' exp ')' {@>@[TeX_( "/yy0{/nx/mathop{/hbox{/nx/ssf block}}(/the/yy(3))}" );@]@=}
| NAME {@>@[TeX_( "/yy0{/nx/ldregexp{/the/yy(1)}}" );@]@=}
| MAX_K '(' exp ',' exp ')' {}
| MIN_K '(' exp ',' exp ')' {}
| ASSERT_K '(' exp ',' NAME ')' {}
- | ORIGIN '(' NAME ')' {}
- | LENGTH '(' NAME ')' {}
+ | ORIGIN '(' NAME ')' {@>@[TeX_( "/def/ldfuncname{origin}" );@]@<Apply a function to a name@>@=}
+ | LENGTH '(' NAME ')' {@>@[TeX_( "/def/ldfuncname{length}" );@]@<Apply a function to a name@>@=}
| LOG2CEIL '(' exp ')' {}
;
@g
@@ -875,6 +887,9 @@ exp :
@[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}}}}" );@]@;
+@ @<Apply a function to a name@>=
+@[TeX_( "/yy0{/nx/mathop{/hbox{/nx/ssf /ldfuncname}}(/nx/ldregexp{/the/yy(3))}}" );@]
+
@ @<Grammar rules@>=
@G
memspec_at_opt:
@@ -966,6 +981,10 @@ section:
@[TeXfo( " {{/the/yy(15)}{/the/yy(16)}{/the/yy(17)}{/the/yy(18)}}}}" );@]@; /*memory specifiers */
@ @<Record an overlay section@>=
+ @[TeXb( "/getfirst{/yy(1)}/to/toksa/getsecond{/yy(1)}/to/toksb" );@]@;
+ @[TeXf( "/yy0{/nx/ldinsertcweb{/the/toksa}{/the/toksb}{osect}{/nx/ldoverlay{/the/yy(3)}{/the/yy(4)}{/the/yy(5)}{/the/yy(6)}" );@]@;
+ @[TeXf( " {/the/yy(10)}" );@]@;/* sections */
+ @[TeXfo( " {{/the/yy(13)}{/the/yy(14)}{/the/yy(15)}{/the/yy(16)}}}}" );@]@; /*memory specifiers, etc.*/
@ @<Grammar rules@>=
@G
@@ -999,8 +1018,8 @@ opt_exp_with_type:
;
opt_exp_without_type:
- exp ':' {}
- | ':' {}
+ exp ':' {@>@[TeX_( "/yy0{/the/yy(1)}" );@]@=}
+ | ':' {@>@[TeX_( "/yy0{}" );@]@=}
;
opt_nocrossrefs:
@@ -1019,12 +1038,12 @@ phdr_opt:
;
overlay_section:
-
+ {@>@[TeX_( "/yy0{}" );@]@=}
| overlay_section
NAME {@>@[TeX_( "/ldlex@@script" );@]@=}
'{' statement_list_opt '}' {@>@[TeX_( "/ldlex@@popstate/ldlex@@expression" );@]@=}
phdr_opt fill_opt {@>@[TeX_( "/ldlex@@popstate" );@]@=}
- opt_comma
+ opt_comma {@>@<Add a section to the overlay@>@=}
;
@g
@@ -1032,6 +1051,15 @@ overlay_section:
@[TeXb( "/yytoksempty{/yy(1)}{/yy0{{/the/yy(3)}}}" );@]@;
@[TeXao( "{/yy0{/the/yy(1)/noexpand/ldor{/the/yy(3)}}}" );@]@;
+@ @<Add a section to the overlay@>=
+ @[TeXb( "/getthird{/yy(2)}/to/toksa/getfourth{/yy(2)}/to/toksb" );@]@;/* \prodstylens{name}{\ldnamespace} pointers */
+ @[TeXf( "/getfifth{/yy(5)}/to/toksc" );@]@;/* \prodstylens{statement\_list\_opt}{\ldnamespace} contents */
+ @[TeXf( "/yytoksempty{/yy(1)}{" );@]@;
+ @[TeXf( " /yy0{/nx/ldoverlaysection{/the/yy(2)}{/the/toksc}{/the/yy(8)}{/the/yy(9)}}" );@]@;
+ @[TeXf( "}{" );@]@;
+ @[TeXf( " /yy0{/the/yy(1)/nx/ldoverlaysection{/the/yy(2)}{/the/toksc}{/the/yy(8)}{/the/yy(9)}}" );@]@;
+ @[TeXfo( "}" );@]@;
+
@ @<Grammar rules@>=
@G
phdrs:
diff --git a/support/splint/examples/ld/ldgramo.w b/support/splint/examples/ld/ldgramo.w
index 46d46f9a1f..a036c858de 100644
--- a/support/splint/examples/ld/ldgramo.w
+++ b/support/splint/examples/ld/ldgramo.w
@@ -1,4 +1,4 @@
-@q Copyright 2020 Alexander Shibakov@>
+@q Copyright 2012-2022 Alexander Shibakov@>
@q Copyright 2002-2015 Free Software Foundation, Inc.@>
@q This file is part of SPLinT@>
@@ -492,17 +492,20 @@ statement_anywhere:
ENTRY '(' NAME ')'
{ lang_add_entry ($3, FALSE); }
| assignment end
- | ASSERT_K {@>@[ldlex_expression ();@>@=} '(' exp ',' NAME ')'
+ | ASSERT_K {@>@[ldlex_expression ();@]@=} '(' exp ',' NAME ')'
{
@O
ldlex_popstate ();
-@o
lang_add_assignment (exp_assert ($4, $6));
+@o
}
;
@g
+@q using a @@[, @@> pair instead of @@[, @@] may lead to some strange spacing artefacts @>
+@q due to the lack of \6; it is instructive to see its effects after replacing the @@] with @@> @>
+@q in the line containing ASSERT_K @>
@ \tracebadcharstrue
The {\setrulecontext{wildcardname}\prodstyle{'*'}} and \prodstyle{'?'} cases are there because the lexer returns them as
separate tokens rather than as \prodstyle{NAME}.
diff --git a/support/splint/examples/ld/ldint.sty b/support/splint/examples/ld/ldint.sty
index 83f3068dc5..a96003a53d 100644
--- a/support/splint/examples/ld/ldint.sty
+++ b/support/splint/examples/ld/ldint.sty
@@ -1,4 +1,4 @@
-% Copyright 2012-2020, Alexander Shibakov
+% Copyright 2012-2022, Alexander Shibakov
% This file is part of SPLinT
%
% SPLinT is free software: you can redistribute it and/or modify
@@ -203,9 +203,12 @@
}
\def\displayinteger#1#2#3#4#5#6#7#8{%
- {\def\ldintsep{$\,$}\hbox{\rm#7#8\rlap{${}_{#1}$}$\yystringempty{#2}{}{\lddisplayintsuffix{#2}}$}}%
+ {\def\ldintsep{$\,$}\hbox{\ldintfont#7#8\ldrlap{${}_{#1}$}$\yystringempty{#2}{}{\lddisplayintsuffix{#2}}$}}%
}
+\let\ldrlap\rlap
+\let\ldintfont\rm
+
\def\lddisplayintsuffix#1{%
\expandafter\ifx\csname ldspecialsuffixdisplay#1\endcsname\relax
\,\hbox{\tt#1}%
@@ -216,7 +219,7 @@
\def\ldspecialsuffixdisplayK{{}\cdot2^{10}}
-\def\ldspecialsuffixdisplayK{\,\hbox{\rm Kb}}
+%\def\ldspecialsuffixdisplayK{\,\hbox{\rm Kb}}
\def\displayintegerws#1#2#3#4#5#6#7{%
{\def\ldintsep{$\,$}\hbox{\rm#6#7\rlap{${}_{\yystringempty{#1}{}{\csname ldradix#1\endcsname}}$}}}%
diff --git a/support/splint/examples/ld/ldlex.w b/support/splint/examples/ld/ldlex.w
index 2312fd1027..0add0b0294 100644
--- a/support/splint/examples/ld/ldlex.w
+++ b/support/splint/examples/ld/ldlex.w
@@ -1,4 +1,4 @@
-@q Copyright 2012-2020 Alexander Shibakov@>
+@q Copyright 2012-2022 Alexander Shibakov@>
@q Copyright 2002-2014 Free Software Foundation, Inc.@>
@q This file is part of SPLinT@>
@@ -17,10 +17,10 @@
@** The lexer.
\ifbootstrapmode
- \input ldman.sty
- \modebootstrap
- \input dcols.sty
- \setupfootnotes
+ \input limbo.sty
+ \input yystype.sty
+ \input grabstates.sty
+ \immediate\openout\stlist=ldl_states.h
\def\MRI{}
\def\ld{}
\fi
@@ -37,7 +37,7 @@ the \bison\ parser which is part of this distribution.
%{@> @<\ld\ lexer \Cee\ preamble@> @=%}
@> @<\ld\ lexer options@> @=
%%
- @> @<\ld\ token regular expressions@> @=
+ @> @<Regular expressions for \ld\ tokens@> @=
%%
@O
void define_all_states( void ) {
@@ -47,7 +47,7 @@ void define_all_states( void ) {
@g
@ @<\ld\ lexer options@>=
-@G
+@G(fs1)
%option bison-bridge
%option noyywrap nounput noinput reentrant
%option noyy_top_state
@@ -57,10 +57,10 @@ void define_all_states( void ) {
@g
@ @<\ld\ lexer \Cee\ preamble@>=
-#include <stdint.h>
-#include <stdbool.h>
-@ @<Collect state definitions for the \ld\ lexer@>=
+@ The file \.{ldl\_states.h} below contains the names of all the start
+conditions@^start conditions@> (or states) collected by the bootstrap parser.
+@<Collect state definitions for the \ld\ lexer@>=
#define _register_name( name ) @[Define_State( #name, name )@]
#include "ldl_states.h"
#undef _register_name
@@ -94,7 +94,7 @@ same section simplifies the job of the
\locallink{bootstrapstates}bootstrap parser\endlink, as well.
\ifbootstrapmode\immediate\openout\stlist=ldl_states.h\fi
@<\ld\ lexer states@>=
-@G
+@G(fs1)
%s SCRIPT
%s EXPRESSION
%s BOTH
@@ -117,8 +117,9 @@ function. The typesetting parser uses the \.{\\ldcomment} macro for
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 adapted to \flex\ syntax.}:
+\url{http://www.cs.dartmouth.edu/~mckeeman/cs118/assignments/comment.html} and
+adapted to \flex\ syntax. Here is the same regular expression pretty printed by
+\splint: \flexrestyle{"/*"("/"`[\^*/]`"*"+[\^*/])*"*"+"/"}}:
$$
\hbox{\.{"/*" ("/"\yl[\^*/]\yl"*"+[\^*/])* "*"+ "/"}}
$$
@@ -193,6 +194,15 @@ possible, however, if \.{\\yylextail} is not used inside actions (in the case of
an `optimized' lexer the restriction is even weaker, namely,
\.{\\yylextail} merely has to be absent in the portion of the action
following \.{\\ldcomment}).
+
+Another remark might be in order. It would seem more appropriate to
+employ \TeX's native grouping mechanism to avoid the side effects
+casued by the assignments performed by the macros (such as
+\.{\\let\\oldyyreturn\\yyreturn}). While this is possible with some
+careful macro writing, a na\:\i ve grouping attempt would interfere
+with the assignments performed by \.{\\yymatch}
+(e.g.~\.{\\yyresetstreams}). Avoiding assignments like these is still
+possible although the effort required is bordering on excessive.
@<Additional macros for the \ld\ lexer/parser@>=
@G(t)
\def\ldcomment#1\yylextail{%
@@ -221,14 +231,24 @@ We would like to simulate the file inclusion by inserting the
appropriate end of file marker for the lexer (a double
\.{\\yyeof}). After the relevant production completes, the marker
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.
+leave it intact to be able to read the end of file multiple times
+while looking for the longest match).
+
+The macro below is designed to handle this task. The idea is to replace
+the double \.{\\yyeof} at the beginning of the input with an appropriate
+lexer action. The \.{\\yyreadinput} handles the input buffer and inserts the
+tail portion of the current \flex\ action in front of it.
@<Additional macros for the \ld\ lexer/parser@>=
@G(t)
\def\ldcleanyyeof#1\yylextail{%
- \let\oldyyinput\yyinput
- \def\yyinput\yyeof\yyeof{\let\yyinput\oldyyinput#1\yylextail}%
- \yymatch
+ \yyreadinput{\ldcl@@anyyeof{#1\yylextail}}{\romannumeral0\yyr@@@@dinput}%
+}
+
+\def\ldcl@@anyyeof#1#2#3{%
+ #3\ldcl@@anyye@@f{#1}#2%
}
+
+\def\ldcl@@anyye@@f#1#2\yyeof\yyeof{#1}
@g
@*1 Regular expressions.
@@ -237,204 +257,166 @@ describe the {\it tokens\/} of the appropriate language. The variey of
tokens recognized by \ld\ is quite extensive and is described in the
sections that follow.
-Variable names and algebraic operations come first.
-@<\ld\ token regular expressions@>=
+Variable names, constants, and algebraic operations come first.
+@<Regular expressions for \ld\ tokens@>=
@G(fs2)
-<BOTH,SCRIPT,EXPRESSION,VERS_START,VERS_NODE,VERS_SCRIPT>"/*" {@> @[TeX_( "/ldcomment/yylexnext" );@]@=}
-<DEFSYMEXP>"-" {@> @[TeX_( "/yylexreturnchar" );@]@=}
-<DEFSYMEXP>"+" {@> @[TeX_( "/yylexreturnchar" );@]@=}
-<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@>@=}
-<SCRIPT,DEFSYMEXP,MRI,BOTH,EXPRESSION>((("$"|0[xX])([0-9A-Fa-f])+)|(([0-9])+))(M|K|m|k)? {
- @> @<Return a constant with a multiplier@>@=}
-<BOTH,SCRIPT,EXPRESSION,MRI>"]" {@> @[TeX_( "/yylexreturnchar" );@]@=}
-<BOTH,SCRIPT,EXPRESSION,MRI>"[" {@> @[TeX_( "/yylexreturnchar" );@]@=}
-<BOTH,SCRIPT,EXPRESSION,MRI>"<<=" {@> @[TeX_( "/yylexreturnptr{LSHIFTEQ}" );@]@=}
-<BOTH,SCRIPT,EXPRESSION,MRI>">>=" {@> @[TeX_( "/yylexreturnptr{RSHIFTEQ}" );@]@=}
-<BOTH,SCRIPT,EXPRESSION,MRI>"||" {@> @[TeX_( "/yylexreturnptr{OROR}" );@]@=}
-<BOTH,SCRIPT,EXPRESSION,MRI>"==" {@> @[TeX_( "/yylexreturnptr{EQ}" );@]@=}
-<BOTH,SCRIPT,EXPRESSION,MRI>"!=" {@> @[TeX_( "/yylexreturnptr{NE}" );@]@=}
-<BOTH,SCRIPT,EXPRESSION,MRI>">=" {@> @[TeX_( "/yylexreturnptr{GE}" );@]@=}
-<BOTH,SCRIPT,EXPRESSION,MRI>"<=" {@> @[TeX_( "/yylexreturnptr{LE}" );@]@=}
-<BOTH,SCRIPT,EXPRESSION,MRI>"<<" {@> @[TeX_( "/yylexreturnptr{LSHIFT}" );@]@=}
-<BOTH,SCRIPT,EXPRESSION,MRI>">>" {@> @[TeX_( "/yylexreturnptr{RSHIFT}" );@]@=}
-<BOTH,SCRIPT,EXPRESSION,MRI>"+=" {@> @[TeX_( "/yylexreturnptr{PLUSEQ}" );@]@=}
-<BOTH,SCRIPT,EXPRESSION,MRI>"-=" {@> @[TeX_( "/yylexreturnptr{MINUSEQ}" );@]@=}
-<BOTH,SCRIPT,EXPRESSION,MRI>"*=" {@> @[TeX_( "/yylexreturnptr{MULTEQ}" );@]@=}
-<BOTH,SCRIPT,EXPRESSION,MRI>"/=" {@> @[TeX_( "/yylexreturnptr{DIVEQ}" );@]@=}
-<BOTH,SCRIPT,EXPRESSION,MRI>"&=" {@> @[TeX_( "/yylexreturnptr{ANDEQ}" );@]@=}
-<BOTH,SCRIPT,EXPRESSION,MRI>"|=" {@> @[TeX_( "/yylexreturnptr{OREQ}" );@]@=}
-<BOTH,SCRIPT,EXPRESSION,MRI>"&&" {@> @[TeX_( "/yylexreturnptr{ANDAND}" );@]@=}
-<BOTH,SCRIPT,EXPRESSION,MRI>">" {@> @[TeX_( "/yylexreturnchar" );@]@=}
-<BOTH,SCRIPT,EXPRESSION,MRI>"," {@> @[TeX_( "/yylexreturnchar" );@]@=}
-<BOTH,SCRIPT,EXPRESSION,MRI>"&" {@> @[TeX_( "/yylexreturnchar" );@]@=}
-<BOTH,SCRIPT,EXPRESSION,MRI>"|" {@> @[TeX_( "/yylexreturnchar" );@]@=}
-<BOTH,SCRIPT,EXPRESSION,MRI>"~" {@> @[TeX_( "/yylexreturnchar" );@]@=}
-<BOTH,SCRIPT,EXPRESSION,MRI>"!" {@> @[TeX_( "/yylexreturnchar" );@]@=}
-<BOTH,SCRIPT,EXPRESSION,MRI>"?" {@> @[TeX_( "/yylexreturnchar" );@]@=}
-<BOTH,SCRIPT,EXPRESSION,MRI>"*" {@> @[TeX_( "/yylexreturnchar" );@]@=}
-<BOTH,SCRIPT,EXPRESSION,MRI>"+" {@> @[TeX_( "/yylexreturnchar" );@]@=}
-<BOTH,SCRIPT,EXPRESSION,MRI>"-" {@> @[TeX_( "/yylexreturnchar" );@]@=}
-<BOTH,SCRIPT,EXPRESSION,MRI>"/" {@> @[TeX_( "/yylexreturnchar" );@]@=}
-<BOTH,SCRIPT,EXPRESSION,MRI>"%" {@> @[TeX_( "/yylexreturnchar" );@]@=}
-<BOTH,SCRIPT,EXPRESSION,MRI>"<" {@> @[TeX_( "/yylexreturnchar" );@]@=}
-<BOTH,SCRIPT,EXPRESSION,MRI>"=" {@> @[TeX_( "/yylexreturnchar" );@]@=}
-<BOTH,SCRIPT,EXPRESSION,MRI>"}" {@> @[TeX_( "/yylexreturnchar" );@]@=}
-<BOTH,SCRIPT,EXPRESSION,MRI>"{" {@> @[TeX_( "/yylexreturnchar" );@]@=}
-<BOTH,SCRIPT,EXPRESSION,MRI>")" {@> @[TeX_( "/yylexreturnchar" );@]@=}
-<BOTH,SCRIPT,EXPRESSION,MRI>"(" {@> @[TeX_( "/yylexreturnchar" );@]@=}
-<BOTH,SCRIPT,EXPRESSION,MRI>":" {@> @[TeX_( "/yylexreturnchar" );@]@=}
-<BOTH,SCRIPT,EXPRESSION,MRI>";" {@> @[TeX_( "/yylexreturnchar" );@]@=}
+<BOTH,SCRIPT,EXPRESSION,VERS_START,VERS_NODE,VERS_SCRIPT>{
+ "/*" {@> @[TeX_( "/ldcomment/yylexnext" );@]@=}
+}
+
+<DEFSYMEXP>{
+ "-" {@> @[TeX_( "/yylexreturnchar" );@]@=}
+ "+" {@> @[TeX_( "/yylexreturnchar" );@]@=}
+ {FILENAMECHAR1}{SYMBOLCHARN}* {@> @[TeX_( "/yylexreturnsym{NAME}" );@]@=}
+ "=" {@> @[TeX_( "/yylexreturnchar" );@]@=}
+}
+
+<MRI,EXPRESSION>{
+ "$"([0-9A-Fa-f])+ {@> @<Return an absolute hex constant@> @=}
+ ([0-9A-Fa-f])+(H|h|X|x|B|b|O|o|D|d) {@> @<Return a constant in a specific radix@>@=}
+}
+
+<SCRIPT,DEFSYMEXP,MRI,BOTH,EXPRESSION>{
+ ((("$"|0[xX])([0-9A-Fa-f])+)|(([0-9])+))(M|K|m|k)? {@> @<Return a constant with a multiplier@>@=}
+}
+
+<BOTH,SCRIPT,EXPRESSION,MRI>{
+ "<<=" {@> @[TeX_( "/yylexreturnptr{LSHIFTEQ}" );@]@=}
+ ">>=" {@> @[TeX_( "/yylexreturnptr{RSHIFTEQ}" );@]@=}
+ "||" {@> @[TeX_( "/yylexreturnptr{OROR}" );@]@=}
+ "==" {@> @[TeX_( "/yylexreturnptr{EQ}" );@]@=}
+ "!=" {@> @[TeX_( "/yylexreturnptr{NE}" );@]@=}
+ ">=" {@> @[TeX_( "/yylexreturnptr{GE}" );@]@=}
+ "<=" {@> @[TeX_( "/yylexreturnptr{LE}" );@]@=}
+ "<<" {@> @[TeX_( "/yylexreturnptr{LSHIFT}" );@]@=}
+ ">>" {@> @[TeX_( "/yylexreturnptr{RSHIFT}" );@]@=}
+ "+=" {@> @[TeX_( "/yylexreturnptr{PLUSEQ}" );@]@=}
+ "-=" {@> @[TeX_( "/yylexreturnptr{MINUSEQ}" );@]@=}
+ "*=" {@> @[TeX_( "/yylexreturnptr{MULTEQ}" );@]@=}
+ "/=" {@> @[TeX_( "/yylexreturnptr{DIVEQ}" );@]@=}
+ "&=" {@> @[TeX_( "/yylexreturnptr{ANDEQ}" );@]@=}
+ "|=" {@> @[TeX_( "/yylexreturnptr{OREQ}" );@]@=}
+ "&&" {@> @[TeX_( "/yylexreturnptr{ANDAND}" );@]@=}
+ [&|~!?*+\-/%=<>{}()\[\]:;,] {@> @[TeX_( "/yylexreturnchar" );@]@=}
+}
@g
@ The bulk of tokens produced by the lexer are the keywords used
inside script files. File name syntax is listed as well, along with
-miscellanea such as whitespace and version symbols.
-@<\ld\ token regular expressions@>=
+the miscellanea like whitespace and version symbols.
+@<Regular expressions for \ld\ tokens@>=
@G(fs2)
-<BOTH,SCRIPT>"MEMORY" {@> @[TeX_( "/yylexreturnptr{MEMORY}" );@]@=}
-<BOTH,SCRIPT>"REGION_ALIAS" {@> @[TeX_( "/yylexreturnptr{REGION_ALIAS}" );@]@=}
-<BOTH,SCRIPT>"LD_FEATURE" {@> @[TeX_( "/yylexreturnptr{LD_FEATURE}" );@]@=}
-<BOTH,SCRIPT,EXPRESSION>"ORIGIN" {@> @[TeX_( "/yylexreturnptr{ORIGIN}" );@]@=}
-<BOTH,SCRIPT>"VERSION" {@> @[TeX_( "/yylexreturnptr{VERSIONK}" );@]@=}
-<EXPRESSION,BOTH,SCRIPT>"BLOCK" {@> @[TeX_( "/yylexreturnptr{BLOCK}" );@]@=}
-<EXPRESSION,BOTH,SCRIPT>"BIND" {@> @[TeX_( "/yylexreturnptr{BIND}" );@]@=}
-<BOTH,SCRIPT,EXPRESSION>"LENGTH" {@> @[TeX_( "/yylexreturnptr{LENGTH}" );@]@=}
-<EXPRESSION,BOTH,SCRIPT>"ALIGN" {@> @[TeX_( "/yylexreturnptr{ALIGN_K}" );@]@=}
-<EXPRESSION,BOTH,SCRIPT>"DATA_SEGMENT_ALIGN" {@> @[TeX_( "/yylexreturnptr{DATA_SEGMENT_ALIGN}" );@]@=}
-<EXPRESSION,BOTH,SCRIPT>"DATA_SEGMENT_RELRO_END" {@> @[TeX_( "/yylexreturnptr{DATA_SEGMENT_RELRO_END}" );@]@=}
-<EXPRESSION,BOTH,SCRIPT>"DATA_SEGMENT_END" {@> @[TeX_( "/yylexreturnptr{DATA_SEGMENT_END}" );@]@=}
-<EXPRESSION,BOTH,SCRIPT>"ADDR" {@> @[TeX_( "/yylexreturnptr{ADDR}" );@]@=}
-<EXPRESSION,BOTH,SCRIPT>"LOADADDR" {@> @[TeX_( "/yylexreturnptr{LOADADDR}" );@]@=}
-<EXPRESSION,BOTH,SCRIPT>"ALIGNOF" {@> @[TeX_( "/yylexreturnptr{ALIGNOF}" );@]@=}
-<EXPRESSION,BOTH>"MAX" {@> @[TeX_( "/yylexreturnptr{MAX_K}" );@]@=}
-<EXPRESSION,BOTH>"MIN" {@> @[TeX_( "/yylexreturnptr{MIN_K}" );@]@=}
-<EXPRESSION,BOTH>"LOG2CEIL" {@> @[TeX_( "/yylexreturnptr{LOG2CEIL}" );@]@=}
-<EXPRESSION,BOTH,SCRIPT>"ASSERT" {@> @[TeX_( "/yylexreturnptr{ASSERT_K}" );@]@=}
-<BOTH,SCRIPT>"ENTRY" {@> @[TeX_( "/yylexreturnptr{ENTRY}" );@]@=}
-<BOTH,SCRIPT,MRI>"EXTERN" {@> @[TeX_( "/yylexreturnptr{EXTERN}" );@]@=}
-<EXPRESSION,BOTH,SCRIPT>"NEXT" {@> @[TeX_( "/yylexreturnptr{NEXT}" );@]@=}
-<EXPRESSION,BOTH,SCRIPT>"sizeof_headers" {@> @[TeX_( "/yylexreturnptr{SIZEOF_HEADERS}" );@]@=}
-<EXPRESSION,BOTH,SCRIPT>"SIZEOF_HEADERS" {@> @[TeX_( "/yylexreturnptr{SIZEOF_HEADERS}" );@]@=}
-<EXPRESSION,BOTH,SCRIPT>"SEGMENT_START" {@> @[TeX_( "/yylexreturnptr{SEGMENT_START}" );@]@=}
-<BOTH,SCRIPT>"MAP" {@> @[TeX_( "/yylexreturnptr{MAP}" );@]@=}
-<EXPRESSION,BOTH,SCRIPT>"SIZEOF" {@> @[TeX_( "/yylexreturnptr{SIZEOF}" );@]@=}
-<BOTH,SCRIPT>"TARGET" {@> @[TeX_( "/yylexreturnptr{TARGET_K}" );@]@=}
-<BOTH,SCRIPT>"SEARCH_DIR" {@> @[TeX_( "/yylexreturnptr{SEARCH_DIR}" );@]@=}
-<BOTH,SCRIPT>"OUTPUT" {@> @[TeX_( "/yylexreturnptr{OUTPUT}" );@]@=}
-<BOTH,SCRIPT>"INPUT" {@> @[TeX_( "/yylexreturnptr{INPUT}" );@]@=}
-<EXPRESSION,BOTH,SCRIPT>"GROUP" {@> @[TeX_( "/yylexreturnptr{GROUP}" );@]@=}
-<EXPRESSION,BOTH,SCRIPT>"AS_NEEDED" {@> @[TeX_( "/yylexreturnptr{AS_NEEDED}" );@]@=}
-<EXPRESSION,BOTH,SCRIPT>"DEFINED" {@> @[TeX_( "/yylexreturnptr{DEFINED}" );@]@=}
-<BOTH,SCRIPT>"CREATE_OBJECT_SYMBOLS" {@> @[TeX_( "/yylexreturnptr{CREATE_OBJECT_SYMBOLS}" );@]@=}
-<BOTH,SCRIPT>"CONSTRUCTORS" {@> @[TeX_( "/yylexreturnptr{CONSTRUCTORS}" );@]@=}
-<BOTH,SCRIPT>"FORCE_COMMON_ALLOCATION" {@> @[TeX_( "/yylexreturnptr{FORCE_COMMON_ALLOCATION}" );@]@=}
-<BOTH,SCRIPT>"INHIBIT_COMMON_ALLOCATION" {@> @[TeX_( "/yylexreturnptr{INHIBIT_COMMON_ALLOCATION}" );@]@=}
-<BOTH,SCRIPT>"SECTIONS" {@> @[TeX_( "/yylexreturnptr{SECTIONS}" );@]@=}
-<BOTH,SCRIPT>"INSERT" {@> @[TeX_( "/yylexreturnptr{INSERT_K}" );@]@=}
-<BOTH,SCRIPT>"AFTER" {@> @[TeX_( "/yylexreturnptr{AFTER}" );@]@=}
-<BOTH,SCRIPT>"BEFORE" {@> @[TeX_( "/yylexreturnptr{BEFORE}" );@]@=}
-<BOTH,SCRIPT>"FILL" {@> @[TeX_( "/yylexreturnptr{FILL}" );@]@=}
-<BOTH,SCRIPT>"STARTUP" {@> @[TeX_( "/yylexreturnptr{STARTUP}" );@]@=}
-<BOTH,SCRIPT>"OUTPUT_FORMAT" {@> @[TeX_( "/yylexreturnptr{OUTPUT_FORMAT}" );@]@=}
-<BOTH,SCRIPT>"OUTPUT_ARCH" {@> @[TeX_( "/yylexreturnptr{OUTPUT_ARCH}" );@]@=}
-<BOTH,SCRIPT>"HLL" {@> @[TeX_( "/yylexreturnptr{HLL}" );@]@=}
-<BOTH,SCRIPT>"SYSLIB" {@> @[TeX_( "/yylexreturnptr{SYSLIB}" );@]@=}
-<BOTH,SCRIPT>"FLOAT" {@> @[TeX_( "/yylexreturnptr{FLOAT}" );@]@=}
-<BOTH,SCRIPT>"QUAD" {@> @[TeX_( "/yylexreturnptr{QUAD}" );@]@=}
-<BOTH,SCRIPT>"SQUAD" {@> @[TeX_( "/yylexreturnptr{SQUAD}" );@]@=}
-<BOTH,SCRIPT>"LONG" {@> @[TeX_( "/yylexreturnptr{LONG}" );@]@=}
-<BOTH,SCRIPT>"SHORT" {@> @[TeX_( "/yylexreturnptr{SHORT}" );@]@=}
-<BOTH,SCRIPT>"BYTE" {@> @[TeX_( "/yylexreturnptr{BYTE}" );@]@=}
-<BOTH,SCRIPT>"NOFLOAT" {@> @[TeX_( "/yylexreturnptr{NOFLOAT}" );@]@=}
-<EXPRESSION,BOTH,SCRIPT>"NOCROSSREFS" {@> @[TeX_( "/yylexreturnptr{NOCROSSREFS}" );@]@=}
-<BOTH,SCRIPT>"OVERLAY" {@> @[TeX_( "/yylexreturnptr{OVERLAY}" );@]@=}
-<BOTH,SCRIPT>"SORT_BY_NAME" {@> @[TeX_( "/yylexreturnptr{SORT_BY_NAME}" );@]@=}
-<BOTH,SCRIPT>"SORT_BY_ALIGNMENT" {@> @[TeX_( "/yylexreturnptr{SORT_BY_ALIGNMENT}" );@]@=}
-<BOTH,SCRIPT>"SORT" {@> @[TeX_( "/yylexreturnptr{SORT_BY_NAME}" );@]@=}
-<BOTH,SCRIPT>"SORT_BY_INIT_PRIORITY" {@> @[TeX_( "/yylexreturnptr{SORT_BY_INIT_PRIORITY}" );@]@=}
-<BOTH,SCRIPT>"SORT_NONE" {@> @[TeX_( "/yylexreturnptr{SORT_NONE}" );@]@=}
-<EXPRESSION,BOTH,SCRIPT>"NOLOAD" {@> @[TeX_( "/yylexreturnptr{NOLOAD}" );@]@=}
-<EXPRESSION,BOTH,SCRIPT>"DSECT" {@> @[TeX_( "/yylexreturnptr{DSECT}" );@]@=}
-<EXPRESSION,BOTH,SCRIPT>"COPY" {@> @[TeX_( "/yylexreturnptr{COPY}" );@]@=}
-<EXPRESSION,BOTH,SCRIPT>"INFO" {@> @[TeX_( "/yylexreturnptr{INFO}" );@]@=}
-<EXPRESSION,BOTH,SCRIPT>"OVERLAY" {@> @[TeX_( "/yylexreturnptr{OVERLAY}" );@]@=}
-<EXPRESSION,BOTH,SCRIPT>"ONLY_IF_RO" {@> @[TeX_( "/yylexreturnptr{ONLY_IF_RO}" );@]@=}
-<EXPRESSION,BOTH,SCRIPT>"ONLY_IF_RW" {@> @[TeX_( "/yylexreturnptr{ONLY_IF_RW}" );@]@=}
-<EXPRESSION,BOTH,SCRIPT>"SPECIAL" {@> @[TeX_( "/yylexreturnptr{SPECIAL}" );@]@=}
-<BOTH,SCRIPT>"o" {@> @[TeX_( "/yylexreturnptr{ORIGIN}" );@]@=}
-<BOTH,SCRIPT>"org" {@> @[TeX_( "/yylexreturnptr{ORIGIN}" );@]@=}
-<BOTH,SCRIPT>"l" {@> @[TeX_( "/yylexreturnptr{LENGTH}" );@]@=}
-<BOTH,SCRIPT>"len" {@> @[TeX_( "/yylexreturnptr{LENGTH}" );@]@=}
-<EXPRESSION,BOTH,SCRIPT>"INPUT_SECTION_FLAGS" {@> @[TeX_( "/yylexreturnptr{INPUT_SECTION_FLAGS}" );@]@=}
-<EXPRESSION,BOTH,SCRIPT>"INCLUDE" {@> @[TeX_( "/yylexreturnptr{INCLUDE}" );@]@=}
-<BOTH,SCRIPT>"PHDRS" {@> @[TeX_( "/yylexreturnptr{PHDRS}" );@]@=}
-<EXPRESSION,BOTH,SCRIPT>"AT" {@> @[TeX_( "/yylexreturnptr{AT}" );@]@=}
-<EXPRESSION,BOTH,SCRIPT>"ALIGN_WITH_INPUT" {@> @[TeX_( "/yylexreturnptr{ALIGN_WITH_INPUT}" );@]@=}
-<EXPRESSION,BOTH,SCRIPT>"SUBALIGN" {@> @[TeX_( "/yylexreturnptr{SUBALIGN}" );@]@=}
-<EXPRESSION,BOTH,SCRIPT>"HIDDEN" {@> @[TeX_( "/yylexreturnptr{HIDDEN}" );@]@=}
-<EXPRESSION,BOTH,SCRIPT>"PROVIDE" {@> @[TeX_( "/yylexreturnptr{PROVIDE}" );@]@=}
-<EXPRESSION,BOTH,SCRIPT>"PROVIDE_HIDDEN" {@> @[TeX_( "/yylexreturnptr{PROVIDE_HIDDEN}" );@]@=}
-<EXPRESSION,BOTH,SCRIPT>"KEEP" {@> @[TeX_( "/yylexreturnptr{KEEP}" );@]@=}
-<EXPRESSION,BOTH,SCRIPT>"EXCLUDE_FILE" {@> @[TeX_( "/yylexreturnptr{EXCLUDE_FILE}" );@]@=}
-<EXPRESSION,BOTH,SCRIPT>"CONSTANT" {@> @[TeX_( "/yylexreturnptr{CONSTANT}" );@]@=}
-<MRI>"#".*\n? {@> @[TeX_( "/yylexnext" );@]@=}
-<MRI>"\n" {@> @[TeX_( "/yylexreturnptr{NEWLINE}" );@]@=}
-<MRI>"*".* {@> @[TeX_( "/yylexnext" );@]@=}
-<MRI>";".* {@> @[TeX_( "/yylexnext" );@]@=}
-<MRI>"END" {@> @[TeX_( "/yylexreturnptr{ENDWORD}" );@]@=}
-<MRI>"ALIGNMOD" {@> @[TeX_( "/yylexreturnptr{ALIGNMOD}" );@]@=}
-<MRI>"ALIGN" {@> @[TeX_( "/yylexreturnptr{ALIGN_K}" );@]@=}
-<MRI>"CHIP" {@> @[TeX_( "/yylexreturnptr{CHIP}" );@]@=}
-<MRI>"BASE" {@> @[TeX_( "/yylexreturnptr{BASE}" );@]@=}
-<MRI>"ALIAS" {@> @[TeX_( "/yylexreturnptr{ALIAS}" );@]@=}
-<MRI>"TRUNCATE" {@> @[TeX_( "/yylexreturnptr{TRUNCATE}" );@]@=}
-<MRI>"LOAD" {@> @[TeX_( "/yylexreturnptr{LOAD}" );@]@=}
-<MRI>"PUBLIC" {@> @[TeX_( "/yylexreturnptr{PUBLIC}" );@]@=}
-<MRI>"ORDER" {@> @[TeX_( "/yylexreturnptr{ORDER}" );@]@=}
-<MRI>"NAME" {@> @[TeX_( "/yylexreturnptr{NAMEWORD}" );@]@=}
-<MRI>"FORMAT" {@> @[TeX_( "/yylexreturnptr{FORMAT}" );@]@=}
-<MRI>"CASE" {@> @[TeX_( "/yylexreturnptr{CASE}" );@]@=}
-<MRI>"START" {@> @[TeX_( "/yylexreturnptr{START}" );@]@=}
-<MRI>"LIST".* {@> @[TeX_( "/yylexreturnptr{LIST}" );@]@=}
-<MRI>"SECT" {@> @[TeX_( "/yylexreturnptr{SECT}" );@]@=}
-<EXPRESSION,BOTH,SCRIPT,MRI>"ABSOLUTE" {@> @[TeX_( "/yylexreturnptr{ABSOLUTE}" );@]@=}
-<MRI>"end" {@> @[TeX_( "/yylexreturnptr{ENDWORD}" );@]@=}
-<MRI>"alignmod" {@> @[TeX_( "/yylexreturnptr{ALIGNMOD}" );@]@=}
-<MRI>"align" {@> @[TeX_( "/yylexreturnptr{ALIGN_K}" );@]@=}
-<MRI>"chip" {@> @[TeX_( "/yylexreturnptr{CHIP}" );@]@=}
-<MRI>"base" {@> @[TeX_( "/yylexreturnptr{BASE}" );@]@=}
-<MRI>"alias" {@> @[TeX_( "/yylexreturnptr{ALIAS}" );@]@=}
-<MRI>"truncate" {@> @[TeX_( "/yylexreturnptr{TRUNCATE}" );@]@=}
-<MRI>"load" {@> @[TeX_( "/yylexreturnptr{LOAD}" );@]@=}
-<MRI>"public" {@> @[TeX_( "/yylexreturnptr{PUBLIC}" );@]@=}
-<MRI>"order" {@> @[TeX_( "/yylexreturnptr{ORDER}" );@]@=}
-<MRI>"name" {@> @[TeX_( "/yylexreturnptr{NAMEWORD}" );@]@=}
-<MRI>"format" {@> @[TeX_( "/yylexreturnptr{FORMAT}" );@]@=}
-<MRI>"case" {@> @[TeX_( "/yylexreturnptr{CASE}" );@]@=}
-<MRI>"extern" {@> @[TeX_( "/yylexreturnptr{EXTERN}" );@]@=}
-<MRI>"start" {@> @[TeX_( "/yylexreturnptr{START}" );@]@=}
-<MRI>"list".* {@> @[TeX_( "/yylexreturnptr{LIST}" );@]@=}
-<MRI>"sect" {@> @[TeX_( "/yylexreturnptr{SECT}" );@]@=}
-<EXPRESSION,BOTH,SCRIPT,MRI>"absolute" {@> @[TeX_( "/yylexreturnptr{ABSOLUTE}" );@]@=}
-<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}" );@]@=}
+<BOTH,SCRIPT>{
+ "MEMORY" {@> @[TeX_( "/yylexreturnptr{MEMORY}" );@]@=}
+ "REGION_ALIAS" {@> @[TeX_( "/yylexreturnptr{REGION_ALIAS}" );@]@=}
+ "LD_FEATURE" {@> @[TeX_( "/yylexreturnptr{LD_FEATURE}" );@]@=}
+ "VERSION" {@> @[TeX_( "/yylexreturnptr{VERSIONK}" );@]@=}
+ "TARGET" {@> @[TeX_( "/yylexreturnptr{TARGET_K}" );@]@=}
+ "SEARCH_DIR" {@> @[TeX_( "/yylexreturnptr{SEARCH_DIR}" );@]@=}
+ "OUTPUT" {@> @[TeX_( "/yylexreturnptr{OUTPUT}" );@]@=}
+ "INPUT" {@> @[TeX_( "/yylexreturnptr{INPUT}" );@]@=}
+ "ENTRY" {@> @[TeX_( "/yylexreturnptr{ENTRY}" );@]@=}
+ "MAP" {@> @[TeX_( "/yylexreturnptr{MAP}" );@]@=}
+ "CREATE_OBJECT_SYMBOLS" {@> @[TeX_( "/yylexreturnptr{CREATE_OBJECT_SYMBOLS}" );@]@=}
+ "CONSTRUCTORS" {@> @[TeX_( "/yylexreturnptr{CONSTRUCTORS}" );@]@=}
+ "FORCE_COMMON_ALLOCATION" {@> @[TeX_( "/yylexreturnptr{FORCE_COMMON_ALLOCATION}" );@]@=}
+ "INHIBIT_COMMON_ALLOCATION" {@> @[TeX_( "/yylexreturnptr{INHIBIT_COMMON_ALLOCATION}" );@]@=}
+ "SECTIONS" {@> @[TeX_( "/yylexreturnptr{SECTIONS}" );@]@=}
+ "INSERT" {@> @[TeX_( "/yylexreturnptr{INSERT_K}" );@]@=}
+ "AFTER" {@> @[TeX_( "/yylexreturnptr{AFTER}" );@]@=}
+ "BEFORE" {@> @[TeX_( "/yylexreturnptr{BEFORE}" );@]@=}
+ "FILL" {@> @[TeX_( "/yylexreturnptr{FILL}" );@]@=}
+ "STARTUP" {@> @[TeX_( "/yylexreturnptr{STARTUP}" );@]@=}
+ "OUTPUT_FORMAT" {@> @[TeX_( "/yylexreturnptr{OUTPUT_FORMAT}" );@]@=}
+ "OUTPUT_ARCH" {@> @[TeX_( "/yylexreturnptr{OUTPUT_ARCH}" );@]@=}
+ "HLL" {@> @[TeX_( "/yylexreturnptr{HLL}" );@]@=}
+ "SYSLIB" {@> @[TeX_( "/yylexreturnptr{SYSLIB}" );@]@=}
+ "FLOAT" {@> @[TeX_( "/yylexreturnptr{FLOAT}" );@]@=}
+ "QUAD" {@> @[TeX_( "/yylexreturnptr{QUAD}" );@]@=}
+ "SQUAD" {@> @[TeX_( "/yylexreturnptr{SQUAD}" );@]@=}
+ "LONG" {@> @[TeX_( "/yylexreturnptr{LONG}" );@]@=}
+ "SHORT" {@> @[TeX_( "/yylexreturnptr{SHORT}" );@]@=}
+ "BYTE" {@> @[TeX_( "/yylexreturnptr{BYTE}" );@]@=}
+ "NOFLOAT" {@> @[TeX_( "/yylexreturnptr{NOFLOAT}" );@]@=}
+ "OVERLAY" {@> @[TeX_( "/yylexreturnptr{OVERLAY}" );@]@=}
+ "SORT_BY_NAME" {@> @[TeX_( "/yylexreturnptr{SORT_BY_NAME}" );@]@=}
+ "SORT_BY_ALIGNMENT" {@> @[TeX_( "/yylexreturnptr{SORT_BY_ALIGNMENT}" );@]@=}
+ "SORT" {@> @[TeX_( "/yylexreturnptr{SORT_BY_NAME}" );@]@=}
+ "SORT_BY_INIT_PRIORITY" {@> @[TeX_( "/yylexreturnptr{SORT_BY_INIT_PRIORITY}" );@]@=}
+ "SORT_NONE" {@> @[TeX_( "/yylexreturnptr{SORT_NONE}" );@]@=}
+ "EXTERN" {@> @[TeX_( "/yylexreturnptr{EXTERN}" );@]@=}
+ "o"|"org" {@> @[TeX_( "/yylexreturnptr{ORIGIN}" );@]@=}
+ "l"|"len" {@> @[TeX_( "/yylexreturnptr{LENGTH}" );@]@=}
+ "PHDRS" {@> @[TeX_( "/yylexreturnptr{PHDRS}" );@]@=}
+}
+
+<EXPRESSION,BOTH,SCRIPT>{
+ "BLOCK" {@> @[TeX_( "/yylexreturnptr{BLOCK}" );@]@=}
+ "BIND" {@> @[TeX_( "/yylexreturnptr{BIND}" );@]@=}
+ "LENGTH" {@> @[TeX_( "/yylexreturnptr{LENGTH}" );@]@=}
+ "ORIGIN" {@> @[TeX_( "/yylexreturnptr{ORIGIN}" );@]@=}
+ "ALIGN" {@> @[TeX_( "/yylexreturnptr{ALIGN_K}" );@]@=}
+ "DATA_SEGMENT_ALIGN" {@> @[TeX_( "/yylexreturnptr{DATA_SEGMENT_ALIGN}" );@]@=}
+ "DATA_SEGMENT_RELRO_END" {@> @[TeX_( "/yylexreturnptr{DATA_SEGMENT_RELRO_END}" );@]@=}
+ "DATA_SEGMENT_END" {@> @[TeX_( "/yylexreturnptr{DATA_SEGMENT_END}" );@]@=}
+ "ADDR" {@> @[TeX_( "/yylexreturnptr{ADDR}" );@]@=}
+ "LOADADDR" {@> @[TeX_( "/yylexreturnptr{LOADADDR}" );@]@=}
+ "ALIGNOF" {@> @[TeX_( "/yylexreturnptr{ALIGNOF}" );@]@=}
+ "ASSERT" {@> @[TeX_( "/yylexreturnptr{ASSERT_K}" );@]@=}
+ "NEXT" {@> @[TeX_( "/yylexreturnptr{NEXT}" );@]@=}
+ "sizeof_headers" {@> @[TeX_( "/yylexreturnptr{SIZEOF_HEADERS}" );@]@=}
+ "SIZEOF_HEADERS" {@> @[TeX_( "/yylexreturnptr{SIZEOF_HEADERS}" );@]@=}
+ "SEGMENT_START" {@> @[TeX_( "/yylexreturnptr{SEGMENT_START}" );@]@=}
+ "SIZEOF" {@> @[TeX_( "/yylexreturnptr{SIZEOF}" );@]@=}
+ "GROUP" {@> @[TeX_( "/yylexreturnptr{GROUP}" );@]@=}
+ "AS_NEEDED" {@> @[TeX_( "/yylexreturnptr{AS_NEEDED}" );@]@=}
+ "DEFINED" {@> @[TeX_( "/yylexreturnptr{DEFINED}" );@]@=}
+ "NOCROSSREFS" {@> @[TeX_( "/yylexreturnptr{NOCROSSREFS}" );@]@=}
+ "NOLOAD" {@> @[TeX_( "/yylexreturnptr{NOLOAD}" );@]@=}
+ "DSECT" {@> @[TeX_( "/yylexreturnptr{DSECT}" );@]@=}
+ "COPY" {@> @[TeX_( "/yylexreturnptr{COPY}" );@]@=}
+ "INFO" {@> @[TeX_( "/yylexreturnptr{INFO}" );@]@=}
+ "OVERLAY" {@> @[TeX_( "/yylexreturnptr{OVERLAY}" );@]@=}
+ "ONLY_IF_RO" {@> @[TeX_( "/yylexreturnptr{ONLY_IF_RO}" );@]@=}
+ "ONLY_IF_RW" {@> @[TeX_( "/yylexreturnptr{ONLY_IF_RW}" );@]@=}
+ "SPECIAL" {@> @[TeX_( "/yylexreturnptr{SPECIAL}" );@]@=}
+ "INPUT_SECTION_FLAGS" {@> @[TeX_( "/yylexreturnptr{INPUT_SECTION_FLAGS}" );@]@=}
+ "INCLUDE" {@> @[TeX_( "/yylexreturnptr{INCLUDE}" );@]@=}
+ "AT" {@> @[TeX_( "/yylexreturnptr{AT}" );@]@=}
+ "ALIGN_WITH_INPUT" {@> @[TeX_( "/yylexreturnptr{ALIGN_WITH_INPUT}" );@]@=}
+ "SUBALIGN" {@> @[TeX_( "/yylexreturnptr{SUBALIGN}" );@]@=}
+ "HIDDEN" {@> @[TeX_( "/yylexreturnptr{HIDDEN}" );@]@=}
+ "PROVIDE" {@> @[TeX_( "/yylexreturnptr{PROVIDE}" );@]@=}
+ "PROVIDE_HIDDEN" {@> @[TeX_( "/yylexreturnptr{PROVIDE_HIDDEN}" );@]@=}
+ "KEEP" {@> @[TeX_( "/yylexreturnptr{KEEP}" );@]@=}
+ "EXCLUDE_FILE" {@> @[TeX_( "/yylexreturnptr{EXCLUDE_FILE}" );@]@=}
+ "CONSTANT" {@> @[TeX_( "/yylexreturnptr{CONSTANT}" );@]@=}
+ "\n" {@> @[TeX_( "/yylexnext" );@]@=}
+}
+
+<EXPRESSION,BOTH>{
+ "MAX" {@> @[TeX_( "/yylexreturnptr{MAX_K}" );@]@=}
+ "MIN" {@> @[TeX_( "/yylexreturnptr{MIN_K}" );@]@=}
+ "LOG2CEIL" {@> @[TeX_( "/yylexreturnptr{LOG2CEIL}" );@]@=}
+}
+
+<EXPRESSION,BOTH,SCRIPT,MRI>{
+ "ABSOLUTE"|"absolute" {@> @[TeX_( "/yylexreturnptr{ABSOLUTE}" );@]@=}
+ [ \t\r]+ {@> @[TeX_( "/yylexnext" );@]@=}
+}
+
+<BOTH>{
+ {FILENAMECHAR1}{FILENAMECHAR}* {@> @[TeX_( "/yylexreturnsym{NAME}" );@]@=}
+ "-l"{FILENAMECHAR}+ {@> @[TeX_( "/yylexreturnsym{NAME}" );@]@=}
+}
+
+<EXPRESSION>{
+ {FILENAMECHAR1}{NOCFILENAMECHAR}* {@> @[TeX_( "/yylexreturnsym{NAME}" );@]@=}
+ "-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" );@]@=}
-<MRI,BOTH,SCRIPT,EXPRESSION>[ \t\r]+ {@> @[TeX_( "/yylexnext" );@]@=}
-<VERS_NODE,VERS_SCRIPT>[:,;] {@> @[TeX_( "/yylexreturnchar" );@]@=}
-<VERS_NODE>global {@> @[TeX_( "/yylexreturnptr{GLOBAL}" );@]@=}
-<VERS_NODE>local {@> @[TeX_( "/yylexreturnptr{LOCAL}" );@]@=}
-<VERS_NODE>extern {@> @[TeX_( "/yylexreturnptr{EXTERN}" );@]@=}
-<VERS_NODE>{V_IDENTIFIER} {@> @[TeX_( "/yylexreturnval{VERS_IDENTIFIER}" );@]@=}
-<VERS_SCRIPT>{V_TAG} {@> @[TeX_( "/yylexreturnval{VERS_TAG}" );@]@=}
-<VERS_START>"{" {@> @[TeX_( "/yyBEGIN{VERS_SCRIPT}/yylexreturnchar" );@]@=}
@g
@ There is a bit of a trick to returning an absolute hex value. The
@@ -455,23 +437,6 @@ macros are looking for a \.{\$} suffix while the contents of
@[TeX_( "{/the/yyfmark}{/the/yysmark}}}/next" );@]@;
@[TeX_( "/yylexreturn{INT}" );@]@;
-@ @<Additional macros for the \ld\ lexer/parser@>=
-@G(t)
-@=\def\matchcomment@@#1/*#2\yyeof#3#4{%@>@;
- \yystringempty{#1}{#3}{#4}%
-}
-\def\matchcomment#1{%
-@= \expandafter\matchcomment@@\the#1/*\yyeof@>@;
-}
-\def\ldstripquotes@@"#1"\yyeof{#1}
-\def\ldstripquotes#1{%
- \yytext\expandafter\expandafter\expandafter
- {\expandafter\ldstripquotes@@\the\yytext\yyeof}%
- \yytextpure\expandafter\expandafter\expandafter
- {\expandafter\ldstripquotes@@\the\yytextpure\yyeof}%
-}
-@g
-
@ {\it 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
@@ -485,31 +450,103 @@ try again.}
@<Return the \prodstyle{NAME} inside quotes@>=
@[TeX_( "/ldstripquotes/yylexreturnsym{NAME}" );@]@;
-@ @<Additional macros for the \ld\ lexer/parser@>=
+@ Some syntax specific to version scripts.
+@<Regular expressions for \ld\ tokens@>=
+@G(fs2)
+<VERS_SCRIPT>{
+ "{" {@> @[TeX_( "/yyBEGIN{VERS_NODE}/versnodenesting=/z@@/yylexreturnchar" );@]@=}
+ "}" {@> @[TeX_( "/yylexreturnchar" );@]@=}
+ {V_TAG} {@> @[TeX_( "/yylexreturnval{VERS_TAG}" );@]@=}
+}
+
+<VERS_NODE>{
+ global {@> @[TeX_( "/yylexreturnptr{GLOBAL}" );@]@=}
+ local {@> @[TeX_( "/yylexreturnptr{LOCAL}" );@]@=}
+ extern {@> @[TeX_( "/yylexreturnptr{EXTERN}" );@]@=}
+ {V_IDENTIFIER} {@> @[TeX_( "/yylexreturnval{VERS_IDENTIFIER}" );@]@=}
+ "{" {@> @[TeX_( "/advance/versnodenesting/@@ne /yylexreturnchar" );@]@=}
+ "}" {@> @<Finish the current group, possibly switch to \flexsnstyle{VERS_SCRIPT}@> @=}
+}
+
+<VERS_NODE,VERS_SCRIPT>[:,;] {@> @[TeX_( "/yylexreturnchar" );@]@=}
+<VERS_START>"{" {@> @[TeX_( "/yyBEGIN{VERS_SCRIPT}/yylexreturnchar" );@]@=}
+
+<VERS_START,VERS_NODE,VERS_SCRIPT>{
+ [\n] {@> @[TeX_( "/yylexnext" );@]@=}
+ #.* {@> @[TeX_( "/yylexnext" );@]@=}
+ [ \t\r]+ {@> @[TeX_( "/yylexnext" );@]@=}
+}
+@g
+
+@ @<Finish the current group, possibly switch to \flexsnstyle{VERS_SCRIPT}@>=
+ @[TeX_( "/advance/versnodenesting/m@@ne" );@]@;
+ @[TeX_( "/ifnum/versnodenesting</z@@" );@]@;
+ @[TeX_( " /yyBEGIN{VERS_SCRIPT}" );@]@;
+ @[TeX_( "/fi" );@]@;
+ @[TeX_( "/yylexreturnchar" );@]@;
+
+@ Some syntax specific to \MRI\ scripts.
+@<Regular expressions for \ld\ tokens@>=
+@G(fs2)
+<MRI>{
+ "#".*\n? {@> @[TeX_( "/yylexnext" );@]@=}
+ "\n" {@> @[TeX_( "/yylexreturnptr{NEWLINE}" );@]@=}
+ "*".* {@> @[TeX_( "/yylexnext" );@]@=}
+ ";".* {@> @[TeX_( "/yylexnext" );@]@=}
+ "END"|"end" {@> @[TeX_( "/yylexreturnptr{ENDWORD}" );@]@=}
+ "ALIGNMOD"|"alignmod" {@> @[TeX_( "/yylexreturnptr{ALIGNMOD}" );@]@=}
+ "ALIGN"|"align" {@> @[TeX_( "/yylexreturnptr{ALIGN_K}" );@]@=}
+ "CHIP"|"chip" {@> @[TeX_( "/yylexreturnptr{CHIP}" );@]@=}
+ "BASE"|"base" {@> @[TeX_( "/yylexreturnptr{BASE}" );@]@=}
+ "ALIAS"|"alias" {@> @[TeX_( "/yylexreturnptr{ALIAS}" );@]@=}
+ "TRUNCATE"|"truncate" {@> @[TeX_( "/yylexreturnptr{TRUNCATE}" );@]@=}
+ "LOAD"|"load" {@> @[TeX_( "/yylexreturnptr{LOAD}" );@]@=}
+ "PUBLIC"|"public" {@> @[TeX_( "/yylexreturnptr{PUBLIC}" );@]@=}
+ "ORDER"|"order" {@> @[TeX_( "/yylexreturnptr{ORDER}" );@]@=}
+ "NAME"|"name" {@> @[TeX_( "/yylexreturnptr{NAMEWORD}" );@]@=}
+ "FORMAT"|"format" {@> @[TeX_( "/yylexreturnptr{FORMAT}" );@]@=}
+ "CASE"|"case" {@> @[TeX_( "/yylexreturnptr{CASE}" );@]@=}
+ "START"|"start" {@> @[TeX_( "/yylexreturnptr{START}" );@]@=}
+ ("LIST"|"list").* {@> @[TeX_( "/yylexreturnptr{LIST}" );@]@=}
+ "SECT"|"sect" {@> @[TeX_( "/yylexreturnptr{SECT}" );@]@=}
+ "EXTERN"|"extern" {@> @[TeX_( "/yylexreturnptr{EXTERN}" );@]@=}
+ {FILENAMECHAR1}{NOCFILENAMECHAR}* {@> @[TeX_( "/yylexreturnsym{NAME}" );@]@=}
+}
+@g
+
+@ The macros and the register definitions used to implement the actions above have been collected in this
+section.
+@<Additional macros for the \ld\ lexer/parser@>=
@G(t)
\newcount\versnodenesting
\newcount\includestackptr
+
+\def\matchcomment#1{%
+@= \expandafter\matchcomment@@\the#1/*\yyeof@>@;
+}
+
+@=\def\matchcomment@@#1/*#2\yyeof#3#4{%@>@;
+ \yystringempty{#1}{#3}{#4}%
+}
+
+\def\ldstripquotes#1{%
+ \yytext\expandafter\expandafter\expandafter
+ {\expandafter\ldstripquotes@@\the\yytext\yyeof}%
+ \yytextpure\expandafter\expandafter\expandafter
+ {\expandafter\ldstripquotes@@\the\yytextpure\yyeof}%
+}
+
+\def\ldstripquotes@@"#1"\yyeof{#1}
@g
-@ Some syntax specific to version scripts.
-@<\ld\ token regular expressions@>=
+@ Catchall actions. These react to unexpected characters with (somewhat misleading) error messages. The placement
+of these rules is important, since they may match a token of the same length defined earlier.
+@<Regular expressions for \ld\ tokens@>=
@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" );@]@=
- @> @[TeX_( "/yylexreturnchar" );@]@=}
-<VERS_START,VERS_NODE,VERS_SCRIPT>[\n] {@> @[TeX_( "/yylexnext" );@]@=}
-<VERS_START,VERS_NODE,VERS_SCRIPT>#.* {@> @[TeX_( "/yylexnext" );@]@=}
-<VERS_START,VERS_NODE,VERS_SCRIPT>[ \t\r]+ {@> @[TeX_( "/yylexnext" );@]@=}
+<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}" );@]@=}
<<EOF>> {@> @[@<Process the end of (possibly included) file@>@]@=}
-
-<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@>=
diff --git a/support/splint/examples/ld/ldlexo.w b/support/splint/examples/ld/ldlexo.w
index a1c5d62bb0..eb273ac7e8 100644
--- a/support/splint/examples/ld/ldlexo.w
+++ b/support/splint/examples/ld/ldlexo.w
@@ -1,4 +1,4 @@
-@q Copyright 2015-2020 Alexander Shibakov@>
+@q Copyright 2015-2022 Alexander Shibakov@>
@q Copyright 2002-2015 Free Software Foundation, Inc.@>
@q This file is part of SPLinT@>
@@ -26,11 +26,17 @@ are a leftover from the archaic days of the original scanner generator.}
@G
@> @<Original \ld\ macros@> @=
%{@>@<Original \ld\ preamble@> @=%}
-%option nounput
+ @> @<Miscellaneous \ld\ lexer options@> @=
@> @<Ignored options@> @=
%%
@> @<Original \ld\ regular expressions@> @=
%%
+ @> @<Original \ld\ postamble@> @=
+@g
+
+@ @<Miscellaneous \ld\ lexer options@>=
+@G(fs1)
+%option nounput
@g
@ @<Original \ld\ preamble@>=
@@ -134,7 +140,7 @@ States:
}%
\ifbootstrapmode\else\yyskipparsefalse\fi
@<\ld\ states@>=
-@G
+@G(fs1)
%s SCRIPT
%s EXPRESSION
%s BOTH
@@ -145,7 +151,7 @@ States:
%s VERS_NODE
@g
-@ @<\ld\ postamble@>=
+@ @<Original \ld\ postamble@>=
if (parser_input != input_selected)
{
/* The first token of the input determines the initial parser state. */
diff --git a/support/splint/examples/ld/ldman.w b/support/splint/examples/ld/ldman.w
index b6eb733dbd..af55b19111 100644
--- a/support/splint/examples/ld/ldman.w
+++ b/support/splint/examples/ld/ldman.w
@@ -1,5 +1,4 @@
-% Copyright 2012-2020, Alexander Shibakov
-% Copyright 2002-2014 Free Software Foundation, Inc.
+% Copyright 2012-2024, Alexander Shibakov
% This file is part of SPLinT
%
% SPLinT is free software: you can redistribute it and/or modify
@@ -15,27 +14,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
-\def\MRI{{\sc MRI}}
\def\optimization{5}
\input ldman.sty
+\input ldsetup.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
+\topskip=9pt
\let\oldN\N
\let\N\chapterN
\let\M\textM
+\initauxstream
\showlastactiontrue
-\immediate\openout\gindex=\jobname.gdx
@** Introduction.
-\setupfootnotes
This is a manual documenting the development of a parser that can be
used to typeset \ld\ files (linker scripts) with or without the help
of \CWEB. An existing parser for \ld\ has been adopted as a base, with
@@ -50,14 +44,15 @@ limitations).
Nearly every aspect of the design is discussed, including the
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.
+in \.{ldman.sty} and \.{ldsetup.sty} which are later included in the
+\TeX\ file produced by \CWEAVE.
@<Set up the generic parser machinery@>=
@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 */
+\let\nx\noexpand %/* a convenient shortcut*/
\input limbo.sty %/* general setup macros */
\input yycommon.sty %/* general routines for stack and array access */
@@ -69,23 +64,32 @@ in \.{ldman.sty} which is later included in the \TeX\ file produced by \CWEAVE.
\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 */
-\expandafter\def %/* adjust the \.{\\yyinput} to recognize \.{\\yyendgame} */
- \expandafter\multicharswitch\expandafter
- {\multicharswitch\yyendgame{\yyinput\yyeof\yyeof\endparseinput\removefinalvb}}
+
+\amendswitch %/* adjust the \.{\\yyinput} to recognize \.{\\yyendgame} */
+ \multicharswitch\near\yyeof\by\yyendgame\to\multicharswitch % /* add a new label */
+\replaceaction\multicharswitch\at\yyendgame % /* replace the new empty action */
+ \by{{\yyinput\yyeof\yyeof\endparseinput\removefinalvb}}\to\multicharswitch
+
+\def\MRI{{\sc MRI}} %/* so we can say that \MRI\ script typesetting is not supported$\ldots$ */
+@g
+
+@ Up to this point, the parser initialization process has been non parser specific (although
+sensitive to the namespace chosen). The next command inputs the data structures used
+by the \ld\ parser. The reader should consult the file below for the details on the \AST\ produced
+by the parser and its semantics.
+@<Define the normal mode@>=
+@G(t)
\input ldunion.sty %@>/* \ld\ parser data structures */@+
@g
@*1 Bootstrapping.
To produce a usable parser/scanner duo, several pieces of code must
be generated. The most important of these are the {\it table files\/}
-(\.{ptab.tex} and \.{ltab.tex}) for the parser and the scanner. These
+(\.{ldptab.tex} and \.{ldltab.tex}) for the parser and the scanner. These
consist of the integer tables defining the operation of the parser and
scanner automata, the values of some constants, and the `action switch'.
@@ -101,10 +105,10 @@ parsing our grammar once again, this time with a \bison\ grammar
designed for typesetting \bison\ files. A special {\it
bootstrapping\/} mode is used to extract the appropriate
information. The name `bootstrapping' notwithstanding, the parser and
-lexer used in the bootstrapping phase are not the minimized versions
+lexer used in the bootstrapping phase are not necessarily the minimized versions
used in bootstrapping the \bison\ parser.
-The first component generated during the bootstrapping pass is a list
+One component generated during the bootstrapping pass is a list
of `token equivalences' (or `aliases') to be used by the lexer. Every
token (to be precise, every {\it named token type}) used in
a \bison\ grammar is declared using one of the
@@ -117,50 +121,44 @@ the token names with their numerical values (accomplished by
\.{\\settokens}). If all tokens are named tokens, no token equivalence
list is necessary to set up the interaction between the lexer and the
parser. In this case (the present \ld\ parser is a typical
-example), the token list serves a secondary role: it provides hints
+example), the token list may also serve a secondary role: to provide hints
for the macros that typeset the grammar terms, after the \.{\\tokeneq}
-macro is redefined to serve this purpose.
+macro is redefined for this purpose.
On the other hand, after a declaration such as `\prodstyle{\%token}
\.{CHAR} \.{"char"}' the string \.{"char"} becomes an alias
for the named token \.{CHAR}. Only the string version gets recorded in
the |yytname| array. Establishing the equivalence between the two
-token forms can now only be accomplished by examining the grammar
+token forms now can be accomplished only by examining the grammar
source file and is delegated to the bootstrapping phase parser.
-\leavevmode\namedspot{bootstrapstates}The other responsibility of the bootstrapping parser is to extract
-the information about \flex\ {\it states\/} used by the lexer from the
-appropriate source file. As is the case with token names, this
-information is output in a rather chaotic fashion by the scanner
-generator and is all but useless for our purposes. The original
-bootstrapping macros were designed to handle \flex's \prodstyle{\%x}
-and \prodstyle{\%s} state declarations and produce a \Cee\ file with the
-appropriate definitions. This file can later be included by the
-`driver' routine to produce the appropriate table file for the lexer.
-To round off the bootstrapping mode we only need to establish the
-output streams for the tokens and the states, supply the appropriate file
-names for the two lists, flag the bootstrapping mode for the
-bootstrapping macros and inline typesetting (\.{\\prodstyle} macros)
-and input the appropriate machinery.
-
-This is done by the macros
-below. The bootstrap lexer setup (\.{\\bootstraplexersetup}) consists
-of inputting the token equivalence table for the \bison\ parser
-(i.e.~the parser that processes the \bison\ grammar file) and defining
-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).
+\leavevmode\namedspot{bootstrapstates}Another (perhaps most important)
+goal of the bootstrapping phase is to extract the information about \flex\
+{\it states\/} used by the lexer from the appropriate source file. As
+is the case with token names, this information is output in a rather
+chaotic fashion by the scanner generator and is all but useless for
+our purposes. The bootstrapping macros are designed to
+handle \flex's \prodstyle{\%x} and \prodstyle{\%s} state declarations
+and produce a \Cee\ file with the appropriate definitions. This file
+can later be included by the `driver' routine to generate the
+appropriate table file for the lexer. To round off the bootstrapping
+mode we only need to establish the output streams for the tokens and
+the states, supply the appropriate file names for the two lists, flag
+the bootstrapping mode for the bootstrapping macros and inline
+typesetting (\.{\\prodstyle} macros) and input the appropriate
+machinery.
+
+This is done by the macros below. The bootstrap lexer setup
+(\.{\\bootstraplexersetup}) consists of inputting the token
+equivalence table for the \bison\ parser (i.e.~the parser that
+processes the \bison\ grammar file) and defining 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 a full
+featured lexer).
@<Define the bootstrapping mode@>=
@G(t)
-\newwrite\tokendefs %/* token list */
-\newwrite\stlist %/* \flex\ state list */
-\newwrite\gindex %/* index entries */
-
\def\modebootstrap{%
- \edef\bstrapparser{dyytab.tex}%
- \bootstrapmodetrue
\def\bootstraplexersetup{%
- \input bo.tok%
\let\yylexreturn\yylexreturnbootstrap /* only return tokens whose value is known */
%\let\yylexreturn\yylexreturnregular /* should also work */
}%
@@ -173,7 +171,7 @@ since we are using full featured lexer and parser).
Every parser/lexer pair (as well as some other macros) operates
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
+tables `tack on' a string of characters representing the current
namespace to the `low level' control sequence name that performs the
actual output or access. Say, \.{\\yytname} becomes an alias of
\.{\\yytname[main]} while in the \.{[main]} namespace. When a parser
@@ -208,16 +206,21 @@ grammar describing prologue declarations uses the \.{[prologue]}
namespace.
\aterm{index}the \.{[index]} namespace is used for typesetting the
-index entries and is not necessarily associated with any parser or
-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).
+index entries for the terms that are automatically inserted by the main parser
+(such as an empty right hand side of a production or an inline action).
+\aterm{index:tex{\rm, }index:visual{\rm, and }texline}
+the macros that typeset \TeX\ entries, use
+\.{index:tex} 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).
+The \.{index:visual} pseudonamespace is used for ordering the index entries for
+\TeX\ macros (this is how the entry for \.{\\getsecond} (\texref{/getsecond})
+ends up in the {\ssf P} section of the index). Finally, the \TeX\ typesetting macros
+use the \.{texline} pseudonamespace to process the names of \TeX\ command sequences
+in action code. The reason we refer to these as {\it pseudo\/}namespaces is that
+only the token (or term) names are aliased, and not, say, the finite automata names
+in the case of the \TeX\ typesetting.
\aterm{flexre{\rm, }flexone{, \rm and} flextwo}the parsers for
\flex\ input use the \.{[flexre]}, \.{[flexone]}, and~\.{[flextwo]} namespaces for
@@ -259,14 +262,37 @@ initializing the \bison\ parser (accomplished by inputting
\newtoks\ldcmds
\def\modenormal{%
+ \commonstartup
+ \input ldtexlex.sty% /* \TeX\ typesetting specific to \ld */
+ \expandafter\def\csname index domain translation [L]\endcsname{%
+ {\noexpand\ld\ index}% /* used to typeset the table of contents */
+ {ld index}% /* outline entry */
+ {L\sc D INDEX}% /* index header */
+ }%
+ \def\otherlangindexheader{%
+ B{\sc ISON}, F{\sc LEX}, \TeX, {\sc AND} L{\sc D INDICES}%
+ }% /* modify the index header */
+ @>@[@<Initialize \ld\ parsers@>@]
+ @>@[@<Modified name parser for \ld\ grammar@>@]
+}
+@g
+
+@ @<Common startup routine@>=
+@G(t)
+\def\commonstartup{
\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 yyinit.sty %
\input yytexlex.sty% /* \TeX\ typesetting macros */
- \input ldtexlex.sty% /* \TeX\ typesetting specific to \ld */
+ \input gindex.sty % /* indexing macros specific to \flex, \bison, and \ld */
+ \input noweb.sty % /* \noweb\ style references */
+ \xreflocaltrue
+ \let\sectionlistsetup\lxrefseparator
+ \let\inx\inxmod
+ \let\fin\finmod
+ \termindextrue
+ \immediate\openout\gindex=\jobname.gdx
\let\hostparsernamespace\ldnamespace /* the namespace where tokens are looked up for typesetting purposes */
- @>@[@<Initialize \ld\ parsers@>@]
- @>@[@<Modified name parser for \ld\ grammar@>@]
}
@g
@@ -288,53 +314,88 @@ wreaking havoc on the lexer state stack.
@g
@ This is the \ld\ parser invocation routine. It is coded according to
-a straightforward sequence initialize-invoke-execute-or-fall back.
+a straightforward sequence initialize-invoke-execute-or-fall back. The
+\.{\\preparseld} macro is invoked by \.{\\lsectionbegin} (see \.{limbo.sty}).
+It starts by defining the postprocessing and typesetting macro (\.{\\postparseld})
+followed by the parser setup.
@<Define the normal mode@>=
@G(t)
\def\preparseld{%
\let\postparse\postparseld
- \expandafter\hidecs\expandafter{\ldunion}% /* inhibit expansion so that fewer \.{\\noexpand}s are necessary */
+ \hidecslist\ldunion % /* inhibit expansion so that fewer \.{\\noexpand}s are necessary */
\toldparser
+ \displayrawtable % /* do this after the parser namespaces are setup */
\ldparserinit
\yyparse
}
+@g
+@ The postprocessing macro defines a procedure for typesetting the output and saving the
+parsed result to a file. After that, a generic postprocessing macro is executed.
+@<Define the normal mode@>=
+@G(t)
\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
+ \let\saveparsedtable\saveldtable
+ \let\typesetparsedtables\typesetldtables
+ \postparsegeneric{(ld script)}%
+}
+@g
+
+@ The table output and typesetting macros are responsible for the parsed table output
+to a log file and the typographic representation of the result. The table is output
+after expanding its contents. The commands
+\begindemo
+^\hidecslist\cwebstreamchars
+^\restorecslist{ld-parser-debug}\ldunion
+\enddemo
+are meant to inhibit most expansions so that only the list (iterator) macros are expanded.
+The parser for \ld\ does not currently use the list macros to speed up the parsing process
+but the general set up is here in case it is needed in the future. Unfortunately, the same technique
+cannot be applied to the display of the \.{\\yystash} and \.{\\yyformat} streams (that use linked lists
+by default), since there are too many random sequences that can appear in such streams. Therefore,
+to facilitate debugging, one should expand the lists before displaying them (see \.{yyinput.sty} for
+details; lists with iterators are a bit more convenient due to their flexibility).
+@<Define the normal mode@>=
+@G(t)
+\def\saveldtable#1{{%
+ \hidecslist\cwebstreamchars
+ \restorecslist{ld-parser-debug}\ldunion
+ \expandafter\saveoutputcode\expandafter{\the\ldcmds}\exampletable{#1}%
+}}
+
+\def\typesetldtables{%
+ \begingroup
+ \displayparsedoutput\ldcmds
+ \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
+ \endgroup
}
+@g
+@ The parsing routine defined above is the first macro in the \ld\ parser stack.
+The only remaining procedure on the stack is an error reporting macro in case
+the parsing pass failed.
+@<Define the normal mode@>=
+@G(t)
\fillpstack{l}{%
\preparseld
{\preparsefallback{++}}% /* skip this section if parsing failed, put \.{++} on the screen */
- \relax % /* this \.{\\relax} serves as a `guard' for the braces */
+ \relax % /* this \.{\\relax} `guards' the braces above during \.{\\poppstack} */
}
@g
@ Unless they are being bootstrapped, the \ld\ parser and its
term parser are initialized by the normal mode. The token typesetting
of \ld\ grammar tokens is adjusted at the same time (see the remarks
-above about the mechanism that is responsible for this). Most nonterminals
+above about the mechanism that is responsible for this). Most terminals
(such as keywords, etc.) may be displayed unchanged (provided the
names used by the lexer agree with their appearance in the script file,
see below), while the typeseting of others is modified in
@@ -358,8 +419,8 @@ examining \.{ltokenset.sty}.
@G(t)
\genericparser
name: ld,
- ptables: ptab.tex,
- ltables: ltab.tex,
+ ptables: ldptab.tex,
+ ltables: ldltab.tex,
tokens: {},
asetup: {},
dsetup: {},
@@ -372,12 +433,28 @@ examining \.{ltokenset.sty}.
host: ld;%
@g
-@ The macros are collected in a single file included at the beginning
-of this documentation.
+@ We also need some modifications to the indexing macros in order to typeset \ld\ terms
+and variables separately.
+@<Additional macros for the \ld\ lexer/parser@>=
+@G(t)
+@g
+
+@ The macros are collected in two files included at the beginning
+of this documentation\footnote{An attentive reader may have noticed that the files
+have the extension \.{.stx} instead of the traditional \.{.sty}. The reason for this
+is the postprocessing step that `cleans' the generated files of various \Cee\
+artifacts output by \CWEB\ and turns \.{ldman.stx} and \.{ldsetup.stx} into
+\.{ldman.sty} and \.{ldsetup.sty} included by \.{ldman.tex}$\ldots$}.
@(ldman.stx@>=
@<Set up the generic parser machinery@>@;
@<Begin namespace setup@>@;
@<Define the bootstrapping mode@>@;
+@<Common startup routine@>@;
+
+@ The macros collected in the file below are not specific to this manual but are needed in
+order to use the \ld\ parser generated and are thus put in a separate which can be included
+by other \TeX\ programs that wish to use them.
+@(ldsetup.stx@>=
@<Define the normal mode@>@;
@<Additional macros for the \ld\ lexer/parser@>@;
@@ -404,23 +481,22 @@ MEMORY
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.
-%
+a better approach.
+%\saveparseoutputtrue\checktabletrue
+%\saveparseoutputfalse\checktablefalse
@<Example \ld\ script@>=
@i ldexample_l.hx
@ @<The same example of an \ld\ script@>=
-@i ldexample_b.hx
+@i ldexample_t.hx
@ @<Some random portion of \ld\ code@>=
@i ldnp.x
@** Appendix. The original code of the \ld\ parser and lexer is reproduced below. It
-is mostly left intact and is typeset by the pretty printing parser for
-\bison\ input. The lexer (\flex) input is reproduced verbatim and is
-left mostly unformatted with the exception of spacing and the embedded
-\Cee\ code.
+is left mostly intact and is typeset by the pretty printing parser for
+\bison\ input. The lexer (\flex) input is given a similar treatment.
The treatment of comments is a bit more invasive. \CWEB\ silently
assumes that the comment refers to the preceding statement or a group
@@ -446,7 +522,7 @@ creators of \ld.%\checktabletrue\saveparseoutputtrue
@q of index entries depends on the placement of this inclusion @>
@i alphas.hx
-@** Index. \checktablefalse\saveparseoutputtrue
+@** Index. \checktablefalse\saveparseoutputtrue \global\let\secrangedisplay\empty
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
@@ -477,15 +553,8 @@ $$
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.
-\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
+\makeunindexablex{{\csstring\the}{\csstring\nx}{\csstring\yy}{\csstring\yylexnext}%
+ {\csstring\else}{\csstring\fi}{\csstring\yyBEGIN}{\csstring\next}}
\let\oldMRL\MRL
\def\MRL#1{\smash{\oldMRL{#1}}} % a more sophisticated way to handle it woud be to add a \smash whenever we are
% in the [index] namespace but this is simpler and works as well
-\def\topofcontents{\null\vskip-3\baselineskip\centerline{C{\sc ONTENTS} (\sc\uppercase\expandafter{\title})}\medskip}
diff --git a/support/splint/examples/ld/ldnp.w b/support/splint/examples/ld/ldnp.w
index 0a99d864fd..9a7d86f097 100644
--- a/support/splint/examples/ld/ldnp.w
+++ b/support/splint/examples/ld/ldnp.w
@@ -1,4 +1,4 @@
-@q Copyright 2012-2020, Alexander Shibakov@>
+@q Copyright 2012-2022, Alexander Shibakov@>
@q This file is part of SPLinT@>
@q SPLinT is free software: you can redistribute it and/or modify@>
@@ -181,11 +181,6 @@ qualifier:
@[TeX_( "/getsecond{/yy(1)}/to/toksb" );@]@;
@[TeX_( "/yy0{/nx/idstr{/the/toksa}{/the/toksb}}" );@]@;
-@ @<Start with a tag@>=
- @[TeX_( "/getfirst{/yy(2)}/to/toksa" );@]@;
- @[TeX_( "/getsecond{/yy(2)}/to/toksb" );@]@;
- @[TeX_( "/yy0{/nx/idstr{</the/toksa>}{</the/toksb>}}" );@]@;
-
@ @<Start with a quoted string@>=
@[TeX_( "/getfirst{/yy(2)}/to/toksa" );@]@;
@[TeX_( "/getsecond{/yy(2)}/to/toksb" );@]@;
@@ -197,9 +192,6 @@ qualifier:
@ @<Start with a \prodstyle{'.'} string@>=
@[TeX_( "/yy0{/nx/visflag{/nx/termvstring}{}/nx/chstr{.}{.}}" );@]@;
-@ @<Turn a qualifier into an identifier@>=
- @<Start with an identifier@>@;
-
@ @<Attach an identifier@>=
@[TeX_( "/getsecond{/yy(1)}/to/toksa" );@]@;
@[TeX_( "/appendr/toksa{/noexpand/_}" );@]@;
@@ -213,7 +205,6 @@ qualifier:
@ @<Attach qualifier to a name@>=
-
@ @<Attach an integer@>=
@[TeX_( "/yy0{/nx/dotsp/nx/sfxi/the/yy(1)}" );@]@;
@@ -262,14 +253,15 @@ as they have to be inserted in a place that is aware of the internal definitions
definitions are used.
@<Name parser \Cee\ postamble@>=
-#define YYPRINT(file, type, value) @[yyprint (file, type, value)@]
- static void yyprint (FILE *file, int type, YYSTYPE value){}
@ Union of types.
@<Union of parser types@>=
-@*1 The name scanner.
+@*1 The name scanner. The scanner for \ld\ name parser is essentially identical to that for the
+\bison\ and \flex\ name parser\footnote{And is just as much of an overkill. This should serve as a
+cautionary tale of how suboptimal but convenient choices tend to take root.}. The only exception
+is the scanning of suffixes.
%\checktabletrue
@(ld_small_lexer.ll@>=
@G
@@ -277,7 +269,7 @@ definitions are used.
%{@> @<Lexer \Cee\ preamble@> @=%}
@> @<Lexer options@> @=
%%
- @> @<Regular expressions@> @=
+ @> @<Regular expressions for the name parser@> @=
%%
@O
void define_all_states( void ) {
@@ -306,18 +298,16 @@ int [0-9]+
@ Strings and characters in directives/rules.
@<Lexer states@>=
-@G
+@G(fs1)
%x SC_ESCAPED_STRING SC_ESCAPED_CHARACTER
@g
@ @<Lexer \Cee\ preamble@>=
-
#include <stdint.h>
-#include <stdbool.h>
+#include <stdbool.h>@t}\yyskipparsefalse{@>
-@t}\yyskipparsefalse{@>
@ @<Lexer options@>=
-@G
+@G(fs1)
%option bison-bridge
%option noyywrap nounput noinput reentrant
%option noyy_top_state
@@ -326,11 +316,18 @@ int [0-9]+
%option outfile="ld_small_lexer.c"
@g
-@ @<Regular expressions@>=
+@ @<Regular expressions for the name parser@>=
@<Scan white space@>@;
@<Scan identifiers@>@;
-@ White space skipping.
+@ White space is skipped in names\footnote{How it finds its way {\em into\/} a name deserves
+some investigation for which we do not have the space here.}.
+Note that the input routine produced by \splint\ springs into action
+{\em after\/} the input passes through the scanning mechanism of \TeX\ which makes it very unlikely
+that any of the characters below in the definition of `whitespace' could make it to the scanner.
+They are left in, however, in case a custom input routine is used that produces such
+characters\footnote{Although, in this case, some special processing by the scanner
+would likely be required.}.
\traceparserstatestrue
\tracestackstrue
\tracerulestrue
@@ -356,11 +353,9 @@ int [0-9]+
[ \f\n\t\v] {@> @[TeX_( "/yylexnext" );@]@=}
@g
-@ This collection of regular expressions might seem redundant, and in
-its present state, it certainly is. However, if later on the
-typesetting style for some of the keywords would need to be adjusted,
-such changes would be easy to implement, since the template is already
-here.
+@ Suffixes specific to \ld\ name scanner are defined here, along with some other
+lexical elements. Most of these definitions mimic the ones for the \bison\ name
+scanner.
@<Scan identifiers@>=
@G(fs2)
"%"({aletter}|[0-9]|[-_]|"%"|[<>])+ {@> @[TeX_( "/yylexreturnval{PERCENT_IDENTIFIER}" );@]@=}
@@ -392,4 +387,4 @@ trivial scanning problems.
@[TeX_( "/iftracebadchars" );@]@;
@[TeX_( " /yycomplain{invalid character(s): /the/yytext}" );@]@;
@[TeX_( "/fi" );@]@;
- @[TeX_( "/yylexreturn{$undefined}" );@]@;
+ @[TeX_( "/yyerrterminate" );@]@;
diff --git a/support/splint/examples/ld/ldnump.w b/support/splint/examples/ld/ldnump.w
index 813628c68c..4050374c25 100644
--- a/support/splint/examples/ld/ldnump.w
+++ b/support/splint/examples/ld/ldnump.w
@@ -1,4 +1,4 @@
-@q Copyright 2012-2020, Alexander Shibakov@>
+@q Copyright 2012-2022, Alexander Shibakov@>
@q This file is part of SPLinT@>
@q SPLinT is free software: you can redistribute it and/or modify@>
@@ -182,8 +182,6 @@ as they have to be inserted in a place that is aware of the internal definitions
definitions are used.
@<Name parser \Cee\ postamble@>=
-#define YYPRINT(file, type, value) @[yyprint (file, type, value)@]
- static void yyprint (FILE *file, int type, YYSTYPE value){}
@ Union of types.
@@ -222,7 +220,7 @@ int [0-9]+
@ Strings and characters in directives/rules.
@<Lexer states@>=
-@G
+@G(fs1)
%x SC_ESCAPED_STRING SC_ESCAPED_CHARACTER
@g
@@ -232,7 +230,7 @@ int [0-9]+
#include <stdbool.h>
@ \yyskipparsefalse@<Lexer options@>=
-@G
+@G(fs1)
%option bison-bridge
%option noyywrap nounput noinput reentrant
%option noyy_top_state
@@ -303,4 +301,4 @@ here.
@[TeX_( "/iftracebadchars" );@]@;
@[TeX_( " /yycomplain{invalid character(s): /the/yytext}" );@]@;
@[TeX_( "/fi" );@]@;
- @[TeX_( "/yylexreturn{$undefined}" );@]@;
+ @[TeX_( "/yyerrterminate" );@]@;
diff --git a/support/splint/examples/ld/ldtexlex.sty b/support/splint/examples/ld/ldtexlex.sty
index 01b8873540..878811dee6 100644
--- a/support/splint/examples/ld/ldtexlex.sty
+++ b/support/splint/examples/ld/ldtexlex.sty
@@ -1,4 +1,4 @@
-% Copyright 2012-2020, Alexander Shibakov
+% Copyright 2012-2022, Alexander Shibakov
% This file is part of SPLinT
%
% SPLinT is free software: you can redistribute it and/or modify
@@ -22,7 +22,7 @@
\def\d@fz#1#2{%
\defx#1{#2}{texline}%
- \d@@z#1{#2}{index}%
+ \d@@z#1{#2}{index:tex}%
}
\def\d@@z#1#2#{%
diff --git a/support/splint/examples/ld/ldunion.sty b/support/splint/examples/ld/ldunion.sty
index 710d4e1725..c59cd601e0 100644
--- a/support/splint/examples/ld/ldunion.sty
+++ b/support/splint/examples/ld/ldunion.sty
@@ -1,4 +1,4 @@
-% Copyright 2012-2020, Alexander Shibakov
+% Copyright 2012-2024, Alexander Shibakov
% This file is part of SPLinT
%
% SPLinT is free software: you can redistribute it and/or modify
@@ -19,9 +19,9 @@
% of TeX tokens; sptr is a pointer to the stash stream, fptr is a pointer to the format stream
\def\yyuniontag{\ldunion}
-\def\parserstrictnamespace{ld-parser-strict}
-\def\parserprototypesnamespace{ld-parser-strict:headers}
-\def\parserdebugnamespace{ld-parser-debug}
+\def\parserstrictnamespace{ld-parser-strict} % expands to an error message
+\def\parserprototypesnamespace{ld-parser-strict:headers} % the parameter strings
+\def\parserdebugnamespace{ld-parser-debug} % control sequences are \let...=\relax for debugging
\def\ldunion{\currentyyunionnamespace}
\def\currentyyunionnamespace{ld-generic}
@@ -34,11 +34,12 @@
% ld commands
+\defp\ldor{} % item separator :: \ldor, is only needed here for debugging (in the ld-parser-debug namespace)
\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\ldattrstring#1#2#3#4{} % attributes string :: \ldattrstring{name}{name11}{fptr}{sptr}
+\defp\ldattrstringneg#1#2#3#4{} % complemented attributes string :: \ldattrstring{name}{name11}{fptr}{sptr}
\defp\ldfilename#1{} % file name :: \ldfilename{name}
\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}
@@ -59,20 +60,38 @@
\defp\ldsectionseparator#1#2{} % section separator :: \ldsectionseparator{fptr}{sptr}
\defp\ldtype#1{} % section type :: \ldtype{type}
\defp\ldstatement#1{} % statement :: \ldstatement{statement}
+\defp\ldfreestmt#1{} % statement in a section :: \ldfreestmt{\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}
+ % {expression}{type}}{at}
% {{}{}{}:alignment}
% {constraint}{statements}
% {{}{}{}{}:placement}
+\defp\ldoverlay#1#2#3#4#5#6{} % overlay section list :: \ldoverlay{expression}{crossrefs}{at}{subalign}
+ % {sections}
+ % {{memspec}{memspec_at}{phdr}{fill}}
+\defp\ldoverlaysection#1#2#3#4{} % overlay section :: \ldoverlaysection{name}{statements}{phdr}{fill}
\defp\ldsectionstash#1#2{} % sections spec stash :: \ldsectionstash{fptr}{sptr}
-\savecslist{ld-parser-prototypes}\ldunion
+\savecslist{ld-parser-prototypes}\ldunion % these consume parameters and expand to nothing
\input ldint.sty
+\def\ldidxdomain{L}
+
+\let\writeldidxentry\writeidxentry % mix the \ld\ index with the
+\let\writeldidxhentry\writeidxhentry % \bison\ index for now
+
+\def\writeldidxhentry#1{%
+ \indxe\gindex{{\secno}{{}{\hostparsernamespace}}{\ldidxdomain}{\headeridxrank}#1}%
+}
+
+\def\writeldidxentry#1{%
+ \indxe\gindex{{\secno}{{}{\hostparsernamespace}}{\ldidxdomain}{\termidxrank}#1}%
+}
+
\def\bigbracedel{\delimiter"4266308}
\newtoks\lddisplay
@@ -116,6 +135,10 @@
\edef\next{\toksc{\gidxentry{\termttstring}{#2}{}{\ntt #2}}}\next
}
+\def\ldextractattrs#1#2#3#4{%
+ \edef\next{\toksc{{\ntt #2}}}\next
+}
+
\def\ldextractmemname#1#2#3#4{%
{%
\expandafter\let\expandafter\tosmallparser\csname to\stripbrackets\cwebclinknamespace parser\endcsname
@@ -134,7 +157,6 @@
% \separatorswitcheq and \separatorswitchneq in yyunion.sty
\defc\ldcommandseparator{%
- \restorecs{table-render}{\strm}%
\expandafter\ifx\csname ldstashentry[#2]\endcsname\relax
\yyifsamestring{#3}{#4}{}{\appendrnx\lddisplay{\medskip}}%
\else
@@ -197,16 +219,16 @@
\def\ldreg@xp#1#2#3#4{%
\expandafter\ifx\csname ldvarname[#2]\endcsname\relax
{%
- \let\termindex\writeidxentry
+ \let\termindex\writeldidxentry
\let\hostparsernamespace\cwebclinknamespace% process the variable names as in \CWEB
- \edef\next{\toksc{\gidxentry{\termttstring}{#1}{}}}\next\the\toksc
+ \edef\next{\toksc{\gidxentry{\termttstring}{#1}{}}}\next
\hbox{\ntt@#1}%
\expandafter
}\the\toksc
\else
\yyifsamestring{#2}{.}{% special . name
{%
- \let\termindex\writeidxentry
+ \let\termindex\writeldidxentry
\let\hostparsernamespace\cwebclinknamespace% for consistency
\edef\next{\toksc{\gidxentry{\termexception}{.origin&}{.}}}\next
\hbox{\csname\prettynamecs\hostparsernamespace{.origin&}\endcsname{}}%
@@ -214,14 +236,14 @@
}\the\toksc
}{%
{%
- \let\termindex\writeidxentry
+ \let\termindex\writeldidxentry
\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
+ \\{\the\toksa}%
}%
\expandafter
}\the\toksc
@@ -259,27 +281,34 @@
\defc\ldmemoryspec{%
\toksb{\hfil&}%
- \let\termindex\writeidxhentry
+ \let\termindex\writeldidxhentry
\ldextractmemname#1\concat\toksb\toksc
\let\termindex\eatone
\appendrnx\toksb{&}%
- \toksc{}#2\concat\toksb\toksc
- \toksc{}#3\concat\toksb\toksc
+ \toksc{}#2\appendrnx\toksc{&}\concat\toksb\toksc% attributes
+ \toksc{}#3\appendrnx\toksc{&}\concat\toksb\toksc
\toksc{}#4\concat\toksb\toksc
\concat\toksa\toksb
\toksb{\cr}\concat\toksa\toksb
}
-\defc\ldattributes{%
- \ldextractname#1\appendrnx\toksc{&}%
+\defc\ldattrstring{%
+ \appendrnx\toksc{{\ntt@ #2}}%
+}
+
+\defc\ldattrstringneg{%
+ \appendrnx\toksc{\hbox{$\neg$}{\ntt@ #2}}%
+}
+
+\defc\ldspace{%
}
\defc\ldlengthspec{%
- \toksc{#1}%
+ \toksc{$#1$}%
}
\defc\ldoriginspec{%
- \toksc{#1&}%
+ \toksc{#1}%
}
\defc\ldinclude{%
@@ -290,15 +319,7 @@
\concat\toksa\toksc
}
-\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
-}
+% TODO: change the code to use linked lists
\defc\ldmemspecseparator{%
\expandafter\ifx\csname ldstashentry[#2]\endcsname\relax
@@ -309,16 +330,6 @@
}
\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}%
@@ -370,7 +381,7 @@
\else
\toksb\expandafter{&}% section header
\advance\tempca\m@ne
- \ldextractitem\tempca{#6}% expression
+ \ldextractitem\tempca{#6}% next statement
\advance\tempca\@ne
\yytoksempty\toksc{%
\ldextractfill#7%
@@ -382,7 +393,7 @@
\fi
\fillextractedtrue
}{%
- \toksc\expandafter{\expandafter\qquad\expandafter$\the\toksc{}$}%
+ \toksc\expandafter{\expandafter\qquad\the\toksc{}}%
}%
\concat\toksb\toksc
\appendrnx\toksb{&}%
@@ -407,7 +418,60 @@
\repeat
}
-\def\ldextractitem#1#2{%
+
+% named section :: \ldnamedsection{name}
+ % {{bind?}{expression}{block?}{expression}{type}}{at}
+ % {{}{}{}:alignment}
+ % {constraint}{statements}
+ % {{memspec}{memspec_at}{phdr}{fill}}
+
+\defc\ldoverlay{% overlay sections :: \ldoverlay{expression}{crossrefs}{at}{subalign}
+ % {sections}
+ % {{memspec}{memspec_at}{phdr}{fill}}
+ \yystringempty{#1}{\tokse{}}{\tokse{ $#1$}}%
+ \yystringempty{#2}{\toksf{}}{\toksf{{ \ttl noxrefs}}}%
+ \yystringempty{#3}{\toksg{}\toksc{}}{\toksg{{\ttl at} $#3$}\toksc{ }}%
+ \yystringempty{#4}{\toksh{}}{\toksh\expandafter{\expandafter{\the\tokc\ttl subalign} $#4$}}%
+ \appendr\toksa{&\hskip-1em\noexpand\ttl overlay\the\tokse\the\toksf&&\the\toksg\the\toksh}%
+ \ldwrapoverlay#6%
+ \appendr\toksa{&\the\toksc&\cr}%
+ #5%
+ \ldoverlayfill#6%
+ \yytoksempty\toksd{}{\appendr\toksa{&\the\toksd&&&&&\cr}}% attach the fill at the end
+ \appendr\toksa{&\hskip-1em{\ttl overlay end}&&&&&\cr}%
+}
+
+\defc\ldoverlaysection{% overlay section :: \ldoverlaysection{name}{statements}{phdr}{fill}
+ \ldnamedsection{#1}%
+ {{}{}{}{}{}}{}%
+ {{}{}{}}%
+ {}{#2}%
+ {{}{}{#3}{#4}}%
+}
+
+\def\ldwrapoverlay#1#2#3#4{% puts memspec... in \toksc and fill in \toksd
+ \toksc{}%
+ \yystringempty{#1}{% any > ?
+ }{%
+ \ldextractname#1%
+ \toksd{{\ttl in }}%
+ \concatl\toksd\toksc
+ }%
+ \yystringempty{#2}{% any AT > ?
+ }{%
+ \yytoksempty\toksc{\toksc{{\ttl as }}}{\appendrnx\toksc{ {\ttl as }}}%
+ \toksd=\toksc
+ \ldextractname#2%
+ \concat\toksd\toksc
+ \toksc=\toksd
+ }%
+}
+
+\def\ldoverlayfill#1#2#3#4{%
+ \ld@xtractfill{#4}%
+}
+
+\def\ldextractitem#1#2{% #1 is a counter, #2 is a list separated by \ldor
\yystringempty{#2}{%
\toksc{}%
}{%
@@ -463,18 +527,23 @@
}
\def\ldextractfill#1#2#3#4{%
+ \toksc{}%
\yystringempty{#4}{%
- \toksc{}%
\fillextractedtrue
}{%
\iffillextracted
- \toksc{}%
\else
- \toksc={\qquad{\ttl fill }$#4$}%
+ \ld@xtractfill{#4}%
+ \appendr\toksc{\noexpand\qquad{\noexpand\ttl fill }$\the\toksd$}%
\fi
}%
}
+\def\ld@xtractfill#1{% #1 must be \ldfill{expression}
+\toksf{#1}%
+ \toksd\expandafter{#1}%
+}
+
\def\ldpushpheaders#1#2#3#4{%
\ldextractitem\tempcc{#3}%
\advance\tempcc\@ne
@@ -491,11 +560,10 @@
\toksd{\hbox{\ttl #1}}%
}
-\defc\ldstatement{{#1}} % the braces form the group for a \toks assignment
-
-\let\ldsecspec\ldstatement
+\defc\ldstatement{{\let\ldrlap\relax\let\ldintfont\ntt@$#1$}} % the braces form the group for a \toks assignment
+\defc\ldfreestmt{\toksb\expandafter{#1}\appendr\toksa{&\the\toksb\cr}}
-\defc\ldsectionseparator{\toksc{&\multispan5\cdotfill\quad\cr}\concat\toksa\toksc}
+\defc\ldsecspec{{$#1$}}
\def\ldboxstash#1{%
\ifchecktrim\errmessage{stash contents: \the\toksa}\fi
@@ -506,16 +574,6 @@
\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}%
@@ -524,17 +582,6 @@
}
\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}%
@@ -546,7 +593,12 @@
\restorecs{ld-display}{\ldregexp\ldassignment\ldfill\ldinsertcweb\ldentry}
\toyyunion{ld-parser:sections}
-% preprocessing macros: collecing stash and marking variables
+% preprocessing macros: collecting stash and marking variables
+% currently these macros do not get inside expressions to extract
+% variable names, consequently if the variable is used before it
+% appears in an assignment, it will not be displayed properly
+% (is this even legal in linker scripts?) although the index will
+% show it correctly
\restorecslist{ld-parser-prototypes}\ldunion
\restorecs{ld-parser-strict}{\insertcweb}
@@ -557,7 +609,8 @@
\readstash{#2}%
\setbox0 \vbox{\toksa\expandafter{\the\yystashlocal}\cleanstash\stripstash\the\toksa}%
\ifdim\ht0=\z@
- \expandafter\let\csname ldstashentry[#2]\endcsname\relax
+ \expandafter\let\csname ldstashentry[#2]\endcsname\relax % this is redundant but we may change \relax to
+ % something else later
\else
\expandafter\edef\csname ldstashentry[#2]\endcsname{\the\yystashlocal}%
\fi
@@ -575,6 +628,12 @@
\defc\ldsections{#1} % ld sections :: \ldsections{sections}
+\defc\ldoverlay{% overlay section :: \ldoverlay{expression}{crossrefs}{at}{subalign}
+ % {sections}
+ % {{memspec}{memspec_at}{phdr}{fill}}
+ #3#5%
+} % TODO: add handling of subalign, memmspec, and memspec_at
+
\defc\ldsectionseparator{%
\readstash{#2}%
\setbox0 \vbox{\toksa\expandafter{\the\yystashlocal}\cleanstash\stripstash\the\toksa}%
@@ -606,37 +665,20 @@
} % command separator :: \ldcommandseparator{fptr}{sptr}{prev command}{next command}
\defc\ldstatement{#1}
-
+\defc\ldfreestmt{#1}
+\defc\ldassignment{#1}
+\defc\ldprovide{#1}
+\defc\ldentry{#1}
+\let\ldhidden\ldprovide
+\let\ldprovidehid\ldprovide
\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!}}%
+\defc\ldregexp{%
+ \ldr@gexprestash#1%
}
-\def\markldname#1{%
- \markldn@me#1%
+\def\ldr@gexprestash#1#2#3#4{
+ \expandafter\def\csname ldvarname[#2]\endcsname{\errmessage{Not an \\ldregexp!, maybe change the parser namespace?}}%
}
-\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 441bad2543..496fe0f2d3 100644
--- a/support/splint/examples/ld/lstokenset.sty
+++ b/support/splint/examples/ld/lstokenset.sty
@@ -1,4 +1,4 @@
-% Copyright 2012-2020, Alexander Shibakov
+% Copyright 2012-2022, Alexander Shibakov
% This file is part of SPLinT
%
% SPLinT is free software: you can redistribute it and/or modify
diff --git a/support/splint/examples/ld/ltokenset.sty b/support/splint/examples/ld/ltokenset.sty
index 846dead6c8..f980114823 100644
--- a/support/splint/examples/ld/ltokenset.sty
+++ b/support/splint/examples/ld/ltokenset.sty
@@ -1,4 +1,4 @@
-% Copyright 2012-2020, Alexander Shibakov
+% Copyright 2012-2022, Alexander Shibakov
% This file is part of SPLinT
%
% SPLinT is free software: you can redistribute it and/or modify
diff --git a/support/splint/examples/symbols/Makefile b/support/splint/examples/symbols/Makefile
index 964927bc9d..80a6aed0c6 100644
--- a/support/splint/examples/symbols/Makefile
+++ b/support/splint/examples/symbols/Makefile
@@ -1,4 +1,4 @@
-# Copyright 2012-2020, Alexander Shibakov
+# Copyright 2012-2022, Alexander Shibakov
# This file is part of SPLinT
#
# SPLinT is free software: you can redistribute it and/or modify
@@ -18,8 +18,8 @@
# purposes; the main directory (../..) follows a slightly more
# modular organization scheme.
-SYMBOLS_PREREQS = %.tex %.idx ${SPLINT_XTEXSTYLES} ${SPLINT_ROOT}cweb/bo.tok ${SPLINT_ROOT}cweb/fo.tok symtoks.sty
-SYMBOLS_PREREQS += ${SPLINT_XPTABLES} ${SPLINT_XLTABLES} symmap.sty symtricks.sty symfm.sty slimbo.sty
+SYMBOLS_PREREQS = %.tex %.idx ${SPLINT_XTEXSTYLES} ${SPLINT_XTABLES} symtoks.sty
+SYMBOLS_PREREQS += symmap.sty symtricks.sty symfm.sty slimbo.sty
SYMBOLS_PREREQS += ${SPLINT_ROOT}cweb/fil.l ${SPLINT_ROOT}cweb/bg.y ${SPLINT_ROOT}cweb/lo.l
@@ -53,7 +53,7 @@ mostlyclean: clean_temp
distclean: clean
cd ${SPLINT_ROOT} && ${MAKE} clean
-.PRECIOUS: ${SPLINT_ROOT}cweb/fo.tok ${SPLINT_ROOT}cweb/bo.tok ${SPLINT_ROOT}cweb/lo.l \
+.PRECIOUS: ${SPLINT_XOTABLES} ${SPLINT_ROOT}cweb/lo.l \
${SPLINT_ROOT}cweb/fil.l ${SPLINT_ROOT}cweb/dyytab.tex ${SPLINT_ROOT}cweb/gyytab.tex \
${SPLINT_ROOT}cweb/fyytab.tex symbols.gdy
diff --git a/support/splint/examples/symbols/slimbo.sty b/support/splint/examples/symbols/slimbo.sty
index 48da360f55..1dcfe15a84 100644
--- a/support/splint/examples/symbols/slimbo.sty
+++ b/support/splint/examples/symbols/slimbo.sty
@@ -1,4 +1,4 @@
-% Copyright 2012-2020, Alexander Shibakov
+% Copyright 2012-2022, Alexander Shibakov
% This file is part of SPLinT
%
% SPLinT is free software: you can redistribute it and/or modify
diff --git a/support/splint/examples/symbols/symbols.w b/support/splint/examples/symbols/symbols.w
index dc58adc0bd..f680b1bffc 100644
--- a/support/splint/examples/symbols/symbols.w
+++ b/support/splint/examples/symbols/symbols.w
@@ -1,4 +1,4 @@
-% Copyright 2012-2020, Alexander Shibakov
+% Copyright 2012-2024, Alexander Shibakov
% This file is part of SPLinT
%
% SPLinT is free software: you can redistribute it and/or modify
@@ -13,7 +13,6 @@
%
% You should have received a copy of the GNU General Public License
% along with SPLinT. If not, see <http://www.gnu.org/licenses/>.
-\newwrite\gindex
% the namespace choices below are a bit random as this is a demo only
@@ -21,11 +20,6 @@
\def\optimization{5}
\input yy.sty
\modenormal
-\input noweb.sty
- \xreflocaltrue
- \readlxrefs
- \newwrite\xrefstream
- \immediate\openout\xrefstream=\jobname.xxr
\input dcols.sty
\input symmap.sty
\let\parsernamespace\flexnamespace
@@ -70,7 +64,8 @@
\input symfm.sty
\input slimbo.sty
-\setupfootnotes
+\topskip=9pt
+\initauxstream
@** Introduction.
The manual supplied with \splint\ presents an outline of the main
@@ -243,7 +238,7 @@ the value of \.{\\gaglue} set by a copy of one of the productions.
\insertraw{\let\stashnext\stashnextwithspace}%
line_breaking_and_symbols:
GEN\stashed{|stash!=0|}ERIC '(' expression',' \ ss another es')' \
- \insertraw{\let\stashnext\stashnextwithnothingnx}%
+ \insertraw{\let\stashnext\stashnextwithnothing}%
` inline_\stashed{look: $\rightarrow\,$}c \{ \stashed{\X{$\infty$}:See this example to deduce $\ldots$\X\6}\stashed{|b == a - c|} \}
` more_inline_c \{ \stashed{|func(int a, char b);|} \}
%
@@ -285,7 +280,7 @@ symbol_tricks:
\input symtricks.sty
\noindent The stash chunks, inserted by \.{\\stashed\{}{\it random input\/}\.{\}} are invisible to the parser.
As an example, the stash producing the action in the first rule below (|stash!=0|) was
-inserted in the middle of the first term (\prodstyle{GENERIC}). The space (\.{ }) is a special case.
+inserted in the middle of the first term (\prodstyle{GENERIC}). The space (\.{\ }) is a special case.
\medskip
\beginprod
line_breaking_and_symbols:
@@ -305,7 +300,7 @@ Here is the same set of productions with stash producing a space in the middle o
\insertraw{\let\stashnext\stashnextwithspace}%
line_breaking_and_symbols:
GEN\stashed{|stash!=0|}ERIC '(' expression',' \ ss another es')' \
- \insertraw{\let\stashnext\stashnextwithnothingnx}%
+ \insertraw{\let\stashnext\stashnextwithnothing}%
` inline_\stashed{look: $\rightarrow\,$}c \{ \stashed{\X{$\infty$}:See this example to deduce $\ldots$\X\6}\stashed{|b == a - c|} \}
` more_inline_c \{ \stashed{|func(int a, char b);|} \}
%
@@ -316,7 +311,7 @@ line_breaking_and_symbols:
{\it \flexrestyle{\^\\\\[\\"\\'?\\\\]}}. Portions of \flex\ files may be typeset with the help of
\.{\\beginflex}$\ldots$\.{\\endflex} macros. Just as in the case of \bison\ productions, care must be taken to
escape some symbols that have special meaning to \TeX. The ones that {\it must be\/} escaped when used inside
-regular expressions are `\.{\{}', `\.{\}}', `\.{\\}', and~`\.{\%}'. Others, such as `\.{\^}', `\.{\_}', `\.{\$}', `\.{\#}',
+regular expressions are `\.{\{}', `\.{\}}', `\.{\\}', `\.{\ }' (see more below), and~`\.{\%}'. Others, such as `\.{\^}', `\.{\_}', `\.{\$}', `\.{\#}',
and~`\.{\&}' do not require any special treatment (although they continue to perform their special functions
inside \.{\\stashed} blocks). As a note of caution, `$\ldots$\.{\\\\]}' results
in `$\ldots$\flexrestyle{\\]}' and not
@@ -331,6 +326,9 @@ this character is nearly inaccessible in the \TeX\ mode of \CTANGLE, which resul
`\.{\\`}' instead. If the example is not part of a \CWEB\ input (for example it is included from its own \TeX\ file similar to
\.{symtricks.sty} above) then
one can use the `\.{\yl}' character as intended. However, even inside a `pure \TeX\ file' to get `\.{`}', one must still type `\.{\\`}'.
+Finally, it is worth remembering that a space (\.{\ }) would terminate a regular expression (and produce a syntax error) inside
+\.{\\flexrestyle}. This is part of the regular \flex\ syntax and not a \splint\ specific limitation. To make a space character
+a part of a regular expression it must be escaped.
Many of the points made above may become more transparent after examining the source of the example following this sentence.
\medskip
\cdebugtrue
@@ -371,6 +369,20 @@ LEXOPT [porkacne]
M4QSTART "[["
M4QEND "]]"
+@ Lexer specific options can be typeset as well. Any portion specific to \Cee\ can be relegated
+to \CWEB\ as can be seen below. Adjusting the typesetting of various \Cee\ terms works as expected
+(see the source for this example).
+@s scan_state int
+@<Lexer options@>=
+@G(fs1)
+%option bison-bridge
+%option noyywrap noinput reentrant nounput
+%option header-file="lexer.h"
+%option prefix="main_c"
+%option extra-type="@>struct scan_state *@="
+%option stack
+@g
+
@ The first three lines of the previous section successfully parse as section~2 input.
\parseverbosetrue
@<As section 2@>=
@@ -425,7 +437,8 @@ NOT_WS [^[:blank:]\r\n]
@q of index entries depends on the placement of this inclusion @>
@i alphas.hx
-@** Index. Various identifiers in \bison\ productions and \flex\ sections are put in the index, along with
+@** Index. \global\let\secrangedisplay\empty% do not show the current section range anymore
+Various identifiers in \bison\ productions and \flex\ sections are put in the index, along with
the identifiers from the \Cee\ portions of the \CWEB\ input. The
mechanism used to typeset these identifiers is different from the one
employed by the \CWEB's indexing macros. While the \.{\\I} macros in
@@ -434,16 +447,9 @@ only outputs the context in which the identifier was encountered. By
redefining the macros that interpret this context to typeset the
index, several useful effects can be achieved\footnote{One pretty common use is to redefine
macros that take parameters to take none.}.
-\unsetfootnotes
-\input gindex.sty
\def\otherlangindexseparator{% the index is too short
\toksg{}%
\vskip.5\baselineskip
\centerline{B{\sc ISON}, F{\sc LEX, AND} \TeX\ {\sc INDICES}}%
\vskip.5\baselineskip
}
-\closeout\gindex
-\termindexfalse % do not attach indexing entries to the terms in the index, or the section list
-\let\inx\inxmod
-\let\fin\finmod
-\def\topofcontents{\null\vskip-3\baselineskip\centerline{C{\sc ONTENTS} (\sc\uppercase\expandafter{\title})}\medskip}
diff --git a/support/splint/examples/symbols/symfm.sty b/support/splint/examples/symbols/symfm.sty
index 9cfeacbeaa..985d4148d1 100644
--- a/support/splint/examples/symbols/symfm.sty
+++ b/support/splint/examples/symbols/symfm.sty
@@ -1,4 +1,4 @@
-% Copyright 2012-2020, Alexander Shibakov
+% Copyright 2012-2022, Alexander Shibakov
% This file is part of SPLinT
%
% SPLinT is free software: you can redistribute it and/or modify
diff --git a/support/splint/examples/symbols/symmap.sty b/support/splint/examples/symbols/symmap.sty
index 450dd9a649..0a4afbc50a 100644
--- a/support/splint/examples/symbols/symmap.sty
+++ b/support/splint/examples/symbols/symmap.sty
@@ -1,4 +1,4 @@
-% Copyright 2012-2020, Alexander Shibakov
+% Copyright 2012-2022, Alexander Shibakov
% This file is part of SPLinT
%
% SPLinT is free software: you can redistribute it and/or modify
@@ -25,7 +25,7 @@
\restorecslist{symbols}\yyunion
\toksa{}\toksb{}\toksc{}\toksd{}%
%\showthe\newsymswitch
- \the\symstream
+ \the\table
\global\newsymswitch\newsymswitch
\else
\newsymswitch{}% otherwise \yysymswitch is trying to expand the wrong names (\namepair is not present to do \csname ... )
@@ -118,7 +118,6 @@
\ifyyparsefail
\errmessage{could not process symbols}%
\else
- \symstream\table
\tointermediateparser % the parsing is finished, so we have two very long strings:
% o the rules of the hosted parser ([intermediate])
% o the rules of the same parser just parsed
diff --git a/support/splint/examples/symbols/symtoks.sty b/support/splint/examples/symbols/symtoks.sty
index 3ab9b142c7..6c1bcff58d 100644
--- a/support/splint/examples/symbols/symtoks.sty
+++ b/support/splint/examples/symbols/symtoks.sty
@@ -1,4 +1,4 @@
-% Copyright 2012-2020, Alexander Shibakov
+% Copyright 2012-2022, Alexander Shibakov
% This file is part of SPLinT
%
% SPLinT is free software: you can redistribute it and/or modify
diff --git a/support/splint/examples/symbols/symtricks.sty b/support/splint/examples/symbols/symtricks.sty
index 04bf5c5ac1..cc29bf7dea 100644
--- a/support/splint/examples/symbols/symtricks.sty
+++ b/support/splint/examples/symbols/symtricks.sty
@@ -1,4 +1,4 @@
-% Copyright 2012-2020, Alexander Shibakov
+% Copyright 2012-2022, Alexander Shibakov
% This file is part of SPLinT
%
% SPLinT is free software: you can redistribute it and/or modify
diff --git a/support/splint/examples/types/Makefile b/support/splint/examples/types/Makefile
index 3dd52abeed..b313a18d0f 100644
--- a/support/splint/examples/types/Makefile
+++ b/support/splint/examples/types/Makefile
@@ -1,4 +1,4 @@
-# Copyright 2012-2020, Alexander Shibakov
+# Copyright 2012-2022, Alexander Shibakov
# This file is part of SPLinT
#
# SPLinT is free software: you can redistribute it and/or modify
diff --git a/support/splint/examples/types/basic.sty b/support/splint/examples/types/basic.sty
index ba0decc237..fb9c35ad7f 100644
--- a/support/splint/examples/types/basic.sty
+++ b/support/splint/examples/types/basic.sty
@@ -1,4 +1,4 @@
-% Copyright 2012-2020, Alexander Shibakov
+% Copyright 2012-2022, Alexander Shibakov
% This file is part of SPLinT
%
% SPLinT is free software: you can redistribute it and/or modify
diff --git a/support/splint/examples/types/test.sty b/support/splint/examples/types/test.sty
index 018b299c29..3158482b1a 100644
--- a/support/splint/examples/types/test.sty
+++ b/support/splint/examples/types/test.sty
@@ -1,4 +1,4 @@
-% Copyright 2012-2020, Alexander Shibakov
+% Copyright 2012-2022, Alexander Shibakov
% This file is part of SPLinT
%
% SPLinT is free software: you can redistribute it and/or modify
diff --git a/support/splint/examples/types/tree.sty b/support/splint/examples/types/tree.sty
index 68171e6a2d..9b004dba2c 100644
--- a/support/splint/examples/types/tree.sty
+++ b/support/splint/examples/types/tree.sty
@@ -1,4 +1,4 @@
-% Copyright 2012-2020, Alexander Shibakov
+% Copyright 2012-2022, Alexander Shibakov
% This file is part of SPLinT
%
% SPLinT is free software: you can redistribute it and/or modify
diff --git a/support/splint/examples/xxpression/Makefile b/support/splint/examples/xxpression/Makefile
index 8d8b6877c6..05dbd4fafd 100644
--- a/support/splint/examples/xxpression/Makefile
+++ b/support/splint/examples/xxpression/Makefile
@@ -1,4 +1,4 @@
-# Copyright 2012-2020, Alexander Shibakov
+# Copyright 2012-2022, Alexander Shibakov
# This file is part of SPLinT
#
# SPLinT is free software: you can redistribute it and/or modify
@@ -18,8 +18,7 @@
# purposes; the main directory (../..) contains a slightly more
# modular organization.
-XXPRESSION_PREREQS = %.tex %.scn %.idx %.tok ${SPLINT_XPTABLES} ${SPLINT_XLTABLES}
-XXPRESSION_PREREQS += ${SPLINT_ROOT}cweb/bo.tok ${SPLINT_ROOT}cweb/fo.tok xymmap.sty xtoks.sty
+XXPRESSION_PREREQS = %.tex %.scn %.idx %.tok ${SPLINT_XTABLES} xymmap.sty xtoks.sty
include ../../makefile.inc
include ${SPLINT_ROOT}makefile.loc
@@ -57,8 +56,7 @@ ${PARSER}.yy ${LEXER}.ll: xxpression.x alphas.hx
${UNLINE} test.txx test.tex
${UNLINE} xymbols.txx xymbols.tex
-xymbols.sns: xymbols.tex xxpression.tok ${SPLINT_ROOT}cweb/bo.tok ${SPLINT_ROOT}cweb/fo.tok \
- ${SPLINT_XPTABLES} ${SPLINT_XLTABLES} ptab.tex
+xymbols.sns: xymbols.tex xxpression.tok ${SPLINT_XTABLES} ptab.tex
${PDFTEX} $<
alphas.hx:
diff --git a/support/splint/examples/xxpression/xtoks.sty b/support/splint/examples/xxpression/xtoks.sty
index 60e7dfa7a6..4ffea41f50 100644
--- a/support/splint/examples/xxpression/xtoks.sty
+++ b/support/splint/examples/xxpression/xtoks.sty
@@ -1,4 +1,4 @@
-% Copyright 2012-2020, Alexander Shibakov
+% Copyright 2012-2022, Alexander Shibakov
% This file is part of SPLinT
%
% SPLinT is free software: you can redistribute it and/or modify
@@ -16,4 +16,3 @@
\prettywordpair{IDENTIFIER}{{$\langle$\rm identifier$\rangle$}}
\prettywordpair{INTEGER}{{\bf int}}
-\prettywordpair{$\ undefined}{{\tt\$undefined}}
diff --git a/support/splint/examples/xxpression/xxpression.sty b/support/splint/examples/xxpression/xxpression.sty
index 1b56c4dce3..7ba9c86535 100644
--- a/support/splint/examples/xxpression/xxpression.sty
+++ b/support/splint/examples/xxpression/xxpression.sty
@@ -1,4 +1,4 @@
-% Copyright 2012-2020, Alexander Shibakov
+% Copyright 2012-2022, Alexander Shibakov
% This file is part of SPLinT
%
% SPLinT is free software: you can redistribute it and/or modify
diff --git a/support/splint/examples/xxpression/xxpression.w b/support/splint/examples/xxpression/xxpression.w
index bdf81b004d..7441b90e0d 100644
--- a/support/splint/examples/xxpression/xxpression.w
+++ b/support/splint/examples/xxpression/xxpression.w
@@ -1,4 +1,4 @@
-@q Copyright 2012-2020, Alexander Shibakov@>
+@q Copyright 2012-2024, Alexander Shibakov@>
@q This file is part of SPLinT@>
@q SPLinT is free software: you can redistribute it and/or modify@>
@@ -32,26 +32,25 @@
% end of the definitions). A more elaborate scheme (similar to how the
% typesetting of rules is set up) using several parsers can be used
% instead.
-\newwrite\gindex
\input limbo.sty
-\input dcols.sty
\def\optimization{5}
\newread\testeof
\immediate\openin\testeof=\jobname.tok
\ifeof\testeof % make the local token equivalence table
\let\nx\noexpand
- \csname newwrite\endcsname\tokendefs
\edef\tokendeffile{\jobname.tok} % where to put the token equivalence table
- \edef\bstrapparser{dyytab.tex}
+ \def\bstrapparser{dyytab.tex}
+ \def\bstraptokens{bo.tok}% use token equivalence table to set the values of non-string tokens
+ % this has to be added if a non-bootstrap parser is used to
+ % extract token information (see the comments above)
\def\bootstraplexersetup{%
\let\yylexreturn\yylexreturnregular
\bootstrapmodetrue
- \input bo.tok % use token equivalence table to set the values of non-string tokens
- % this has to be added if a non-bootstrap parser is used to
- % extract token information (see the comments above)
}
\toks0{%
- \input trt1.sty %/* \TeX\ `runtime': temporary register definitions */
+ \let\fin\finmod % this is necessary since the original modifies \output
+ % in a way that conflicts with the scheme in dcols.sty
+ \input trt1.sty % \TeX\ `runtime': temporary register definitions
\input yycommon.sty % general routines for stack and array access
\input yymisc.sty % helper macros (stack manipulation, table processing, value stack pointers)
% parser initialization, optimization
@@ -85,8 +84,9 @@
\fi
\immediate\closein\testeof
\the\toks0
-
-@**Parser file. \setupfootnotes
+\input dcols.sty
+\initauxstream
+@**Parser file.
This is an enhanced parser for expressions. It takes
advantage of the `symbolic term name' mechanism and extends the basic
expression syntax.
@@ -225,8 +225,6 @@ as they have to be inserted in a place that is aware of the internal definitions
definitions are used.
@<Extended \.{expression} parser \Cee\ postamble@>=
-#define YYPRINT(file, type, value) @[yyprint (file, type, value)@]
- static void yyprint (FILE *file, int type, YYSTYPE value){}
@ Union of types. Empty as well.
@@ -261,7 +259,7 @@ int [0-9]+
void define_all_states( void ){}
@ @<Lexer options@>=
-@G
+@G(fs1)
%option bison-bridge
%option noyywrap nounput noinput reentrant
%option noyy_top_state
@@ -309,7 +307,7 @@ int [0-9]+
@[TeX_( "/iftracebadchars" );@]@;
@[TeX_( " /yycomplain{invalid character(s): /the/yytext}" );@]@;
@[TeX_( "/fi" );@]@;
- @[TeX_( "/yylexreturn{$undefined}" );@]@;
+ @[TeX_( "/yyerrterminate" );@]@;
@**Generating symbols. This is the routine that creates symbolic name
assignments for the grammar. The internal mechanics of creating such
@@ -331,6 +329,7 @@ that can be activated to see the inner workings of the parser and
scanner routines.
@(test.txx@>=
@G
+\chardef\other=12 % needed for some macros to work
\input xxpression.sty
\iftrue
@@ -373,13 +372,7 @@ scanner routines.
@q of index entries depends on the placement of this inclusion @>
@i alphas.hx
-@**Index.
-\unsetfootnotes
-\input gindex.sty
-\closeout\gindex
-\termindexfalse % do not attach indexing entries to the terms in the index, or the section list
-\let\inx\inxmod
-\let\fin\finmod
-\immediate\closeout\exampletable
+@**Index.\global\let\secrangedisplay\empty% do not show the current section range anymore
+\global\topskip=9pt
\def\Tex{\TeX\ output}
\def\TeXx{\TeX\ output}
diff --git a/support/splint/examples/xxpression/xymmap.sty b/support/splint/examples/xxpression/xymmap.sty
index d38d23ca9b..e5576ee9cd 100644
--- a/support/splint/examples/xxpression/xymmap.sty
+++ b/support/splint/examples/xxpression/xymmap.sty
@@ -1,4 +1,4 @@
-% Copyright 2012-2020, Alexander Shibakov
+% Copyright 2012-2022, Alexander Shibakov
% This file is part of SPLinT
%
% SPLinT is free software: you can redistribute it and/or modify
@@ -19,7 +19,7 @@
\def\makesymbols{%
\restorecslist{symbols}\yyunion
\toksa{}\toksb{}\toksc{}\toksd{}%
- \the\symstream
+ \the\table
\global\newsymswitch\newsymswitch
}
@@ -109,7 +109,6 @@
\ifyyparsefail
\errmessage{could not process symbols}%
\else
- \symstream\table
\tointermediateparser % the parsing is finished, so we have two very long strings:
% o the rules of the hosted parser ([intermediate])
% o the rules of the same parser just parsed