diff options
Diffstat (limited to 'web/tweb/bin')
-rw-r--r-- | web/tweb/bin/unprimit | 166 | ||||
-rw-r--r-- | web/tweb/bin/web2tex | 133 |
2 files changed, 299 insertions, 0 deletions
diff --git a/web/tweb/bin/unprimit b/web/tweb/bin/unprimit new file mode 100644 index 0000000000..b77df7e85b --- /dev/null +++ b/web/tweb/bin/unprimit @@ -0,0 +1,166 @@ +#!/usr/bin/perl + +@index = <>; + +# >> A << + +$primitives = '{above@|' . '{abovedisplayshortskip@|' . + '{abovedisplayskip@|' . '{accent@|' . '{adjdemerits@|' . + '{advance@|' . '{afterassignment@|' . '{aftergroup@|' . + '{atop@|' . '{atopwithdelims@' ; + +@index = grep( !/$primitives/, @index); + +# >> B << + +$primitives = '{badness@|' . '{baselineskip@|' . '{batchmode@|' . + '{begingroup@|' . '{belowdisplayshortskip@|' . '{belowdisplayskip@|' . + '{binoppenalty@|' . '{botmark@|' . '{box@|' . '{boxmaxdepth@|' . + '{brokenpenalty@' ; + +@index = grep( !/$primitives/, @index); + +# >> C << + +$primitives = '{catcode@|' . '{char@|' . '{chardef@|' . '{cleaders@|' . + '{closein@|' . '{closeout@|' . '{clubpenalty@|' . '{copy@|' . + '{count@|' . '{countdef@|' . '{cr@|' . '{crcr@|' . + '{csname@' ; + +@index = grep( !/$primitives/, @index); + +# >> D << + +$primitives = '{day@|' . '{deadcycles@|' . '{def@|' . + '{defaulthyphenchar@|' . '{defaultskewchar@|' . + '{delcode@|' . '{delimiter@|' . '{delimiterfactor@|' . + '{delimitershortfall@|' . '{dimen@|' . '{dimendef@|' . + '{discretionary@|' . '{displayindent@|' . '{displaylimits@|' . + '{displaystyle@|' . '{displaywidowpenalty@|' . '{displaywidth@|' . + '{divide@|' . '{doublehyphendemerits@|' . '{dp@|' . + '{dump@' ; + +@index = grep( !/$primitives/, @index); + +# >> E << + +$primitives = '{edef@|' . '{else@|' . '{emergencystretch@|' . + '{end@|' . '{endcsname@|' . '{endgroup@|' . '{endinput@|' . + '{endlinechar@|' . '{eqno@|' . '{errhelp@|' . '{errmessage@|' . + '{errorcontextlines@|' . '{errorstopmode@|' . + '{escapechar@|' . '{everycr@|' . '{everydisplay@|' . + '{everyhbox@|' . '{everyjob@|' . '{everymath@|' . '{everypar@|' . + '{everyvbox@|' . '{exhyphenpenalty@|' . '{expandafter@' ; + +@index = grep( !/$primitives/, @index); + +# >> F--G << + +$primitives = '{fam@|' . '{fi@|' . '{finalhyphendemerits@|' . + '{firstmark@|' . '{floatingpenalty@|' . '{font@|' . + '{fontdimen@|' . '{fontname@|' . '{futurelet@|' . + '{gdef@|' . '{global@|' . '{globaldefs@' ; + +@index = grep( !/$primitives/, @index); + +# >> H << + +$primitives = '{halign@|' . '{hangafter@|' . '{hangindent@|' . + '{hbadness@|' . '{hbox@|' . '{hfil@|' . '{hfill@|' . + '{hfuzz@|' . '{hoffset@|' . '{holdinginserts@|' . '{hrule@|' . + '{hsize@|' . '{hskip@|' . '{hss@|' . '{ht@|' . '{hyphenation@|' . + '{hyphenchar@|' . '{hyphenpenalty@' ; + +@index = grep( !/$primitives/, @index); + +# >> I--K << + +$primitives = '{if@|' . '{ifcase@|' . '{ifcat@|' . '{ifdim@|' . + '{ifeof@|' . '{ifffalse@|' . '{ifhbox@|' . '{ifhmode@|' . + '{ifinner@|' . '{ifmmode@|' . '{ifnum@|' . '{ifodd@|' . + '{iftrue@|' . '{ifvbox@|' . '{iifvmode@|' . '{ifvoid@|' . '{ifx@|' . + '{ignorespaces@|' . + '{immediate@|' . '{indent@|' . '{input@|' . '{inputlineno@|' . + '{insert@|' . '{insertpenalties@|' . '{interlinepenalty@|' . + '{jobname@|' . + '{kern@' ; + +@index = grep( !/$primitives/, @index); + +# >> L--M << + +$primitives = '{language@|' . '{lastbox@|' . '{lastkern@|' . + '{lastpenalty@|' . '{lastskip@|' . '{lccode@|' . '{leaders@|' . + '{left@|' . '{lefthyphenmin@|' . '{leftskip@|' . '{leqno@|' . '{let@|' . + '{limits@|' . '{linepenalty@|' . '{lineskip@|' . '{lineskiplimit@|' . + '{long@|' . '{looseness@|' . '{lower@|' . '{lowercase@|' . + '{mag@|' . '{mark@|' . '{mathaccent@|' . '{mathbin@|' . + '{mathchar@|' . '{mathchardef@|' . '{mathchoice@|' . + '{mathclose@|' . '{mathcode@|' . '{mathinner@|' . '{mathop@|' . + '{mathopen@|' . '{mathord@|' . '{mathpunct@|' . '{mathrel@|' . + '{mathsurround@|' . '{maxdeadcycles@|' . '{maxdepth@|' . + '{meaning@|' . '{medmuskip@|' . '{message@|' . '{mkern@|' . + '{month@|' . '{moveleft@|' . '{moveright@|' . '{mskip@|' . + '{multiply@|' . '{muskip@|' . '{muskipdef@' ; + +@index = grep( !/$primitives/, @index); + +# >> N--P << + +$primitives = '{newlinechar@|' . '{noalign@|' . '{noboundary@|' . + '{noexpand@|' . '{noindent@|' . '{nolimits@|' . '{nonscript@|' . + '{nonstopmode@|' . + '{nulldelimiterspace@|' . '{nullfont@|' . '{number@|' . + '{omit@|' . '{openin@|' . '{openout@|' . '{or@|' . '{outer@|' . + '{output@|' . '{outputpenalty@|' . '{over@|' . '{overfullrule@|' . + '{overline@|' . '{overwithdelims@|' . + '{pagedepth@|' . '{pagefilllstretch@|' . '{pagefillstretch@|' . + '{pagefilstretch@|' . '{pagegoal@|' . '{pageshrink@|' . + '{pagestretch@|' . '{pagetotal@|' . '{par@|' . '{parparfillskip@|' . + '{parindent@|' . '{parshape@|' . '{parskip@|' . '{patterns@|' . + '{pausing@|' . '{penalty@|' . '{postdisplaypenalty@|' . + '{predisplaypenalty@|' . '{predisplaysize@|' . '{pretolerance@|' . + '{prevdepth@|' . '{prevgraf@' ; + +@index = grep( !/$primitives/, @index); + +# >> R--S << + +$primitives = '{radical@|' . '{raise@|' . '{read@|' . '{relax@|' . + '{relpenalty@|' . '{right@|' . '{righthyphenmin@|' . + '{rightskip@|' . '{romannumeral@|' . '{scriptfont@|' . + '{scriptscriptfont@|' . '{scriptscriptstyle@|' . + '{scriptspace@|' . '{scriptstyle@|' . '{scrollmode@|' . + '{setbox@|' . '{setlanguage@|' . '{sfcode@|' . '{shipout@|' . + '{show@|' . '{showbox@|' . '{showboxbreadth@|' . + '{showboxdepth@|' . '{showlists@|' . '{showthe@|' . + '{skewchar@|' . '{skip@|' . '{skipdef@|' . '{spacefactor@|' . + '{spaceskip@|' . '{span@|' . '{special@|' . '{splitbotmark@|' . + '{splitfirstmark@|' . '{splitmaxdepth@|' . '{splittopskip@|' . + '{string@' ; + +@index = grep( !/$primitives/, @index); + +# >> T--Z << + +$primitives = '{tabskip@|' . '{textfont@|' . '{textstyle@|' . + '{the@|' . '{thickmuskip@|' . '{thinmuskip{' . '{time@|' . + '{toks@|' . '{toksdef@|' . '{tolerance@|' . '{topmark@|' . + '{topskip@|' . '{tracingcommands@|' . '{tracinglostchars@|' . + '{tracingmacros@|' . '{tracingonline@|' . '{tracingoutput@|' . + '{tracingpages@|' . '{tracingparagraphs@|' . '{tracingrestores@|' . + '{tracingstats@|' . + '{uccode@|' . '{uchyph@|' . '{underline@|' . '{unhbox@|' . + '{unhcopy@|' . '{unkern@|' . '{unpenalty@|' . '{unskip@|' . + '{unvbox@|' . '{unvcopy@|' . '{uppercase@|' . + '{vadjust@|' . '{valign@|' . '{vbadness@|' . '{vbox@|' . '{vcenter@|' . + '{vfil@|' . '{vfill@|' . '{vfilneg@|' . '{vfuzz@|' . + '{voffset@|' . '{vrule@|' . '{vsize@|' . '{vskip@|' . + '{vsplit@|' . '{vss@|' . '{vtop@|' . + '{wd@|' . '{widowpenalty@|' . '{write@|' . + '{xdef@|' . '{xleaders@|' . '{xspaceskip@|' . + '{year@'; + +@index = grep( !/$primitives/, @index); + +print " @index\n"; diff --git a/web/tweb/bin/web2tex b/web/tweb/bin/web2tex new file mode 100644 index 0000000000..78b2994b8c --- /dev/null +++ b/web/tweb/bin/web2tex @@ -0,0 +1,133 @@ +BEGIN { code = 0
+ codeno = 0
+ codechunkno = 1
+
+ definitions = ":def:|:edef:|:xdef:|:gdef:"\
+ ":let:|"\
+ ":chardef:|:mathchardef:|"\
+ ":newcount:|:countdef:|"\
+ ":newdimen:|:dimendef:|"\
+ ":newskip:|:skipdef:|"\
+ ":newtoks:|:toksdef:|"\
+ ":muskipdef:|"\
+ ":newif:|"\
+ ":newbox:|"\
+ ":read:"\
+ ":font:"
+
+ print "\\input tweb.sty\n\n"\
+ "{\\catcode`\\| = 0 |catcode`|\\ = 12 %\n"\
+ "|obeylines |gdef|ttfinish#1\\EDOC{|gobblespace#1|endgroup}}\n\n"\
+ "\\makeindexes\n"
+}
+
+END { print "\n"\
+ "\\printuserleveldefs\n"\
+ "\\printdefs\n"\
+ "\\printchunks\n"\
+ "\\bye"
+}
+
+
+/^@text %%% *version *= *"/ \
+{
+ gsub(/^@text %%% *version *= *"/, "")
+ gsub(/",/, "")
+ printf "\\gdef \\RCSversion {%s}\n", $0
+ next
+}
+
+/^@file / { printf "\\def\\filename{%s}\n", substr($0,7) ; next }
+
+/^@quote$/ { printf "\|" ; next }
+/^@endquote$/ { printf "\|" ; next }
+
+/^@begin code/ {
+ print "\\BEGINCODE"
+ code = 1
+ codeno = $3
+ next
+ }
+/^@end code/ {
+ print "\\ENDCODE"
+ code = 0
+ next
+ }
+
+/^@begin docs/ {
+ printf "\\BEGINDOC\n"
+ next
+ }
+/^@end docs/ { printf "\\ENDDOC\n" ; next }
+
+/^@defn / {
+ gsub(/\[\[/, "\\CODE "); gsub(/]]/, "\\EDOC")
+ name = substr($0,7)
+ defs[name] += 1
+ printf "\\noindent\\LA %s\\RA", name
+
+ if (defs[name] > 1)
+ printf "$+\\!\\!\\equiv$"
+ else
+ printf "$\\equiv$"
+
+ gsub("@", "\"@", name)
+ printf "\%\n\\chk{\\LA %s\\RA}"\
+ "\n\\nobreak\\medskip", name
+
+ next
+ }
+/^@use / {
+ gsub(/\[\[/, "\\CODE "); gsub(/]]/, "\\EDOC")
+ name = substr($0,6)
+ used[name] = codeno
+ printf "\\LA %s\\RA", name
+ gsub("@", "\"@", name)
+ printf "\%\n\\chk{\\LA %s\\RA}", name, name
+
+ getline
+ next
+ }
+
+/^@literal / { printf "%s", substr($0, 10) ; next }
+
+/^@nl$/ { printf "\n" ; next }
+
+/^@text / { line = junk = substr($0,7)
+ indexed = ""
+ found = ""
+
+ if (code)
+ {
+ while (match(junk, /\\[a-zA-Z@]+/)>0\
+ && substr(junk, 1, RSTART) !~ /%/)
+ {
+ prefix = "\\ddx{"
+
+ found = substr(junk, RSTART+1, RLENGTH-1)
+ junk = substr(junk, RSTART+RLENGTH)
+
+ if ( ":" found ":" ~ definitions )
+ {
+ prefix = "\\udx{"
+ match(junk, /\\[a-zA-Z@]+|\\[^a-zA-Z@]/)
+ found = substr(junk, RSTART+1, RLENGTH-1)
+ junk = substr(junk, RSTART+RLENGTH)
+ }
+
+ if (found != "" && found !~ /[^a-zA-Z@]/)
+ {
+ gsub("@", "\"@", found)
+ indexed = "\%\n"\
+ prefix found\
+ "@\\\\" found "\|N{"\
+ codechunkno "}}" indexed
+ }
+ }
+ printf "\\NO{%d}\\CODE %s\\EDOC%s",\
+ codechunkno++, line, indexed
+ }
+ else
+ printf "%s", line
+ }
+
|