summaryrefslogtreecommitdiff
path: root/support/splint/examples/ld/ltokenset.sty
diff options
context:
space:
mode:
Diffstat (limited to 'support/splint/examples/ld/ltokenset.sty')
-rw-r--r--support/splint/examples/ld/ltokenset.sty113
1 files changed, 82 insertions, 31 deletions
diff --git a/support/splint/examples/ld/ltokenset.sty b/support/splint/examples/ld/ltokenset.sty
index d5d0d9b1ee..846dead6c8 100644
--- a/support/splint/examples/ld/ltokenset.sty
+++ b/support/splint/examples/ld/ltokenset.sty
@@ -1,4 +1,4 @@
-% Copyright 2012-2015, Alexander Shibakov
+% Copyright 2012-2020, Alexander Shibakov
% This file is part of SPLinT
%
% SPLinT is free software: you can redistribute it and/or modify
@@ -14,13 +14,21 @@
% You should have received a copy of the GNU General Public License
% along with SPLinT. If not, see <http://www.gnu.org/licenses/>.
-\prettywordpair{comma}{{\tt,}}
-\prettywordpair{semicolon}{{\tt;}}
-\prettywordpair@@{file\_NAME\_list}{\ifinheader\itbold\else\it\fi file\_{\rm name}\_list}
-\prettywordpair@@{high\_level\_library\_NAME\_list}{\ifinheader\itbold\else\it\fi high\_level\_library\_{\rm name}\_list}
-\prettywordpair@@{low\_level\_library\_NAME\_list}{\ifinheader\itbold\else\it\fi low\_level\_library\_{\rm name}\_list}
+\let\currentparsernamespace\parsernamespace
+\let\parsernamespace\indexpseudonamespace % use the correct namespace
+\input yypretty.sty % input standard prettified tokens first
+ % so that we can change their appearance below
+\let\parsernamespace\cwebclinknamespace
+\prettywordpair{.origin&}{{$\cdot\cdot$}}% special . name in \ld\ scripts
+\let\parsernamespace\currentparsernamespace
+
+\prettywordpairwvis{comma}{{\tt,}}{,}
+\prettywordpairwvis{semicolon}{{\tt;}}{;}
+\prettywordpair@@{file\_NAME\_list}{{\ifinheader\itbold\else\it\fi file\_{\rm name}\_list}}
+\prettywordpair@@{high\_level\_library\_NAME\_list}{{\ifinheader\itbold\else\it\fi high\_level\_library\_{\rm name}\_list}}
+\prettywordpair@@{low\_level\_library\_NAME\_list}{{\ifinheader\itbold\else\it\fi low\_level\_library\_{\rm name}\_list}}
\prettywordpair@@{NAME}{{\rm name}}
-\prettywordpair@@{LNAME}{{\rm name$_{\rm L}$}}
+\prettywordpair@@wvis{LNAME}{{\rm name$_{\rm L}$}}{name_L}
\prettywordpair@@{END}{{\rm end}}
\prettywordpair@@{UNARY}{{\rm unary}}
\prettywordpair@@{VERSIONK}{{\tt VERSION}$_{\rm K}$}
@@ -30,23 +38,23 @@
\prettytoken{TARGET}
\prettytoken{ASSERT}
\prettytoken{INSERT}
-\prettywordpair@@{PLUSEQ}{{}$\MRL{+{\K}}${}}
-\prettywordpair@@{MINUSEQ}{{}$\MRL{-{\K}}${}}
-\prettywordpair@@{MULTEQ}{{}$\MRL{\times{\K}}${}}
-\prettywordpair@@{DIVEQ}{{}$\MRL{{\div}{\K}}${}}
-\prettywordpair@@{ANDEQ}{{}$\Xandxeq${}}
-\prettywordpair@@{OREQ}{{}$\Xorxeq${}}
-\prettywordpair@@{LSHIFTEQ}{{}$\MRL{\ll{\K}}${}}
-\prettywordpair@@{RSHIFTEQ}{{}$\MRL{\gg{\K}}${}}
-\prettywordpair@@{NE}{{}$\not=${}}
-\prettywordpair@@{LE}{{}$\leq${}}
-\prettywordpair@@{GE}{{}$\geq${}}
-\prettywordpair@@{EQ}{{}$=${}}
-\prettywordpair@@{OROR}{{}$\V${}}
-\prettywordpair@@{ANDAND}{{}$\W${}}
-\prettywordpair@@{LSHIFT}{{}$\ll${}}
-\prettywordpair@@{RSHIFT}{{}$\gg${}}
-\prettywordpair@@{=}{{}$\K${}}
+\prettywordpair@@wvis{PLUSEQ}{{}$\MRL{+{\K}}${}}{=+}
+\prettywordpair@@wvis{MINUSEQ}{{}$\MRL{-{\K}}${}}{=-}
+\prettywordpair@@wvis{MULTEQ}{{}$\MRL{\times{\K}}${}}{=*}
+\prettywordpair@@wvis{DIVEQ}{{}$\MRL{{\div}{\K}}${}}{=/}
+\prettywordpair@@wvis{ANDEQ}{{}$\Xandxeq${}}{=W}
+\prettywordpair@@wvis{OREQ}{{}$\Xorxeq${}}{=V}
+\prettywordpair@@wvis{LSHIFTEQ}{{}$\MRL{\ll{\K}}${}}{=<<}
+\prettywordpair@@wvis{RSHIFTEQ}{{}$\MRL{\gg{\K}}${}}{=>>}
+\prettywordpair@@wvis{NE}{{}$\not=${}}{= }
+\prettywordpair@@wvis{LE}{{}$\leq${}}{<=}
+\prettywordpair@@wvis{GE}{{}$\geq${}}{>=}
+\prettywordpair@@wvis{EQ}{{}$=${}}{=}
+\prettywordpair@@wvis{OROR}{{}$\V${}}{||}
+\prettywordpair@@wvis{ANDAND}{{}$\W${}}{&&}
+\prettywordpair@@wvis{LSHIFT}{{}$\ll${}}{<<}
+\prettywordpair@@wvis{RSHIFT}{{}$\gg${}}{>>}
+\prettywordpair@@wvis{=}{{}$\K${}}{=:}
\prettywordpair@@{+}{{}$+${}}
\prettywordpair@@{-}{{}$-${}}
\prettywordpair@@{!}{{}$\CM${}}
@@ -54,9 +62,16 @@
\prettywordpair@@{^}{{}$\XOR${}}
\prettywordpair@@{|}{{}$\OR${}}
\prettywordpair@@{&}{{}$\AND${}}
+\prettywordpair@@{\{}{{\ntt@\{}}% the purpose is to adjust the indexing
+\prettywordpair@@{\}}{{\ntt@\}}}% the purpose is to adjust the indexing
+
+% the switches below are sloppy, since the macros in the index
+% read a-z as letters (category 11) whereas the parser records them as
+% non-letters, it would be beter to use category 12 throughout (by,
+% for example passing the context as a stream of character codes
\def\gtsymswitch{%
- \raw exp *left *right\raw {%
+ exp \raw exp *left *right\raw {%
{}$>${}%
}
}
@@ -64,7 +79,7 @@
\def\gtsymswitchdefault{{\tt >}}
\def\ltsymswitch{%
- \raw exp *left *right\raw {%
+ exp \raw exp *left *right\raw {%
{}$<${}%
}
}
@@ -74,17 +89,53 @@
\setspecialcharsfrom\gtsymswitch
\setspecialcharsfrom\ltsymswitch
-\prettywordpair@@{>}{{%
+% the visual key switches below slightly abuse the properties of
+% \yyifsamestring, namely that it ignores the category code of the characters
+
+\prettywordpair@@wvis{>}{{%
\let\default\gtsymswitchdefault
\switchon{#1}\in\gtsymswitch
-}}
+}}{%
+ \yyifsamestring{exp}{#1}{> exp}{%
+ \yyifsamestring{*left}{#1}{> exp}{%
+ \yyifsamestring{*right}{#1}{> exp}{>}%
+ }%
+ }%
+}
-\prettywordpair@@{<}{{%
+\prettywordpair@@wvis{<}{{%
\let\default\ltsymswitchdefault
\switchon{#1}\in\ltsymswitch
-}}
+}}{%
+ \yyifsamestring{exp}{#1}{< exp}{%
+ \yyifsamestring{*left}{#1}{< exp}{%
+ \yyifsamestring{*right}{#1}{< exp}{<}%
+ }%
+ }%
+}
-\prettywordpair@@{*}{\yyifsamestring{exp}{#1}{{}$\times${}}{{\tt *}}}
+\def\astsymswitch{%
+ exp \raw exp *left *right\raw {%
+ {}$\times${}%
+ }
+}
+
+\def\astsymswitchdefault{{\tt *}}
+
+\setspecialcharsfrom\astsymswitch
+
+\prettywordpair@@wvis{*}{%
+ {%
+ \let\default\astsymswitchdefault
+ \switchon{#1}\in\astsymswitch
+ }%
+}{%
+ \yyifsamestring{exp}{#1}{* exp}{%
+ \yyifsamestring{*left}{#1}{* exp}{%
+ \yyifsamestring{*right}{#1}{* exp}{*}%
+ }%
+ }%
+}
\prettywordpair@@{/}{{}$/${}}