diff options
-rw-r--r-- | doc/expert/README | 2 | ||||
-rw-r--r-- | doc/expert/all | 6 | ||||
-rw-r--r-- | doc/expert/det_gall | 33 | ||||
-rw-r--r-- | doc/expert/det_lexi | 11 | ||||
-rw-r--r-- | doc/expert/det_size | 17 | ||||
-rw-r--r-- | doc/expert/mydefs | 5 | ||||
-rw-r--r-- | doc/expert/pre | 1 | ||||
-rw-r--r-- | doc/expert/pre_outl | 21 | ||||
-rw-r--r-- | doc/expert/pre_yuni | 9 | ||||
-rw-r--r-- | doc/expert/preface | 2 | ||||
-rw-r--r-- | doc/slides/README | 2 | ||||
-rw-r--r-- | doc/user/README | 10 | ||||
-rw-r--r-- | doc/user/all | 7 | ||||
-rw-r--r-- | doc/user/ap_qck | 2 | ||||
-rw-r--r-- | doc/user/bas_lang | 1 | ||||
-rw-r--r-- | doc/user/bgr | 1 | ||||
-rw-r--r-- | doc/user/bgr_outl | 16 | ||||
-rw-r--r-- | doc/user/cpp | 89 | ||||
-rw-r--r-- | doc/user/cpp_chan | 40 | ||||
-rw-r--r-- | doc/user/cpp_comm | 31 | ||||
-rw-r--r-- | doc/user/cpp_eiff | 42 | ||||
-rw-r--r-- | doc/user/cpp_embe | 144 | ||||
-rw-r--r-- | doc/user/cpp_erro | 39 | ||||
-rw-r--r-- | doc/user/cpp_lone | 23 | ||||
-rw-r--r-- | doc/user/cpp_opti | 105 | ||||
-rw-r--r-- | doc/user/cpp_pipe | 57 | ||||
-rw-r--r-- | doc/user/cpp_prog | 35 | ||||
-rw-r--r-- | doc/user/cpp_tabs | 34 | ||||
-rw-r--r-- | doc/user/dia | 10 | ||||
-rw-r--r-- | doc/user/dia_node | 51 | ||||
-rw-r--r-- | doc/user/dia_summ | 99 | ||||
-rw-r--r-- | doc/user/dia_synt | 573 | ||||
-rw-r--r-- | doc/user/equ_summ | 5 | ||||
-rw-r--r-- | doc/user/johnson | 19 | ||||
-rw-r--r-- | doc/user/johnson.out | 66 | ||||
-rw-r--r-- | doc/user/mydefs | 13 | ||||
-rw-r--r-- | doc/user/preface | 4 | ||||
-rw-r--r-- | doc/user/tbl | 7 | ||||
-rw-r--r-- | doc/user/tbl_alig | 31 | ||||
-rw-r--r-- | doc/user/tbl_inde | 13 | ||||
-rw-r--r-- | doc/user/tbl_mark | 2 | ||||
-rw-r--r-- | doc/user/tbl_plai | 63 | ||||
-rw-r--r-- | doc/user/tbl_span | 12 | ||||
-rw-r--r-- | doc/user/tbl_summ | 6 | ||||
-rw-r--r-- | doc/user/vcpp | 1 | ||||
-rw-r--r-- | externs.h | 207 | ||||
-rw-r--r-- | hyph/old.italian.lh | 135 | ||||
-rw-r--r-- | hyph/portugal.lh | 104 | ||||
-rw-r--r-- | include/README | 18 | ||||
-rw-r--r-- | include/blue | 71 | ||||
-rw-r--r-- | include/bluef | 275 | ||||
-rw-r--r-- | include/book | 11 | ||||
-rw-r--r-- | include/bsf.lpg | 1 | ||||
-rw-r--r-- | include/cprint | 7 | ||||
-rw-r--r-- | include/cprintf | 251 | ||||
-rw-r--r-- | include/diag | 286 | ||||
-rw-r--r-- | include/diagf | 2648 | ||||
-rw-r--r-- | include/doc | 9 | ||||
-rw-r--r-- | include/dsf | 14 | ||||
-rw-r--r-- | include/eiffel | 71 | ||||
-rw-r--r-- | include/eiffelf | 274 | ||||
-rw-r--r-- | include/eqf | 233 | ||||
-rw-r--r-- | include/langdefs | 1 | ||||
-rw-r--r-- | include/picture | 9 | ||||
-rw-r--r-- | include/progf | 259 | ||||
-rw-r--r-- | include/report | 12 | ||||
-rw-r--r-- | include/reportf | 6 | ||||
-rw-r--r-- | include/slides | 9 | ||||
-rw-r--r-- | include/tblf | 8 | ||||
-rw-r--r-- | makefile | 53 | ||||
-rw-r--r-- | man/prg2lout.1 | 135 | ||||
-rw-r--r-- | man/prg2lout.txt | 96 | ||||
-rw-r--r-- | maps/LtLatin2.LCM | 4 | ||||
-rw-r--r-- | prg2lout.c | 1832 | ||||
-rw-r--r-- | software/lout.eiffel | 36 | ||||
-rw-r--r-- | whatsnew | 18 | ||||
-rw-r--r-- | z01.c | 7 | ||||
-rw-r--r-- | z02.c | 8 | ||||
-rw-r--r-- | z03.c | 4 | ||||
-rw-r--r-- | z04.c | 7 | ||||
-rw-r--r-- | z05.c | 7 | ||||
-rw-r--r-- | z06.c | 16 | ||||
-rw-r--r-- | z07.c | 8 | ||||
-rw-r--r-- | z08.c | 36 | ||||
-rw-r--r-- | z09.c | 10 | ||||
-rw-r--r-- | z10.c | 4 | ||||
-rw-r--r-- | z11.c | 4 | ||||
-rw-r--r-- | z12.c | 17 | ||||
-rw-r--r-- | z13.c | 10 | ||||
-rw-r--r-- | z14.c | 30 | ||||
-rw-r--r-- | z15.c | 4 | ||||
-rw-r--r-- | z16.c | 4 | ||||
-rw-r--r-- | z17.c | 10 | ||||
-rw-r--r-- | z18.c | 5 | ||||
-rw-r--r-- | z19.c | 4 | ||||
-rw-r--r-- | z20.c | 4 | ||||
-rw-r--r-- | z21.c | 5 | ||||
-rw-r--r-- | z22.c | 5 | ||||
-rw-r--r-- | z23.c | 12 | ||||
-rw-r--r-- | z24.c | 99 | ||||
-rw-r--r-- | z25.c | 7 | ||||
-rw-r--r-- | z26.c | 7 | ||||
-rw-r--r-- | z27.c | 4 | ||||
-rw-r--r-- | z28.c | 4 | ||||
-rw-r--r-- | z29.c | 6 | ||||
-rw-r--r-- | z30.c | 4 | ||||
-rw-r--r-- | z31.c | 7 | ||||
-rw-r--r-- | z32.c | 5 | ||||
-rw-r--r-- | z33.c | 4 | ||||
-rw-r--r-- | z34.c | 4 | ||||
-rw-r--r-- | z35.c | 4 | ||||
-rw-r--r-- | z36.c | 6 | ||||
-rw-r--r-- | z37.c | 4 | ||||
-rw-r--r-- | z38.c | 7 | ||||
-rw-r--r-- | z39.c | 4 | ||||
-rw-r--r-- | z40.c | 4 | ||||
-rw-r--r-- | z41.c | 7 | ||||
-rw-r--r-- | z42.c | 4 | ||||
-rw-r--r-- | z43.c | 4 | ||||
-rw-r--r-- | z44.c | 8 | ||||
-rw-r--r-- | z45.c | 4 | ||||
-rw-r--r-- | z46.c | 5 | ||||
-rw-r--r-- | z47.c | 4 | ||||
-rw-r--r-- | z48.c | 7 |
124 files changed, 8210 insertions, 1087 deletions
diff --git a/doc/expert/README b/doc/expert/README index 9b9c3e0..d066d57 100644 --- a/doc/expert/README +++ b/doc/expert/README @@ -16,4 +16,4 @@ copy of the final outfile.ps is included. There should be no warning messages on the fifth run. Jeffrey H. Kingston -!7 September 1999 +26 February 2000 diff --git a/doc/expert/all b/doc/expert/all index 46471c0..e2a5a78 100644 --- a/doc/expert/all +++ b/doc/expert/all @@ -10,9 +10,9 @@ Lout Document Formatting System } @Author { Jeffrey H. Kingston } - @Edition { Version 3.17 -September, 1999 } - @Publisher { @I { @CopyRight Copyright 1991, 1999, Jeffrey + @Edition { Version 3.18 +February, 2000 } + @Publisher { @I { @CopyRight Copyright 1991, 2000, Jeffrey H. Kingston, Basser Department of Computer Science, The University of Sydney 2006, Australia.} } @InitialLanguage { English } diff --git a/doc/expert/det_gall b/doc/expert/det_gall index e68d58f..e5e6e99 100644 --- a/doc/expert/det_gall +++ b/doc/expert/det_gall @@ -325,24 +325,33 @@ enclose.sym @Index @@Enclose meaning: when components of the galley replace a @@Galley or @@ForceGalley symbol, that symbol is first replaced by @@Enclose @@Galley or @@Enclose @@ForceGalley. For example, -@ID @Code { -"def @Enclose" -" right x" -"{" -" @Box x" -"}" +@ID @Code @Verbatim { +def @Figure into @FigurePlace&&following + right @Body +{ + def @Enclose + right x + { + @Box x + } + + @Body +} } -within some galley definition causes each @@Galley or @@ForceGalley -symbol that receives components of the galley to be replaced by -{@Code "@Box @Galley"} or {@Code "@Box @ForceGalley"}, assuming an -appropriate definition of @Code "@Box". This is useful, for example, -when producing multi-page boxed displays, figures, and tables. +causes each @@Galley or @@ForceGalley symbol that receives components of +galley @Code "@Figure" to be replaced by {@Code "@Box @Galley"} or +{@Code "@Box @ForceGalley"}, assuming an appropriate definition of +@Code "@Box". This is useful, for example, when producing multi-page +boxed displays, figures, and tables. @PP An @@Enclose symbol may have only one parameter, which must be a right parameter. It would not make sense to allow more parameters, since there is no suitable value to assign to them. However, the @@Enclose symbol may contain inner definitions, and it may make use -of any symbol that is available at that point, in the usual way. +of any symbol that is available at that point, in the usual way. The +@@Enclose symbol may be a named parameter (itself with a right parameter) +of the galley symbol, rather than an inner definition as shown above, +if desired. @PP A @Code "following" galley may fail to find a first target lying in a following component of the same galley as its invocation point. This is diff --git a/doc/expert/det_lexi b/doc/expert/det_lexi index e0ad9f1..4f98875 100644 --- a/doc/expert/det_lexi +++ b/doc/expert/det_lexi @@ -98,6 +98,8 @@ do so. The complete list of predefined identifiers is @JL "@CurrFace" @JL "@CurrFamily" @JL "@CurrLang" + @JL "@CurrYUnit" + @JL "@CurrZUnit" @JL "@Database" @JL "@End" @JL "@Enclose" @@ -117,9 +119,9 @@ do so. The complete list of predefined identifiers is @JL "@HLimited" @JL "@HScale" @JL "@HShift" - @JL "@HSpan" } |4.4cx { - "@Include" + "@HSpan" + @JL "@Include" @JL "@IncludeGraphic" @JL "@Insert" @JL "@KernShrink" @@ -142,15 +144,16 @@ do so. The complete list of predefined identifiers is @JL "@OneRow" @JL "@Open" @JL "@Optimize" + @JL "@Outline" @JL "@PAdjust" @JL "@PageLabel" @JL "@PlainGraphic" @JL "@Plus" @JL "@PrependGraphic" @JL "@RawVerbatim" - @JL "@Rotate" } |4.4cx { - "@Rump" + "@Rotate" + @JL "@Rump" @JL "@Scale" @JL "@SetColor" @JL "@SetColour" diff --git a/doc/expert/det_size b/doc/expert/det_size index aea894b..56738ac 100644 --- a/doc/expert/det_size +++ b/doc/expert/det_size @@ -26,6 +26,7 @@ measurement (Section {@NumberOf yunit}); } (also defining the @Code v unit); } @ListItem { Whether to permit hyphenation or not; } @ListItem { What colour the object is to appear in; } +@ListItem { Whether @@Outline is in effect; } @ListItem { The language of the object; } @ListItem { Whether @@VAdjust, @@HAdjust and @@PAdjust are in effect. } @EndList @@ -34,16 +35,16 @@ document. For example, the style of a parameter depends on where it is used; the style of a galley is the style of the first target that it attempts to attach itself to. Of course, the style of any object can be changed by using the @@Font, @@Break, @@Space, @@SetColour or -@@SetColor, and @@Language symbols. +@@SetColor, @@Outline, and @@Language symbols. @PP There are no standard default values for style, except that small capitals -are initially off, the interpretation of white space is initially {@Code -lout}, and the values of the @Code y and @Code z units are zero. Therefore -one must ensure that the root galley or each of its components is enclosed -in @@Font, @@Break, @@SetColour or @@SetColor, and @@Language symbols. From -there the style is passed to incoming galleys and the objects within -them. Enclosure in @@Space is not required because the @Code "s" unit -is also set by @@Font (Section {@NumberOf space}). +and outlining are initially off, the interpretation of white space is +initially {@Code lout}, and the values of the @Code y and @Code z units +are zero. Therefore one must ensure that the root galley or each of its +components is enclosed in @@Font, @@Break, @@SetColour or @@SetColor, and +@@Language symbols. From there the style is passed to incoming galleys +and the objects within them. Enclosure in @@Space is not required because +the @Code "s" unit is also set by @@Font (Section {@NumberOf space}). @PP width. @Index { Width of an object } height. @Index { Height of an object } diff --git a/doc/expert/mydefs b/doc/expert/mydefs index e7f0d15..0a4d364 100644 --- a/doc/expert/mydefs +++ b/doc/expert/mydefs @@ -24,6 +24,8 @@ def @@CurrLang { @Code "@CurrLang" } def @@CurrFamily { @Code "@CurrFamily" } def @@CurrFace { @Code "@CurrFace" } + def @@CurrYUnit { @Code "@CurrYUnit" } + def @@CurrZUnit { @Code "@CurrZUnit" } def @@Database { @Code "@Database" } def @@End { @Code "@End" } def @@Enclose { @Code "@Enclose" } @@ -60,9 +62,10 @@ def @@OneOf { @Code "@OneOf" } def @@OneRow { @Code "@OneRow" } def @@Open { @Code "@Open" } + def @@Outline { @Code "@Outline" } def @@PAdjust { @Code "@PAdjust" } def @@PageLabel { @Code "@PageLabel" } - def @@PlainGraphic { @Code "@PlainGraphic" } + def @@PlainGraphic { @Code "@PlainGraphic" } def @@PrependGraphic { @Code "@PrependGraphic" } def @@RawVerbatim { @Code "@RawVerbatim" } def @@Rotate { @Code "@Rotate" } diff --git a/doc/expert/pre b/doc/expert/pre index 72a4fa3..02320cc 100644 --- a/doc/expert/pre +++ b/doc/expert/pre @@ -10,6 +10,7 @@ @Include { pre_spac } @Include { pre_yuni } @Include { pre_colo } +@Include { pre_outl } @Include { pre_lang } @Include { pre_oner } @Include { pre_wide } diff --git a/doc/expert/pre_outl b/doc/expert/pre_outl new file mode 100644 index 0000000..f62ec9f --- /dev/null +++ b/doc/expert/pre_outl @@ -0,0 +1,21 @@ +@Section + @Title { "@Outline" } + @Tag { outline } +@Begin +@PP +The @@Outline symbol +outline.sym @Index { @@Outline symbol } +causes all the words in the right parameter (which may be an +arbitrary object) to be printed in outline, rather than filled as +is usual. For example, +@ID @Code @Verbatim { @Outline @Box 24p @Font HELP } +produces +@ID @Outline @Box 24p @Font HELP +Outlining is part of the style information, in the same way as +colour, font, underlining, and so forth. Outlining can be applied +to any font likely to be used in practice. At the time of writing, +there is no way to control the thickness of the outline, and +@@Outline has no effect in PDF output. The size of outlined +words is taken by Lout to be the same as if they had not been +outlined, even though they are in reality slightly larger. +@End @Section diff --git a/doc/expert/pre_yuni b/doc/expert/pre_yuni index 7b06b5d..cd5dd17 100644 --- a/doc/expert/pre_yuni +++ b/doc/expert/pre_yuni @@ -1,5 +1,5 @@ @Section - @Title { "@YUnit" and "@ZUnit" } + @Title { "@YUnit", "@ZUnit", "@CurrYUnit", and "@CurrZUnit" } @Tag { yunit } @Begin @PP @@ -21,6 +21,13 @@ but it may begin with @Code "+" or @Code "-" to indicate that value is to be added to or subtracted from the current value. Any negative result of using @Code "-" will be silently replaced by zero. @PP +The @@CurrYUnit and @@CurrZUnit symbols report the value of the @Code y +and @Code z units, in points, truncated to the nearest integer. For example, +@ID @Code "1i @YUnit { The current value of the y unit is @CurrYUnit }" +produces +@ID @Code "1i @YUnit { The current value of the y unit is @CurrYUnit }" +since there are 72 points in one inch (at least, Lout thinks there are). +@PP These units are not used internally by Lout. They are supplied as part of the style information for the convenience of application packages. For example, the Eq equation formatting package uses them diff --git a/doc/expert/preface b/doc/expert/preface index 1150929..9e37913 100644 --- a/doc/expert/preface +++ b/doc/expert/preface @@ -21,7 +21,7 @@ This manual presents Version 3 of Basser Lout, publicly released in September 1994 @Cite { $kingston1995lout.program }. This manual was rendered into PostScript postscript @Index { PostScript } -by Version 3.17 of the Basser Lout interpreter, using the symbols +by Version 3.18 of the Basser Lout interpreter, using the symbols described in the User's Guide @Cite { $kingston1995lout.user }. @DP @Heading { Acknowledgment. } Version 3 has benefited from hundreds of diff --git a/doc/slides/README b/doc/slides/README index a494b7c..66d5a78 100644 --- a/doc/slides/README +++ b/doc/slides/README @@ -15,4 +15,4 @@ after the second run. A copy of the final outfile.ps is included. Jeff Kingston -17 September 1999 +26 February 2000 diff --git a/doc/user/README b/doc/user/README index fd69ccb..2363b0c 100644 --- a/doc/user/README +++ b/doc/user/README @@ -16,9 +16,9 @@ nearly all beginning with "unresolved cross reference". These should gradually go away on later runs. The following shows the error message output on the fifth run for A4 size printing: -lout file "cpp_tabs" (from "cpp" line 24, from "all" line 38): - 53,23: c2lout: C text ended inside a comment - 55,35: c2lout: C text ended inside a comment +lout file "cpp_tabs" (from "cpp" line 80, from "all" line 45): + 56,23: prg2lout 2,1: program text ended within comment + 58,35: prg2lout 2,1: program text ended within comment These two warnings point to two places where a C program text ended inside a comment, which in these cases was deliberate so is no problem. @@ -31,7 +31,7 @@ repeated failure to converge, caused by footnotes and floating figures close to large unbreakable displays. A copy of the final PostScript output file (A4 paper size) is -stored at "ftp://ftp.cs.su.oz.au/jeff/lout/lout.3.17.user.ps.gz". +stored at "ftp://ftp.cs.su.oz.au/jeff/lout/lout-3.18.user.ps.gz". Jeffrey H. Kingston -17 September 1999 +23 February 2000 diff --git a/doc/user/all b/doc/user/all index 1b131f6..ef7fcdf 100644 --- a/doc/user/all +++ b/doc/user/all @@ -6,6 +6,7 @@ @SysInclude { pas } @SysInclude { diag } @SysInclude { cprint } +@SysInclude { eiffel } @SysInclude { book } # @Include { letterbook } # for testing Letter size formatting @@ -19,10 +20,10 @@ Lout Document Formatting System } @Author { Jeffrey H. Kingston } - @Edition { Version 3.17 -September, 1999 } + @Edition { Version 3.18 +February, 2000 } @Publisher { -Copyright @CopyRight 1991, 1999 Jeffrey H. Kingston, +Copyright @CopyRight 1991, 2000 Jeffrey H. Kingston, Basser Department of Computer Science, The University of Sydney 2006, Australia. ISBN 0 86758 951 5. } diff --git a/doc/user/ap_qck b/doc/user/ap_qck index 92ea7ad..092673d 100644 --- a/doc/user/ap_qck +++ b/doc/user/ap_qck @@ -56,8 +56,8 @@ " @PageHeaders { Simple }" " @FirstPageNumber { 1 }" " @ColumnNumber { 1 }" +" @Abstract { ... }" "//" -"@Abstract ... @End @Abstract" "@Section ... @End @Section" "@Appendix ... @End @Appendix" } diff --git a/doc/user/bas_lang b/doc/user/bas_lang index 3b32a94..01fbf2d 100644 --- a/doc/user/bas_lang +++ b/doc/user/bas_lang @@ -45,6 +45,7 @@ Hungarian Magyar Italian Italiano Norwegian Norsk Polish Polski +Portuguese Português Russian Slovenian Slovenia Slovenija Spanish Espa{@Char ntilde}ol diff --git a/doc/user/bgr b/doc/user/bgr index 9452ff0..86e0af4 100644 --- a/doc/user/bgr +++ b/doc/user/bgr @@ -10,6 +10,7 @@ get them. @BeginSections @Include { bgr_colo } @Include { bgr_boxs } +@Include { bgr_outl } @Include { bgr_rota } @Include { bgr_scal } @Include { bgr_incl } diff --git a/doc/user/bgr_outl b/doc/user/bgr_outl new file mode 100644 index 0000000..af11eb1 --- /dev/null +++ b/doc/user/bgr_outl @@ -0,0 +1,16 @@ +@Section + @Title { Outlined words } + @Tag { outline } +@Begin +@PP +The @@Outline symbol +outline.sym @Index { @@Outline symbol } +causes all the words in the following object (which may be +arbitrary as usual) to be printed in outline. For example, +@ID @Code @Verbatim { @Outline @Box 24p @Font HELP } +produces +@ID @Outline @Box 24p @Font HELP +There is no way to control the thickness of the outline, and +@@Outline has no effect in PDF output. On the other hand, +it works with any font likely to be used in practice. +@End @Section diff --git a/doc/user/cpp b/doc/user/cpp index 9b413ed..0e7748a 100644 --- a/doc/user/cpp +++ b/doc/user/cpp @@ -1,27 +1,86 @@ @Chapter - @Title { C and C++ Programs } + @Title { Computer Programs } @Tag { cprint } @Begin @LP -This chapter describes how to typeset C and C++ program text using the -cp. @Index @Code "@CP" -c. @Index { C++ } -@Code "@CP" symbol in conjunction with the @Code c2lout filter. The -@Code "@CP" symbol looks after printing keywords in bold, variables -in italic, and so on, depending on a style you choose. It does not lay -out programs in the sense of choosing indenting, it preserves the layout -you give to the program. From now on, `C' means `C or C++' wherever -it occurs. +This chapter describes how to typeset computer program text using Lout +in conjunction with the @Code prg2lout +prg2lout. @Index { @Code prg2lout filter program } +@FootNote { +Prior to Version 3.18 of Lout, this chapter described how to typeset +programs written in the C programming language using the +@Code c2lout filter, and Eiffel programs using the @Code eif2lout +filter. These have now been withdrawn and replaced by {@Code prg2lout}, +which handles multiple languages. Ordinary Lout documents require no +modifications as a result of this change. +} +filter program, which is always installed wherever Lout is. @PP -It is possible to simply print out one or more C files; we call this -@I { stand-alone mode }. Alternatively, the C program text may be printed -as part of a larger Lout document; we call this @I { embedded mode }. +It is possible to simply print out one or more program files independently +of any document. Alternatively, the program text may be printed as part of +a larger Lout document. Either way, Lout does not lay out the programs in +the sense of choosing line breaks and indenting; it uses whatever line +breaks and indenting you give to the program. What Lout does do is cope +with characters in the program text that it would ordinarily either reject +or interpret in some way (braces and so on), ensuring that you can include +program texts with absolutely no modifications; plus, if you wish, Lout +will print keywords in bold, identifiers in italics, etc. +@PP +At the time of writing, the available programming languages are: +eiffel. @Index { Eiffel program printing } +c. @Index { C and C++ program printing } +blue. @Index { Blue program printing } +@CD @Tbl + mv { 0.5vx } + af { Italic } + arb { yes } + aformat { @Cell A | @Cell B | @Cell C | @Cell D | @Cell E } + bformat { @Cell A | @Cell @Code B | @Cell @Code C | @Cell @Code D | @Cell E } +{ +@Rowa + A { Language name } + B { Setup file name } + C { Lout symbol } + D { Default style } + E { ` ' escapes } +@Rowb + A { C, C++ } + B { cprint } + C { "@CP" } + D { fixed } + E { No } +@Rowb + A { Eiffel } + B { eiffel } + C { "@Eiffel" } + D { varying } + E { Yes } +@Rowb + A { Blue } + B { blue } + C { "@Blue" } + D { varying } + E { Yes } +} +C and C++ are handled together since, for formatting purposes, they +differ only in that C++ has some additional keywords plus an extra +way to make comments. Whenever we mention C from now on, we mean +both C and C++. The second to fifth columns of this table will be +explained at various points later in this chapter. +@PP +The list of languages is likely to expand, because the @Code "prg2lout" +program has been designed to make it easy to add new languages. Consult +the instructions at the top of the source file of that program if you +want to try it yourself. @BeginSections @Include { cpp_lone } @Include { cpp_embe } +@Include { cpp_opti } @Include { cpp_chan } -@Include { cpp_comm } @Include { cpp_tabs } -@Include { cpp_eiff } +@Include { cpp_comm } +@Include { cpp_prog } +@Include { cpp_pipe } +@Include { cpp_erro } @EndSections @End @Chapter diff --git a/doc/user/cpp_chan b/doc/user/cpp_chan index ddedd51..bee0493 100644 --- a/doc/user/cpp_chan +++ b/doc/user/cpp_chan @@ -1,27 +1,28 @@ @Section - @Title { Changing the default values } + @Title { Changing the appearance of all programs simultaneously } @Tag { cpsetup } @Begin @PP -We have just seen that the @Code "@CP" symbol has many options for -changing the appearance of the C text. However, most people would -not want to have a different style for every C text in their document; -they want to define the style once at the start, and have all their -C texts come out in that style without laboriously setting options -on every @Code "@CP" symbol. This is done by copying the setup file -and changing it. +We have just seen that the {@Code "@CP"}, {@Code "@Eiffel"} etc. symbols +have many options for changing the appearance of the program text. However, +most people would not want to have a different style for every program text +in their document; they want to define the style once at the start, and have +all their program texts come out in that style without laboriously setting +options on every symbol. You do this by copying the setup file and +changing it. @PP For general information about how to make your own setup file, consult Section {@NumberOf setup}. The options that determine the default -values are in the @Code "@CPSetup" @Code "@Use" clause near the end of +values are in the @Code "@Use" clause which occupies most of the setup +file. Here is the @Code "@Use" clause from {@Code cprint}: cprint. @Index @Code "@CPSetup" -the @Code "cpsetup." setup file: -@ID @Code @Tab - vmargin { 0.5vx } - @Fmta { @Col A ! @Col B ! @Col C} - @Fmtb { @Col { " #" A } ! @Col { "{" B } ! @Col "}" } +@ID @Code @Tbl + mv { 0.5vx } + aformat { @Cell A | @Cell B | @Cell C } + bformat { @Cell { " #" A } | @Cell { "{" B } | @Cell "}" } { @Rowa A { "@Use { @CPSetup" } +@Rowb A { "pipe" } B { } @Rowb A { "style" } B { fixed } @Rowa @@ -65,13 +66,13 @@ the @Code "cpsetup." setup file: @Rowa A { "}" } } -These show the default font families, font faces, font sizes, line +This shows the default font families, font faces, font sizes, line spacings, and tab settings in force for the three styles, and also that the default style is {@Code "fixed"}. Notice that the font family name for @Code "fixed" style is {@Code "Courier"}, but for the other styles is empty. This causes the @Code "fixed" style to always switch to Courier, and the other styles to use the same font family as in the surrounding -document. +document. The @Code pipe option will be explained in Section {@NumberOf pipes}. @PP To change a default value, delete the preceding @Code "#" and change the part between braces. For example, suppose you are happy with @Code "fixed" @@ -80,4 +81,11 @@ except that you want bold keywords. Then one line needs to be changed, to Or suppose you like @Code "varying" as it stands, but would like it to be the default style rather than {@Code "fixed"}. Again, only one line needs to be changed, to {@Code "style { varying }"}. +@PP +The setup files for the other languages are identical to this one, except +that the symbol after @Code "@Use" is different, and some of the +default values may be different. Changing an option affects only the +language of that setup file; if you have multiple languages you can +have multiple setup files and change their options quite independently +of each other. @End @Section diff --git a/doc/user/cpp_comm b/doc/user/cpp_comm index f877c06..96ac110 100644 --- a/doc/user/cpp_comm +++ b/doc/user/cpp_comm @@ -1,20 +1,27 @@ @Section - @Title { Lout inside C comments } + @Title { Embedding Lout commands within program comments } @Tag { cpcomm } @Begin @PP -It is possible to embed Lout text inside C and C++ comments, by -starting off the comment with an @Code "@" character. The entire -comment after the @Code "@" character should be Lout text. For -example, to force Lout to start a new page at some point within a C -program, place +It is possible to embed Lout text inside program comments. How this +is done could in principle vary from language to language, but in +every language supported so far it is done by starting off the comment +with an @Code "@" character. If the language has several ways to get +a comment, this will work every way. The entire comment after the @Code "@" +character should then be Lout text. For example, to force Lout to start +a new page at some point within a C program, place @ID @Code "/*@ @NP */" -at that point. Or you could make a heading like this: -@ID @Code "/*@ @Display @Heading { treeprint() } */" -Other possible uses for this feature include index entries and margin -notes. Incredible as it may seem, you can even write +at that point. (In this case you can also simply include a formfeed +formfeed. @Index { formfeed in program texts } +character, control-L, without any comment; whatever the language, a formfeed +in program text is taken to be a request to start a new page.) Or, to +make a heading in an Eiffel program, do this: +@ID @Code "--@ @Display @Heading { treeprint() }" +(Eiffel comments begin with @Code "--" and end at the end of the +line.) Other possible uses for this feature include index entries and +margin notes. Incredible as it may seem, you can even write @ID @Code "/*@ @CD @Heading { Function @CP { treeprint() } } */" with a @Code "@CP" symbol and some C code inside the Lout code -inside the C code. You probably can't go further, however, since -that would require a C comment inside a C comment. +inside the C code. You probably can't go further, however, at least +not in C, since that would require a C comment inside a C comment. @End @Section diff --git a/doc/user/cpp_eiff b/doc/user/cpp_eiff deleted file mode 100644 index d0ec6df..0000000 --- a/doc/user/cpp_eiff +++ /dev/null @@ -1,42 +0,0 @@ -@Section - @Title { Eiffel program printing } - @Tag { eiffel } -@Begin -@PP -There is an @Code "@Eiffel" symbol for typesetting Eiffel programs -in conjuction with a filter called {@Code "eif2lout"}. Apart from -the change of language, everything is identical to C printing. The -file and symbol names are different, of course: -@ID @OneRow @Tab - vmargin { 0.5vx } - @Fmta { @Col A ! @Col B } -{ -@Rowa - A { @Code cprint } - B { @Code eiffel } -@Rowa - A { @Code c2lout } - B { @Code eif2lout } -@Rowa - A { @Code "@CP" } - B { @Code "@Eiffel" } -@Rowa - A { @Code "@CPSetup" } - B { @Code "@EiffelSetup" } -} -but everything works in an exactly analogous way: you place -@ID @Code "@SysInclude { eiffel }" -at the top of your document, enclose Eiffel program texts in -@Code "@Eiffel { ... }", embed Lout into Eiffel using comments -beginning with {@Code "--@"}, and so on. The default style has been -changed to {@Code varying}, so as to conform to the style guidelines -in the standard Eiffel reference @Cite { $meyer1992eiffel }. Some care -has gone into making this conformance strict; in particular, if you -enclose identifiers within comments in ` and ', as the style guidelines -say you should, they will come out in italics; in fact, arbitrary text -between ` and ' within comments will be set as Eiffel code. -@PP -The files needed for Eiffel printing are distributed separately from -Basser Lout. You can get them from the author's @Code ftp directory -(see the preface of this guide). -@End @Section diff --git a/doc/user/cpp_embe b/doc/user/cpp_embe index 8ca2dfc..0cefc84 100644 --- a/doc/user/cpp_embe +++ b/doc/user/cpp_embe @@ -1,11 +1,11 @@ @Section - @Title { Embedded mode } + @Title { Typesetting computer programs as part of a larger document } @Tag { embedded } @Begin @PP -When the C program texts are to be embedded in a larger Lout document, -the procedure is somewhat different. You need to include the -@Code "cprint" setup file, like this: +When the program texts are to be part of a larger Lout document, +the procedure is somewhat different. You need to include the setup file +appropriate to your language, like this: @ID @OneRow @Code { "@SysInclude { cprint }" "@SysInclude { doc }" @@ -13,9 +13,13 @@ the procedure is somewhat different. You need to include the "..." "@End @Text" } -This file includes everything needed to set up for C program formatting. +The @Code cprint setup file includes everything needed to set up for C +program formatting; for the other languages, consult the second column +of the table at the start of this chapter. @PP -The C parts of the document are enclosed in @Code "@CP { ... }" like this: +The program texts within the Lout document are enclosed in braces +preceded by the Lout symbol from the third column of the table, like +this for the C language: @ID @OneRow @Code { "@IndentedDisplay @CP {" "#include <stdio.h>" @@ -31,9 +35,10 @@ The C parts of the document are enclosed in @Code "@CP { ... }" like this: "}" "}" } -Although C programs violate the rules of legal Lout input in many ways, -these rules are suspended by the @Code "@CP" symbol, allowing the C -text to be incorporated with absolutely no modifications. The result is +Although computer programs violate the rules of legal Lout input in many ways, +these rules are suspended by the {@Code "@CP"}, {@Code "@Eiffel"} etc. symbols, +allowing the program text to be incorporated with absolutely no +modifications. The result is @ID @OneRow @CP { #include <stdio.h> @@ -49,104 +54,29 @@ struct tnode *p; } We have chosen to use the @Code "@IndentedDisplay" symbol from Section {@NumberOf displays} to obtain an indented display, but in fact -@Code "@CP" may appear anywhere at all. When including a C text within -a paragraph, use @Code "@OneCol @CP { ... }" to prevent it being broken -across two lines, if desired. +{@Code "@CP"}, {@Code "@Eiffel"} and the rest may appear anywhere at +all: the result is an object in the usual way, which may go +anywhere. When including a program text within a paragraph, use +@Code "@OneCol @CP { ... }" (or @Code "@OneCol @Eiffel { ... }" etc. for +other languages) to prevent it being broken across two lines, if desired. @PP -In cases where the C text has unbalanced braces, it is necessary to -use the alternative form @Code "@CP @Begin ... @End @CP" so that -Lout does not confuse C braces with Lout braces. +In cases where the program text has unbalanced braces, it is necessary to +use the alternative form @Code "@CP @Begin ... @End @CP" (or the +equivalent for other languages), so that Lout does not confuse program +braces with Lout braces. In that case the program text must not +contain {@Code "@End"}; and in either case the program text must not +include @Code "@Include" or @Code "@SysInclude" unless you are really +including a file at that point (which is allowed, and follows the +rules given for @Code "@Verbatim" in Section {@NumberOf verbatim}). @PP -The @Code "@CP" symbol has a @Code "style" option for changing the -printing style. The default value of @Code "style" is {@Code "fixed"}, -which produces the style shown above. To obtain a varying-width font -style, use @Code "style { varying }" like this: -@ID @OneRow @Code { -"@CP" -" style { varying }" -"{" -"#include <stdio.h>" -"" -"treeprint(p) /* print tree p recursively */" -"struct tnode *p;" -"{" -" if (p != NULL) {" -" treeprint(p->left);" -" printf(\"%4d %s\\n\", p->count, p->word);" -" treeprint(p->right);" -" }" -"}" -"}" -} -The result in this case will be -@ID @OneRow @CP style { varying } -{ -#include <stdio.h> - -treeprint(p) /* print tree p recursively */ -struct tnode *p; -{ - if (p != NULL) { - treeprint(p->left); - printf("%4d %s\n", p->count, p->word); - treeprint(p->right); - } -} -} -There is also a third style called @Code "style { symbol }" which is -similar to @Code "varying" except that it uses characters from the -Adobe Symbol font to produce a more mathematical-looking result: -@ID @OneRow @CP style { symbol } -{ -#include <stdio.h> - -treeprint(p) /* print tree p recursively */ -struct tnode *p; -{ - if (p != NULL) { - treeprint(p->left); - printf("%4d %s\n", p->count, p->word); - treeprint(p->right); - } -} -} -The @Code "@CP" symbol has additional options which allow a finer -control over the style. Here they all are, with their default values: -@ID @OneRow @Code { -"@CP" -" style { fixed }" -" font { Courier }" -" strings { Base }" -" identifiers { Base }" -" comments { Base }" -" keywords { Base }" -" numbers { Base }" -" operators { Base }" -" size { -1.0p }" -" line { 1.0vx }" -" tabin { 8 }" -" tabout { 8s }" -"{" -" ..." -"}" -} -We are already familiar with {@Code "style"}. After that comes -{@Code "font"}, which determines the font family to use, followed -by six options giving the particular faces within that family in which to -print C strings, identifiers, comments, keywords, numbers, and -operators. {@Code "Base"} means the basic face; other commonly available -choices are {@Code "Slope"} and {@Code "Bold"}. These options may all be -set to different faces if desired. The default values shown are correct -for @Code "style { fixed }" only; the other styles have other defaults -(Section {@NumberOf cpsetup}). -@PP -The @Code "size" option is the font size to use, and @Code "line" is the -inter-line spacing. The default values specify that @Code "size" is -to be one point smaller than in the surrounding document; this was done -to compensate for Courier's relatively large appearance compared -to other fonts of the same nominal size. Again, these defaults are -different for different values of {@Code "style"}. -@PP -The @Code "tabin" and @Code "tabout" options are the subject of -Section {@NumberOf tabs}. +If your Lout document contains program texts in several languages, +simply add one @Code "@SysInclude" line for each of them and proceed +as before. If your programming language is not currently supported, +a viable alternative is +@ID @Code "@F @Verbatim { ... }" +These symbols cause the text between braces to be set verbatim in +a fixed-width font, as explained elsewhere in this guide. This fallback +method will not handle tab and formfeed characters very well. Again, +use @Code "@Begin" and @Code "@End @Verbatim" instead of braces if +your program text contains unbalanced braces. @End @Section diff --git a/doc/user/cpp_erro b/doc/user/cpp_erro new file mode 100644 index 0000000..ff89591 --- /dev/null +++ b/doc/user/cpp_erro @@ -0,0 +1,39 @@ +@Section + @Title { Error messages } + @Tag { cpp_erro } +@Begin +@PP +In order to understand the error messages produced by program +printing, it is necessary to understand that Lout's first step when +given a program text is to pass it to the separate {@Code prg2lout} +program for analysis. This separate program is the source of most +of the error messages associated with program printing. +@PP +The {@Code prg2lout} program is quite happy to format a fragment of a +computer program: there is no need to supply a complete routine, or +a complete statement, or any such thing. However, it will complain if +you supply only a fragment of one lexical unit, such as a comment or +string without its terminating delimiter. It will also complain if +there is a character that cannot be classified as part of an identifier, +number, etc. according to the rules of the language as they have been +given to @Code prg2lout by the implementer. Irrespective of the +language rules, @Code prg2lout always interprets spaces, tabs, newlines, +and formfeed characters in the usual way. +@PP +If an error message is generated by {@Code prg2lout}, it will contain +a line and column number counting from the start of the program text +involved. Lout will precede this error message with a file name, +line number, and column number pointing to the Lout symbol +({@Code "@CP"}, {@Code "@Eiffel"} etc.) whose program text caused the +error message, like this: +@ID @Code @Verbatim { +lout file "cpp_tabs" (from "cpp" line 80, from "all" line 45): + 56,23: prg2lout 2,1: program text ended within comment +} +This is an actual message produced when formatting this chapter. The +program text in question has only one line, containing an incomplete comment, +so when @Code "prg2lout" tried to start the second line and found nothing, +it complained as shown. In general, then, you have to add +{@Code "prg2lout"}'s line number to Lout's line number, and use some +initiative, to find the precise point of the problem. +@End @Section diff --git a/doc/user/cpp_lone b/doc/user/cpp_lone index 8d8e367..a377d86 100644 --- a/doc/user/cpp_lone +++ b/doc/user/cpp_lone @@ -1,21 +1,22 @@ @Section - @Title { Stand-alone mode } + @Title { Typesetting computer programs independently of any document } @Tag { alone } @Begin @PP -Printing of C files in stand-alone mode is accomplished by the following -c2lout @Index { @Code "c2lout" filter } -Unix pipeline: -@ID @Code "c2lout options C-files | lout -s > out.ps" -As usual with Lout, the output will be a PostScript file. Each input -file will begin on a new page of the output, starting with its name -in bold type. The options provide control over the final appearance, -as follows: +Printing of program files independently of any document is accomplished by +the following Unix pipeline: +@ID @Code "prg2lout -l language options files | lout -s > out.ps" +where @Code language stands for any one of the programming language +names in the first column of the table above. As usual with Lout, the +output will be a PostScript file. Each input file will begin on a new +page of the output, starting with its name in bold type. The options +provide control over the final appearance, as follows: @WideTaggedList @TI { {@Code-p}{@I style} } { Select a printing style. Your choices are {@Code -pfixed}, -{@Code -pvarying}, and {@Code -psymbol}, with the default being -{@Code -pfixed}. Consult Section {@NumberOf embedded} for examples +{@Code -pvarying}, and {@Code -psymbol}, with the default value +varying with the language as given in the fourth column of the +table above. Consult Section {@NumberOf embedded} for examples of these styles. } @TI { @Code -n } { diff --git a/doc/user/cpp_opti b/doc/user/cpp_opti new file mode 100644 index 0000000..538bda2 --- /dev/null +++ b/doc/user/cpp_opti @@ -0,0 +1,105 @@ +@Section + @Title { Changing the appearance of a program } + @Tag { cpp_opti } +@Begin +@PP +The {@Code "@CP"}, {@Code "@Eiffel"} etc. symbols have a number of +options for changing the appearance of the printed program. These +options are the same for all symbols, although their default values +may vary. The @Code "style" option changes the printing style; its +value may be {@Code "fixed"} (fixed-width font), {@Code "varying"} +(varying-width font), or {@Code "symbol"} (varying-width font with +mathematical symbols used for some operators). Its default value +depends on the language, and may be found in the fourth column of +the table at the start of this chapter. The example in the previous +section was in @Code fixed style; we can switch styles like this: +@ID @OneRow @Code { +"@CP" +" style { varying }" +"{" +"#include <stdio.h>" +"" +"treeprint(p) /* print tree p recursively */" +"struct tnode *p;" +"{" +" if (p != NULL) {" +" treeprint(p->left);" +" printf(\"%4d %s\\n\", p->count, p->word);" +" treeprint(p->right);" +" }" +"}" +"}" +} +The result in this case will be +@ID @OneRow @CP style { varying } +{ +#include <stdio.h> + +treeprint(p) /* print tree p recursively */ +struct tnode *p; +{ + if (p != NULL) { + treeprint(p->left); + printf("%4d %s\n", p->count, p->word); + treeprint(p->right); + } +} +} +If we use @Code "style { symbol }" we get this: +@ID @OneRow @CP style { symbol } +{ +#include <stdio.h> + +treeprint(p) /* print tree p recursively */ +struct tnode *p; +{ + if (p != NULL) { + treeprint(p->left); + printf("%4d %s\n", p->count, p->word); + treeprint(p->right); + } +} +} +with mathematical symbols replacing some of the operators. +@PP +The {@Code "@CP"}, {@Code "@Eiffel"} etc. symbols have additional options +which allow a finer control over the style. Here they all are, with their +default values: +@ID @OneRow @Code { +"@CP [ or @Eiffel, @Blue, etc. ]" +" style { fixed }" +" font { Courier }" +" strings { Base }" +" identifiers { Base }" +" comments { Base }" +" keywords { Base }" +" numbers { Base }" +" operators { Base }" +" size { -1.0p }" +" line { 1.0vx }" +" tabin { 8 }" +" tabout { 8s }" +"{" +" ..." +"}" +} +We are already familiar with {@Code "style"}. After that comes +{@Code "font"}, which determines the font family to use, followed +by six options giving the particular faces within that family in which to +print strings, identifiers, comments, keywords, numbers, and +operators. {@Code "Base"} means the basic face; other commonly available +choices are {@Code "Slope"} and {@Code "Bold"}. These options may all be +set to different faces if desired. The default values shown are correct +for @Code "style { fixed }" only; the other styles have other defaults +(Section {@NumberOf cpsetup}). +@PP +The @Code "size" option is the font size to use, and @Code "line" is the +inter-line spacing. The default values specify that @Code "size" is +to be one point smaller than in the surrounding document; this was done +to compensate for Courier's relatively large appearance compared +to other fonts of the same nominal size. Again, these defaults are +different for different values of {@Code "style"}. +@PP +The @Code "tabin" and @Code "tabout" options are the subject of +Section {@NumberOf tabs}. +@End @Section diff --git a/doc/user/cpp_pipe b/doc/user/cpp_pipe new file mode 100644 index 0000000..afbb87e --- /dev/null +++ b/doc/user/cpp_pipe @@ -0,0 +1,57 @@ +@Section + @Title { Reading and selecting program text from separate files } + @Tag { pipes } +@Begin +@PP +We have said that program text within @Code "@CP { ... }" and the other +symbols is passed directly to @Code prg2lout for analysis. However, +there is an exception. The program text may contain an +@Code "@Include" or @Code "@SysInclude" command, which, as for the +@Code "@Verbatim" symbol (Section {@NumberOf verbatim}), causes Lout +to take the program text from a file: +@ID @Code { +"@Eiffel" +"{" +" @Include { \"/usr/staff/jeff/Eiffel/hash.e\" }" +"}" +} +The included file is not examined for balanced braces or @Code "@End" or +{@Code "@Include"}; it is treated entirely verbatim and passed straight +on to {@Code prg2lout}. There may be several @Code "@Include" commands, +and any amount of program text as well, within @Code "@CP { ... }" and +the rest. +@PP +When including files in this way it often happens that only part of an +actual program file is wanted for display. Rather than placing the +wanted part in a separate file, which is error-prone and tedious when +the program is changing, Unix users can use the @Code "pipe" option +to pipe the entire file through an arbitrary sequence of Unix commands, +which may be used to make the wanted selection before the program text +is passed to {@Code prg2lout}. +@PP +For example, suppose that all your Eiffel routines begin with the +routine name one tab stop from the left margin and end at the first +following @Eiffel { end } indented two tab stops. Then +@ID @Code { +"@Eiffel" +" pipe { \"sed -n /^.insert/,/^..end/p\" }" +"{" +" @Include { \"/usr/staff/jeff/Eiffel/hash.e\" }" +"}" +} +will select just the @Eiffel { insert } routine from the @Code { hash.e } +file. Assuming that your program text has been laid out in a +disciplined manner, every line of the selection will begin with a +tab character that is not wanted in this display, so an even better +pipe is +@ID @Code { +"@Eiffel" +" pipe { \"sed -n /^.insert/,/^..end/p | cut -c2-\" }" +"{" +" @Include { \"/usr/staff/jeff/Eiffel/hash.e\" }" +"}" +} +since it cuts away the unwanted tab characters. Unfortunately, we +can't show the result of this on an actual example, since that would +prevent this manual from being formatted on a non-Unix system. +@End @Section diff --git a/doc/user/cpp_prog b/doc/user/cpp_prog new file mode 100644 index 0000000..a049e3d --- /dev/null +++ b/doc/user/cpp_prog @@ -0,0 +1,35 @@ +@Section + @Title { Embedding program text within program comments } + @Tag { cpp_prog } +@Begin +@PP +The standard reference for the Eiffel language @Cite { $meyer1992eiffel } +specifies that identifiers within comments may or should be enclosed +in ` and ' so that they may be noticed and printed in an italic +font: +@ID lines @Break @F @Verbatim { +@ID @Eiffel { +deposit(amount: REAL) is + -- deposit `amount' dollars +} +} +produces +@ID @Eiffel { +deposit(amount: REAL) is + -- deposit `amount' dollars +} +This has been generalized in Lout: arbitrary text within an +Eiffel comment between ` and ' will be treated as Eiffel text and +printed accordingly. Some other languages may also offer this +feature: see the fifth column of the table at the start of this +chapter. In principle the precise means of getting it could vary +from language to language, but the languages available at the moment +either do not have it at all, or else they use ` and ' like Eiffel. +@PP +On the subject of Eiffel, the Eiffel reference @Cite { $meyer1992eiffel } +has some quite detailed style guidelines, and these have been closely +followed in the implementation of the @Code "@Eiffel" symbol. In +particular, @Code "@Eiffel" prints dots larger than usual when they +denote feature calls, as the example @OneCol @Eiffel { account.deposit(20) } +shows. +@End @Section diff --git a/doc/user/cpp_tabs b/doc/user/cpp_tabs index 1157a51..3a04bfa 100644 --- a/doc/user/cpp_tabs +++ b/doc/user/cpp_tabs @@ -1,28 +1,31 @@ @Section - @Title { Tab characters } + @Title { Dealing with tab characters in programs } @Tag { tabs } @Begin @PP -Tab characters provide a convenient way to indent and align parts of C -tab.c @Index { tab characters in C programs } -programs. With care, this alignment can be preserved in the final +Tab characters provide a convenient way to indent and align parts of +tab.c @Index { tab characters in programs } +computer programs. With care, this alignment can be preserved in the final print even with varying-width fonts. @PP -The distance between two tab stops in the input file is by default taken +The distance between two tab stops in the program text is by default taken to be 8 characters, which is standard for Unix. This can be changed with the @Code "tabin" option. For example, @ID @Code "@CP tabin { 4 }" -informs Lout that tab stops occur every 4 characters in the input file. +informs Lout that tab stops occur every 4 characters in the program +text. All the symbols ({@Code "@CP"}, {@Code "@Eiffel"}, etc.) and +their setup files have this option and the next; but to save repetition +we will stick with C for the rest of this section. @PP -The distance between two tab stops in the output file (on the printed -page) is quite a different thing, and it is determined by the value of -the @Code "tabout" option, which must be a Lout length. For example, +The distance between two tab stops on the printed page is quite a different +thing, and it is determined by the value of the @Code "tabout" option, which +must be a Lout length. For example, @ID @Code "@CP tabout { 0.5i }" requests that tab stops be placed at half-inch intervals. In other -words, a distance of one tab stop in the input will be equivalent to a -distance of half an inch in the output. For example, +words, a distance of one tab stop in the program text will be equivalent to a +distance of half an inch on the printed page. For example, @ID @Code "@CP style { varying } tabout { 3f }" -might produce the following, where tab characters in the input file +might produce the following, where tab characters in the program text have been used for indenting and also to align the comments: @ID @OneRow @CP style { varying } tabout { 3f } { struct tnode { /* the basic node */ @@ -37,7 +40,7 @@ it is the default value of @Code "tabout" for the @Code { varying } and @Code { symbol } styles (Section {@NumberOf cpsetup}). In a 12 point font this is 36 points, or half an inch. @PP -If @Code "tabout" is made too small, there is a danger that the +If @Code "tabout" is too small, there is a danger that the alignment might fail. For example, @ID @Code "@CP style { varying } tabout { 0.2i }" produces @@ -56,7 +59,8 @@ wider than this. This causes @CP { /* } to be shifted further to the right than expected, and the alignment is lost. The only solution is to increase {@Code "tabout"}. @PP -In stand-alone mode there are @Code "-t" and @Code "-T" options -equivalent to @Code "tabin" and @Code "tabout" respectively. For +When typesetting computer program texts independently of any document, +there are @Code "-t" and @Code "-T" options to the @Code "prg2lout" +program equivalent to @Code "tabin" and @Code "tabout" respectively. For example, @Code "-T0.5i" produces a half-inch tab width. @End @Section diff --git a/doc/user/dia b/doc/user/dia index 4029cec..6462c88 100644 --- a/doc/user/dia +++ b/doc/user/dia @@ -6,6 +6,13 @@ This chapter describes how to use the @@Diag symbol diag. @Index { @@Diag } @FootNote { +Starting with Version 3.18 of Lout, the @@Diag symbol was enhanced with +the {@Code "@ANode"}, {@Code "@BNode"}, and {@Code "@CNode"} symbols +described in Section {@NumberOf dia_node}, and with the symbols for +syntax diagrams described in Section {@NumberOf dia_synt}. These +enhancements are upwardly compatible, unless the user has defined +symbols with these same names and used them within diagrams. +@LP Prior to Version 3.09 of Lout, this chapter described a symbol called fig. @Index @Code "@Fig" {@Code "@Fig"} which was similar to but more primitive than @@ -29,7 +36,7 @@ diag. @Index @Code "@Diag" // @Arrow from { E } to { D } } @@Diag offers nodes and links, arrows, labels, positioning using coordinates, -and tree diagrams. +tree diagrams, and syntax diagrams. @BeginSections @Include { dia_intr } @Include { dia_node } @@ -38,6 +45,7 @@ and tree diagrams. @Include { dia_labe } @Include { dia_posi } @Include { dia_tree } +@Include { dia_synt } @Include { dia_erro } @Include { dia_defi } @Include { dia_geom } diff --git a/doc/user/dia_node b/doc/user/dia_node index b72c6e2..8980978 100644 --- a/doc/user/dia_node +++ b/doc/user/dia_node @@ -79,10 +79,53 @@ document. As the number of nodes increases, it becomes very tedious and error-prone to duplicate options at all the nodes. Giving each option just once, at the @Code "@Diag" symbol or in the setup file, saves time and makes it easy to change all the nodes into squares or any other shape -later on. Any setup file option may be overridden in a diagram by -giving the option to its @Code "@Diag" symbol; any @Code "@Diag" option -or setup file option may be overridden at any node by giving the option -again there. +later on. Any setup file option may be overridden in a diagram by giving +the option to its @Code "@Diag" symbol; any @Code "@Diag" option or setup +file option may be overridden at any node by giving the option again there. +@PP +Sometimes a diagram contains several different node types, each with +its own combination of options (for example, the syntax diagrams of +Section {@NumberOf dia_synt} have three node types). To handle these +cases there are three alternative versions of the @Code "@Node" +symbol, called {@Code "@ANode"}, {@Code "@BNode"}, and +anode.fig @Index { @Code "@ANode" in @Code "@Diag" } +bnode.fig @Index { @Code "@BNode" in @Code "@Diag" } +cnode.fig @Index { @Code "@CNode" in @Code "@Diag" } +{@Code "@CNode"}. These have exactly the same options as +{@Code "@Node"}, but the @I default values of these options +are different, in that they come from @Code "@Diag" options, +or else setup file options, that have an extra letter in front +of their name: @Code { a }, @Code { b }, or @Code { c }. Here is +a small example (see later in this section for the @Code font option): +@ID @OneRow { +@Code @Verbatim { +@Diag + aoutline { box } + afont { Italic } + boutline { curvebox } + bfont { Bold } +{ + @ANode identifier + @DP + @BNode keyword +} +} +||7ct +@Diag + aoutline { box } + afont { Italic } + boutline { curvebox } + bfont { Bold } +{ + @ANode identifier + @DP + @BNode keyword +} +} +Note that when giving an option directly to {@Code "@ANode"}, +{@Code "@BNode"}, and {@Code "@CNode"}, the initial @Code { a }, +@Code { b }, or @Code { c } used with @Code "@Diag" and in the +setup file is omitted. @PP To save time in simple cases, @Code "@Diag" provides nine other node symbols called diff --git a/doc/user/dia_summ b/doc/user/dia_summ index b9dc9e9..4539785 100644 --- a/doc/user/dia_summ +++ b/doc/user/dia_summ @@ -1212,6 +1212,93 @@ The @Code "@HTree" option has a similar @Code "treevindent" option, which may be {@Code "top"}, {@Code ctr}, {@Code foot}, or any length from Section {@NumberOf objects}. @PP +Here are all the syntax diagrams symbols, used within {@Code "@SyntaxDiag"} +usually but also available within {@Code "@Diag"}. To begin with we have +the six starter symbols: +@CD @SyntaxDiag { +@Tbl + aformat { @Cell @Code A | @Cell B | @Cell | @Cell @Code C | + @Cell D | @Cell | @Cell @Code E | @Cell F } +{ +@Rowa + A { "@StartRight ..." } + B { @StartRight @ACell "..." } + C { "@StartUp ..." } + D { @StartUp @ACell "..." } + E { +"@StartRightRight" + "A { ... }" + "B { ... }" +} + F { @StartRightRight A { @ACell A } B { @ACell B } } +@Rowa + A { "@StartLeft ..." } + B { @StartLeft @ACell "..." } + C { "@StartDown ..." } + D { @StartDown @ACell "..." } + E { +"@StartRightDown" + "A { ... }" + "B { ... }" +} + F { @StartRightDown A { @ACell A } B { @ACell B } } +} +} +And here are all the syntax diagram types, shown in all four directions +(right, up, left, and down). @Code "@Sequence" and @Code "@Select" may +have up to twelve options, {@Code "A"} to {@Code "L"}. +@IndentedList + +@LI @SyntaxDiag { @Four code { "@ACell ..." } @ACell "..." } + +@LI @SyntaxDiag { @Four code { "@BCell ..." } @BCell "..." } + +@LI @SyntaxDiag { @Four code { "@CCell ..." } @CCell "..." } + +@LI @SyntaxDiag { @Four code { "@Skip" } @Skip } + +@LI @SyntaxDiag { @Four code { +"@Sequence" + "A { ... }" + "B { ... }" + "C { ... }" +} @Sequence A { @ACell A } B { @ACell B } C { @ACell C } } + +@LI @SyntaxDiag { @Four code { +"@Select" + "A { ... }" + "B { ... }" + "C { ... }" +} @Select A { @ACell A } B { @ACell B } C { @ACell C } } + +@LI @SyntaxDiag { @Four code { "@Optional ..." } @Optional @ACell "..." } + +@LI @SyntaxDiag { @Four code { "@OptionalDiverted ..." } + @OptionalDiverted @ACell "..." } + +@LI @SyntaxDiag { @Four code { "@Diverted ..." } @Diverted @ACell "..." } + +@LI @SyntaxDiag { @Four code { +"@Loop" + "A { ... }" + "B { ... }" +} @Loop A { @ACell A } B { @ACell B } } + +@LI @SyntaxDiag { @Four code { "@Repeat ..." } @Repeat @ACell "..." } + +@LI @SyntaxDiag { @Four code { +"@LoopOpposite" + "A { ... }" + "B { ... }" +} @LoopOpposite A { @ACell A } B { @ACell B } } + +@LI @SyntaxDiag { @Four code { "@RepeatOpposite ..." } + @RepeatOpposite @ACell "..." } + +@LI @SyntaxDiag { @Four code { "@RepeatDiverted ..." } + @RepeatDiverted @ACell "..." } + +@EndList The @Code "@Diag" symbol and to the {@Code "@DiagSetup"} setup file symbol have all of the options of {@Code "@Node"}, {@Code "@Link"}, {@Code "@Tree"}, and {@Code "@HTree"}. They also have the following @@ -1240,8 +1327,16 @@ options: B { 0.5f } C { any length from Section {@NumberOf objects} } @Rowa - A { " treevsep" } - B { 0.5f } + A { " syntaxgap" } + B { 0.35f } + C { any length from Section {@NumberOf objects} } +@Rowa + A { " syntaxbias" } + B { 1.0f } + C { any length from Section {@NumberOf objects} } +@Rowa + A { " syntaxradius" } + B { 0.3f } C { any length from Section {@NumberOf objects} } } @DP diff --git a/doc/user/dia_synt b/doc/user/dia_synt new file mode 100644 index 0000000..6cef550 --- /dev/null +++ b/doc/user/dia_synt @@ -0,0 +1,573 @@ +@Section + @Tag { dia_synt } + @Title { Syntax diagrams } +@Begin +@PP +A variant of the @@Diag symbol, called {@Code "@SyntaxDiag"}, +syntax.diag @Index { @Code "@SyntaxDiag" symbol } +syntax.diagrams @Index { syntax diagrams } +railroad.diagrams @Index { railroad diagrams } +produces syntax diagrams (sometimes called railroad diagrams): +@CD @SyntaxDiag + title { call-chain } +{ + @StartRight @Sequence + A { @Optional @Sequence + A { @BCell "super" } + B { @CCell "!" } + } + B { @Loop + A { @Sequence + A { @ACell identifier } + B { @Optional @Sequence + A { @CCell "(" } + B { @Loop + A { @ACell expression } + B { @CCell "," } + } + C { @CCell ")" } + } + } + B { @CCell "." } + } +} +These are used to define the syntax of computer programming languages, +although they could be put to other uses. We'll explain how to get +syntax diagrams first. At the end of this section is an explanation of +how to change the formats of things, which people who use these diagrams +for other purposes will probably need to do. +@PP +A syntax diagram can be @I { right-moving }, which means it starts +at the left and heads right (like the example above), or it can be +@I { down-moving }, starting at the top and heading downwards. The +@Code "@StartRight" and @Code "@StartDown" symbols are used at the start +of the diagram to say which of these directions is wanted: +@ID @OneRow @Code @Verbatim { +@SyntaxDiag + title { call-chain } +{ + @StartRight ... +} +} +where @Code { ... } stands for the rest of the diagram, as we are about +to describe. For completeness there are also @Code "@StartLeft" and +@Code "@StartUp" symbols, but diagrams never start off in these directions. +@PP +The @Code title option is optional; if given, the effect is as shown +(this option is also available with {@Code "@Diag"}). Subsequent +examples will omit the enclosing {@Code "@SyntaxDiag { ... }"}. +@PP +The basic components of syntax diagrams are @I { category cells }, +shown as boxes in the example above and obtained with the +@Code "@ACell" symbol; @I { keyword cells }, shown as curved boxes +and obtained with {@Code "@BCell"}; and @I { punctuation cells }, +containing punctuation symbols small enough to be enclosed in circles, +and obtained with {@Code "@CCell"}. After each symbol, place whatever +has to go inside the cell: +@ID @OneRow { +@Code @Verbatim { @StartRight @BCell loop } +|7ct +@SyntaxDiag { +@StartRight @BCell loop +} +} +Lout will insert the appropriate arrows, taking account of which +direction (right, up, left, or down) the diagram is currently +moving. This is true for all the syntax diagram symbols; we +won't mention it again. +@FootNote { +This wonderfully useful effect is achieved by a dirty trick, one +of whose consequences is that if you see an error message +similar to `@Code { replacing unknown "@Case" option 0p by 1p }' +it means you've forgotten the initial @Code "@StartRight" or +whatever. +} +@PP +Occasionally, instead of a cell one wants the horizontal or +vertical line to continue uninterrupted. For this there is +the @Code "@Skip" symbol: +@ID @OneRow { +@Code @Verbatim { @StartDown @Skip } +|7ct +@SyntaxDiag { +@StartDown @Skip +} +} +Some examples of its use in practice appear below. +@PP +There are three main ways to build up larger syntax diagrams out +of smaller ones: @I { sequencing }, @I { selection }, and +@I { looping }. For sequencing there is the @Code "@Sequence" symbol: +@ID @OneRow { +@Code @Verbatim { +@StartRight @Sequence + A { @BCell loop } + B { @ACell statements } + C { @BCell end } +} +||7ct +@SyntaxDiag { +@StartRight @Sequence + A { @BCell loop } + B { @ACell statements } + C { @BCell end } +} +} +This is what the sequence looks like in the other three directions: +@CD @OneRow @SyntaxDiag { +@Tbl + mh { 1f } + mv { 0i } + iv { top } + aformat { @Cell ml { 0i } @StartUp A | @Cell @StartLeft A | + @Cell mr { 0i } @StartDown A } +{ +@Rowa A { +@Sequence + A { @BCell loop } + B { @ACell statements } + C { @BCell end } +} +} } +Whatever the direction, the arrows go from option @Code A to option @Code B +to option @Code C and so on. You can have up to twelve items in the +sequence, in options @Code A to {@Code L}; if more than twelve are needed, +just place another sequence inside any one of these options: where one +syntax diagram is allowed, any syntax diagram is allowed, provided there +is enough space on the page (Lout makes a total mess of any diagram that +is too wide to fit on the page). +@PP +After sequencing comes selection, which is obtained with the +@Code "@Select" symbol: +@ID @OneRow { +@Code @Verbatim { +@StartRight @Select + A { @ACell asst } + B { @ACell call-chain } + C { @Sequence + A { @BCell assert } + B { @ACell condition } + } +} +||7ct +@SyntaxDiag { +@StartRight @Select + A { @ACell asst } + B { @ACell call-chain } + C { @Sequence + A { @BCell assert } + B { @ACell condition } + } +} +} +This example shows right-moving selection of three alternatives, +the third being a sequence of things. Here is the same example +in the other three directions: +@CD @OneRow @SyntaxDiag { +@Tbl + mh { 1f } + mv { 0i } + iv { top } + aformat { @Cell ml { 0i } @StartUp A | @Cell @StartLeft A | + @Cell mr { 0i } @StartDown A } +{ +@Rowa A { +@Select + A { @ACell asst } + B { @ACell call-chain } + C { @Sequence + A { @BCell assert } + B { @ACell condition } + } +} } } +When building up complex diagrams like this, it pays to keep the indenting +perfect in the source document. As with sequences, there can be +up to twelve alternatives, in options from @Code A to {@Code L}. +@PP +To say that something is @I optional is to select either that thing or +nothing: +@ID @OneRow { +@Code @Verbatim { +@StartRight @Select + A { @Skip } + B { @ACell parameters } +} +||7ct +@SyntaxDiag { +@StartRight @Select + A { @Skip } + B { @ACell parameters } +} +} +Since this case is so common, there is an @Code "@Optional" symbol for it: +@ID @OneRow { +@Code @Verbatim { +@StartRight @Optional +@ACell parameters +} +||7ct +@SyntaxDiag { +@StartRight @Optional +@ACell parameters +} +} +@Code "@Optional" is exactly like @Code "@Select" with option @Code A +set to @Code "@Skip" and option @Code B set to the syntax diagram +following the @Code "@Optional" symbol. Here is the same example in +the other three directions: +@CD @OneRow @SyntaxDiag { +@Tbl + mh { 1f } + mv { 0i } + iv { top } + aformat { @Cell ml { 0i } @StartUp A | @Cell @StartLeft A | + @Cell mr { 0i } @StartDown A } +{ +@Rowa A { +@Optional @ACell parameters +} } } +There is another kind of `optional' layout, {@Code "@OptionalDiverted"}: +@ID @OneRow { +@Code @Verbatim { +@StartDown @OptionalDiverted +@Sequence + A { @BCell creation } + B { @ACell parameters } +} +||7ct +@SyntaxDiag { +@StartDown @OptionalDiverted @Sequence + A { @BCell creation } + B { @ACell parameters } +} +} +Here is the same example in the other three directions: +@CD @OneRow @SyntaxDiag { +@Tbl + mh { 1f } + mv { 0i } + iv { top } + aformat { @Cell ml { 0i } @StartRight A | @Cell @StartUp A | + @Cell mr { 0i } @StartLeft A } +{ +@Rowa A { +@OptionalDiverted @Sequence + A { @BCell creation } + B { @ACell parameters } +} } } +The optional material goes in a direction perpendicular to what +it would have otherwise: right-moving if previously up or down, and +down-moving if previously left or right. +@PP +Another, related symbol is {@Code "@Diverted"}; it is similar to +@Code "@OptionalDiverted" but without the path which produces nothing: +@ID @OneRow { +@Code @Verbatim { +@StartDown @Diverted @Sequence + A { @BCell creation } + B { @ACell parameters } +} +||7ct +@SyntaxDiag { +@StartDown @Diverted @Sequence + A { @BCell creation } + B { @ACell parameters } +} +} +Here is the same example in the other three directions: +@CD @OneRow @SyntaxDiag { +@Tbl + mh { 1f } + mv { 0i } + iv { top } + aformat { @Cell ml { 0i } @StartRight A | @Cell @StartUp A | + @Cell mr { 0i } @StartLeft A } +{ +@Rowa A { +@Diverted @Sequence + A { @BCell creation } + B { @ACell parameters } +} } } +This symbol is a great aid to packing a big syntax diagram into a +compact shape. +@PP +That covers sequencing and selection; now for looping. The @Code "@Loop" +symbol produces a loop, with option @Code A going forwards and option +@Code B centred and going backwards: +@ID @OneRow { +@Code @Verbatim { +@StartRight @Loop + A { @Sequence + A { @ACell identifier } + B { @CCell : } + C { @ACell type } + } + B { @CCell , } +} +||7ct +@SyntaxDiag { +@StartRight @Loop + A { @Sequence + A { @ACell identifier } + B { @CCell : } + C { @ACell type } + } + B { @CCell , } +} +} +Here is the same example in the other three directions: +@CD @OneRow @SyntaxDiag { +@Tbl + mh { 1f } + mv { 0i } + iv { top } + aformat { @Cell ml { 0i } @StartUp A | @Cell @StartLeft A | + @Cell mr { 0i } @StartDown A } +{ +@Rowa A { +@Loop + A { @Sequence + A { @ACell identifier } + B { @CCell : } + C { @ACell type } + } + B { @CCell , } +} } } +One common case of looping is to have nothing on the way back. We could +get this by placing @Code "@Skip" in option {@Code B} of {@Code "@Loop"}, +but there is an even easier way, the {@Code "@Repeat"} symbol: +@ID @OneRow { +@Code @Verbatim { +@StartRight @Repeat +@ACell statement +} +||7ct +@SyntaxDiag { +@StartRight @Repeat +@ACell statement +} +} +Here is the same example in the other three directions: +@CD @OneRow @SyntaxDiag { +@Tbl + mh { 1f } + mv { 0i } + iv { top } + aformat { @Cell ml { 0i } @StartUp A | @Cell @StartLeft A | + @Cell mr { 0i } @StartDown A } +{ +@Rowa A { +@Repeat +@ACell statement +} } } +Occasionally it looks better to have the empty returning arrow go on +the opposite side of the forward part; for that, there are +@Code "@LoopOpposite" and @Code "@RepeatOpposite" symbols: +@ID @OneRow { +@Code @Verbatim { +@StartRight @LoopOpposite + A { @Sequence + A { @ACell identifier } + B { @CCell : } + C { @ACell type } + } + B { @CCell , } +} +||7ct +@SyntaxDiag { +@StartRight @LoopOpposite + A { @Sequence + A { @ACell identifier } + B { @CCell : } + C { @ACell type } + } + B { @CCell , } +} +} +Here is the same example in the other three directions: +@CD @OneRow @SyntaxDiag { +@Tbl + mh { 1f } + mv { 0i } + iv { top } + aformat { @Cell ml { 0i } @StartUp A | @Cell @StartLeft A | + @Cell mr { 0i } @StartDown A } +{ +@Rowa A { +@LoopOpposite + A { @Sequence + A { @ACell identifier } + B { @CCell : } + C { @ACell type } + } + B { @CCell , } +} } } +@Code "@RepeatOpposite" is particularly useful around a large +{@Code "@Select"}: +@ID @OneRow { +@Code @Verbatim { +@StartRight @RepeatOpposite +@Select + A { @ACell asst } + B { @ACell call-chain } + C { @BCell return } + D { @Sequence + A { @BCell assert } + B { @ACell condition } + } + E { @ACell conditional } + F { @ACell selection } + G { @ACell loop } +} +||7ct +@SyntaxDiag { +@StartRight @RepeatOpposite +@Select + A { @ACell asst } + B { @ACell call-chain } + C { @BCell return } + D { @Sequence + A { @BCell assert } + B { @ACell condition } + } + E { @ACell conditional } + F { @ACell selection } + G { @ACell loop } +} +} +since it clearly distinguishes the loop from the selection. +@PP +Finally, the @Code "@RepeatDiverted" symbol combines the two ideas +of repetition and diversion: +@ID @OneRow { +@Code @Verbatim { +@StartDown @RepeatDiverted +@ACell statement +} +||7ct +@SyntaxDiag { +@StartDown @RepeatDiverted +@ACell statement +} +} +Here is the same example in the other three directions: +@CD @OneRow @SyntaxDiag { +@Tbl + mh { 1f } + mv { 0i } + iv { top } + aformat { @Cell ml { 0i } @StartRight A | @Cell @StartUp A | + @Cell mr { 0i } @StartLeft A } +{ +@Rowa A { +@RepeatDiverted +@ACell statement +} } } +There is no {@Code "@LoopDiverted"} symbol, for good reason. +@PP +Every syntax diagram, from the simplest to the most complex, has +one arrow going into it, and one coming out. There are no exceptions +to this rule. In most syntax diagrams, these two arrows lie on the +same (invisible) line and point in the same direction, and this is +the direction that we say the diagram is moving. There are two symbols +that produce syntax diagrams that lack this second property. Because +of this lack, these symbols cannot be used at arbitrary places in a +complex diagram; they can only be used instead of the @Code "@StartRight" +or @Code "@StartDown" symbols at the beginning of a diagram. The first +symbol, {@Code "@StartRightDown"}, prints its option @Code A right-moving +and its option @Code B down-moving like this: +@ID @OneRow { +@Code @Verbatim { +@StartRightDown + A { @ACell A } + B { @ACell B } +} +||7ct +@SyntaxDiag { +@StartRightDown + A { @ACell A } + B { @ACell B } +} +} +The second symbol, {@Code "@StartRightRight"}, prints both options +right-moving like this: +@ID @OneRow { +@Code @Verbatim { +@StartRightRight + A { @ACell A } + B { @ACell B } +} +||7ct +@SyntaxDiag { +@StartRightRight + A { @ACell A } + B { @ACell B } +} +} +As usual, the options to these symbols may contain arbitrarily complex +syntax diagrams. +@PP +Finally, a few words about changing things. The @Code "@SyntaxDiag" +symbol used the {@Code "@ANode"}, {@Code "@BNode"}, and {@Code "@CNode"} +symbols of @@Diag to construct its three types of cells. In fact, the +@Code "@SyntaxDiag" symbol is nothing more than this: +@ID @OneRow @Code @Verbatim { +@Diag + avalign { mark } + avstrut { yes } + amargin { 0.2f } + aoutline { box } + afont { Italic } + bvalign { mark } + bvstrut { yes } + bmargin { 0.2f } + boutline { curvebox } + bfont { Bold } + cvalign { mark } + cvstrut { yes } + cmargin { 0.2f } + coutline { circle } + chsize { 1f } + arrowlength { 0.4f } +} +So any of the other @Code "@Diag" options can be used freely with +{@Code "@SyntaxDiag"}; and the format of the three cell types can be +changed by using @Code "@Diag" instead of {@Code "@SyntaxDiag"}, and +choosing new values for these (and other) options. +@PP +If there are more than three cell types, it is necessary to fall back +on the {@Code "@XCell"} symbol, which produces a cell without nominating +any particular cell type. After @Code "@XCell" there must be a regular +@Code "@Diag" node, like this: +@ID @OneRow { +@Code @Verbatim { +@StartRight @XCell @Ellipse INIT +} +|7ct +@SyntaxDiag { +@StartRight @XCell @Ellipse INIT +} +} +This way there is no limit to the number of different kinds of cells. Also, +since (for example) @Code "@ACell" is merely an abbreviation for +@ID @OneRow @Code @Verbatim { @XCell @ANode } +any node options may follow {@Code "@ACell"}, {@Code "@BCell"}, and +{@Code "@CCell"}. The appearance of the arrows can be changed in the usual +way, by setting options as has been done above for {@Code "arrowlength"}. +@PP +There are three options specifically related to syntax diagrams: +@ID @OneRow @Code @Verbatim { +@SyntaxDiag + syntaxgap { 0.35f } + syntaxbias { 1.0f } + syntaxradius { 0.3f } +} +The @Code syntaxgap option determines the spacing between the various +elements; changing it causes the syntax diagrams to be set tighter or +looser in a consistent way. The default value shown is 0.35 times the +current font size. The @Code syntaxbias and @Code syntaxradius +options affect the appearance of curved lines, as in @Code "@RVLCurve" +and its relatives. These options are also available with {@Code "@Diag"}, +and in the setup file. Note however that these options cannot be given to +individual elements in a syntax diagram, only to the diagram as a whole. +@End @Section diff --git a/doc/user/equ_summ b/doc/user/equ_summ index bcfbeb3..b1e6fbc 100644 --- a/doc/user/equ_summ +++ b/doc/user/equ_summ @@ -37,6 +37,9 @@ and full names. The auxiliary symbols are: @Rowa A { @Code "big x" } B { Make @Code x larger } +@Rowa + A { @Code "small x" } + B { Make @Code x smaller } } Here are all the parameterized symbols, shown in groups of equal precedence, with the precedence itself at right: @@ -262,6 +265,7 @@ ragged @Break { "propto" @Dbl @Eq { propto } "models" @Dbl @Eq { models } "doteq" @Dbl @Eq { doteq } +"trieq" @Dbl @Eq { trieq } "perp" @Dbl @Eq { perp } "notsub" @Dbl @Eq { notsub } "notin" @Dbl @Eq { notin } @@ -504,6 +508,7 @@ ragged @Break { "exists" @Dbl @Eq { exists } "neg" @Dbl @Eq { neg } "circle" @Dbl @Eq { circle } +"filledcircle" @Dbl @Eq { filledcircle } "square" @Dbl @Eq { square } "ldots" @Dbl @Eq { ldots } "cdots" @Dbl @Eq { cdots } diff --git a/doc/user/johnson b/doc/user/johnson new file mode 100644 index 0000000..aaedd4c --- /dev/null +++ b/doc/user/johnson @@ -0,0 +1,19 @@ +@SysInclude { fig } +@SysInclude { diag } +@SysInclude { eq } +@SysInclude { tbl } +@SysInclude { doc } +@Doc @Text @Begin +@QD @Tbl + rule { yes } +{ +@Row format { @StartVSpan @Cell A | @StartHSpan @Cell B | @HSpan } + A { @SomeText } + B { @SomeText } +@Row format { @VSpan | @Cell B | @StartVSpan @Cell C } + B { @SomeText } + C { @SomeText } +@Row format { @StartHSpan @Cell A | @HSpan | @VSpan } + A { @SomeText } +} +@End @Text diff --git a/doc/user/johnson.out b/doc/user/johnson.out new file mode 100644 index 0000000..ead54ef --- /dev/null +++ b/doc/user/johnson.out @@ -0,0 +1,66 @@ + + + + + + + ................................................... + . . . + . Johnson . Johnson suddenly uttered, in . + . suddenly . a strong determined tone, an . + . uttered, . apophegm, at which many will . + . in a strong . start: `Patriotism is the . + . determined . last refuge of a scoundrel.' . + . tone, an . . + . apophegm, at . . + . which many .................................. + . will start: . . . + . `Patriotism . Johnson . Johnson . + . is the last . suddenly . suddenly . + . refuge of a . uttered, . uttered, . + . scoundrel.' . in a strong . in a strong . + . . determined . determined . + . . tone, an . tone, an . + . . apophegm, at . apophegm, at . + . . which many . which many . + . . will start: . will start: . + . . `Patriotism . `Patriotism . + . . is the last . is the last . + . . refuge of a . refuge of a . + . . scoundrel.' . scoundrel.' . + . . . . + . . . . + .................................. . + . . . + . Johnson suddenly uttered, in . . + . a strong determined tone, an . . + . apophegm, at which many will . . + . start: `Patriotism is the . . + . last refuge of a scoundrel.' . . + . . . + . . . + ................................................... + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/doc/user/mydefs b/doc/user/mydefs index 2ef9639..727bb27 100644 --- a/doc/user/mydefs +++ b/doc/user/mydefs @@ -39,6 +39,7 @@ def @@OneCol { @Code "@OneCol" } def @@OneRow { @Code "@OneRow" } def @@Open { @Code "@Open" } + def @@Outline { @Code "@Outline" } def @@PAdjust { @Code "@PAdjust" } def @@PrependGraphic { @Code "@PrependGraphic" } def @@Rotate { @Code "@Rotate" } @@ -189,7 +190,7 @@ which many will start: `Patriotism is the last refuge of a scoundrel.' def @AmberLight { @OneRow @Tbl - aformat { @Cell A } + aformat { @Cell indentvertical { align } A } marginhorizontal { 0i } marginvertical { 0i } strut { no } @@ -201,3 +202,13 @@ which many will start: `Patriotism is the last refuge of a scoundrel.' @Rowa A { @OpenCircle } } } + + import @DiagSetup @Diag + def @Four named code { } right x + { + 3.8c @Wide @Code code ||0.3c + 2.7c @Wide @StartRight x ||0.3c + 2.7c @Wide @StartUp x ||0.3c + 2.7c @Wide @StartLeft x ||0.3c + 2.2c @Wide @StartDown x + } diff --git a/doc/user/preface b/doc/user/preface index eada554..9b3e964 100644 --- a/doc/user/preface +++ b/doc/user/preface @@ -16,9 +16,9 @@ with the software. Lout is distributed free of charge under the GNU Public License. The gnu. @Index { GNU Public License } primary source is directory -@ID @Code "ftp://ftp.cs.su.oz.au/jeff/lout" +@ID @Code "ftp://ftp.cs.usyd.edu.au/jeff/lout" in which may be found a gzipped tar file containing the main distribution -(currently {@Code "lout-3.17.tar.gz"}), and various other things including +(currently {@Code "lout-3.18.tar.gz"}), and various other things including a PostScript version of this guide. The distribution contains source code, libraries, documentation, license, and installation instructions. @PP diff --git a/doc/user/tbl b/doc/user/tbl index 230c69e..5ed15e1 100644 --- a/doc/user/tbl +++ b/doc/user/tbl @@ -27,6 +27,13 @@ matrix atleft { ( } atright { ) } { n above k } a sup k b sup n-k } As the example shows, the tables may contain spanning columns, aligned columns, and rules, and the cells may contain arbitrary objects. +@FootNote { +There has been a slight change to {@Code "@Tbl"}, starting with Version +3.18: if you want columns whose entries are aligned (on decimal points, +equals signs, etc.), or the analogous thing with rows, you have to ask +for it now, whereas before it happened automatically. See +Section {@NumberOf tbl_alig} for the details. +} @BeginSections @Include { tbl_intr } # introduction diff --git a/doc/user/tbl_alig b/doc/user/tbl_alig index 24b6864..0032e86 100644 --- a/doc/user/tbl_alig +++ b/doc/user/tbl_alig @@ -7,19 +7,21 @@ Columns of numbers are often presented with decimal points aligned: aligned.columns @Index { aligned columns in tables } @CD @OneRow @Tbl marginvertical { 0.5vx } - aformat { @Cell A } + aformat { @Cell indent { align } A } { @Rowa A { 5^.46 } marginabove { 0i } @Rowa A { 3^.4159 } @Rowa A { 5772^ } marginbelow { 0i } } -You can produce this by placing a @Code "^" symbol, which is used -generally throughout Lout for alignment, just before the alignment point in +To produce this you need two steps. First, indicate that you want +an aligned column, using @Code "indent { align }" on the relevant +cell; and second, place a @Code "^" symbol, which is used generally +throughout Lout for alignment, just before the alignment point in each entry: @ID @OneRow @Code @Verbatim { @Tbl marginvertical { 0.5vx } - aformat { @Cell A } + aformat { @Cell indent { align } A } { @Rowa A { 5^.46 } @Rowa A { 3^.4159 } @@ -27,12 +29,17 @@ each entry: } } The equals signs of equations can be aligned in the same way (see the -example at the start of this chapter). Aligned cells should have no -@Code indent option. +example at the start of this chapter). @PP -Owing to problems behind the scenes, getting a heading over the top -of an aligned column is a problem with no ideal solution. What most -people want is for the heading to be centred in the column, and the +Owing to problems behind the scenes, in a column in which one cell is +labelled {@Code "indent { align }"}, all the other cells have to be +so labelled, otherwise Lout make a mess of things. This is a problem +when we want to get a heading over the top of an aligned column: if +we follow the rule, the @I heading gets aligned, which is wrong; but +if we don't, Lout makes a mess of things. There is no ideal solution +to this problem. +@PP +What most people want is for the heading to be centred in the column, and the aligned entries to be centred in the column as a block, but Lout cannot do this. One approximation is to make the heading cell a spanning cell with centring, like this: @@ -51,14 +58,14 @@ an empty second column. } @Rowb A { 5772^ } } } -The spanning frees the heading from alignment, permitting -@Code "indent { ctr }" to work: +The spanning quarantines the centred cell from the aligned cells, +permitting @Code "indent { ctr }" to work: @CD @OneRow @Tbl marginvertical { 0.5vx } aformat { @StartHSpan @Cell indent { ctr } @B A | } bformat { @Cell A | } { -@Rowa A { Heading } marginabove { 0i } +@Rowa A { V } marginabove { 0i } @Rowb A { 5^.46 } @Rowb A { 3^.4159 } @Rowb A { 5772^ } marginbelow { 0i } diff --git a/doc/user/tbl_inde b/doc/user/tbl_inde index 75a3471..22f89cc 100644 --- a/doc/user/tbl_inde +++ b/doc/user/tbl_inde @@ -10,19 +10,18 @@ horizontally. For example, horizontally centres the entry within the cell. The other possible values centred.entries @Index { centred entries in tables } right.justified.entries @Index { right justified entries in tables } -of this option are {@Code "left"}, {@Code "right"}, or any length (for +of this option are {@Code "left"} (the default value), {@Code "right"}, +{@Code "align"} (Section {@NumberOf tbl_alig}), or any length (for example, {@Code 2f}) meaning that much indent. @PP There is a corresponding @Code "indentvertical" option for vertical indenting within the cell. It takes the same values except that @Code "left" is -renamed {@Code "top"}, and @Code "right" is renamed {@Code foot}. -A common problem with vertical placement is that words that lack -ascenders (parts of letters that rise up) or descenders (parts that -sink down) can easily become misaligned with words that -don't. Looking at +renamed {@Code "top"}, @Code "right" is renamed {@Code foot}. A common +problem with vertical placement is that words that lack ascenders (parts +of letters that rise up) or descenders (parts that sink down) can easily +become misaligned with words that don't. Looking at @CD @Tbl aformat { @Cell A | @Cell B | @Cell C } - marginvertical { 0i } { @Rowa A { resume } diff --git a/doc/user/tbl_mark b/doc/user/tbl_mark index 8761979..fcd4768 100644 --- a/doc/user/tbl_mark +++ b/doc/user/tbl_mark @@ -44,7 +44,7 @@ import @TblSetup def @AmberLight { @OneRow @Tbl - aformat { @Cell A } + aformat { @Cell indentvertical { align } A } margin { 0i } strut { no } paint { no } rule { no } diff --git a/doc/user/tbl_plai b/doc/user/tbl_plai index 0813717..d887b86 100644 --- a/doc/user/tbl_plai +++ b/doc/user/tbl_plai @@ -7,35 +7,40 @@ Tables work well with plain text output (Section {@NumberOf plain}): plain.text.tables @Index { plain text tables } @CD @OneRow -1px @Break @F @Verbatim { ................................................... -. . . -. Johnson . Johnson suddenly uttered an . -. suddenly . apophegm, at which many will . -. uttered an . start: `Patriotism is the . -. apophegm, at . last refuge of a scoundrel.' . -. which many . . -. will start: . . -. `Patriotism ................................. -. is the last . . . -. refuge of a . Johnson . Johnson . -. scoundrel.' . suddenly . suddenly . -. . uttered an . uttered an . -. . apophegm, at . apophegm, at . -. . which many . which many . -. . will start: . will start: . -. . `Patriotism . `Patriotism . -. . is the last . is the last . -. . refuge of a . refuge of a . -. . scoundrel.' . scoundrel.' . -. . . . -. . . . -................................... . -. . . -. Johnson suddenly uttered an . . -. apophegm, at which many will . . -. start: `Patriotism is the . . -. last refuge of a scoundrel.' . . -. . . -. . . +. . . +. Johnson . Johnson suddenly uttered, in . +. suddenly . a strong determined tone, an . +. uttered, . apophegm, at which many will . +. in a strong . start: `Patriotism is the . +. determined . last refuge of a scoundrel.' . +. tone, an . . +. apophegm, at . . +. which many .................................. +. will start: . . . +. `Patriotism . Johnson . Johnson . +. is the last . suddenly . suddenly . +. refuge of a . uttered, . uttered, . +. scoundrel.' . in a strong . in a strong . +. . determined . determined . +. . tone, an . tone, an . +. . apophegm, at . apophegm, at . +. . which many . which many . +. . will start: . will start: . +. . `Patriotism . `Patriotism . +. . is the last . is the last . +. . refuge of a . refuge of a . +. . scoundrel.' . scoundrel.' . +. . . . +. . . . +.................................. . +. . . +. Johnson suddenly uttered, in . . +. a strong determined tone, an . . +. apophegm, at which many will . . +. start: `Patriotism is the . . +. last refuge of a scoundrel.' . . +. . . +. . . ................................................... } This table was produced by a separate run of Lout and pasted into this diff --git a/doc/user/tbl_span b/doc/user/tbl_span index 5621961..ec568dc 100644 --- a/doc/user/tbl_span +++ b/doc/user/tbl_span @@ -134,12 +134,12 @@ The names given to the entries ({@Code "A"}, {@Code "B"}, {@Code "C"}, etc.) are quite irrelevant: having a @Code "@Cell D" in one row and a @Code "@Cell D" in another does not mean that the cells will appear in the same column. -@PP -There is an asymmetry in the spiral above: the first column -occupies slightly more space than the other two. This arises -because the left margin of the leftmost column is excluded from the -calculation of how much space is available. This anomaly might be -corrected some day. +# @PP +# There is an asymmetry in the spiral above: the first column +# occupies slightly more space than the other two. This arises +# because the left margin of the leftmost column is excluded from the +# calculation of how much space is available. This anomaly might be +# corrected some day. @PP There is a @Code "@StartHVSpan" symbol which combines the effects of @Code "@StartHSpan" and {@Code "@StartVSpan"}. You need to diff --git a/doc/user/tbl_summ b/doc/user/tbl_summ index 6fed734..53f957e 100644 --- a/doc/user/tbl_summ +++ b/doc/user/tbl_summ @@ -58,10 +58,12 @@ plain text } D { any length e.g. @Code 3c } @Rowa A { indent i } - D { {@Code left}, {@Code ctr}, {@Code mctr}, {@Code right}, or any length } + B { @Code left } + D { {@Code left}, {@Code ctr}, {@Code align}, {@Code mctr}, {@Code right}, or any length } @Rowa A { indentvertical iv } - D { {@Code top}, {@Code ctr}, {@Code mctr}, {@Code foot}, or any length } + B { @Code top } + D { {@Code top}, {@Code ctr}, {@Code align}, {@Code mctr}, {@Code foot}, or any length } @Rowa A { strut s } B { yes } diff --git a/doc/user/vcpp b/doc/user/vcpp new file mode 100644 index 0000000..b7c18ca --- /dev/null +++ b/doc/user/vcpp @@ -0,0 +1 @@ +vi cpp cpp_lone cpp_embe cpp_opti cpp_chan cpp_tabs cpp_comm cpp_prog cpp_pipe cpp_erro @@ -1,7 +1,7 @@ /*@externs.h:External Declarations:Directories and file conventions@**********/ /* */ -/* THE LOUT DOCUMENT FORMATTING SYSTEM (VERSION 3.17) */ -/* COPYRIGHT (C) 1991, 1999 Jeffrey H. Kingston */ +/* THE LOUT DOCUMENT FORMATTING SYSTEM (VERSION 3.18) */ +/* COPYRIGHT (C) 1991, 2000 Jeffrey H. Kingston */ /* */ /* Jeffrey H. Kingston (jeff@cs.usyd.edu.au) */ /* Basser Department of Computer Science */ @@ -95,7 +95,7 @@ extern nl_catd MsgCat; /* */ /*****************************************************************************/ -#define LOUT_VERSION AsciiToFull("Basser Lout Version 3.17 (September 1999)") +#define LOUT_VERSION AsciiToFull("Basser Lout Version 3.18 (February 2000)") #define CROSS_DB AsciiToFull("lout") #define SOURCE_SUFFIX AsciiToFull(".lt") #define INDEX_SUFFIX AsciiToFull(".li") @@ -225,7 +225,7 @@ If you're compiling this, you've got the wrong settings in the makefile! /* */ /* MAX_COLOUR The maximum number of distinct left parameters of */ /* @SetColour and @SetColor symbols allowed (after */ -/* evaluation). This can be increased beyond 4096 */ +/* evaluation). This can be increased beyond 1024 */ /* only by setting aside a larger word_colour() field. */ /* */ /* MAX_LANGUAGE The maximum number of distinct languages allowed. */ @@ -614,7 +614,8 @@ typedef struct SHORT_LENGTH oyunit; /* value of y unit of measurement */ SHORT_LENGTH ozunit; /* value of z unit of measurement */ FONT_NUM ofont : 12; /* current font */ - COLOUR_NUM ocolour : 12; /* current colour */ + COLOUR_NUM ocolour : 10; /* current colour */ + BOOLEAN ooutline : 2; /* TRUE if outlining words */ LANGUAGE_NUM olanguage : 6; /* current language */ BOOLEAN onobreakfirst : 1; /* no break after first line of para */ BOOLEAN onobreaklast : 1; /* no break after last line of para */ @@ -632,6 +633,7 @@ typedef struct #define display_style(x)(x).osu2.oss2.odisplay_style #define font(x) (x).ofont #define colour(x) (x).ocolour +#define outline(x) (x).ooutline #define language(x) (x).olanguage #define nobreakfirst(x) (x).onobreaklast #define nobreaklast(x) (x).onobreakfirst @@ -647,6 +649,7 @@ typedef struct GapCopy(space_gap(x), space_gap(y)), \ font(x) = font(y), \ colour(x) = colour(y), \ + outline(x) = outline(y), \ language(x) = language(y), \ nobreakfirst(x) = nobreakfirst(y), \ nobreaklast(x) = nobreaklast(y), \ @@ -768,7 +771,8 @@ typedef union struct /* used by WORD objects only, except underline used by all */ /* objects, including GAP_OBJ */ { FONT_NUM oword_font : 12; - COLOUR_NUM oword_colour : 11; + COLOUR_NUM oword_colour : 10; + BOOLEAN oword_outline : 1; LANGUAGE_NUM oword_language : 6; unsigned ounderline : 2; unsigned oword_hyph : 1; @@ -962,6 +966,7 @@ typedef union /* zunit Value of z unit of measurement */ /* font Which internal font (including size) to use */ /* colour Which internal colour to use */ +/* outline TRUE if outlining words rather than filling them */ /* language Which internal language to use */ /* nobreakfirst TRUE if break not allowed after first line of para */ /* nobreaklastt TRUE if break not allowed before last line of para */ @@ -1064,6 +1069,7 @@ typedef union /* SIZED The size of the word */ /* word_font Font to print this word in (from style) */ /* word_colour Colour to print this word in (from style) */ +/* word_outline If TRUE, print this word in outline (from style) */ /* word_language Language (for hyphenation) of this word (from style) */ /* underline TRUE if continuous underlining goes under this word */ /* word_hyph Hyphenation wanted for this word (from style) */ @@ -1230,7 +1236,8 @@ typedef union /* last child The right parameter of this symbol */ /* */ /* FONT, SPACE, BREAK - @Font, @Space, @Break symbols */ -/* YUNIT, ZUNIT, COLOUR, LANGUAGE - @YUnit, @ZUnit, @Colour, @Language syms */ +/* YUNIT, ZUNIT - @YUnit, @ZUnit symbols */ +/* COLOUR, OUTLINE, LANGUAGE - @Colour, @Outline, @Language symbols */ /* PLUS, MINUS, - @Plus, @Minus symbols */ /* MELD, COMMON, RUMP, INSERT - @Meld, @Common, @Rump, @Insert symbols */ /* OPEN, TAGGED - @Open, @Tagged symbols */ @@ -1279,6 +1286,7 @@ typedef union /* CENV, CLOS, LVIS, LUSE, LEO - @LCEnv, @LClos, @LVis, @LUse, @LEO tokens */ /* BACKEND - @BackEnd symbol */ /* CURR_LANG, CURR_FAMILY, CURR_FACE - @CurrLang, @CurrFamily, @CurrFace */ +/* CURR_YUNIT, CURR_ZUNIT - @CurrYUnit, @CurrZUnit */ /* */ /* TOKEN While still being parsed */ /* */ @@ -1598,6 +1606,7 @@ typedef union rec #define spanner_count(x) word_font(x) #define word_colour(x) (x)->os1.ou2.os22.oword_colour #define spanner_sized(x) word_colour(x) +#define word_outline(x) (x)->os1.ou2.os22.oword_outline #define word_language(x) (x)->os1.ou2.os22.oword_language #define spanner_broken(x) word_language(x) #define underline(x) (x)->os1.ou2.os22.ounderline @@ -1886,85 +1895,88 @@ typedef struct mapvec { #define BREAK 59 /* to s @Break */ #define UNDERLINE 60 /* to s @Underline */ #define COLOUR 61 /* to s @SetColour and @SetColor */ -#define LANGUAGE 62 /* to s @Language */ -#define CURR_LANG 63 /* to s @CurrLang */ -#define CURR_FAMILY 64 /* to s @CurrFamily */ -#define CURR_FACE 65 /* to s @CurrFace */ -#define COMMON 66 /* to s @Common */ -#define RUMP 67 /* to s @Rump */ -#define MELD 68 /* to s @Meld */ -#define INSERT 69 /* to s @Insert */ -#define ONE_OF 70 /* to s @OneOf */ -#define NEXT 71 /* to s @Next */ -#define PLUS 72 /* to s @Plus */ -#define MINUS 73 /* to s @Minus */ -#define ENV_OBJ 74 /* to s object with envt (no name) */ -#define ENV 75 /* to s @LEnv */ -#define ENVA 76 /* to s @LEnvA */ -#define ENVB 77 /* to s @LEnvB */ -#define ENVC 78 /* to s @LEnvC */ -#define ENVD 79 /* to s @LEnvD */ -#define CENV 80 /* to s @LCEnv */ -#define CLOS 81 /* to s @LClos */ -#define LVIS 82 /* to s @LVis */ -#define LUSE 83 /* to s @LUse */ -#define LEO 84 /* to s @LEO */ -#define OPEN 85 /* to s @Open */ -#define TAGGED 86 /* to s @Tagged */ -#define INCGRAPHIC 87 /* to s @IncludeGraphic */ -#define SINCGRAPHIC 88 /* to s @SysIncludeGraphic */ -#define PLAIN_GRAPHIC 89 /* to s @PlainGraphic */ -#define GRAPHIC 90 /* to s @Graphic */ -#define TSPACE 91 /* t a space token, parser only */ -#define TJUXTA 92 /* t a juxta token, parser only */ -#define LBR 93 /* t s left brace token */ -#define RBR 94 /* t s right brace token */ -#define BEGIN 95 /* t s @Begin token */ -#define END 96 /* t s @End token */ -#define USE 97 /* t s @Use */ -#define NOT_REVEALED 98 /* t s @NotRevealed */ -#define GSTUB_NONE 99 /* t a galley stub, no rpar */ -#define GSTUB_INT 100 /* t galley stub internal rpar */ -#define GSTUB_EXT 101 /* t galley stub external rpar */ -#define UNEXPECTED_EOF 102 /* t unexpected end of file */ -#define INCLUDE 103 /* s @Include */ -#define SYS_INCLUDE 104 /* s @SysInclude */ -#define PREPEND 105 /* s @Prepend */ -#define SYS_PREPEND 106 /* s @SysPrepend */ -#define DATABASE 107 /* s @Database */ -#define SYS_DATABASE 108 /* s @SysDatabase */ -/* #define START 109 */ /* s \Start */ -#define DEAD 110 /* i a dead galley */ -#define UNATTACHED 111 /* i an inner, unsized galley */ -#define RECEPTIVE 112 /* i a receptive object index */ -#define RECEIVING 113 /* i a receiving object index */ -#define RECURSIVE 114 /* i a recursive definite obj. */ -#define PRECEDES 115 /* i an ordering constraint */ -#define FOLLOWS 116 /* i other end of ordering c. */ -#define CROSS_LIT 117 /* i literal word cross-ref */ -#define CROSS_FOLL 118 /* i following type cross-ref */ -#define CROSS_FOLL_OR_PREC 119 /* i follorprec type cross-ref */ -#define GALL_FOLL 120 /* i galley with &&following */ -#define GALL_FOLL_OR_PREC 121 /* i galley with &&following */ -#define CROSS_TARG 122 /* i value of cross-ref */ -#define GALL_TARG 123 /* i target of these galleys */ -#define GALL_PREC 124 /* i galley with &&preceding */ -#define CROSS_PREC 125 /* i preceding type cross-ref */ -#define PAGE_LABEL_IND 126 /* i index of PAGE_LABEL */ -#define SCALE_IND 127 /* i index of auto SCALE */ -#define COVER_IND 128 /* i index of HCOVER or VCOVER */ -#define EXPAND_IND 129 /* i index of HEXPAND or VEXPD */ -#define THREAD 130 /* a sequence of threads */ -#define CROSS_SYM 131 /* cross-ref info */ -#define CR_ROOT 132 /* RootCross */ -#define MACRO 133 /* a macro symbol */ -#define LOCAL 134 /* a local symbol */ -#define LPAR 135 /* a left parameter */ -#define NPAR 136 /* a named parameter */ -#define RPAR 137 /* a right parameter */ -#define EXT_GALL 138 /* an external galley */ -#define CR_LIST 139 /* a list of cross references */ -#define DISPOSED 140 /* a disposed record */ +#define OUTLINE 62 /* to s @Outline */ +#define LANGUAGE 63 /* to s @Language */ +#define CURR_LANG 64 /* to s @CurrLang */ +#define CURR_FAMILY 65 /* to s @CurrFamily */ +#define CURR_FACE 66 /* to s @CurrFace */ +#define CURR_YUNIT 67 /* to s @CurrYUnit */ +#define CURR_ZUNIT 68 /* to s @CurrZUnit */ +#define COMMON 69 /* to s @Common */ +#define RUMP 70 /* to s @Rump */ +#define MELD 71 /* to s @Meld */ +#define INSERT 72 /* to s @Insert */ +#define ONE_OF 73 /* to s @OneOf */ +#define NEXT 74 /* to s @Next */ +#define PLUS 75 /* to s @Plus */ +#define MINUS 76 /* to s @Minus */ +#define ENV_OBJ 77 /* to s object with envt (no name) */ +#define ENV 78 /* to s @LEnv */ +#define ENVA 79 /* to s @LEnvA */ +#define ENVB 80 /* to s @LEnvB */ +#define ENVC 81 /* to s @LEnvC */ +#define ENVD 82 /* to s @LEnvD */ +#define CENV 83 /* to s @LCEnv */ +#define CLOS 84 /* to s @LClos */ +#define LVIS 85 /* to s @LVis */ +#define LUSE 86 /* to s @LUse */ +#define LEO 87 /* to s @LEO */ +#define OPEN 88 /* to s @Open */ +#define TAGGED 89 /* to s @Tagged */ +#define INCGRAPHIC 90 /* to s @IncludeGraphic */ +#define SINCGRAPHIC 91 /* to s @SysIncludeGraphic */ +#define PLAIN_GRAPHIC 92 /* to s @PlainGraphic */ +#define GRAPHIC 93 /* to s @Graphic */ +#define TSPACE 94 /* t a space token, parser only */ +#define TJUXTA 95 /* t a juxta token, parser only */ +#define LBR 96 /* t s left brace token */ +#define RBR 97 /* t s right brace token */ +#define BEGIN 98 /* t s @Begin token */ +#define END 99 /* t s @End token */ +#define USE 100 /* t s @Use */ +#define NOT_REVEALED 101 /* t s @NotRevealed */ +#define GSTUB_NONE 102 /* t a galley stub, no rpar */ +#define GSTUB_INT 103 /* t galley stub internal rpar */ +#define GSTUB_EXT 104 /* t galley stub external rpar */ +#define UNEXPECTED_EOF 105 /* t unexpected end of file */ +#define INCLUDE 106 /* s @Include */ +#define SYS_INCLUDE 107 /* s @SysInclude */ +#define PREPEND 108 /* s @Prepend */ +#define SYS_PREPEND 109 /* s @SysPrepend */ +#define DATABASE 110 /* s @Database */ +#define SYS_DATABASE 111 /* s @SysDatabase */ +/* #define START 112 */ /* s \Start */ +#define DEAD 113 /* i a dead galley */ +#define UNATTACHED 114 /* i an inner, unsized galley */ +#define RECEPTIVE 115 /* i a receptive object index */ +#define RECEIVING 116 /* i a receiving object index */ +#define RECURSIVE 117 /* i a recursive definite obj. */ +#define PRECEDES 118 /* i an ordering constraint */ +#define FOLLOWS 119 /* i other end of ordering c. */ +#define CROSS_LIT 120 /* i literal word cross-ref */ +#define CROSS_FOLL 121 /* i following type cross-ref */ +#define CROSS_FOLL_OR_PREC 122 /* i follorprec type cross-ref */ +#define GALL_FOLL 123 /* i galley with &&following */ +#define GALL_FOLL_OR_PREC 124 /* i galley with &&following */ +#define CROSS_TARG 125 /* i value of cross-ref */ +#define GALL_TARG 126 /* i target of these galleys */ +#define GALL_PREC 127 /* i galley with &&preceding */ +#define CROSS_PREC 128 /* i preceding type cross-ref */ +#define PAGE_LABEL_IND 129 /* i index of PAGE_LABEL */ +#define SCALE_IND 130 /* i index of auto SCALE */ +#define COVER_IND 131 /* i index of HCOVER or VCOVER */ +#define EXPAND_IND 132 /* i index of HEXPAND or VEXPD */ +#define THREAD 133 /* a sequence of threads */ +#define CROSS_SYM 134 /* cross-ref info */ +#define CR_ROOT 135 /* RootCross */ +#define MACRO 136 /* a macro symbol */ +#define LOCAL 137 /* a local symbol */ +#define LPAR 138 /* a left parameter */ +#define NPAR 139 /* a named parameter */ +#define RPAR 140 /* a right parameter */ +#define EXT_GALL 141 /* an external galley */ +#define CR_LIST 142 /* a list of cross references */ +#define DISPOSED 143 /* a disposed record */ #define is_indefinite(x) ((x) >= CLOSURE && (x) <= HEAD) #define is_definite(x) ((x) >= SPLIT && (x) <= GRAPHIC) @@ -2029,9 +2041,9 @@ typedef struct mapvec { #define SMALL_CAPS_ON 1 /* small capitals */ /* sides of a mark */ -#define BACK 141 /* means lies to left of mark */ -#define ON 142 /* means lies on mark */ -#define FWD 143 /* means lies to right of mark */ +#define BACK 144 /* means lies to left of mark */ +#define ON 145 /* means lies on mark */ +#define FWD 146 /* means lies to right of mark */ /* statuses of thread objects */ #define NOTSIZED 0 /* this thread object is not sized */ @@ -2039,15 +2051,15 @@ typedef struct mapvec { #define FINALSIZE 2 /* thread object size is now final */ /* constraint statuses */ -#define PROMOTE 144 /* this component may be promoted */ -#define CLOSE 145 /* must close dest before promoting */ -#define BLOCK 146 /* cannot promote this component */ -#define CLEAR 147 /* this constraint is now satisfied */ +#define PROMOTE 147 /* this component may be promoted */ +#define CLOSE 148 /* must close dest before promoting */ +#define BLOCK 149 /* cannot promote this component */ +#define CLEAR 150 /* this constraint is now satisfied */ /* gap increment types */ -#define GAP_ABS 148 /* absolute, e.g. 3p */ -#define GAP_INC 149 /* increment, e.g. +3p */ -#define GAP_DEC 150 /* decrement, e.g. -3p */ +#define GAP_ABS 151 /* absolute, e.g. 3p */ +#define GAP_INC 152 /* increment, e.g. +3p */ +#define GAP_DEC 153 /* decrement, e.g. -3p */ /* file types */ #define SOURCE_FILE 0 /* input file from command line */ @@ -2231,10 +2243,13 @@ typedef struct mapvec { #define KW_UNDERLINE AsciiToFull("@Underline") #define KW_COLOUR AsciiToFull("@SetColour") #define KW_COLOR AsciiToFull("@SetColor") +#define KW_OUTLINE AsciiToFull("@Outline") #define KW_LANGUAGE AsciiToFull("@Language") #define KW_CURR_LANG AsciiToFull("@CurrLang") #define KW_CURR_FAMILY AsciiToFull("@CurrFamily") #define KW_CURR_FACE AsciiToFull("@CurrFace") +#define KW_CURR_YUNIT AsciiToFull("@CurrYUnit") +#define KW_CURR_ZUNIT AsciiToFull("@CurrZUnit") #define KW_ENV AsciiToFull("@LEnv") #define KW_ENVA AsciiToFull("@@A") #define KW_ENVB AsciiToFull("@@B") diff --git a/hyph/old.italian.lh b/hyph/old.italian.lh deleted file mode 100644 index 032366c..0000000 --- a/hyph/old.italian.lh +++ /dev/null @@ -1,135 +0,0 @@ -Lout hyphenation information -% -% Italian hyphenation file, created by Andrea Cisternino on -% 20 April 1997 from a TeX file supplied by Claudio Beccari. -% See long comment below for full information about the origin -% of this file, and a copyright notice. -% -% JeffK has made the following modifications to convert to ISO-LATIN-1: -% -% TeX file Lout file -% 'a \341 -% 'e \351 -% 'i \355 -% 'o \363 -% 'u \372 -% "u \374 -% ~n \361 -% - -Classes: -@!$%^&*()_-+=~`{[}]:;|<,.>?/0123456789 -aA -bB -cC -dD -eE -fF -gG -hH -iI -jJ -kK -lL -mM -nN -oO -pP -qQ -rR -sS -tT -uU -vV -wW -xX -yY -zZ -áÁ -éÉ -íÍ -óÓ -úÚ -' - -Patterns: -%%%%%%%%%%%%%%%%%%%%%%%%%%% file ithyph.tex %%%%%%%%%%%%%%%%%%%%%%%%%%%%% -% -% Prepared by Claudio Beccari e-mail beccari@polito.it -% -% Dipartimento di Elettronica -% Politecnico di Torino -% Corso Duca degli Abruzzi, 24 -% 10129 TORINO -% -% \versionnumber{4.2} \versiondate{24 may 1996} -% -% These hyphenation patterns for the Italian language are supposed to comply -% with the Reccomendation UNI 6461 on hyphenation issued by the Italian -% Standards Institution (Ente Nazionale di Unificazione UNI). No guarantee -% or declaration of fitness to any particular purpose is given and any -% liability is disclaimed. -% -% See comments and loading instructions at the end of the file -% -% Commented (AC): \lccode`\'=`\' % Apostrophe has its own lccode -% Commented (AC): % so that it is treated as a -% Commented (AC): % letter -% Commented (AC): \patterns{ -.anti1 .anti3m2n -.di2s3cine -.e2x -.fran2k3 -.circu2m1 -.wa2g3n -.ca4p3s -.opto1 -.para1 -.pre1 -.p2s -%.ri1a2 .ri1e2 .re1i2 .ri1o2 .ri1u2 -.su2b3lu .su2b3r -.wel2t1 -3p2sic -3p2neu1 -a1ia a1ie a1io a1iu a1uo a1ya 2at. -e1iu e2w -io1i -o1ia o1ie o1io o1iu -u1u -% -'2 -1b 2bb 2bc 2bd 2bf 2bm 2bn 2bp 2bs 2bt 2bv - b2l b2r 2b. 2b'. 2b'' -1c 2cb 2cc 2cd 2cf 2ck 2cm 2cn 2cq 2cs 2ct 2cz - 2chh c2h 2chb ch2r 2chn c2l c2r 2c. 2c'. 2c'' .c2 -1d 2db 2dd 2dg 2dl 2dm 2dn 2dp d2r 2ds 2dt 2dv 2dw - 2d. 2d'. 2d'' .d2 -1f 2fb 2fg 2ff 2fn f2l f2r 2fs 2ft 2f. 2f'. 2f'' -1g 2gb 2gd 2gf 2gg g2h g2l 2gm g2n 2gp g2r 2gs 2gt - 2gv 2gw 2gz 2gh2t 2g. 2g'. 2g'' -1h 2hb 2hd h2l 2hm 2hn 2hr 2hv 2h. 2h'. 2h'' -1j 2j. 2j'. 2j'' -1k 2kg 2kf k2h 2kk k2l k2r 2kt 2k. 2k'. 2k'' -1l 2lb 2lc 2ld 2l3f2 2lg l2h 2lk 2ll 2lm 2ln 2lp - 2lq 2lr 2ls 2lt 2lv 2lw 2lz 2l. 2l'. 2l'' -1m 2mb 2mc 2mf 2ml 2mm 2mn 2mp 2mq 2mr 2ms 2mt 2mv 2mw - 2m. 2m'. 2m'' -1n 2nc 2nd 2nf 2ng 2nk 2nl 2nm 2nn 2np 2nq 2nr 2ns n2s3r - 2nt 2nv 2nz 2n' n2g3n 2nheit. 2n. 2n'. 2n'' -1p 2pd p2h p2l 2pn 2pp p2r 2ps 2pt 2pz 2p. 2p'. 2p'' -1q 2qq 2q. 2q'. 2q'' -1r 2rb 2rc 2rd 2rf r2h 2rg 2rk 2rl 2rm 2rn 2rp - 2rq 2rr 2rs 2rt rt2s3 2rv 2rx 2rw 2rz 2r. 2r'. 2r'' -1s2 2shm 2s3s 2s3p2n 2stb 2stc 2std 2stf 2stg 2stm 2stn 2stp 2sts 2stt 2stv 2sz - 4s. 4s'. 4s'' -1t 2tb 2tc 2td 2tf 2tg t2h t2l 2tm 2tn 2tp t2r 2ts 3t2sch - 2tt 2tv 2tw t2z 2tzk 2tzs 2t. 2t'. 2t'' -1v 2vc 2vl v2r 2vv 2v. 2v'. 2v'' -1w w2h wa2r 2w1y 2w. 2w'. 2w'' -1x 2xw 2x. 2x'. 2x'' -y1ou y1i -1z 2zb 2zd 2zl 2zn 2zp 2zt 2zs 2zv 2zz 2z. 2z'. 2z'' .z2 -% Commented (AC): } % Pattern end -% Commented (AC): -% Commented (AC): \endinput diff --git a/hyph/portugal.lh b/hyph/portugal.lh new file mode 100644 index 0000000..8139f55 --- /dev/null +++ b/hyph/portugal.lh @@ -0,0 +1,104 @@ +Lout hyphenation information +% Portuguese hyphenation file, created by José Roberto B. de A. Monteiro +% at 29 october 1999 from scratch +% +% (C) 1999 José Roberto B. de A. Monteiro (betoes@sel.eesc.sc.usp.br) +% +% This is free software. You may copy it or redistribute under the +% terms of GNU General Public License. +% +% END OF COPYRIGHT NOTICE +% +% + +Classes: +@!$%^&*()_-+=~`{[}]:;'|<,.>?/0123456789 +aA +áÁ +â +àÀ +ãà +bB +cC +çÇ +dD +eE +éÉ +êÊ +fF +gG +hH +iI +íÍ +jJ +kK +lL +mM +nN +oO +óÓ +ôÔ +õÕ +pP +qQ +rR +sS +tT +uU +úÚ +üÜ +vV +wW +xX +yY +zZ + +Patterns: +% simple patterns +1ba 1be 1bi 1bo 1bu 1bá 1bé 1bí 1bó 1bú 1bâ 1bê 1bô 1bã 1bõ +1ca 1ce 1ci 1co 1cu 1cá 1cé 1cí 1có 1cú 1câ 1cê 1cô 1cã 1cõ +1da 1de 1di 1do 1du 1dá 1dé 1dí 1dó 1dú 1dâ 1dê 1dô 1dã 1dõ +1fa 1fe 1fi 1fo 1fu 1fá 1fé 1fí 1fó 1fú 1fâ 1fê 1fô 1fã 1fõ +1ga 1ge 1gi 1go 1gu 1gá 1gé 1gí 1gó 1gú 1gâ 1gê 1gô 1gã 1gõ +1ha 1he 1hi 1ho 1hu 1há 1hé 1hí 1hó 1hú 1hâ 1hê 1hô 1hã 1hõ +1ja 1je 1ji 1jo 1ju 1já 1jé 1jí 1jó 1jú 1jâ 1jê 1jô 1jã 1jõ +1ka 1ke 1ki 1ko 1ku 1ká 1ké 1kí 1kó 1kú 1kâ 1kê 1kô 1kã 1kõ +1la 1le 1li 1lo 1lu 1lá 1lé 1lí 1ló 1lú 1lâ 1lê 1lô 1lã 1lõ +1ma 1me 1mi 1mo 1mu 1má 1mé 1mí 1mó 1mú 1mâ 1mê 1mô 1mã 1mõ +1na 1ne 1ni 1no 1nu 1ná 1né 1ní 1nó 1nú 1nâ 1nê 1nô 1nã 1nõ +1pa 1pe 1pi 1po 1pu 1pá 1pé 1pí 1pó 1pú 1pâ 1pê 1pô 1pã 1põ +% q-u is not used +1ra 1re 1ri 1ro 1ru 1rá 1ré 1rí 1ró 1rú 1râ 1rê 1rô 1rã 1rõ +1sa 1se 1si 1so 1su 1sá 1sé 1sí 1só 1sú 1sâ 1sê 1sô 1sã 1sõ +1ta 1te 1ti 1to 1tu 1tá 1té 1tí 1tó 1tú 1tâ 1tê 1tô 1tã 1tõ +1va 1ve 1vi 1vo 1vu 1vá 1vé 1ví 1vó 1vú 1vâ 1vê 1vô 1vã 1võ +1wa 1we 1wi 1wo 1wu 1wá 1wé 1wí 1wó 1wú 1wâ 1wê 1wô 1wã 1wõ +1xa 1xe 1xi 1xo 1xu 1xá 1xé 1xí 1xó 1xú 1xâ 1xê 1xô 1xã 1xõ +1ya 1ye 1yi 1yo 1yu 1yá 1yé 1yí 1yó 1yú 1yâ 1yê 1yô 1yã 1yõ +1za 1ze 1zi 1zo 1zu 1zá 1zé 1zí 1zó 1zú 1zâ 1zê 1zô 1zã 1zõ +1- + +1b2l 1b2r +1c2h 1c2l 1c2r +1d2l 1d2r +1f2l 1f2r +1g2l 1g2r 1gu4a 1gu4e 1gu4i 1gü4e 1gü4i +1k2l 1k2r +1l2h +1n2h +1p2l 1p2r +1qu4a 1qu4e 1qu4i 1qu4o 1qü4e 1qü4i +1t2l 1t2r +1v2l 1v2r +1w2l 1w2r + +a3a a3e a3o +c3c +e3a e3e e3o +i3a i3e i3i i3o i3â i3ê i3ô +o3a o3e o3o +r3r +s3s +u3a u3e u3o u3u +% sub- ... +su2b2r su2b2l diff --git a/include/README b/include/README index 0204b0c..dc2cd91 100644 --- a/include/README +++ b/include/README @@ -22,12 +22,17 @@ Setup files (containing mainly lists of options settable by the user) diag The Diag diagram drawing package fig The Fig advanced graphics package (OBSOLETE, use diag) graph The Graph graph drawing package - cprint The cprint C and C++ program printing package pas The Pas Pascal progam printing package modula The Modula Modula-2 progam printing package latin2 The Latin2 (Eastern European characters) package russian The Russian language package + Setup files for program formatting packages (choose any combination): + + cprint C and C++ + eiffel Eiffel + blue Blue + Source files (containing Lout and PostScript source code for the packages) -------------------------------------------------------------------------- @@ -53,9 +58,12 @@ Source files (containing Lout and PostScript source code for the packages) graphf The Graph graph drawing package graphf.etc A file included by graphf graphf.lpg A PostScript prepend file needed by graphf - cprintf The cprint C and C++ program printing package - pasf The Pas Pascal progam printing package - modulaf The Modula Modula-2 progam printing package + progf Programming language formatting (for use by prg2lout) + cprintf C and C++ + eiffelf Eiffel + bluef Blue + pasf Pascal + modulaf Modula-2 latin2.fd Latin2 font definitions file (placeholder file) russian.fd Russian font definitions file (placeholder file) @@ -70,4 +78,4 @@ Miscellaneous Jeffrey H. Kingston -26 May 1999 +26 February 2000 diff --git a/include/blue b/include/blue new file mode 100644 index 0000000..78c5d33 --- /dev/null +++ b/include/blue @@ -0,0 +1,71 @@ +############################################################################### +# # +# Lout setup file for Blue program printing # +# # +# Jeffrey H. Kingston # +# 23 February 2000 # +# # +############################################################################### + + +############################################################################### +# # +# The @SysInclude { bluef } line # +# # +# This line causes Lout to read the definitions for Blue, and should # +# not be touched. # +# # +############################################################################### + +@SysInclude { bluef } + + +############################################################################### +# # +# The @BlueSetup @Use clause # +# # +# To change the default value of any option, delete the # at the start of # +# its line and change the value between braces. # +# # +############################################################################### + +@Use { @BlueSetup + # style { varying @OrIfPlain fixed } # fixed, varying, or symbol + # pipe { } # pipe source through this + + # fixedfont { Courier } # font family if fixed + # fixedstrings { Base } # string face if fixed + # fixedidentifiers { Base } # identifier face if fixed + # fixedcomments { Base } # comment face if fixed + # fixedkeywords { Base } # keyword face if fixed + # fixednumbers { Base } # number face if fixed + # fixedoperators { Base } # operator face if fixed + # fixedsize { -1.0p } # font size if fixed + # fixedline { 1.0vx } # line-space if fixed + # fixedtabin { 8 } # tab interval if fixed + # fixedtabout { 8s } # tab width if fixed + + # varyingfont { } # font family if varying + # varyingstrings { Slope } # string face if varying + # varyingidentifiers { Slope } # identifier face if varying + # varyingcomments { Base } # comment face if varying + # varyingkeywords { Bold } # keyword face if varying + # varyingnumbers { Base } # number face if varying + # varyingoperators { Base } # operator face if varying + # varyingsize { 1.0f } # font size if varying + # varyingline { 1.0vx } # line-space if varying + # varyingtabin { 8 } # tab interval if varying + # varyingtabout { 3f } # tab width if varying + + # symbolfont { } # font family if symbol + # symbolstrings { Slope } # string face if symbol + # symbolidentifiers { Slope } # identifier face if symbol + # symbolcomments { Base } # comment face if symbol + # symbolkeywords { Bold } # keyword face if symbol + # symbolnumbers { Base } # number face if symbol + # symboloperators { Base } # operator face if symbol + # symbolsize { 1.0f } # font size if symbol + # symbolline { 1.0vx } # line-space if symbol + # symboltabin { 8 } # tab interval if symbol + # symboltabout { 3f } # tab width if symbol +} diff --git a/include/bluef b/include/bluef new file mode 100644 index 0000000..5d4a06d --- /dev/null +++ b/include/bluef @@ -0,0 +1,275 @@ + +############################################################################### +# # +# Lout @BlueSetup package for formatting Blue programs # +# # +# Version 2.0 by Jeffrey H. Kingston, February 2000. # +# # +# This package uses a filtered body parameter to convert Blue source # +# code into Lout source. The filter program is prg2lout, which is # +# distributed with Lout and should be compiled and installed wherever # +# Lout itself is. # +# # +############################################################################### + +export @Blue +def @BlueSetup + named style + named @OrIfPlain left x right y + { @BackEnd @Case { PlainText @Yield y else @Yield x } } + { varying @OrIfPlain fixed } # print style + named pipe { } # pipe through this first + + named fixedfont { Courier } # font family if fixed + named fixedstrings { Base } # string face if fixed + named fixedidentifiers { Base } # identifier face if fixed + named fixedcomments { Base } # comment face if fixed + named fixedkeywords { Base } # keyword face if fixed + named fixednumbers { Base } # number face if fixed + named fixedoperators { Base } # operator face if fixed + named fixedsize { -1.0p } # font size if fixed + named fixedline { 1.0vx } # line-space if fixed + named fixedtabin { 8 } # tab interval if fixed + named fixedtabout { 8s } # tab width if fixed + + named varyingfont { } # font family if varying + named varyingstrings { Slope } # string face if varying + named varyingidentifiers { Slope } # identifier face if varying + named varyingcomments { Base } # comment face if varying + named varyingkeywords { Bold } # keyword face if varying + named varyingnumbers { Base } # number face if varying + named varyingoperators { Base } # operator face if varying + named varyingsize { 1.0f } # font size if varying + named varyingline { 1.0vx } # line-space if varying + named varyingtabin { 8 } # tab interval if varying + named varyingtabout { 3f } # tab width if varying + + named symbolfont { } # font family if symbol + named symbolstrings { Slope } # string face if symbol + named symbolidentifiers { Slope } # identifier face if symbol + named symbolcomments { Base } # comment face if symbol + named symbolkeywords { Bold } # keyword face if symbol + named symbolnumbers { Base } # number face if symbol + named symboloperators { Base } # operator face if symbol + named symbolsize { 1.0f } # font size if symbol + named symbolline { 1.0vx } # line-space if symbol + named symboltabin { 8 } # tab interval if symbol + named symboltabout { 3f } # tab width if symbol + +@Begin + + export + + "$>" @S @D @C @K @N @O @A @ST @ED @M + + def @Blue + named style { style } # style + named pipe { pipe } # pipe through this first + named font { dft } # font family + named strings { dft } # string font + named identifiers { dft } # ident. font + named comments { dft } # comment font + named keywords { dft } # keyword font + named numbers { dft } # number font + named operators { dft } # operator font + named size { dft } # font size + named line { dft } # line-space + named tabin { dft } # tab interval + named tabout { dft } # tab width + body @Body # filtered, see below + @Begin + + def @Test # returns x unless x is dft + left x + named iffixed {} + named ifvarying {} + named ifsymbol {} + { + x @Case { + dft @Yield { + style @Case { + fixed @Yield { iffixed } + varying @Yield { ifvarying } + symbol @Yield { ifsymbol } + } + } + else @Yield x + } + } + + def @InitTab + { + tabin @Test + iffixed { fixedtabin } + ifvarying { varyingtabin } + ifsymbol { symboltabin } + } + + def @InitTabWidth + { + tabout @Test + iffixed { fixedtabout } + ifvarying { varyingtabout } + ifsymbol { symboltabout } + } + + def @Filter + { + pipe @Case { + "" @Yield { + "prg2lout -r -lBlue" -i{@FilterIn} -o{@FilterOut} -e{@FilterErr} + -t{@InitTab} -T{@InitTabWidth} + } + else @Yield { + "cat" @FilterIn "|" pipe "|" + "prg2lout -r -lBlue" -o{@FilterOut} + -e{@FilterErr} -t{@InitTab} -T{@InitTabWidth} + } + } + } + + def @InitFontFamily + { + font @Test + iffixed { fixedfont } + ifvarying { varyingfont } + ifsymbol { symbolfont } + } + + def @InitSize + { + size @Test + iffixed { fixedsize } + ifvarying { varyingsize } + ifsymbol { symbolsize } + } + + def @InitLine + { + line @Test + iffixed { fixedline } + ifvarying { varyingline } + ifsymbol { symbolline } + } + + def @S # for formatting strings + right x + { + # "\"" & + strings @Test + iffixed { fixedstrings } + ifvarying { varyingstrings } + ifsymbol { symbolstrings } + @Font x + # & "\"" + } + +# def "`" +# { +# style @Case { +# symbol @Yield { "`" } +# else @Yield { "'" } +# } +# } + + def @D # for formatting identifiers + right x + { + identifiers @Test + iffixed { fixedidentifiers } + ifvarying { varyingidentifiers } + ifsymbol { symbolidentifiers } + @Font x + } + + def @C # for formatting comments + right x + { + comments @Test + iffixed { fixedcomments } + ifvarying { varyingcomments } + ifsymbol { symbolcomments } + @Font x + } + + def @K # for formatting keywords + right x + { + keywords @Test + iffixed { fixedkeywords } + ifvarying { varyingkeywords } + ifsymbol { symbolkeywords } + @Font x + } + + def @N # for formatting numbers + right x + { + numbers @Test + iffixed { fixednumbers } + ifvarying { varyingnumbers } + ifsymbol { symbolnumbers } + @Font x + } + + def @O # for formatting operators + named symb {} + right x + { + operators @Test + iffixed { fixedoperators } + ifvarying { varyingoperators } + ifsymbol { symboloperators } + @Font x + } + + def @A # get characters from the Adobe Symbol font + left sym + right x + { + style @Case { + symbol @Yield { { Symbol Base } @Font @Char sym } + else @Yield { x } + } + } + + def @ST # for formatting asterisks + right x + { + operators @Test + iffixed { fixedoperators } + ifvarying { varyingoperators } + ifsymbol { symboloperators } + @Font "0.5w" @VShift x + } + + def @ED # for formatting larger dots + right x + { + operators @Test + iffixed { fixedoperators } + ifvarying { varyingoperators } + ifsymbol { symboloperators } + @Font @BackEnd @Case { + PlainText @Yield x + else @Yield { "1.2f" @Font "+0.05f" @VShift @O x &"0.05f" } + } + } + + macro "$>" { {} & } + + def @M right x + { + style @Case { + fixed @Yield "-" + varying @Yield { { Symbol Base } @Font @Char minus } + symbol @Yield { { Symbol Base } @Font @Char minus } + } + } + + { @InitFontFamily Base @InitSize } @Font + { @InitLine lines } @Break @Body + + @End @Blue + +@End @BlueSetup diff --git a/include/book b/include/book index 2d28f62..4a8a5a8 100644 --- a/include/book +++ b/include/book @@ -101,9 +101,12 @@ # @TableNumbers { Arabic } # method of numbering tables # @FigureCaptionPos { Below } # Above or Below # @TableCaptionPos { Below } # Above or Below - # @CaptionFont { } # figure, table caption font - # @CaptionBreak { } # figure, table caption break - # @CaptionFormat { @B { number @DotSep @OneCol } } # figure, table caption format + # @FigureCaptionFont { -2p } # figure caption font + # @FigureCaptionBreak { adjust hyphen 1.2fx } # figure caption break + # @FigureCaptionFormat{ {@B { word @NumSep number. &2s }} @Insert caption } + # @TableCaptionFont { -2p } # table caption font + # @TableCaptionBreak { adjust hyphen 1.2fx } # table caption break + # @TableCaptionFormat { {@B { word @NumSep number. &2s }} @Insert caption } # @MakeFigureContents { No } # list of figures at start # @MakeTableContents { No } # list of tables at start # @MakeContents { No } # make contents? Yes or No @@ -254,6 +257,7 @@ # @FigureListWord { figurelist } # word for "List of Figures" # @TableListWord { tablelist } # word for "List of Tables" # @IntroductionWord { introduction } # word for "Introduction" + # @AbbreviationsWord { abbreviations } # word for "Abbreviations" # @ChapterWord { chapter } # word for "Chapter" # @AppendixWord { appendix } # word for "Appendix" # @IndexWord { index } # word for "Index" @@ -304,6 +308,7 @@ # @SubSubSectionGap { 1.5v @OrIfPlain 2f } # between sub-subs. # @SubAppendixGap { 2.0v @OrIfPlain 3f } # between subappendices # @SubSubAppendixGap { 1.5v @OrIfPlain 2f } # between sub-subapps + # @PrefaceInContents { Yes } # add preface to contents # @AbbreviationsInContents { Yes } # add abbreviations to contents # @IntroductionInContents { Yes } # add introduction to contents # @PartInContents { Yes } # add parts to contents diff --git a/include/bsf.lpg b/include/bsf.lpg index 8eb6c02..9183b69 100644 --- a/include/bsf.lpg +++ b/include/bsf.lpg @@ -2,7 +2,6 @@ % width height linethickness louteuro - % draw a Euro symbol of this width and height with this line thickness -% Author: Jeff Kingston, based on code from Andrew Beardsley /louteuro { 20 dict begin /eurothick exch def diff --git a/include/cprint b/include/cprint index d7acb06..e720b22 100644 --- a/include/cprint +++ b/include/cprint @@ -1,9 +1,9 @@ ############################################################################### # # -# Lout setup file for C and C++ program printing # +# Lout setup file for C program printing # # # # Jeffrey H. Kingston # -# 5 February 1999 # +# 23 February 2000 # # # ############################################################################### @@ -12,7 +12,7 @@ # # # The @SysInclude { cprintf } line # # # -# This line causes Lout to read the definitions for C printing, and should # +# This line causes Lout to read the definitions for C, and should # # not be touched. # # # ############################################################################### @@ -31,6 +31,7 @@ @Use { @CPSetup # style { fixed } # fixed, varying, or symbol + # pipe { } # pipe source through this # fixedfont { Courier } # font family if fixed # fixedstrings { Base } # string face if fixed diff --git a/include/cprintf b/include/cprintf index fca806e..311369c 100644 --- a/include/cprintf +++ b/include/cprintf @@ -1,22 +1,25 @@ ############################################################################### # # -# Lout @CPSetup package for formatting C and C++ programs (Version 1.1) # +# Lout @CPSetup package for formatting C programs # # # -# Version 1.0 by Jeffrey H. Kingston, March 1994. # -# Version 1.1 by Jeffrey H. Kingston, November 1998 (name change only) # +# Version 2.0 by Jeffrey H. Kingston, February 2000. # # # -# This package uses a filtered body parameter to convert C and C++ source # -# code into Lout source. The filter program is c2lout which is distributed # -# with Basser Lout Version 3. The list of keywords and tokens is from # -# Stroustrup, 2nd Edition. See "User's Guide to the Lout Document # -# Formatting System" for user information. # +# This package uses a filtered body parameter to convert C source # +# code into Lout source. The filter program is prg2lout, which is # +# distributed with Lout and should be compiled and installed wherever # +# Lout itself is. # # # ############################################################################### export @CP def @CPSetup - named style { fixed } # print style + named style + named @OrIfPlain left x right y + { @BackEnd @Case { PlainText @Yield y else @Yield x } } + { fixed } # print style + + named pipe { } # pipe through this first named fixedfont { Courier } # font family if fixed named fixedstrings { Base } # string face if fixed @@ -58,29 +61,11 @@ def @CPSetup export - "$$" "$>" "`" @L @S @C - - "0" "1" "2" "3" "4" "5" "6" "7" "8" "9" - - "!" "%" "^" "&" "*" "(" ")" "-" "+" "=" "${" "$}" "|" "~" - "[" "]" ";" "'" ":" "<" ">" "?" "," "." "/" - - "->" "++" "--" ".*" "->*" "<<" ">>" "<=" ">=" "==" "!=" "&&" - "||" "*=" "/=" "%=" "+=" "-=" "<<=" ">>=" "&=" "^=" "|=" "::" - - asm continue float new signed try - auto default for operator sizeof typedef - break delete friend private static union - case do goto protected struct unsigned - catch double if public switch virtual - char else inline register template void - class enum int return this volatile - const extern long short throw while - - @EvaluateCp + "$>" @S @D @C @K @N @O @A @ST @ED @M def @CP named style { style } # style + named pipe { pipe } # pipe through this first named font { dft } # font family named strings { dft } # string font named identifiers { dft } # ident. font @@ -131,8 +116,17 @@ def @CPSetup def @Filter { - c2lout -r -i{@FilterIn} -o{@FilterOut} -e{@FilterErr} - -t{@InitTab} -T{@InitTabWidth} + pipe @Case { + "" @Yield { + "prg2lout -r -lC" -i{@FilterIn} -o{@FilterOut} -e{@FilterErr} + -t{@InitTab} -T{@InitTabWidth} + } + else @Yield { + "cat" @FilterIn "|" pipe "|" + "prg2lout -r -lC" -o{@FilterOut} + -e{@FilterErr} -t{@InitTab} -T{@InitTabWidth} + } + } } def @InitFontFamily @@ -159,47 +153,37 @@ def @CPSetup ifsymbol { symbolline } } - def @S # for formatting C strings + def @S # for formatting strings right x { - "\"" & + # "\"" & strings @Test iffixed { fixedstrings } ifvarying { varyingstrings } ifsymbol { symbolstrings } @Font x - & "\"" + # & "\"" } - def "`" - { - style @Case { - symbol @Yield { "`" } - else @Yield { "'" } - } - } +# def "`" +# { +# style @Case { +# symbol @Yield { "`" } +# else @Yield { "'" } +# } +# } - def @L # for formatting C character literals + def @D # for formatting identifiers right x { - ` & - strings @Test - iffixed { fixedstrings } - ifvarying { varyingstrings } - ifsymbol { symbolstrings } - @Font x - & ' - } - - def @Ident # for formatting C identifiers - { identifiers @Test iffixed { fixedidentifiers } ifvarying { varyingidentifiers } ifsymbol { symbolidentifiers } + @Font x } - def @C # for formatting C comments + def @C # for formatting comments right x { comments @Test @@ -209,7 +193,7 @@ def @CPSetup @Font x } - def @K # for formatting C keywords + def @K # for formatting keywords right x { keywords @Test @@ -219,7 +203,7 @@ def @CPSetup @Font x } - def @N # for formatting C numbers + def @N # for formatting numbers right x { numbers @Test @@ -229,7 +213,8 @@ def @CPSetup @Font x } - def @O # for formatting C operators + def @O # for formatting operators + named symb {} right x { operators @Test @@ -249,133 +234,41 @@ def @CPSetup } } - macro "$>" { {} & } - - def "$$" { "#" } - - def "0" { @N "0" } - def "1" { @N "1" } - def "2" { @N "2" } - def "3" { @N "3" } - def "4" { @N "4" } - def "5" { @N "5" } - def "6" { @N "6" } - def "7" { @N "7" } - def "8" { @N "8" } - def "9" { @N "9" } - - def "!" { @O "!" } - def "%" { @O "%" } - def "^" { @O "^" } - def "&" { @O "&" } - def "*" { asteriskmath @A @O "*" } - def "(" { @O "(" } - def ")" { @O ")" } - def "-" { minus @A @O "-" } - def "+" { plus @A @O "+" } - def "=" { equal @A @O "=" } - def "${" { @O "{" } - def "$}" { @O "}" } - def "|" { @O "|" } - def "~" { @O "~" } - def "[" { @O "[" } - def "]" { @O "]" } - def ";" { @O ";" } - def "'" { @O "'" } - def ":" { @O ":" } - def "<" { less @A @O "<" } - def ">" { greater @A @O ">" } - def "?" { @O "?" } - def "," { @O "," } - def "." { @O "." } - def "/" { @O "/" } - def "->" { arrowright @A @O "->" } - def "++" { { + }{ + } } - def "--" { { - }{ - } } - def ".*" { { . }{ * } } - def "->*" { { ->}{ * } } - def "<<" { { < }{ < } } - def ">>" { { > }{ > } } - def "<=" { lessequal @A @O "<=" } - def ">=" { greaterequal @A @O ">=" } - def "==" { { = }{ = } } - def "!=" { notequal @A @O "!=" } - def "&&" { { & }{ & } } - def "||" { { | }{ | } } - def "*=" { { * }{ = } } - def "/=" { { / }{ = } } - def "%=" { { % }{ = } } - def "+=" { { + }{ = } } - def "-=" { { - }{ = } } - def "<<=" { { <<}{ = } } - def ">>=" { { >>}{ = } } - def "&=" { { & }{ = } } - def "^=" { { ^ }{ = } } - def "|=" { { | }{ = } } - def "::" { { : }{ : } } - - def asm { @K "asm" } - def auto { @K "auto" } - def break { @K "break" } - def case { @K "case" } - def catch { @K "catch" } - def char { @K "char" } - def class { @K "class" } - def const { @K "const" } - - def continue { @K "continue" } - def default { @K "default" } - def delete { @K "delete" } - def do { @K "do" } - def double { @K "double" } - def else { @K "else" } - def enum { @K "enum" } - def extern { @K "extern" } - - def float { @K "float" } - def for { @K "for" } - def friend { @K "friend" } - def goto { @K "goto" } - def if { @K "if" } - def inline { @K "inline" } - def int { @K "int" } - def long { @K "long" } - - def new { @K "new" } - def operator { @K "operator" } - def private { @K "private" } - def protected { @K "protected" } - def public { @K "public" } - def register { @K "register" } - def return { @K "return" } - def short { @K "short" } - - def signed { @K "signed" } - def sizeof { @K "sizeof" } - def static { @K "static" } - def struct { @K "struct" } - def switch { @K "switch" } - def template { @K "template" } - def this { @K "this" } - def throw { @K "throw" } + def @ST # for formatting asterisks + right x + { + operators @Test + iffixed { fixedoperators } + ifvarying { varyingoperators } + ifsymbol { symboloperators } + @Font "0.5w" @VShift x + } + + def @ED # for formatting larger dots (not used in C) + right x + { + operators @Test + iffixed { fixedoperators } + ifvarying { varyingoperators } + ifsymbol { symboloperators } + @Font @BackEnd @Case { + PlainText @Yield x + else @Yield { "1.2f" @Font "+0.05f" @VShift @O x &"0.05f" } + } + } - def try { @K "try" } - def typedef { @K "typedef" } - def union { @K "union" } - def unsigned { @K "unsigned" } - def virtual { @K "virtual" } - def void { @K "void" } - def volatile { @K "volatile" } - def while { @K "while" } + macro "$>" { {} & } - def @EvaluateCp right x + def @M right x { - { @InitFontFamily Base } @Font - { @Ident @InitSize } @Font - { @InitLine lines } @Break x + style @Case { + fixed @Yield "-" + varying @Yield { { Symbol Base } @Font @Char minus } + symbol @Yield { { Symbol Base } @Font @Char minus } + } } - { @InitFontFamily Base } @Font { @Ident @InitSize } @Font + { @InitFontFamily Base @InitSize } @Font { @InitLine lines } @Break @Body @End @CP diff --git a/include/diag b/include/diag index b4ffdb2..9289975 100644 --- a/include/diag +++ b/include/diag @@ -32,6 +32,15 @@ @Use { @DiagSetup # save { no } # maxlabels { 200 } + # title { (none) } + # titleformat { Italic @Font @Title //0.7f ||0.35f @Body } + + ############################################################################# + # # + # Node options # + # # + ############################################################################# + # outline { box } # margin { 0.6f } # shadow { 0.4f } @@ -109,6 +118,265 @@ # dlabelangle { } # dlabelctr { } # dlabeladjust { } + + ############################################################################# + # # + # @ANode options # + # # + ############################################################################# + + # aoutline { box } + # amargin { 0.6f } + # ashadow { 0.4f } + # asides { 3 } + # aangle { "dup 180 exch div" } # 180d / sides + # atranslate { } + # aoutlinestyle { solid } + # aoutlinedashlength { 0.2f } + # aoutlinewidth { 0.02f } + # apaint { nopaint } + # afont { } + # abreak { } + # aformat { @Body } + # avalign { ctr } + # avsize { } + # avindent { ctr } + # avstrut { no } + # avmargin { } + # atopmargin { } + # afootmargin { } + # ahalign { ctr } + # ahsize { } + # ahindent { ctr } + # ahstrut { no } + # ahmargin { } + # aleftmargin { } + # arightmargin { } + # anodelabel { } + # anodelabelmargin { 0.2f } + # anodelabelfont { "-2p" } + # anodelabelbreak { ragged nohyphen } + # anodelabelformat { @Body } + # anodelabelpos { } + # anodelabelprox { outside } + # anodelabelangle { horizontal } + # anodelabelctr { no } + # anodelabeladjust { 0 0 } + # aalabel { } + # aalabelmargin { } + # aalabelfont { } + # aalabelbreak { } + # aalabelformat { } + # aalabelpos { NE } + # aalabelprox { } + # aalabelangle { } + # aalabelctr { } + # aalabeladjust { } + # ablabel { } + # ablabelmargin { } + # ablabelfont { } + # ablabelbreak { } + # ablabelformat { } + # ablabelpos { NW } + # ablabelprox { } + # ablabelangle { } + # ablabelctr { } + # ablabeladjust { } + # aclabel { } + # aclabelmargin { } + # aclabelfont { } + # aclabelbreak { } + # aclabelformat { } + # aclabelpos { SW } + # aclabelprox { } + # aclabelangle { } + # aclabelctr { } + # aclabeladjust { } + # adlabel { } + # adlabelmargin { } + # adlabelfont { } + # adlabelbreak { } + # adlabelformat { } + # adlabelpos { SE } + # adlabelprox { } + # adlabelangle { } + # adlabelctr { } + # adlabeladjust { } + + ############################################################################# + # # + # @BNode options # + # # + ############################################################################# + + # boutline { box } + # bmargin { 0.6f } + # bshadow { 0.4f } + # bsides { 3 } + # bangle { "dup 180 exch div" } # 180d / sides + # btranslate { } + # boutlinestyle { solid } + # boutlinedashlength { 0.2f } + # boutlinewidth { 0.02f } + # bpaint { nopaint } + # bfont { } + # bbreak { } + # bformat { @Body } + # bvalign { ctr } + # bvsize { } + # bvindent { ctr } + # bvstrut { no } + # bvmargin { } + # btopmargin { } + # bfootmargin { } + # bhalign { ctr } + # bhsize { } + # bhindent { ctr } + # bhstrut { no } + # bhmargin { } + # bleftmargin { } + # brightmargin { } + # bnodelabel { } + # bnodelabelmargin { 0.2f } + # bnodelabelfont { "-2p" } + # bnodelabelbreak { ragged nohyphen } + # bnodelabelformat { @Body } + # bnodelabelpos { } + # bnodelabelprox { outside } + # bnodelabelangle { horizontal } + # bnodelabelctr { no } + # bnodelabeladjust { 0 0 } + # balabel { } + # balabelmargin { } + # balabelfont { } + # balabelbreak { } + # balabelformat { } + # balabelpos { NE } + # balabelprox { } + # balabelangle { } + # balabelctr { } + # balabeladjust { } + # bblabel { } + # bblabelmargin { } + # bblabelfont { } + # bblabelbreak { } + # bblabelformat { } + # bblabelpos { NW } + # bblabelprox { } + # bblabelangle { } + # bblabelctr { } + # bblabeladjust { } + # bclabel { } + # bclabelmargin { } + # bclabelfont { } + # bclabelbreak { } + # bclabelformat { } + # bclabelpos { SW } + # bclabelprox { } + # bclabelangle { } + # bclabelctr { } + # bclabeladjust { } + # bdlabel { } + # bdlabelmargin { } + # bdlabelfont { } + # bdlabelbreak { } + # bdlabelformat { } + # bdlabelpos { SE } + # bdlabelprox { } + # bdlabelangle { } + # bdlabelctr { } + # bdlabeladjust { } + + ############################################################################# + # # + # @CNode options # + # # + ############################################################################# + + # coutline { box } + # cmargin { 0.6f } + # cshadow { 0.4f } + # csides { 3 } + # cangle { "dup 180 exch div" } # 180d / sides + # ctranslate { } + # coutlinestyle { solid } + # coutlinedashlength { 0.2f } + # coutlinewidth { 0.02f } + # cpaint { nopaint } + # cfont { } + # cbreak { } + # cformat { @Body } + # cvalign { ctr } + # cvsize { } + # cvindent { ctr } + # cvstrut { no } + # cvmargin { } + # ctopmargin { } + # cfootmargin { } + # chalign { ctr } + # chsize { } + # chindent { ctr } + # chstrut { no } + # chmargin { } + # cleftmargin { } + # crightmargin { } + # cnodelabel { } + # cnodelabelmargin { 0.2f } + # cnodelabelfont { "-2p" } + # cnodelabelbreak { ragged nohyphen } + # cnodelabelformat { @Body } + # cnodelabelpos { } + # cnodelabelprox { outside } + # cnodelabelangle { horizontal } + # cnodelabelctr { no } + # cnodelabeladjust { 0 0 } + # calabel { } + # calabelmargin { } + # calabelfont { } + # calabelbreak { } + # calabelformat { } + # calabelpos { NE } + # calabelprox { } + # calabelangle { } + # calabelctr { } + # calabeladjust { } + # cblabel { } + # cblabelmargin { } + # cblabelfont { } + # cblabelbreak { } + # cblabelformat { } + # cblabelpos { NW } + # cblabelprox { } + # cblabelangle { } + # cblabelctr { } + # cblabeladjust { } + # cclabel { } + # cclabelmargin { } + # cclabelfont { } + # cclabelbreak { } + # cclabelformat { } + # cclabelpos { SW } + # cclabelprox { } + # cclabelangle { } + # cclabelctr { } + # cclabeladjust { } + # cdlabel { } + # cdlabelmargin { } + # cdlabelfont { } + # cdlabelbreak { } + # cdlabelformat { } + # cdlabelpos { SE } + # cdlabelprox { } + # cdlabelangle { } + # cdlabelctr { } + # cdlabeladjust { } + + ############################################################################# + # # + # Link options # + # # + ############################################################################# + # path { line } # from { 0, 0 } # to { 1, 1 } @@ -186,8 +454,26 @@ # tolabelangle { parallel } # tolabelctr { no } # tolabeladjust { 0 0 } + + ############################################################################# + # # + # Tree options # + # # + ############################################################################# + # treehsep { 0.5f } # treevsep { 0.5f } # treehindent { ctr } # treevindent { ctr } + + ############################################################################# + # # + # Syntax diagram options # + # # + ############################################################################# + + # syntaxgap { 0.35f } + # syntaxbias { 1.0f } + # syntaxradius { 0.3f } + } diff --git a/include/diagf b/include/diagf index 18b888a..999c82e 100644 --- a/include/diagf +++ b/include/diagf @@ -2,9 +2,10 @@ ############################################################################### # # # Lout @Diag package for drawing diagrams # -# Version 1.0 (July 1996) # +# Version 1.1 (February 2000) # # Jeffrey H. Kingston # # # +# Version 1.0 (July 1996) # # Based on Version 2.0 of the @Fig package (Jeffrey H. Kingston, Dec 1992). # # # ############################################################################### @@ -12,10 +13,27 @@ @SysPrependGraphic { diagf.lpg } @SysInclude { diagf.etc } -export @Diag +############################################################################### +# # +# @DiagSetup symbol # +# # +############################################################################### + +export @Diag @SyntaxDiag def @DiagSetup named save { no } named maxlabels { 200 } + named title { "--titledft--" } + named titleformat + left @Title + right @Body + { Italic @Font @Title //0.7f ||0.35f @Body } + + ########################################################################### + # # + # @Node options of @DiagSetup # + # # + ########################################################################### import @Geometry named outline named margin {} @@ -123,6 +141,348 @@ def @DiagSetup named dlabelctr { } import @Geometry named dlabeladjust { } + ########################################################################### + # # + # @ANode options of @DiagSetup # + # # + ########################################################################### + + import @Geometry named aoutline + named margin {} + named shadow {} + named sides {} + named angle {} + { box } + named amargin { 0.6f } + import @Geometry named ashadow { 0.4f } + import @Geometry named asides { 3 } + import @Geometry named aangle { "dup 180 exch div" } + named atranslate { } + named aoutlinestyle + named solid { "/ldiagsolid" } + named dashed { "/ldiagdashed" } + named cdashed { "/ldiagcdashed" } + named dotted { "/ldiagdotted" } + named noline { "/ldiagnoline" } + { solid } + import @Geometry named aoutlinedashlength { 0.2f } + import @Geometry named aoutlinewidth + named thin { 0.04 ft } + named medium { 0.08 ft } + named thick { 0.12 ft } + { thin } + named apaint { nopaint } + named afont { } + named abreak { } + named aformat right @Body { @Body } + + named avalign { ctr } + named avsize { } + named avindent { ctr } + named avstrut + named no { 0.0f } + named yes { 1.0f } + { no } + named avmargin { } + named atopmargin { } + named afootmargin { } + + named ahalign { ctr } + named ahsize { } + named ahindent { ctr } + named ahstrut + named no { 0.0f } + named yes { 1.0f } + { no } + named ahmargin { } + named aleftmargin { } + named arightmargin { } + + named anodelabel { } + named anodelabelmargin { 0.2f } + named anodelabelfont { -2p } + named anodelabelbreak { ragged nohyphen } + named anodelabelformat right @Body { @Body } + import @Geometry named anodelabelpos{ } + named anodelabelprox { outside } + import @Geometry named anodelabelangle { horizontal } + named anodelabelctr { no } + import @Geometry named anodelabeladjust { 0 0 } + + named aalabel { } + named aalabelmargin { } + named aalabelfont { } + named aalabelbreak { } + named aalabelformat right @Body { } + import @Geometry named aalabelpos { NE } + named aalabelprox { } + import @Geometry named aalabelangle { } + named aalabelctr { } + import @Geometry named aalabeladjust{ } + + named ablabel { } + named ablabelmargin { } + named ablabelfont { } + named ablabelbreak { } + named ablabelformat right @Body { } + import @Geometry named ablabelpos { NW } + named ablabelprox { } + import @Geometry named ablabelangle { } + named ablabelctr { } + import @Geometry named ablabeladjust{ } + + named aclabel { } + named aclabelmargin { } + named aclabelfont { } + named aclabelbreak { } + named aclabelformat right @Body { } + import @Geometry named aclabelpos { SW } + named aclabelprox { } + import @Geometry named aclabelangle { } + named aclabelctr { } + import @Geometry named aclabeladjust{ } + + named adlabel { } + named adlabelmargin { } + named adlabelfont { } + named adlabelbreak { } + named adlabelformat right @Body { } + import @Geometry named adlabelpos { SE } + named adlabelprox { } + import @Geometry named adlabelangle { } + named adlabelctr { } + import @Geometry named adlabeladjust{ } + + ########################################################################### + # # + # @BNode options of @DiagSetup # + # # + ########################################################################### + + import @Geometry named boutline + named margin {} + named shadow {} + named sides {} + named angle {} + { box } + named bmargin { 0.6f } + import @Geometry named bshadow { 0.4f } + import @Geometry named bsides { 3 } + import @Geometry named bangle { "dup 180 exch div" } + named btranslate { } + named boutlinestyle + named solid { "/ldiagsolid" } + named dashed { "/ldiagdashed" } + named cdashed { "/ldiagcdashed" } + named dotted { "/ldiagdotted" } + named noline { "/ldiagnoline" } + { solid } + import @Geometry named boutlinedashlength { 0.2f } + import @Geometry named boutlinewidth + named thin { 0.04 ft } + named medium { 0.08 ft } + named thick { 0.12 ft } + { thin } + named bpaint { nopaint } + named bfont { } + named bbreak { } + named bformat right @Body { @Body } + + named bvalign { ctr } + named bvsize { } + named bvindent { ctr } + named bvstrut + named no { 0.0f } + named yes { 1.0f } + { no } + named bvmargin { } + named btopmargin { } + named bfootmargin { } + + named bhalign { ctr } + named bhsize { } + named bhindent { ctr } + named bhstrut + named no { 0.0f } + named yes { 1.0f } + { no } + named bhmargin { } + named bleftmargin { } + named brightmargin { } + + named bnodelabel { } + named bnodelabelmargin { 0.2f } + named bnodelabelfont { -2p } + named bnodelabelbreak { ragged nohyphen } + named bnodelabelformat right @Body { @Body } + import @Geometry named bnodelabelpos{ } + named bnodelabelprox { outside } + import @Geometry named bnodelabelangle { horizontal } + named bnodelabelctr { no } + import @Geometry named bnodelabeladjust { 0 0 } + + named balabel { } + named balabelmargin { } + named balabelfont { } + named balabelbreak { } + named balabelformat right @Body { } + import @Geometry named balabelpos { NE } + named balabelprox { } + import @Geometry named balabelangle { } + named balabelctr { } + import @Geometry named balabeladjust{ } + + named bblabel { } + named bblabelmargin { } + named bblabelfont { } + named bblabelbreak { } + named bblabelformat right @Body { } + import @Geometry named bblabelpos { NW } + named bblabelprox { } + import @Geometry named bblabelangle { } + named bblabelctr { } + import @Geometry named bblabeladjust{ } + + named bclabel { } + named bclabelmargin { } + named bclabelfont { } + named bclabelbreak { } + named bclabelformat right @Body { } + import @Geometry named bclabelpos { SW } + named bclabelprox { } + import @Geometry named bclabelangle { } + named bclabelctr { } + import @Geometry named bclabeladjust{ } + + named bdlabel { } + named bdlabelmargin { } + named bdlabelfont { } + named bdlabelbreak { } + named bdlabelformat right @Body { } + import @Geometry named bdlabelpos { SE } + named bdlabelprox { } + import @Geometry named bdlabelangle { } + named bdlabelctr { } + import @Geometry named bdlabeladjust{ } + + ########################################################################### + # # + # @CNode options of @DiagSetup # + # # + ########################################################################### + + import @Geometry named coutline + named margin {} + named shadow {} + named sides {} + named angle {} + { box } + named cmargin { 0.6f } + import @Geometry named cshadow { 0.4f } + import @Geometry named csides { 3 } + import @Geometry named cangle { "dup 180 exch div" } + named ctranslate { } + named coutlinestyle + named solid { "/ldiagsolid" } + named dashed { "/ldiagdashed" } + named cdashed { "/ldiagcdashed" } + named dotted { "/ldiagdotted" } + named noline { "/ldiagnoline" } + { solid } + import @Geometry named coutlinedashlength { 0.2f } + import @Geometry named coutlinewidth + named thin { 0.04 ft } + named medium { 0.08 ft } + named thick { 0.12 ft } + { thin } + named cpaint { nopaint } + named cfont { } + named cbreak { } + named cformat right @Body { @Body } + + named cvalign { ctr } + named cvsize { } + named cvindent { ctr } + named cvstrut + named no { 0.0f } + named yes { 1.0f } + { no } + named cvmargin { } + named ctopmargin { } + named cfootmargin { } + + named chalign { ctr } + named chsize { } + named chindent { ctr } + named chstrut + named no { 0.0f } + named yes { 1.0f } + { no } + named chmargin { } + named cleftmargin { } + named crightmargin { } + + named cnodelabel { } + named cnodelabelmargin { 0.2f } + named cnodelabelfont { -2p } + named cnodelabelbreak { ragged nohyphen } + named cnodelabelformat right @Body { @Body } + import @Geometry named cnodelabelpos{ } + named cnodelabelprox { outside } + import @Geometry named cnodelabelangle { horizontal } + named cnodelabelctr { no } + import @Geometry named cnodelabeladjust { 0 0 } + + named calabel { } + named calabelmargin { } + named calabelfont { } + named calabelbreak { } + named calabelformat right @Body { } + import @Geometry named calabelpos { NE } + named calabelprox { } + import @Geometry named calabelangle { } + named calabelctr { } + import @Geometry named calabeladjust{ } + + named cblabel { } + named cblabelmargin { } + named cblabelfont { } + named cblabelbreak { } + named cblabelformat right @Body { } + import @Geometry named cblabelpos { NW } + named cblabelprox { } + import @Geometry named cblabelangle { } + named cblabelctr { } + import @Geometry named cblabeladjust{ } + + named cclabel { } + named cclabelmargin { } + named cclabelfont { } + named cclabelbreak { } + named cclabelformat right @Body { } + import @Geometry named cclabelpos { SW } + named cclabelprox { } + import @Geometry named cclabelangle { } + named cclabelctr { } + import @Geometry named cclabeladjust{ } + + named cdlabel { } + named cdlabelmargin { } + named cdlabelfont { } + named cdlabelbreak { } + named cdlabelformat right @Body { } + import @Geometry named cdlabelpos { SE } + named cdlabelprox { } + import @Geometry named cdlabelangle { } + named cdlabelctr { } + import @Geometry named cdlabeladjust{ } + + ########################################################################### + # # + # @Link options of @DiagSetup # + # # + ########################################################################### + import @Geometry named path named from {} named to {} @@ -236,6 +596,12 @@ def @DiagSetup named tolabelctr { no } import @Geometry named tolabeladjust { 0 0 } + ########################################################################### + # # + # Tree and syntax diagram options of @DiagSetup # + # # + ########################################################################### + named treehsep { 0.5f } named treevsep { 0.5f } named treehindent @@ -249,13 +615,21 @@ def @DiagSetup named foot { 1.0rt } { ctr } + named syntaxgap { 0.35f } + named syntaxbias { 1.0f } + named syntaxradius { 0.3f } { - export "::" @ShowPoints @ShowTags @ShowDirections @CatchTags @Transform - @Tree @HTree + ########################################################################### + # # + # @Diag symbol # + # # + ########################################################################### + + export "::" @ShowPoints @ShowTags @ShowDirections @CatchTags @Transform - @Node + @Node @ANode @BNode @CNode @Box @CurveBox @ShadowBox @Square @Diamond @Polygon @Isosceles @Ellipse @Circle @ArrowHead @SolidArrowHead @OpenArrowHead @HalfOpenArrowHead @@ -273,9 +647,28 @@ def @DiagSetup @DWrapLine @DWrapArrow @UWrapLine @UWrapArrow @DWrapCurve @DWrapCurveArrow @UWrapCurve @UWrapCurveArrow + @Tree @HTree + + @StartRight @StartUp @StartLeft @StartDown + @StartRightRight @StartRightDown + @Skip @XCell @ACell @BCell @CCell + @Sequence @Select @Optional @OptionalDiverted @Diverted + @Loop @LoopOpposite @Repeat @RepeatOpposite @RepeatDiverted + def @Diag named save { save } named maxlabels { maxlabels } + named title { title } + named titleformat + left @Title + right @Body + { @Title titleformat @Body } + + ####################################################################### + # # + # @Node options of @Diag # + # # + ####################################################################### import @Geometry named outline named margin {} @@ -332,6 +725,195 @@ def @DiagSetup named leftmargin { leftmargin } named rightmargin { rightmargin } + ####################################################################### + # # + # @ANode options of @Diag # + # # + ####################################################################### + + import @Geometry named aoutline + named margin {} + named shadow {} + named sides {} + named angle {} + { aoutline + margin { margin } + shadow { shadow } + sides { sides } + angle { angle } + } + named amargin { amargin } + import @Geometry named ashadow { ashadow } + import @Geometry named asides { asides } + import @Geometry named aangle { aangle } + named atranslate { atranslate } + named anodetag { } + named aoutlinestyle + named solid { "/ldiagsolid" } + named dashed { "/ldiagdashed" } + named cdashed { "/ldiagcdashed" } + named dotted { "/ldiagdotted" } + named noline { "/ldiagnoline" } + { aoutlinestyle } + import @Geometry named aoutlinedashlength{ aoutlinedashlength } + import @Geometry named aoutlinewidth + named thin { 0.04 ft } + named medium { 0.08 ft } + named thick { 0.12 ft } + { aoutlinewidth } + named apaint { apaint } + named afont { afont } + named abreak { abreak } + named aformat right @Body { aformat @Body } + named avalign { avalign } + named avsize { avsize } + named avindent { avindent } + named avstrut + named no { 0.0f } + named yes { 1.0f } + { avstrut } + named avmargin { avmargin } + named atopmargin { atopmargin } + named afootmargin { afootmargin } + named ahalign { ahalign } + named ahsize { ahsize } + named ahindent { ahindent } + named ahstrut + named no { 0.0f } + named yes { 1.0f } + { ahstrut } + named ahmargin { ahmargin } + named aleftmargin { aleftmargin } + named arightmargin { arightmargin } + + ####################################################################### + # # + # @BNode options of @Diag # + # # + ####################################################################### + + import @Geometry named boutline + named margin {} + named shadow {} + named sides {} + named angle {} + { boutline + margin { margin } + shadow { shadow } + sides { sides } + angle { angle } + } + named bmargin { bmargin } + import @Geometry named bshadow { bshadow } + import @Geometry named bsides { bsides } + import @Geometry named bangle { bangle } + named btranslate { btranslate } + named bnodetag { } + named boutlinestyle + named solid { "/ldiagsolid" } + named dashed { "/ldiagdashed" } + named cdashed { "/ldiagcdashed" } + named dotted { "/ldiagdotted" } + named noline { "/ldiagnoline" } + { boutlinestyle } + import @Geometry named boutlinedashlength{ boutlinedashlength } + import @Geometry named boutlinewidth + named thin { 0.04 ft } + named medium { 0.08 ft } + named thick { 0.12 ft } + { boutlinewidth } + named bpaint { bpaint } + named bfont { bfont } + named bbreak { bbreak } + named bformat right @Body { bformat @Body } + named bvalign { bvalign } + named bvsize { bvsize } + named bvindent { bvindent } + named bvstrut + named no { 0.0f } + named yes { 1.0f } + { bvstrut } + named bvmargin { bvmargin } + named btopmargin { btopmargin } + named bfootmargin { bfootmargin } + named bhalign { bhalign } + named bhsize { bhsize } + named bhindent { bhindent } + named bhstrut + named no { 0.0f } + named yes { 1.0f } + { bhstrut } + named bhmargin { bhmargin } + named bleftmargin { bleftmargin } + named brightmargin { brightmargin } + + ####################################################################### + # # + # @CNode options of @Diag # + # # + ####################################################################### + + import @Geometry named coutline + named margin {} + named shadow {} + named sides {} + named angle {} + { coutline + margin { margin } + shadow { shadow } + sides { sides } + angle { angle } + } + named cmargin { cmargin } + import @Geometry named cshadow { cshadow } + import @Geometry named csides { csides } + import @Geometry named cangle { cangle } + named ctranslate { ctranslate } + named cnodetag { } + named coutlinestyle + named solid { "/ldiagsolid" } + named dashed { "/ldiagdashed" } + named cdashed { "/ldiagcdashed" } + named dotted { "/ldiagdotted" } + named noline { "/ldiagnoline" } + { coutlinestyle } + import @Geometry named coutlinedashlength{ coutlinedashlength } + import @Geometry named coutlinewidth + named thin { 0.04 ft } + named medium { 0.08 ft } + named thick { 0.12 ft } + { coutlinewidth } + named cpaint { cpaint } + named cfont { cfont } + named cbreak { cbreak } + named cformat right @Body { cformat @Body } + named cvalign { cvalign } + named cvsize { cvsize } + named cvindent { cvindent } + named cvstrut + named no { 0.0f } + named yes { 1.0f } + { cvstrut } + named cvmargin { cvmargin } + named ctopmargin { ctopmargin } + named cfootmargin { cfootmargin } + named chalign { chalign } + named chsize { chsize } + named chindent { chindent } + named chstrut + named no { 0.0f } + named yes { 1.0f } + { chstrut } + named chmargin { chmargin } + named cleftmargin { cleftmargin } + named crightmargin { crightmargin } + + ####################################################################### + # # + # @Link options of @Diag # + # # + ####################################################################### + import @Geometry named path named from {} named to {} @@ -513,6 +1095,12 @@ def @DiagSetup named tolabelctr { tolabelctr } import @Geometry named tolabeladjust { tolabeladjust } + ####################################################################### + # # + # Tree and syntax diagram options of @Diag # + # # + ####################################################################### + named treehsep { treehsep } named treevsep { treevsep } named treehindent @@ -525,9 +1113,19 @@ def @DiagSetup named ctr { 0.5rt } named foot { 1.0rt } { treevindent } + named syntaxgap { syntaxgap } + named syntaxbias { syntaxbias } + named syntaxradius { syntaxradius } body @Body @Begin + + ####################################################################### + # # + # Miscellaneous helper definitions # + # # + ####################################################################### + # Like @Graphic, but affects the graphics state of right parameter def @InnerGraphic left ps @@ -615,6 +1213,12 @@ def @DiagSetup } } + def @ShowMarks right x + { + { "xmark -0.5 cm moveto xmark ysize 0.5 cm add lineto stroke" } @Graphic x + } + + def "::" precedence 33 associativity right @@ -759,6 +1363,13 @@ def @DiagSetup } } + + ####################################################################### + # # + # @DoLabel definition for drawing one label # + # # + ####################################################################### + def @DoLabel named which {} named labeltag { LABEL } @@ -1571,9 +2182,14 @@ def @DiagSetup } + ####################################################################### + # # + # @Node # + # # + ####################################################################### + def @Node import @Geometry named translate -# named to precedence 10 left x right y { x y "ldiagpsub" } named to precedence 10 left x right y { @BackEnd @Case { PostScript @Yield { x y "ldiagpsub" } @@ -1908,6 +2524,1042 @@ def @DiagSetup } } + + ####################################################################### + # # + # @ANode # + # # + ####################################################################### + + def @ANode + import @Geometry named translate + named to precedence 10 left x right y { + @BackEnd @Case { + PostScript @Yield { x y "ldiagpsub" } + PDF @Yield {""} + } + } + {} + import @Geometry named rotate { 0d } + import @Geometry named outline + named margin {} + named shadow {} + named sides {} + named angle {} + { aoutline + margin { margin } + shadow { shadow } + sides { sides } + angle { angle } + } + named margin { amargin } + import @Geometry named shadow { ashadow } + import @Geometry named sides { asides } + import @Geometry named angle { aangle } + named nodetag { anodetag } + named outlinestyle + named solid { "/ldiagsolid" } + named dashed { "/ldiagdashed" } + named cdashed { "/ldiagcdashed" } + named dotted { "/ldiagdotted" } + named noline { "/ldiagnoline" } + { aoutlinestyle } + import @Geometry named outlinedashlength { aoutlinedashlength} + import @Geometry named outlinewidth + named thin { 0.04 ft } + named medium { 0.08 ft } + named thick { 0.12 ft } + { aoutlinewidth } + named paint { apaint } + named font { afont } + named break { abreak } + named format right @Body { aformat @Body } + named valign { avalign } + named vsize { avsize } + named vindent { avindent } + named vstrut + named no { 0.0f } + named yes { 1.0f } + { avstrut } + named vmargin { avmargin } + named topmargin { atopmargin } + named footmargin { afootmargin } + + named halign { ahalign } + named hsize { ahsize } + named hindent { ahindent } + named hstrut + named no { 0.0f } + named yes { 1.0f } + { ahstrut } + named hmargin { ahmargin } + named leftmargin { aleftmargin } + named rightmargin { arightmargin } + + named nodelabel { anodelabel } + named nodelabelmargin { anodelabelmargin } + named nodelabelfont { anodelabelfont } + named nodelabelbreak { anodelabelbreak } + named nodelabelformat right @Body { anodelabelformat @Body } + import @Geometry named nodelabelpos { anodelabelpos } + named nodelabelprox { anodelabelprox } + import @Geometry named nodelabelangle { anodelabelangle } + named nodelabelctr { anodelabelctr } + import @Geometry named nodelabeladjust { anodelabeladjust } + + named alabel { aalabel } + named alabelmargin { aalabelmargin } + named alabelfont { aalabelfont } + named alabelbreak { aalabelbreak } + named alabelformat right @Body { aalabelformat @Body } + import @Geometry named alabelpos { aalabelpos } + named alabelprox { aalabelprox } + import @Geometry named alabelangle { aalabelangle } + named alabelctr { aalabelctr } + import @Geometry named alabeladjust { aalabeladjust } + + named blabel { ablabel } + named blabelmargin { ablabelmargin } + named blabelfont { ablabelfont } + named blabelbreak { ablabelbreak } + named blabelformat right @Body { ablabelformat @Body } + import @Geometry named blabelpos { ablabelpos } + named blabelprox { ablabelprox } + import @Geometry named blabelangle { ablabelangle } + named blabelctr { ablabelctr } + import @Geometry named blabeladjust { ablabeladjust } + + named clabel { aclabel } + named clabelmargin { aclabelmargin } + named clabelfont { aclabelfont } + named clabelbreak { aclabelbreak } + named clabelformat right @Body { aclabelformat @Body } + import @Geometry named clabelpos { aclabelpos } + named clabelprox { aclabelprox } + import @Geometry named clabelangle { aclabelangle } + named clabelctr { aclabelctr } + import @Geometry named clabeladjust { aclabeladjust } + + named dlabel { adlabel } + named dlabelmargin { adlabelmargin } + named dlabelfont { adlabelfont } + named dlabelbreak { adlabelbreak } + named dlabelformat right @Body { adlabelformat @Body } + import @Geometry named dlabelpos { adlabelpos } + named dlabelprox { adlabelprox } + import @Geometry named dlabelangle { adlabelangle } + named dlabelctr { adlabelctr } + import @Geometry named dlabeladjust { adlabeladjust } + + right @Body + { + + def @LabelPos + left x + right y + { + nodelabelpos @Case { + x @Yield y + else @Yield "" + } + } + + def @If + left cond + right x + { + cond @Case { + { yes Yes } @Yield x + else @Yield "" + } + } + + + def @Strut right x + { + def vs { 0.5w @VShift { vstrut @High } } + def hs { hstrut @Wide } + + @HContract @VContract { + @HContract @VContract x | vs / hs | + } + } + + def @Indent right x + { + x @Case { + { top left } @Yield 0.0rt + { ctr } @Yield 0.5rt + { foot right } @Yield 1.0rt + { mctr } @Yield 0.5bx + else @Yield x + } + } + + def @VSize right x + { + vsize @Case { + "" @Yield x + else @Yield { vsize @High { /{@Indent vindent} x / } } + } + } + + def @HSize right x + { + hsize @Case { + "" @Yield x + else @Yield { hsize @Wide { |{@Indent hindent} x | } } + } + } + + def @Align right x + { + x @Case { + { top left } @Yield 0.0w + { ctr } @Yield 0.5w + { foot right } @Yield 1.0w + { mark } @Yield "+0i" + else @Yield x + } + } + + def @ALabel + { + @DoLabel + which { "a" } + label { alabel @Else nodelabel } + labelmargin { alabelmargin @Else nodelabelmargin } + labelfont { alabelfont @Else nodelabelfont } + labelbreak { alabelbreak @Else nodelabelbreak } + labelformat { alabelformat @Body @Else nodelabelformat @Body} + labelpos { alabelpos @Else nodelabelpos } + labelprox { alabelprox @Else nodelabelprox } + labelangle { alabelangle @Else nodelabelangle } + labelctr { alabelctr @Else nodelabelctr } + labeladjust { alabeladjust @Else nodelabeladjust } + } + + def @BLabel + { + @DoLabel + which { "b" } + label { blabel @Else nodelabel } + labelmargin { blabelmargin @Else nodelabelmargin } + labelfont { blabelfont @Else nodelabelfont } + labelbreak { blabelbreak @Else nodelabelbreak } + labelformat { blabelformat @Body @Else nodelabelformat @Body} + labelpos { blabelpos @Else nodelabelpos } + labelprox { blabelprox @Else nodelabelprox } + labelangle { blabelangle @Else nodelabelangle } + labelctr { blabelctr @Else nodelabelctr } + labeladjust { blabeladjust @Else nodelabeladjust } + } + + def @CLabel + { + @DoLabel + which { "c" } + label { clabel @Else nodelabel } + labelmargin { clabelmargin @Else nodelabelmargin } + labelfont { clabelfont @Else nodelabelfont } + labelbreak { clabelbreak @Else nodelabelbreak } + labelformat { clabelformat @Body @Else nodelabelformat @Body} + labelpos { clabelpos @Else nodelabelpos } + labelprox { clabelprox @Else nodelabelprox } + labelangle { clabelangle @Else nodelabelangle } + labelctr { clabelctr @Else nodelabelctr } + labeladjust { clabeladjust @Else nodelabeladjust } + } + + def @DLabel + { + @DoLabel + which { "d" } + label { dlabel @Else nodelabel } + labelmargin { dlabelmargin @Else nodelabelmargin } + labelfont { dlabelfont @Else nodelabelfont } + labelbreak { dlabelbreak @Else nodelabelbreak } + labelformat { dlabelformat @Body @Else nodelabelformat @Body} + labelpos { dlabelpos @Else nodelabelpos } + labelprox { dlabelprox @Else nodelabelprox } + labelangle { dlabelangle @Else nodelabelangle } + labelctr { dlabelctr @Else nodelabelctr } + labeladjust { dlabeladjust @Else nodelabeladjust } + } + + import @Geometry + def @OutLine + { + @BackEnd @Case { + PostScript @Yield { + outline @Case { + box @Yield { "ldiagbox" } + curvebox @Yield { "("margin") ldiagcurvebox" } + shadowbox @Yield { shadow "ldiagshadow ldiagbox" } + square @Yield { "ldiagsquare" } + diamond @Yield { "ldiagdiamond" } + polygon @Yield { sides angle "ldiagpolygon" } + isosceles @Yield { "ldiagisosceles" } + ellipse @Yield { "ldiagellipse" } + circle @Yield { "ldiagcircle" } + else @Yield { + outline + margin { "("margin") ldiagdecodelength" } + shadow { shadow } + sides { sides } + angle { angle } + } + } + } + PDF @Yield {} + } + } + + def @Value + { + @BackEnd @Case { + PostScript @Yield { + @HContract @VContract + { + { + "ldiagnodebegin [" @OutLine "]" + outlinedashlength "[" outlinestyle "]" + outlinewidth "/ldiag"paint "ldiagnodeend" + "(IN) ldiagpushtagdict" + // + "ldiagpopuptagdict" + } + @Graphic + { + {@Align valign} @VShift {@Align halign} @HShift + @AddMargins + mtop { topmargin @Else vmargin @Else margin } + mfoot { footmargin @Else vmargin @Else margin } + mleft { leftmargin @Else hmargin @Else margin } + mright { rightmargin @Else hmargin @Else margin } + @HSize @VSize @HContract @VContract + font @Font break @Break format @Strut @Body + } + / {alabel @Else nodelabel} @IfNonEmpty @ALabel + / {blabel @Else nodelabel} @IfNonEmpty @BLabel + / {clabel @Else nodelabel} @IfNonEmpty @CLabel + / {dlabel @Else nodelabel} @IfNonEmpty @DLabel + } + } + PDF @Yield {} + } + } + + def @TValue + { + nodetag @Case { + "" @Yield @Value + else @Yield { nodetag:: @Value } + } + } + + translate @Case { + "" @Yield @TValue + else @Yield { + @Null & # so that preceding space gets chewed up + @Transform translate { translate } rotate { rotate } @TValue + } + } + } + + + ####################################################################### + # # + # @BNode # + # # + ####################################################################### + + def @BNode + import @Geometry named translate + named to precedence 10 left x right y { + @BackEnd @Case { + PostScript @Yield { x y "ldiagpsub" } + PDF @Yield {""} + } + } + {} + import @Geometry named rotate { 0d } + import @Geometry named outline + named margin {} + named shadow {} + named sides {} + named angle {} + { boutline + margin { margin } + shadow { shadow } + sides { sides } + angle { angle } + } + named margin { bmargin } + import @Geometry named shadow { bshadow } + import @Geometry named sides { bsides } + import @Geometry named angle { bangle } + named nodetag { bnodetag } + named outlinestyle + named solid { "/ldiagsolid" } + named dashed { "/ldiagdashed" } + named cdashed { "/ldiagcdashed" } + named dotted { "/ldiagdotted" } + named noline { "/ldiagnoline" } + { boutlinestyle } + import @Geometry named outlinedashlength { boutlinedashlength} + import @Geometry named outlinewidth + named thin { 0.04 ft } + named medium { 0.08 ft } + named thick { 0.12 ft } + { boutlinewidth } + named paint { bpaint } + named font { bfont } + named break { bbreak } + named format right @Body { bformat @Body } + named valign { bvalign } + named vsize { bvsize } + named vindent { bvindent } + named vstrut + named no { 0.0f } + named yes { 1.0f } + { bvstrut } + named vmargin { bvmargin } + named topmargin { btopmargin } + named footmargin { bfootmargin } + + named halign { bhalign } + named hsize { bhsize } + named hindent { bhindent } + named hstrut + named no { 0.0f } + named yes { 1.0f } + { bhstrut } + named hmargin { bhmargin } + named leftmargin { bleftmargin } + named rightmargin { brightmargin } + + named nodelabel { bnodelabel } + named nodelabelmargin { bnodelabelmargin } + named nodelabelfont { bnodelabelfont } + named nodelabelbreak { bnodelabelbreak } + named nodelabelformat right @Body { bnodelabelformat @Body } + import @Geometry named nodelabelpos { bnodelabelpos } + named nodelabelprox { bnodelabelprox } + import @Geometry named nodelabelangle { bnodelabelangle } + named nodelabelctr { bnodelabelctr } + import @Geometry named nodelabeladjust { bnodelabeladjust } + + named alabel { balabel } + named alabelmargin { balabelmargin } + named alabelfont { balabelfont } + named alabelbreak { balabelbreak } + named alabelformat right @Body { balabelformat @Body } + import @Geometry named alabelpos { balabelpos } + named alabelprox { balabelprox } + import @Geometry named alabelangle { balabelangle } + named alabelctr { balabelctr } + import @Geometry named alabeladjust { balabeladjust } + + named blabel { bblabel } + named blabelmargin { bblabelmargin } + named blabelfont { bblabelfont } + named blabelbreak { bblabelbreak } + named blabelformat right @Body { bblabelformat @Body } + import @Geometry named blabelpos { bblabelpos } + named blabelprox { bblabelprox } + import @Geometry named blabelangle { bblabelangle } + named blabelctr { bblabelctr } + import @Geometry named blabeladjust { bblabeladjust } + + named clabel { bclabel } + named clabelmargin { bclabelmargin } + named clabelfont { bclabelfont } + named clabelbreak { bclabelbreak } + named clabelformat right @Body { bclabelformat @Body } + import @Geometry named clabelpos { bclabelpos } + named clabelprox { bclabelprox } + import @Geometry named clabelangle { bclabelangle } + named clabelctr { bclabelctr } + import @Geometry named clabeladjust { bclabeladjust } + + named dlabel { bdlabel } + named dlabelmargin { bdlabelmargin } + named dlabelfont { bdlabelfont } + named dlabelbreak { bdlabelbreak } + named dlabelformat right @Body { bdlabelformat @Body } + import @Geometry named dlabelpos { bdlabelpos } + named dlabelprox { bdlabelprox } + import @Geometry named dlabelangle { bdlabelangle } + named dlabelctr { bdlabelctr } + import @Geometry named dlabeladjust { bdlabeladjust } + + right @Body + { + + def @LabelPos + left x + right y + { + nodelabelpos @Case { + x @Yield y + else @Yield "" + } + } + + def @If + left cond + right x + { + cond @Case { + { yes Yes } @Yield x + else @Yield "" + } + } + + + def @Strut right x + { + def vs { 0.5w @VShift { vstrut @High } } + def hs { hstrut @Wide } + + @HContract @VContract { + @HContract @VContract x | vs / hs | + } + } + + def @Indent right x + { + x @Case { + { top left } @Yield 0.0rt + { ctr } @Yield 0.5rt + { foot right } @Yield 1.0rt + { mctr } @Yield 0.5bx + else @Yield x + } + } + + def @VSize right x + { + vsize @Case { + "" @Yield x + else @Yield { vsize @High { /{@Indent vindent} x / } } + } + } + + def @HSize right x + { + hsize @Case { + "" @Yield x + else @Yield { hsize @Wide { |{@Indent hindent} x | } } + } + } + + def @Align right x + { + x @Case { + { top left } @Yield 0.0w + { ctr } @Yield 0.5w + { foot right } @Yield 1.0w + { mark } @Yield "+0i" + else @Yield x + } + } + + def @ALabel + { + @DoLabel + which { "a" } + label { alabel @Else nodelabel } + labelmargin { alabelmargin @Else nodelabelmargin } + labelfont { alabelfont @Else nodelabelfont } + labelbreak { alabelbreak @Else nodelabelbreak } + labelformat { alabelformat @Body @Else nodelabelformat @Body} + labelpos { alabelpos @Else nodelabelpos } + labelprox { alabelprox @Else nodelabelprox } + labelangle { alabelangle @Else nodelabelangle } + labelctr { alabelctr @Else nodelabelctr } + labeladjust { alabeladjust @Else nodelabeladjust } + } + + def @BLabel + { + @DoLabel + which { "b" } + label { blabel @Else nodelabel } + labelmargin { blabelmargin @Else nodelabelmargin } + labelfont { blabelfont @Else nodelabelfont } + labelbreak { blabelbreak @Else nodelabelbreak } + labelformat { blabelformat @Body @Else nodelabelformat @Body} + labelpos { blabelpos @Else nodelabelpos } + labelprox { blabelprox @Else nodelabelprox } + labelangle { blabelangle @Else nodelabelangle } + labelctr { blabelctr @Else nodelabelctr } + labeladjust { blabeladjust @Else nodelabeladjust } + } + + def @CLabel + { + @DoLabel + which { "c" } + label { clabel @Else nodelabel } + labelmargin { clabelmargin @Else nodelabelmargin } + labelfont { clabelfont @Else nodelabelfont } + labelbreak { clabelbreak @Else nodelabelbreak } + labelformat { clabelformat @Body @Else nodelabelformat @Body} + labelpos { clabelpos @Else nodelabelpos } + labelprox { clabelprox @Else nodelabelprox } + labelangle { clabelangle @Else nodelabelangle } + labelctr { clabelctr @Else nodelabelctr } + labeladjust { clabeladjust @Else nodelabeladjust } + } + + def @DLabel + { + @DoLabel + which { "d" } + label { dlabel @Else nodelabel } + labelmargin { dlabelmargin @Else nodelabelmargin } + labelfont { dlabelfont @Else nodelabelfont } + labelbreak { dlabelbreak @Else nodelabelbreak } + labelformat { dlabelformat @Body @Else nodelabelformat @Body} + labelpos { dlabelpos @Else nodelabelpos } + labelprox { dlabelprox @Else nodelabelprox } + labelangle { dlabelangle @Else nodelabelangle } + labelctr { dlabelctr @Else nodelabelctr } + labeladjust { dlabeladjust @Else nodelabeladjust } + } + + import @Geometry + def @OutLine + { + @BackEnd @Case { + PostScript @Yield { + outline @Case { + box @Yield { "ldiagbox" } + curvebox @Yield { "("margin") ldiagcurvebox" } + shadowbox @Yield { shadow "ldiagshadow ldiagbox" } + square @Yield { "ldiagsquare" } + diamond @Yield { "ldiagdiamond" } + polygon @Yield { sides angle "ldiagpolygon" } + isosceles @Yield { "ldiagisosceles" } + ellipse @Yield { "ldiagellipse" } + circle @Yield { "ldiagcircle" } + else @Yield { + outline + margin { "("margin") ldiagdecodelength" } + shadow { shadow } + sides { sides } + angle { angle } + } + } + } + PDF @Yield {} + } + } + + def @Value + { + @BackEnd @Case { + PostScript @Yield { + @HContract @VContract + { + { + "ldiagnodebegin [" @OutLine "]" + outlinedashlength "[" outlinestyle "]" + outlinewidth "/ldiag"paint "ldiagnodeend" + "(IN) ldiagpushtagdict" + // + "ldiagpopuptagdict" + } + @Graphic + { + {@Align valign} @VShift {@Align halign} @HShift + @AddMargins + mtop { topmargin @Else vmargin @Else margin } + mfoot { footmargin @Else vmargin @Else margin } + mleft { leftmargin @Else hmargin @Else margin } + mright { rightmargin @Else hmargin @Else margin } + @HSize @VSize @HContract @VContract + font @Font break @Break format @Strut @Body + } + / {alabel @Else nodelabel} @IfNonEmpty @ALabel + / {blabel @Else nodelabel} @IfNonEmpty @BLabel + / {clabel @Else nodelabel} @IfNonEmpty @CLabel + / {dlabel @Else nodelabel} @IfNonEmpty @DLabel + } + } + PDF @Yield {} + } + } + + def @TValue + { + nodetag @Case { + "" @Yield @Value + else @Yield { nodetag:: @Value } + } + } + + translate @Case { + "" @Yield @TValue + else @Yield { + @Null & # so that preceding space gets chewed up + @Transform translate { translate } rotate { rotate } @TValue + } + } + } + + + ####################################################################### + # # + # @CNode # + # # + ####################################################################### + + def @CNode + import @Geometry named translate + named to precedence 10 left x right y { + @BackEnd @Case { + PostScript @Yield { x y "ldiagpsub" } + PDF @Yield {""} + } + } + {} + import @Geometry named rotate { 0d } + import @Geometry named outline + named margin {} + named shadow {} + named sides {} + named angle {} + { coutline + margin { margin } + shadow { shadow } + sides { sides } + angle { angle } + } + named margin { cmargin } + import @Geometry named shadow { cshadow } + import @Geometry named sides { csides } + import @Geometry named angle { cangle } + named nodetag { cnodetag } + named outlinestyle + named solid { "/ldiagsolid" } + named dashed { "/ldiagdashed" } + named cdashed { "/ldiagcdashed" } + named dotted { "/ldiagdotted" } + named noline { "/ldiagnoline" } + { coutlinestyle } + import @Geometry named outlinedashlength { coutlinedashlength} + import @Geometry named outlinewidth + named thin { 0.04 ft } + named medium { 0.08 ft } + named thick { 0.12 ft } + { coutlinewidth } + named paint { cpaint } + named font { cfont } + named break { cbreak } + named format right @Body { cformat @Body } + named valign { cvalign } + named vsize { cvsize } + named vindent { cvindent } + named vstrut + named no { 0.0f } + named yes { 1.0f } + { cvstrut } + named vmargin { cvmargin } + named topmargin { ctopmargin } + named footmargin { cfootmargin } + + named halign { chalign } + named hsize { chsize } + named hindent { chindent } + named hstrut + named no { 0.0f } + named yes { 1.0f } + { chstrut } + named hmargin { chmargin } + named leftmargin { cleftmargin } + named rightmargin { crightmargin } + + named nodelabel { cnodelabel } + named nodelabelmargin { cnodelabelmargin } + named nodelabelfont { cnodelabelfont } + named nodelabelbreak { cnodelabelbreak } + named nodelabelformat right @Body { cnodelabelformat @Body } + import @Geometry named nodelabelpos { cnodelabelpos } + named nodelabelprox { cnodelabelprox } + import @Geometry named nodelabelangle { cnodelabelangle } + named nodelabelctr { cnodelabelctr } + import @Geometry named nodelabeladjust { cnodelabeladjust } + + named alabel { calabel } + named alabelmargin { calabelmargin } + named alabelfont { calabelfont } + named alabelbreak { calabelbreak } + named alabelformat right @Body { calabelformat @Body } + import @Geometry named alabelpos { calabelpos } + named alabelprox { calabelprox } + import @Geometry named alabelangle { calabelangle } + named alabelctr { calabelctr } + import @Geometry named alabeladjust { calabeladjust } + + named blabel { cblabel } + named blabelmargin { cblabelmargin } + named blabelfont { cblabelfont } + named blabelbreak { cblabelbreak } + named blabelformat right @Body { cblabelformat @Body } + import @Geometry named blabelpos { cblabelpos } + named blabelprox { cblabelprox } + import @Geometry named blabelangle { cblabelangle } + named blabelctr { cblabelctr } + import @Geometry named blabeladjust { cblabeladjust } + + named clabel { cclabel } + named clabelmargin { cclabelmargin } + named clabelfont { cclabelfont } + named clabelbreak { cclabelbreak } + named clabelformat right @Body { cclabelformat @Body } + import @Geometry named clabelpos { cclabelpos } + named clabelprox { cclabelprox } + import @Geometry named clabelangle { cclabelangle } + named clabelctr { cclabelctr } + import @Geometry named clabeladjust { cclabeladjust } + + named dlabel { cdlabel } + named dlabelmargin { cdlabelmargin } + named dlabelfont { cdlabelfont } + named dlabelbreak { cdlabelbreak } + named dlabelformat right @Body { cdlabelformat @Body } + import @Geometry named dlabelpos { cdlabelpos } + named dlabelprox { cdlabelprox } + import @Geometry named dlabelangle { cdlabelangle } + named dlabelctr { cdlabelctr } + import @Geometry named dlabeladjust { cdlabeladjust } + + right @Body + { + + def @LabelPos + left x + right y + { + nodelabelpos @Case { + x @Yield y + else @Yield "" + } + } + + def @If + left cond + right x + { + cond @Case { + { yes Yes } @Yield x + else @Yield "" + } + } + + + def @Strut right x + { + def vs { 0.5w @VShift { vstrut @High } } + def hs { hstrut @Wide } + + @HContract @VContract { + @HContract @VContract x | vs / hs | + } + } + + def @Indent right x + { + x @Case { + { top left } @Yield 0.0rt + { ctr } @Yield 0.5rt + { foot right } @Yield 1.0rt + { mctr } @Yield 0.5bx + else @Yield x + } + } + + def @VSize right x + { + vsize @Case { + "" @Yield x + else @Yield { vsize @High { /{@Indent vindent} x / } } + } + } + + def @HSize right x + { + hsize @Case { + "" @Yield x + else @Yield { hsize @Wide { |{@Indent hindent} x | } } + } + } + + def @Align right x + { + x @Case { + { top left } @Yield 0.0w + { ctr } @Yield 0.5w + { foot right } @Yield 1.0w + { mark } @Yield "+0i" + else @Yield x + } + } + + def @ALabel + { + @DoLabel + which { "a" } + label { alabel @Else nodelabel } + labelmargin { alabelmargin @Else nodelabelmargin } + labelfont { alabelfont @Else nodelabelfont } + labelbreak { alabelbreak @Else nodelabelbreak } + labelformat { alabelformat @Body @Else nodelabelformat @Body} + labelpos { alabelpos @Else nodelabelpos } + labelprox { alabelprox @Else nodelabelprox } + labelangle { alabelangle @Else nodelabelangle } + labelctr { alabelctr @Else nodelabelctr } + labeladjust { alabeladjust @Else nodelabeladjust } + } + + def @BLabel + { + @DoLabel + which { "b" } + label { blabel @Else nodelabel } + labelmargin { blabelmargin @Else nodelabelmargin } + labelfont { blabelfont @Else nodelabelfont } + labelbreak { blabelbreak @Else nodelabelbreak } + labelformat { blabelformat @Body @Else nodelabelformat @Body} + labelpos { blabelpos @Else nodelabelpos } + labelprox { blabelprox @Else nodelabelprox } + labelangle { blabelangle @Else nodelabelangle } + labelctr { blabelctr @Else nodelabelctr } + labeladjust { blabeladjust @Else nodelabeladjust } + } + + def @CLabel + { + @DoLabel + which { "c" } + label { clabel @Else nodelabel } + labelmargin { clabelmargin @Else nodelabelmargin } + labelfont { clabelfont @Else nodelabelfont } + labelbreak { clabelbreak @Else nodelabelbreak } + labelformat { clabelformat @Body @Else nodelabelformat @Body} + labelpos { clabelpos @Else nodelabelpos } + labelprox { clabelprox @Else nodelabelprox } + labelangle { clabelangle @Else nodelabelangle } + labelctr { clabelctr @Else nodelabelctr } + labeladjust { clabeladjust @Else nodelabeladjust } + } + + def @DLabel + { + @DoLabel + which { "d" } + label { dlabel @Else nodelabel } + labelmargin { dlabelmargin @Else nodelabelmargin } + labelfont { dlabelfont @Else nodelabelfont } + labelbreak { dlabelbreak @Else nodelabelbreak } + labelformat { dlabelformat @Body @Else nodelabelformat @Body} + labelpos { dlabelpos @Else nodelabelpos } + labelprox { dlabelprox @Else nodelabelprox } + labelangle { dlabelangle @Else nodelabelangle } + labelctr { dlabelctr @Else nodelabelctr } + labeladjust { dlabeladjust @Else nodelabeladjust } + } + + import @Geometry + def @OutLine + { + @BackEnd @Case { + PostScript @Yield { + outline @Case { + box @Yield { "ldiagbox" } + curvebox @Yield { "("margin") ldiagcurvebox" } + shadowbox @Yield { shadow "ldiagshadow ldiagbox" } + square @Yield { "ldiagsquare" } + diamond @Yield { "ldiagdiamond" } + polygon @Yield { sides angle "ldiagpolygon" } + isosceles @Yield { "ldiagisosceles" } + ellipse @Yield { "ldiagellipse" } + circle @Yield { "ldiagcircle" } + else @Yield { + outline + margin { "("margin") ldiagdecodelength" } + shadow { shadow } + sides { sides } + angle { angle } + } + } + } + PDF @Yield {} + } + } + + def @Value + { + @BackEnd @Case { + PostScript @Yield { + @HContract @VContract + { + { + "ldiagnodebegin [" @OutLine "]" + outlinedashlength "[" outlinestyle "]" + outlinewidth "/ldiag"paint "ldiagnodeend" + "(IN) ldiagpushtagdict" + // + "ldiagpopuptagdict" + } + @Graphic + { + {@Align valign} @VShift {@Align halign} @HShift + @AddMargins + mtop { topmargin @Else vmargin @Else margin } + mfoot { footmargin @Else vmargin @Else margin } + mleft { leftmargin @Else hmargin @Else margin } + mright { rightmargin @Else hmargin @Else margin } + @HSize @VSize @HContract @VContract + font @Font break @Break format @Strut @Body + } + / {alabel @Else nodelabel} @IfNonEmpty @ALabel + / {blabel @Else nodelabel} @IfNonEmpty @BLabel + / {clabel @Else nodelabel} @IfNonEmpty @CLabel + / {dlabel @Else nodelabel} @IfNonEmpty @DLabel + } + } + PDF @Yield {} + } + } + + def @TValue + { + nodetag @Case { + "" @Yield @Value + else @Yield { nodetag:: @Value } + } + } + + translate @Case { + "" @Yield @TValue + else @Yield { + @Null & # so that preceding space gets chewed up + @Transform translate { translate } rotate { rotate } @TValue + } + } + } + + + ####################################################################### + # # + # @Box, @CurveBox, and other standard node abbreviations # + # # + ####################################################################### + macro @@Node { @Node } macro @Box { @Node outline { box } } macro @CurveBox { @Node outline { curvebox } } @@ -1920,6 +3572,12 @@ def @DiagSetup macro @Circle { @Node outline { circle } } + ####################################################################### + # # + # Arrowheads # + # # + ####################################################################### + macro @InsulatedNode { @Node topmargin { 0i } @@ -2202,6 +3860,13 @@ def @DiagSetup } } + + ####################################################################### + # # + # @Link # + # # + ####################################################################### + def @Link import @Geometry named path named from {} @@ -3575,6 +5240,13 @@ def @DiagSetup } } + + ####################################################################### + # # + # Abbreviations for standard link types # + # # + ####################################################################### + macro @Line { @Link path { line } } macro @DoubleLine { @Link path { doubleline } } macro @Arrow { @Link path { line } arrow { yes } } @@ -3616,6 +5288,13 @@ def @DiagSetup macro @UWrapCurve { @Link path {uwrapcurve} } macro @UWrapCurveArrow { @Link path {uwrapcurve} arrow { yes } } + + ####################################################################### + # # + # Tree code. # + # # + ####################################################################### + export @Node @Box @CurveBox @ShadowBox @Square @Diamond @@ -3828,18 +5507,953 @@ def @DiagSetup @HContract @VContract x } - @BackEnd @Case { - PostScript @Yield { - { - save @Case { { yes Yes } @Yield "grestore save gsave" else @Yield {} } - maxlabels "ldiagbegin" - // - "ldiagend" - save @Case { { yes Yes } @Yield "restore" else @Yield {} } - } @Graphic @Body - } - PDF @Yield {} + + ####################################################################### + # # + # Syntax diagrams code # + # # + # Helper definitions; also skips # + # # + ####################################################################### + + def pslength right x { "("x") ldiagdecodelength" } + def pssyntaxgap { "("syntaxgap") ldiagdecodelength" } + def pssyntaxbias { "("syntaxbias") ldiagdecodelength" } + def pssyntaxradius { "("syntaxradius") ldiagdecodelength" } + + def @ArrowLeftFrom left direction right pt + { + @Line arrow { direction } from { pt } to { pt -- { pssyntaxgap 0 } } + } + + def @ArrowRightFrom left direction right pt + { + @Line arrow { direction } from { pt } to { pt ++ { pssyntaxgap 0 } } + } + + def @ArrowUpFrom left direction right pt + { + @Line arrow { direction } from { pt } to { pt ++ { 0 pssyntaxgap } } + } + + def @ArrowDownFrom left direction right pt + { + @Line arrow { direction } from { pt } to { pt -- { 0 pssyntaxgap } } + } + + macro @LineLeftFrom { no @ArrowLeftFrom } + macro @LineRightFrom { no @ArrowRightFrom } + macro @LineUpFrom { no @ArrowUpFrom } + macro @LineDownFrom { no @ArrowDownFrom } + + macro @Right { "1p" } + macro @Up { "2p" } + macro @Left { "3p" } + macro @Down { "4p" } + + macro @CurrDirection { @CurrZUnit } + + def @GoRight right x { @Right @ZUnit x } + def @GoUp right x { @Up @ZUnit x } + def @GoLeft right x { @Left @ZUnit x } + def @GoDown right x { @Down @ZUnit x } + + def @GoReverse right x + { + @CurrDirection @Case { + @Right @Yield @GoLeft x + @Up @Yield @GoDown x + @Left @Yield @GoRight x + @Down @Yield @GoUp x + } + } + + + def @LabelMarks right x { + @HContract @VContract @ANode + outline { + NMK:: { xmark ysize } + SMK:: { xmark 0 } + WMK:: { 0 ymark } + EMK:: { xsize ymark } + NW:: { 0 ysize } + SW:: { 0 0 } + SE:: { xsize 0 } + NE:: { xsize ysize } + } + font {} + margin { 0c } + vstrut { no } + outlinestyle { noline } + halign { mark } + valign { mark } + x + } + + def @HSkip + { + OX:: @LabelMarks { syntaxgap @Wide {} } + / @Line from { "OX@WMK" } to { "OX@EMK" } + } + + def @VSkip + { + OX:: @LabelMarks { syntaxgap @High {} } + / @Line from { "OX@NMK" } to { "OX@SMK" } + } + + def @Skip + { + @CurrDirection @Case { + { @Left @Right } @Yield @HSkip + { @Up @Down } @Yield @VSkip + } + } + + def @LRLine right x + { + @HContract @VContract { @HSkip | x | @HSkip } + } + + def @UDLine right x + { + @HContract @VContract { @VSkip / x / @VSkip } + } + + + ####################################################################### + # # + # Ordinary starts: @StartRight, @StartUp, @StartLeft, @StartDown # + # # + ####################################################################### + + def @StartRight right x + { + @VContract { + @LabelMarks { + |syntaxgap @GoRight x |syntaxgap + } + / @LineRightFrom WMK + / back @ArrowLeftFrom EMK + } + } + + def @StartUp right x + { + @VContract { + @LabelMarks { + ^/syntaxgap @GoUp x /syntaxgap + } + / @LineUpFrom SMK + / back @ArrowDownFrom NMK + } + } + + def @StartLeft right x + { + @VContract { + @LabelMarks { + |syntaxgap @GoLeft x |syntaxgap + } + / @LineLeftFrom EMK + / back @ArrowRightFrom WMK + } + } + + def @StartDown right x + { + @VContract { + @LabelMarks { + ^/syntaxgap @GoDown x /syntaxgap + } + / @LineDownFrom NMK + / back @ArrowUpFrom SMK + } + } + + + ####################################################################### + # # + # Fancy starts: @StartRightRight, @StartRightDown # + # # + ####################################################################### + + def @StartRightRight + named A {} + named B {} + { + AA:: @LabelMarks { @HSkip & @GoRight A } + //syntaxgap + //syntaxgap + |syntaxgap |syntaxgap |syntaxgap |syntaxgap |syntaxgap |syntaxgap + CC:: @LabelMarks {} + //syntaxgap + //syntaxgap + |syntaxgap |syntaxgap |syntaxgap |syntaxgap |syntaxgap |syntaxgap + BB:: @LabelMarks { @GoRight B & @HSkip } + // @RVLCurve from { AA@EMK } to { CC@WMK } + bias { pssyntaxbias } radius { pssyntaxradius } + // @LVRCurve from { CC@WMK } to { BB@WMK } + bias { pssyntaxbias } radius { pssyntaxradius } + back @ArrowLeftFrom BB@EMK + } + + def @StartRightDown + named A {} + named B {} + { + @HContract @VContract { + / BB:: @LabelMarks |syntaxgap AA::@LabelMarks @GoRight A |syntaxbias + /syntaxgap | | + /syntaxgap | | + } + / @Line from { BB@EMK } to { AA@WMK } + / @RVLCurve from { AA@EMK } to { xcoord AA@EMK pssyntaxgap } + bias { pssyntaxbias } radius { pssyntaxradius } + / @HVCurve from { xcoord AA@EMK pssyntaxgap } to { 0 0 } + bias { pssyntaxbias } radius { pssyntaxradius } + / @GoDown B + / @VSkip + / CC:: @LabelMarks {} + / back @ArrowUpFrom CC@NMK + } + + + ####################################################################### + # # + # Cells: @XCell, @ACell, @BCell, @CCell # + # # + ####################################################################### + + def @RightCell right x + { + @VContract { + @LabelMarks { + |syntaxgap x |syntaxgap + } + / forward @ArrowRightFrom WMK + / @LineLeftFrom EMK + } + } + + def @LeftCell right x + { + @VContract { + @LabelMarks { + |syntaxgap x |syntaxgap + } + / forward @ArrowLeftFrom EMK + / @LineRightFrom WMK + } + } + + def @DownCell right x + { + @VContract { + @LabelMarks { + ^/syntaxgap x /syntaxgap + } + / forward @ArrowDownFrom NMK + / @LineUpFrom SMK + } + } + + def @UpCell right x + { + @VContract { + @LabelMarks { + ^/syntaxgap x /syntaxgap + } + / forward @ArrowUpFrom SMK + / @LineDownFrom NMK + } + } + + def @XCell right x + { + @CurrDirection @Case { + @Right @Yield @RightCell x + @Up @Yield @UpCell x + @Left @Yield @LeftCell x + @Down @Yield @DownCell x + } + } + + macro @ACell { @XCell @ANode } + macro @BCell { @XCell @BNode } + macro @CCell { @XCell @CNode } + + + ####################################################################### + # # + # @Sequence # + # # + ####################################################################### + + def @Sequence + named A {} + named B {} + named C {} + named D {} + named E {} + named F {} + named G {} + named H {} + named I {} + named J {} + named K {} + named L {} + { + + @CurrDirection @Case { + @Right @Yield + @HContract { A | B | C | D | E | F | G | H | I | J | K | L } + @Up @Yield + @VContract { L / K / J / I / H / G / F / E / D / C / B / A } + @Left @Yield + @HContract { L | K | J | I | H | G | F | E | D | C | B | A } + @Down @Yield + @VContract { A / B / C / D / E / F / G / H / I / J / K / L } + } + } + + + ####################################################################### + # # + # @Select and @Optional # + # # + ####################################################################### + + def @Select + named A {} + named B {} + named C {} + named D {} + named E {} + named F {} + named G {} + named H {} + named I {} + named J {} + named K {} + named L {} + { + + def @RLFirstOrMiddle + left label + named i { 0i } + named al { no } + named ar { no } + right x + { + {|i @HContract { |syntaxgap label:: @LabelMarks x |syntaxgap }} + // @Line from { label"@WMK" } to { 0 ycoord label"@WMK" } + arrow { al } + // @Line from { label"@EMK" } to { xsize ycoord label"@EMK" } + arrow { ar } + } + + def @UDFirstOrMiddle + left label + named i { 0i } + named au { no } + named ad { no } + right x + { + {/i @VContract { /syntaxgap label:: @LabelMarks x /syntaxgap }} + || @Line from { label"@NMK" } to { xcoord label"@NMK" ysize } + arrow { au } + || @Line from { label"@SMK" } to { xcoord label"@SMK" 0 } + arrow { ad } + } + + def @RLLast + left label + named i { 0i } + named al { no } + named ar { no } + right x + { + {|i @HContract { |syntaxgap label:: @LabelMarks x |syntaxgap }} + // @HVCurve from { label"@WMK" } to { 0 ycoord "AX@WMK" } + arrow { al } bias { pssyntaxbias } radius { pssyntaxradius } + // @HVCurve from { label"@EMK" } to { xsize ycoord "AX@WMK" } + arrow { ar } bias { pssyntaxbias } radius { pssyntaxradius } + } + + def @UDLast + left label + named i { 0i } + named au { no } + named ad { no } + right x + { + {/i @VContract { /syntaxgap label:: @LabelMarks x /syntaxgap }} + || @VHCurve from { label"@NMK" } to { xcoord "AX@NMK" ysize } + arrow { au } bias { pssyntaxbias } radius { pssyntaxradius } + || @VHCurve from { label"@SMK" } to { xcoord "AX@SMK" 0 } + arrow { ad } bias { pssyntaxbias } radius { pssyntaxradius } + } + + def @DirectedSelect + named @First left label right x {} + named @Middle left label right x {} + named @Last left label right x {} + named @Join precedence 90 left x right y {} + { + + def @LastIsA + { + A + } + + def @LastIsB + { + AX @First A + @Join BX @Last B + } + + def @LastIsC + { + AX @First A + @Join BX @Middle B + @Join CX @Last C + } + + def @LastIsD + { + AX @First A + @Join BX @Middle B + @Join CX @Middle C + @Join DX @Last D + } + + def @LastIsE + { + AX @First A + @Join BX @Middle B + @Join CX @Middle C + @Join DX @Middle D + @Join EX @Last E + } + + def @LastIsF + { + AX @First A + @Join BX @Middle B + @Join CX @Middle C + @Join DX @Middle D + @Join EX @Middle E + @Join FX @Last F + } + + def @UpToF + { + AX @First A + @Join BX @Middle B + @Join CX @Middle C + @Join DX @Middle D + @Join EX @Middle E + @Join FX @Middle F + } + + def @LastIsG + { + @UpToF + @Join GX @Last G + } + + def @LastIsH + { + @UpToF + @Join GX @Middle G + @Join HX @Last H + } + + def @LastIsI + { + @UpToF + @Join GX @Middle G + @Join HX @Middle H + @Join IX @Last I + } + + def @LastIsJ + { + @UpToF + @Join GX @Middle G + @Join HX @Middle H + @Join IX @Middle I + @Join JX @Last J + } + + def @LastIsK + { + @UpToF + @Join GX @Middle G + @Join HX @Middle H + @Join IX @Middle I + @Join JX @Middle J + @Join KX @Last K + } + + def @LastIsL + { + @UpToF + @Join GX @Middle G + @Join HX @Middle H + @Join IX @Middle I + @Join JX @Middle J + @Join KX @Middle K + @Join LX @Last L + } + + def @TryA { A @Case { {} @Yield @Skip else @Yield @LastIsA } } + def @TryB { B @Case { {} @Yield @TryA else @Yield @LastIsB } } + def @TryC { C @Case { {} @Yield @TryB else @Yield @LastIsC } } + def @TryD { D @Case { {} @Yield @TryC else @Yield @LastIsD } } + def @TryE { E @Case { {} @Yield @TryD else @Yield @LastIsE } } + def @TryF { F @Case { {} @Yield @TryE else @Yield @LastIsF } } + def @TryG { G @Case { {} @Yield @TryF else @Yield @LastIsG } } + def @TryH { H @Case { {} @Yield @TryG else @Yield @LastIsH } } + def @TryI { I @Case { {} @Yield @TryH else @Yield @LastIsI } } + def @TryJ { J @Case { {} @Yield @TryI else @Yield @LastIsJ } } + def @TryK { K @Case { {} @Yield @TryJ else @Yield @LastIsK } } + def @TryL { L @Case { {} @Yield @TryK else @Yield @LastIsL } } + + @TryL + } + + def @RightSelect + { + @LRLine @DirectedSelect + @First { label @RLFirstOrMiddle x } + @Middle { label @RLFirstOrMiddle ar { yes } x } + @Last { label @RLLast ar { yes } x } + @Join { x //syntaxgap y } + } + + def @UpSelect + { + @UDLine @DirectedSelect + @First { label @UDFirstOrMiddle i { 1r } x } + @Middle { label @UDFirstOrMiddle i { 1r } au { yes } x } + @Last { label @UDLast i { 1r } au { yes } x } + @Join { x ||syntaxgap y } + } + + def @LeftSelect + { + @LRLine @DirectedSelect + @First { label @RLFirstOrMiddle i { 1r } x } + @Middle { label @RLFirstOrMiddle i { 1r } al { yes } x } + @Last { label @RLLast i { 1r } al { yes } x } + @Join { x //syntaxgap y } + } + + def @DownSelect + { + @UDLine @DirectedSelect + @First { label @UDFirstOrMiddle x } + @Middle { label @UDFirstOrMiddle ad { yes } x } + @Last { label @UDLast ad { yes } x } + @Join { x ||syntaxgap y } + } + + @CurrDirection @Case { + @Right @Yield @RightSelect + @Up @Yield @UpSelect + @Left @Yield @LeftSelect + @Down @Yield @DownSelect + } + } + + + def @Optional right x + { + @Select A { @Skip } B { x } + } + + + ####################################################################### + # # + # @OptionalDiverted # + # # + ####################################################################### + + def @DownRightOptionalDiverted right x + { + @UDLine { + OX:: @LabelMarks { + |syntaxgap AX:: @LabelMarks @GoRight x |syntaxbias + /syntaxgap + } + / @Line from { "OX@NW" } to { "OX@SW" } + / @Line from { "OX@WMK" } to { "OX@IN@AX@WMK" } + / @RVLCurveArrow from { "OX@IN@AX@EMK" } to { "OX@SW" } + bias { pssyntaxbias } radius { pssyntaxradius } + } + } + + def @UpRightOptionalDiverted right x + { + @UDLine { + OX:: @LabelMarks { + ^/syntaxgap + |syntaxgap AX:: @LabelMarks @GoRight x |syntaxbias + } + / @Line from { "OX@NW" } to { "OX@SW" } + / @Line from { "OX@WMK" } to { "OX@IN@AX@WMK" } + / @RVLCurveArrow from { "OX@IN@AX@EMK" } to { "OX@NW" } + bias { pssyntaxbias } radius { pssyntaxradius } + } + } + + def @RightDownOptionalDiverted right x + { + @LRLine { + OX:: @LabelMarks { + { /syntaxgap AX:: @LabelMarks @GoDown x /syntaxbias } + |syntaxgap + } + / @Line from { "OX@NW" } to { "OX@NE" } + / @Line from { "OX@NMK" } to { "OX@IN@AX@NMK" } + / @VHCurve from {"OX@IN@AX@SMK"} to { "OX@SE"--{pssyntaxgap 0} } + bias { pssyntaxbias } radius { pssyntaxradius } + / @HVCurve from { "OX@SE" -- {pssyntaxgap 0} } to { "OX@NE" } + arrow { yes } bias { pssyntaxbias } radius { pssyntaxradius } + } + } + + def @LeftDownOptionalDiverted right x + { + @LRLine { + OX:: @LabelMarks { + ^|syntaxgap + { /syntaxgap AX:: @LabelMarks @GoDown x /syntaxbias } + } + / @Line from { "OX@NW" } to { "OX@NE" } + / @Line from { "OX@NMK" } to { "OX@IN@AX@NMK" } + / @VHCurve from {"OX@IN@AX@SMK"} to { "OX@SW"++{pssyntaxgap 0} } + bias { pssyntaxbias } radius { pssyntaxradius } + / @HVCurve from { "OX@SW" ++ {pssyntaxgap 0} } to { "OX@NW" } + arrow { yes } bias { pssyntaxbias } radius { pssyntaxradius } + } + } + + def @OptionalDiverted right x + { + @CurrDirection @Case { + @Right @Yield @RightDownOptionalDiverted x + @Up @Yield @UpRightOptionalDiverted x + @Left @Yield @LeftDownOptionalDiverted x + @Down @Yield @DownRightOptionalDiverted x + } + } + + + ####################################################################### + # # + # @Diverted # + # # + ####################################################################### + + def @DownRightDiverted right x + { + @UDLine { + OX:: @LabelMarks { + |syntaxgap AX:: @LabelMarks @GoRight x |syntaxbias + ^/syntaxgap + /syntaxgap + } + / @VHCurve from { "OX@NW" } to { "OX@IN@AX@WMK" } + bias { pssyntaxbias } radius { pssyntaxradius } + / @RVLCurve from { "OX@IN@AX@EMK" } + to { xcoord "OX@IN@AX@WMK" ycoord "OX@EMK" } + bias { pssyntaxbias } radius { pssyntaxradius } + / @HVCurve from { xcoord "OX@IN@AX@WMK" ycoord "OX@EMK" } + to { "OX@SW" } bias { pssyntaxbias } radius {pssyntaxradius} + } + } + + def @UpRightDiverted right x + { + @UDLine { + OX:: @LabelMarks { + ^/syntaxgap + /syntaxgap + |syntaxgap AX:: @LabelMarks @GoRight x |syntaxbias + } + / @VHCurve from { "OX@SW" } to { "OX@IN@AX@WMK" } + bias { pssyntaxbias } radius { pssyntaxradius } + / @RVLCurve from { "OX@IN@AX@EMK" } + to { xcoord "OX@IN@AX@WMK" ycoord "OX@EMK" } + bias { pssyntaxbias } radius { pssyntaxradius } + / @HVCurve from { xcoord "OX@IN@AX@WMK" ycoord "OX@EMK" } + to { "OX@NW" } bias { pssyntaxbias } radius {pssyntaxradius} + } + } + + def @RightDownDiverted right x + { + @LRLine { + OX:: @LabelMarks { + { /syntaxgap AX:: @LabelMarks @GoDown x /syntaxbias } + ^|syntaxgap + |syntaxgap + } + / @HVCurve from { "OX@NW" } to { "OX@IN@AX@NMK" } + bias { pssyntaxbias } radius { pssyntaxradius } + / @VHCurve from { "OX@IN@AX@SMK" } + to { xcoord "OX@IN@AX@EMK" ycoord "OX@SMK" } + bias { pssyntaxbias } radius { pssyntaxradius } + / @HVCurve from { xcoord "OX@IN@AX@EMK" ycoord "OX@SMK" } + to { "OX@IN@AX@EMK" ++ { pssyntaxgap 0 } } + bias { pssyntaxbias } radius {pssyntaxradius} + / @VHCurve from { "OX@IN@AX@EMK" ++ { pssyntaxgap 0 } } + to { "OX@NE" } bias { pssyntaxbias } radius {pssyntaxradius} + } + } + + def @LeftDownDiverted right x + { + @LRLine { + OX:: @LabelMarks { + |syntaxgap + ^|syntaxgap + { /syntaxgap AX:: @LabelMarks @GoDown x /syntaxbias } + } + / @HVCurve from { "OX@NE" } to { "OX@IN@AX@NMK" } + bias { pssyntaxbias } radius { pssyntaxradius } + / @VHCurve from { "OX@IN@AX@SMK" } + to { xcoord "OX@IN@AX@WMK" ycoord "OX@SMK" } + bias { pssyntaxbias } radius { pssyntaxradius } + / @HVCurve from { xcoord "OX@IN@AX@WMK" ycoord "OX@SMK" } + to { "OX@IN@AX@WMK" -- { pssyntaxgap 0 } } + bias { pssyntaxbias } radius {pssyntaxradius} + / @VHCurve from { "OX@IN@AX@WMK" -- { pssyntaxgap 0 } } + to { "OX@NW" } bias { pssyntaxbias } radius {pssyntaxradius} + } + } + + def @Diverted right x + { + @CurrDirection @Case { + @Right @Yield @RightDownDiverted x + @Up @Yield @UpRightDiverted x + @Left @Yield @LeftDownDiverted x + @Down @Yield @DownRightDiverted x + } + } + + + ####################################################################### + # # + # @RepeatDiverted # + # # + ####################################################################### + + def @RepeatDiverted right x + { + # this implementation exploits the coincidental similarity + # of @RepeatDiverted to @OptionalDiverted + + @CurrDirection @Case { + @Right @Yield @LeftDownOptionalDiverted x + @Up @Yield @DownRightOptionalDiverted x + @Left @Yield @RightDownOptionalDiverted x + @Down @Yield @UpRightOptionalDiverted x + } + } + + + + ####################################################################### + # # + # @Loop and @Repeat # + # # + ####################################################################### + + def @Loop + named A {} + named B {} + { + def @LeftOrRightLoop + named al { no } + named ar { no } + { + @LRLine { + @HContract @VContract { OX:: @LabelMarks { + { |syntaxgap AX:: @LabelMarks A |syntaxgap } + //syntaxgap + { |0.5rt BX:: @LabelMarks @GoReverse B |syntaxgap } + } } + / @Line from { "OX@WMK" } to { "OX@IN@AX@WMK" } + / @Line from { "OX@EMK" } to { "OX@IN@AX@EMK" } + / @HVCurve from { "OX@IN@BX@EMK" } to { "OX@EMK" } + arrow { ar } bias {pssyntaxbias} radius {pssyntaxradius} + / @HVCurve from { "OX@IN@BX@WMK" } to { "OX@WMK" } + arrow { al } bias {pssyntaxbias} radius {pssyntaxradius} + } + } + + def @UpOrDownLoop + named au { no } + named ad { no } + { + @UDLine { + @HContract @VContract { OX:: @LabelMarks { + { /syntaxgap AX:: @LabelMarks A /syntaxgap } + ||syntaxgap + { /0.5rt BX:: @LabelMarks @GoReverse B /syntaxgap } + } } + / @Line from { "OX@NMK" } to { "OX@IN@AX@NMK" } + / @Line from { "OX@SMK" } to { "OX@IN@AX@SMK" } + / @VHCurve from { "OX@IN@BX@NMK" } to { "OX@NMK" } + arrow { au } bias {pssyntaxbias} radius {pssyntaxradius} + / @VHCurve from { "OX@IN@BX@SMK" } to { "OX@SMK" } + arrow { ad } bias {pssyntaxbias} radius {pssyntaxradius} + } + } + + @CurrDirection @Case { + @Right @Yield @LeftOrRightLoop al { yes } + @Up @Yield @UpOrDownLoop ad { yes } + @Left @Yield @LeftOrRightLoop ar { yes } + @Down @Yield @UpOrDownLoop au { yes } + } + } + + def @Repeat right x + { + @Loop + A { x } + B { @Skip } + } + + + ####################################################################### + # # + # @LoopOpposite and @RepeatOpposite # + # # + ####################################################################### + + def @LoopOpposite + named A {} + named B {} + { + def @LeftOrRightLoopOpposite + named al { no } + named ar { no } + { + @LRLine { + @HContract @VContract { OX:: @LabelMarks { + { |0.5rt BX:: @LabelMarks @GoReverse B |syntaxgap } + ^//syntaxgap + { |syntaxgap AX:: @LabelMarks A |syntaxgap } + } } + / @Line from { "OX@WMK" } to { "OX@IN@AX@WMK" } + / @Line from { "OX@EMK" } to { "OX@IN@AX@EMK" } + / @HVCurve from { "OX@IN@BX@EMK" } to { "OX@EMK" } + arrow { ar } bias {pssyntaxbias} radius {pssyntaxradius} + / @HVCurve from { "OX@IN@BX@WMK" } to { "OX@WMK" } + arrow { al } bias {pssyntaxbias} radius {pssyntaxradius} + } + } + + def @UpOrDownLoopOpposite + named au { no } + named ad { no } + { + @UDLine { + @HContract @VContract { OX:: @LabelMarks { + { /0.5rt BX:: @LabelMarks @GoReverse B /syntaxgap } + ^||syntaxgap + { /syntaxgap AX:: @LabelMarks A /syntaxgap } + } } + / @Line from { "OX@NMK" } to { "OX@IN@AX@NMK" } + / @Line from { "OX@SMK" } to { "OX@IN@AX@SMK" } + / @VHCurve from { "OX@IN@BX@NMK" } to { "OX@NMK" } + arrow { au } bias {pssyntaxbias} radius {pssyntaxradius} + / @VHCurve from { "OX@IN@BX@SMK" } to { "OX@SMK" } + arrow { ad } bias {pssyntaxbias} radius {pssyntaxradius} + } + } + + @CurrDirection @Case { + @Right @Yield @LeftOrRightLoopOpposite al { yes } + @Up @Yield @UpOrDownLoopOpposite ad { yes } + @Left @Yield @LeftOrRightLoopOpposite ar { yes } + @Down @Yield @UpOrDownLoopOpposite au { yes } + } + } + + def @RepeatOpposite right x + { + @LoopOpposite + A { x } + B { @Skip } + } + + + ####################################################################### + # # + # Value of whole diagram # + # # + ####################################################################### + + def @DiagValue right x + { + @BackEnd @Case { + PostScript @Yield { + { + save @Case { + { yes Yes } @Yield "grestore save gsave" + else @Yield {} + } + maxlabels "ldiagbegin" + // + "ldiagend" + save @Case { + { yes Yes } @Yield "restore" + else @Yield {} + } + } @Graphic x } + + PDF @Yield {} + } + } + + title @Case { + + "--titledft--" @Yield @DiagValue @Body + + else @Yield { title titleformat @DiagValue @Body } } @End @Diag + + + macro @SyntaxDiag { + @Diag + avalign { mark } + avstrut { yes } + amargin { 0.2f } + aoutline { box } + afont { Italic } + + bvalign { mark } + bvstrut { yes } + bmargin { 0.2f } + boutline { curvebox } + bfont { Bold } + + cvalign { mark } + cvstrut { yes } + cmargin { 0.2f } + coutline { circle } + chsize { 1f } + + arrowlength { 0.4f } + } } diff --git a/include/doc b/include/doc index 7dda601..cf483ef 100644 --- a/include/doc +++ b/include/doc @@ -103,9 +103,12 @@ # @TableNumbers { Arabic } # method of numbering tables # @FigureCaptionPos { Below } # Above or Below # @TableCaptionPos { Below } # Above or Below - # @CaptionFont { } # figure, table caption font - # @CaptionBreak { } # figure, table caption break - # @CaptionFormat { @B { number @DotSep @OneCol } } # figure, table caption format + # @FigureCaptionFont { -2p } # figure caption font + # @FigureCaptionBreak { adjust hyphen 1.2fx } # figure caption break + # @FigureCaptionFormat{ {@B { word @NumSep number. &2s }} @Insert caption } + # @TableCaptionFont { -2p } # table caption font + # @TableCaptionBreak { adjust hyphen 1.2fx } # table caption break + # @TableCaptionFormat { {@B { word @NumSep number. &2s }} @Insert caption } # @MakeFigureContents { No } # list of figures at start # @MakeTableContents { No } # list of tables at start # @MakeContents { No } # make contents? Yes or No diff --git a/include/dsf b/include/dsf index 082c59d..fda93f9 100644 --- a/include/dsf +++ b/include/dsf @@ -96,14 +96,14 @@ def @DocumentSetup named @TableNumbers { Arabic } # method of numbering tables named @FigureCaptionPos { Below } # Above or Below named @TableCaptionPos { Below } # Above or Below - named @FigureCaptionFont { } # figure caption font - named @FigureCaptionBreak { } # figure caption break + named @FigureCaptionFont { -2p } # figure caption font + named @FigureCaptionBreak { adjust hyphen 1.2fx } # figure caption break named @FigureCaptionFormat named word {} named number {} named caption {} - { @B { word @NumSep number. &2s } @Insert caption } - named @TableCaptionFont { } # figure caption font - named @TableCaptionBreak { } # figure caption break + { {@B { word @NumSep number. &2s }} @Insert caption } + named @TableCaptionFont { -2p } # figure caption font + named @TableCaptionBreak { adjust hyphen 1.2fx } # figure caption break named @TableCaptionFormat named word {} named number {} named caption {} - { @B { word @NumSep number. &2s } @Insert caption } + { {@B { word @NumSep number. &2s }} @Insert caption } named @MakeFigureContents { No } # list of figures at start named @MakeTableContents { No } # list of tables at start named @MakeContents { No } # make contents? Yes or No @@ -3425,7 +3425,7 @@ def @DocumentSetup def @NoCite body cite { macro "$" { @NoRef } - def "," precedence 90 left x { x } + def "," precedence 90 left x { x"," } def ";" precedence 90 left x { x";" } @MakeReferences @Case { diff --git a/include/eiffel b/include/eiffel new file mode 100644 index 0000000..a55d5f7 --- /dev/null +++ b/include/eiffel @@ -0,0 +1,71 @@ +############################################################################### +# # +# Lout setup file for Eiffel program printing # +# # +# Jeffrey H. Kingston # +# 23 February 2000 # +# # +############################################################################### + + +############################################################################### +# # +# The @SysInclude { eiffelf } line # +# # +# This line causes Lout to read the definitions for Eiffel, and should # +# not be touched. # +# # +############################################################################### + +@SysInclude { eiffelf } + + +############################################################################### +# # +# The @EiffelSetup @Use clause # +# # +# To change the default value of any option, delete the # at the start of # +# its line and change the value between braces. # +# # +############################################################################### + +@Use { @EiffelSetup + # style { varying @OrIfPlain fixed } # fixed, varying, or symbol + # pipe { } # pipe source through this + + # fixedfont { Courier } # font family if fixed + # fixedstrings { Base } # string face if fixed + # fixedidentifiers { Base } # identifier face if fixed + # fixedcomments { Base } # comment face if fixed + # fixedkeywords { Base } # keyword face if fixed + # fixednumbers { Base } # number face if fixed + # fixedoperators { Base } # operator face if fixed + # fixedsize { -1.0p } # font size if fixed + # fixedline { 1.0vx } # line-space if fixed + # fixedtabin { 8 } # tab interval if fixed + # fixedtabout { 8s } # tab width if fixed + + # varyingfont { } # font family if varying + # varyingstrings { Slope } # string face if varying + # varyingidentifiers { Slope } # identifier face if varying + # varyingcomments { Base } # comment face if varying + # varyingkeywords { Bold } # keyword face if varying + # varyingnumbers { Base } # number face if varying + # varyingoperators { Base } # operator face if varying + # varyingsize { 1.0f } # font size if varying + # varyingline { 1.0vx } # line-space if varying + # varyingtabin { 8 } # tab interval if varying + # varyingtabout { 3f } # tab width if varying + + # symbolfont { } # font family if symbol + # symbolstrings { Slope } # string face if symbol + # symbolidentifiers { Slope } # identifier face if symbol + # symbolcomments { Base } # comment face if symbol + # symbolkeywords { Bold } # keyword face if symbol + # symbolnumbers { Base } # number face if symbol + # symboloperators { Base } # operator face if symbol + # symbolsize { 1.0f } # font size if symbol + # symbolline { 1.0vx } # line-space if symbol + # symboltabin { 8 } # tab interval if symbol + # symboltabout { 3f } # tab width if symbol +} diff --git a/include/eiffelf b/include/eiffelf new file mode 100644 index 0000000..5ba94e1 --- /dev/null +++ b/include/eiffelf @@ -0,0 +1,274 @@ + +############################################################################### +# # +# Lout @EiffelSetup package for formatting Eiffel programs # +# # +# Version 2.0 by Jeffrey H. Kingston, February 2000. # +# # +# This package uses a filtered body parameter to convert Eiffel source # +# code into Lout source. The filter program is prg2lout, which is # +# distributed with Lout and should be compiled and installed wherever # +# Lout itself is. # +# # +############################################################################### + +export @Eiffel +def @EiffelSetup + named style + named @OrIfPlain left x right y + { @BackEnd @Case { PlainText @Yield y else @Yield x } } + { varying @OrIfPlain fixed } # print style + named pipe { } # pipe through this first + + named fixedfont { Courier } # font family if fixed + named fixedstrings { Base } # string face if fixed + named fixedidentifiers { Base } # identifier face if fixed + named fixedcomments { Base } # comment face if fixed + named fixedkeywords { Base } # keyword face if fixed + named fixednumbers { Base } # number face if fixed + named fixedoperators { Base } # operator face if fixed + named fixedsize { -1.0p } # font size if fixed + named fixedline { 1.0vx } # line-space if fixed + named fixedtabin { 8 } # tab interval if fixed + named fixedtabout { 8s } # tab width if fixed + + named varyingfont { } # font family if varying + named varyingstrings { Slope } # string face if varying + named varyingidentifiers { Slope } # identifier face if varying + named varyingcomments { Base } # comment face if varying + named varyingkeywords { Bold } # keyword face if varying + named varyingnumbers { Base } # number face if varying + named varyingoperators { Base } # operator face if varying + named varyingsize { 1.0f } # font size if varying + named varyingline { 1.0vx } # line-space if varying + named varyingtabin { 8 } # tab interval if varying + named varyingtabout { 3f } # tab width if varying + + named symbolfont { } # font family if symbol + named symbolstrings { Slope } # string face if symbol + named symbolidentifiers { Slope } # identifier face if symbol + named symbolcomments { Base } # comment face if symbol + named symbolkeywords { Bold } # keyword face if symbol + named symbolnumbers { Base } # number face if symbol + named symboloperators { Base } # operator face if symbol + named symbolsize { 1.0f } # font size if symbol + named symbolline { 1.0vx } # line-space if symbol + named symboltabin { 8 } # tab interval if symbol + named symboltabout { 3f } # tab width if symbol + +@Begin + + export + + "$>" @S @D @C @K @N @O @A @ST @ED @M + + def @Eiffel + named style { style } # style + named pipe { pipe } # pipe through this first + named font { dft } # font family + named strings { dft } # string font + named identifiers { dft } # ident. font + named comments { dft } # comment font + named keywords { dft } # keyword font + named numbers { dft } # number font + named operators { dft } # operator font + named size { dft } # font size + named line { dft } # line-space + named tabin { dft } # tab interval + named tabout { dft } # tab width + body @Body # filtered, see below + @Begin + + def @Test # returns x unless x is dft + left x + named iffixed {} + named ifvarying {} + named ifsymbol {} + { + x @Case { + dft @Yield { + style @Case { + fixed @Yield { iffixed } + varying @Yield { ifvarying } + symbol @Yield { ifsymbol } + } + } + else @Yield x + } + } + + def @InitTab + { + tabin @Test + iffixed { fixedtabin } + ifvarying { varyingtabin } + ifsymbol { symboltabin } + } + + def @InitTabWidth + { + tabout @Test + iffixed { fixedtabout } + ifvarying { varyingtabout } + ifsymbol { symboltabout } + } + + def @Filter + { + pipe @Case { + "" @Yield { + "prg2lout -r -lEiffel" -i{@FilterIn} -o{@FilterOut} -e{@FilterErr} + -t{@InitTab} -T{@InitTabWidth} + } + else @Yield { + "cat" @FilterIn "|" pipe "|" + "prg2lout -r -lEiffel" -o{@FilterOut} + -e{@FilterErr} -t{@InitTab} -T{@InitTabWidth} + } + } + } + + def @InitFontFamily + { + font @Test + iffixed { fixedfont } + ifvarying { varyingfont } + ifsymbol { symbolfont } + } + + def @InitSize + { + size @Test + iffixed { fixedsize } + ifvarying { varyingsize } + ifsymbol { symbolsize } + } + + def @InitLine + { + line @Test + iffixed { fixedline } + ifvarying { varyingline } + ifsymbol { symbolline } + } + + def @S # for formatting strings + right x + { + # "\"" & + strings @Test + iffixed { fixedstrings } + ifvarying { varyingstrings } + ifsymbol { symbolstrings } + @Font x + # & "\"" + } + +# def "`" +# { +# style @Case { +# symbol @Yield { "`" } +# else @Yield { "'" } +# } +# } + + def @D # for formatting identifiers + right x + { + identifiers @Test + iffixed { fixedidentifiers } + ifvarying { varyingidentifiers } + ifsymbol { symbolidentifiers } + @Font x + } + + def @C # for formatting comments + right x + { + comments @Test + iffixed { fixedcomments } + ifvarying { varyingcomments } + ifsymbol { symbolcomments } + @Font x + } + + def @K # for formatting keywords + right x + { + keywords @Test + iffixed { fixedkeywords } + ifvarying { varyingkeywords } + ifsymbol { symbolkeywords } + @Font x + } + + def @N # for formatting numbers + right x + { + numbers @Test + iffixed { fixednumbers } + ifvarying { varyingnumbers } + ifsymbol { symbolnumbers } + @Font x + } + + def @O # for formatting operators + right x + { + operators @Test + iffixed { fixedoperators } + ifvarying { varyingoperators } + ifsymbol { symboloperators } + @Font x + } + + def @A # get characters from the Adobe Symbol font + left sym + right x + { + style @Case { + symbol @Yield { { Symbol Base } @Font @Char sym } + else @Yield { x } + } + } + + def @ST # for formatting asterisks + right x + { + operators @Test + iffixed { fixedoperators } + ifvarying { varyingoperators } + ifsymbol { symboloperators } + @Font "0.5w" @VShift x + } + + def @ED # for formatting larger dots + right x + { + operators @Test + iffixed { fixedoperators } + ifvarying { varyingoperators } + ifsymbol { symboloperators } + @Font @BackEnd @Case { + PlainText @Yield x + else @Yield { "1.2f" @Font "+0.05f" @VShift @O x &"0.05f" } + } + } + + macro "$>" { {} & } + + def @M right x + { + style @Case { + fixed @Yield "-" + varying @Yield { { Symbol Base } @Font @Char minus } + symbol @Yield { { Symbol Base } @Font @Char minus } + } + } + + { @InitFontFamily Base @InitSize } @Font + { @InitLine lines } @Break @Body + + @End @Eiffel + +@End @EiffelSetup diff --git a/include/eqf b/include/eqf index 4437edf..e03bb3e 100644 --- a/include/eqf +++ b/include/eqf @@ -22,7 +22,7 @@ # # ############################################################################### -export "`" "``" "```" bin rel punct non vctr big +export "`" "``" "```" bin rel punct non vctr big small space exclam universal numbersign existential percent ampersand suchthat parenleft parenright asteriskmath @@ -56,7 +56,8 @@ export "`" "``" "```" bin rel punct non vctr big bracerightbt hbar Re Im partial infty prime nabla surd top bot dbar - triangle backslash forall exists neg circle square + triangle backslash forall exists neg + circle filledcircle square "0" "1" "2" "3" "4" "5" "6" "7" "8" "9" @@ -64,14 +65,14 @@ export "`" "``" "```" bin rel punct non vctr big boplus buplus "+" "-" "+-" "-+" setminus cdot times "*" circ div cap cup uplus - sqcap sqcup triangleleft triangleright wr bigcirc bigtriangleup - bigtriangledown vee wedge oplus ominus otimes oslash odot dagger - daggerdbl amalg + sqcap sqcup triangleleft triangleright + wr bigcirc bigtriangleup bigtriangledown vee wedge oplus ominus + otimes oslash odot dagger daggerdbl amalg "<" ">" "=" "<=" prec preceq "<<" subset subseteq sqsubseteq in vdash smile frown ">=" succ succeq ">>" supset supseteq sqsupseteq ni dashv mid parallel "==" "~" "-~" asymp "~~" - "=~" bowtie propto models doteq perp notsub notin "!=" not + "=~" bowtie propto models doteq trieq perp notsub notin "!=" not "<->" "<--" "-->" up down "<=>" "<==" "==>" dblup dbldown ":" "::" ":=" @@ -98,7 +99,7 @@ export "`" "``" "```" bin rel punct non vctr big nearrow searrow swarrow nwarrow sup sub tsub supp on ton frac half third over from to widefrom wideto - dot dotdot hat tilde vec dyad overbar underbar sqrt root + dot dotdot hat tilde vec dyad overbar underbar sqrt root zroot nextcol above labove cabove rabove mabove matrix pmatrix bmatrix brmatrix fmatrix cmatrix amatrix @@ -164,6 +165,7 @@ def @Eq def punct right x { x ` } def non right x { 0c @YUnit x } def big right x { 1.3f @Font @SpaceGap @Space x } + def small right x { 0.6f @Font @SpaceGap @Space x } def @Base right x { Base @Font x } def @Sym right x { {Symbol Base} @Font x } @@ -460,93 +462,129 @@ def @Eq def exists { existential } def neg { logicalnot } - def circle { @HContract @VContract - @BackEnd @Case { - PostScript @Yield { - { "xsize ysize 2 div moveto" - "xsize 2 div ysize 2 div xsize 2 div 0 360 arc" - "0.04 ft setlinewidth stroke" - } - @Graphic { 0.7f @Wide 0.3f @High ^/ 0.3f @High } - } - PDF @Yield { -# -# VT: draws a counterclockwise 360 degree arc from 0 to +360 degree positions -# (straight right to straight right) with centre = (xsize/2, ysize/2) -# and radius = xsize/2 -# -# implemented as two counterclockwise 180 degree arcs: -# - { - "__mul(0.04, __loutf) w" -# -# start at (xsize, ysize/2) -# the control points are: -# pt1 = (xsize, ysize/2 + (4/3 * xsize/2)) and pt2 = (0, ysize/2 + (4/3 * xsize/2)) -# end at (0, ysize/2) -# - "__xsize __div(__ysize, 2) m" - "__xsize __add(__div(__ysize, 2), __div(__mul(2, __xsize), 3))" # pt1 - "0 __add(__div(__ysize, 2), __div(__mul(2, __xsize), 3))" # pt2 - "0 __div(__ysize, 2) c" # pt3 -# -# start at (0, ysize/2) -# the control points are: -# pt1 = (0, ysize/2 - (4/3 * xsize/2)) and pt2 = (xsize, ysize/2 - (4/3 * xsize/2)) -# end at (xsize, ysize/2) -# - "0 __sub(__div(__ysize, 2), __div(__mul(2, __xsize), 3))" # pt1 - "__xsize __sub(__div(__ysize, 2), __div(__mul(2, __xsize), 3))" # pt2 - "__xsize __div(__ysize, 2) c S" # pt3 - } - @Graphic { 0.7f @Wide 0.3f @High ^/ 0.3f @High } - } - } - } + def circle + { @HContract @VContract @BackEnd @Case { + PostScript @Yield { + { + "xsize ysize 2 div moveto" + "xsize 2 div ysize 2 div xsize 2 div 0 360 arc" + "0.04 ft setlinewidth stroke" + } @Graphic { 0.7f @Wide 0.3f @High ^/ 0.3f @High } + } + PDF @Yield { + # + # VT: draws a counterclockwise 360 degree arc from 0 to +360 + # degree positions (straight right to straight right) with + # centre = (xsize/2, ysize/2) and radius = xsize/2, + # implemented as two counterclockwise 180 degree arcs. + # start at (xsize, ysize/2); the control points are: + # + # pt1 = (xsize, ysize/2 + (4/3 * xsize/2)) + # pt2 = (0, ysize/2 + (4/3 * xsize/2)) + # + # end at (0, ysize/2). Then start at (0, ysize/2); control points + # + # pt1 = (0, ysize/2 - (4/3 * xsize/2)) + # pt2 = (xsize, ysize/2 - (4/3 * xsize/2)) + # + # and end at (xsize, ysize/2). + + { + "__mul(0.04, __loutf) w" + "__xsize __div(__ysize, 2) m" + "__xsize __add(__div(__ysize, 2), __div(__mul(2, __xsize), 3))" + "0 __add(__div(__ysize, 2), __div(__mul(2, __xsize), 3))" + "0 __div(__ysize, 2) c" + "0 __sub(__div(__ysize, 2), __div(__mul(2, __xsize), 3))" + "__xsize __sub(__div(__ysize, 2), __div(__mul(2, __xsize), 3))" + "__xsize __div(__ysize, 2) c S" + } @Graphic { 0.7f @Wide 0.3f @High ^/ 0.3f @High } + } + } + } - def square { @HContract @VContract - @BackEnd @Case { - PostScript @Yield { - { "0 0 moveto xsize 0 lineto xsize ysize lineto" - "0 ysize lineto closepath" - "0.04 ft setlinewidth stroke" - } - @Graphic { 0.6f @Wide 0.3f @High ^/ 0.3f @High } - } - PDF @Yield { - { "__mul(__loutf, 0.04) w" - "0 0 m __xsize 0 l __xsize __ysize l" - "0 __ysize l s" - } - @Graphic { 0.6f @Wide 0.3f @High ^/ 0.3f @High } - } - } - } + def filledcircle + { @HContract @VContract @BackEnd @Case { + PostScript @Yield { + { + "xsize ysize 2 div moveto" + "xsize 2 div ysize 2 div xsize 2 div 0 360 arc" + "0.04 ft setlinewidth fill" + } @Graphic { 0.7f @Wide 0.3f @High ^/ 0.3f @High } + } + PDF @Yield { + # + # JK: I don't know how to fill in PDF, so this doesn't! + # + # VT: draws a counterclockwise 360 degree arc from 0 to +360 + # degree positions (straight right to straight right) with + # centre = (xsize/2, ysize/2) and radius = xsize/2, + # implemented as two counterclockwise 180 degree arcs. + # start at (xsize, ysize/2); the control points are: + # + # pt1 = (xsize, ysize/2 + (4/3 * xsize/2)) + # pt2 = (0, ysize/2 + (4/3 * xsize/2)) + # + # end at (0, ysize/2). Then start at (0, ysize/2); control points + # + # pt1 = (0, ysize/2 - (4/3 * xsize/2)) + # pt2 = (xsize, ysize/2 - (4/3 * xsize/2)) + # + # and end at (xsize, ysize/2). + + { + "__mul(0.04, __loutf) w" + "__xsize __div(__ysize, 2) m" + "__xsize __add(__div(__ysize, 2), __div(__mul(2, __xsize), 3))" + "0 __add(__div(__ysize, 2), __div(__mul(2, __xsize), 3))" + "0 __div(__ysize, 2) c" + "0 __sub(__div(__ysize, 2), __div(__mul(2, __xsize), 3))" + "__xsize __sub(__div(__ysize, 2), __div(__mul(2, __xsize), 3))" + "__xsize __div(__ysize, 2) c S" + } @Graphic { 0.7f @Wide 0.3f @High ^/ 0.3f @High } + } + } + } - def triangle { @HContract @VContract - @BackEnd @Case { - PostScript @Yield { - { "0 0 moveto xsize 0 lineto" - "xsize 2 div ysize lineto closepath" - "0.04 ft setlinewidth stroke" - } - @Graphic - { 0.3f @Wide 0.3f @High ^| ^/ - 0.3f @Wide 0.3f @High - } - } - PDF @Yield { - { "__mul(__loutf, 0.04) w" - "0 0 m __xsize 0 l" - "__div(__xsize, 2) __ysize l s" - } - @Graphic - { 0.3f @Wide 0.3f @High ^| ^/ - 0.3f @Wide 0.3f @High - } - } - } - } + def square + { @HContract @VContract @BackEnd @Case { + PostScript @Yield { + { + "0 0 moveto xsize 0 lineto xsize ysize lineto" + "0 ysize lineto closepath" + "0.04 ft setlinewidth stroke" + } @Graphic { 0.6f @Wide 0.3f @High ^/ 0.3f @High } + } + PDF @Yield { + { + "__mul(__loutf, 0.04) w" + "0 0 m __xsize 0 l __xsize __ysize l" + "0 __ysize l s" + } @Graphic { 0.6f @Wide 0.3f @High ^/ 0.3f @High } + } + } + } + + def triangle + { @HContract @VContract @BackEnd @Case { + PostScript @Yield { + { + "0 0 moveto xsize 0 lineto" + "xsize 2 div ysize lineto closepath" + "0.04 ft setlinewidth stroke" + } @Graphic { 0.3f @Wide 0.3f @High ^| ^/ 0.3f @Wide 0.3f @High } + } + PDF @Yield { + { + "__mul(__loutf, 0.04) w" + "0 0 m __xsize 0 l" + "__div(__xsize, 2) __ysize l s" + } @Graphic { 0.3f @Wide 0.3f @High ^| ^/ 0.3f @Wide 0.3f @High } + } + } + } + + def triangledown { 180d @Rotate triangle } ################################################################### # # @@ -774,6 +812,7 @@ def @Eq def bowtie { rel{non triangleright non triangleleft}} def propto { rel proportional } def models { rel{@Base vctr "|" &0.05fo vctr equal}} + def trieq { rel @OneRow @HContract {&0.5rt small triangle^/0.15f equal}} def doteq { rel @OneRow @HContract {&0.5rt dotmath^/0.15f equal}} def perp { rel perpendicular } @@ -1446,6 +1485,16 @@ def @Eq "" sup x &0io sqrt y } + def zroot + precedence 56 + left x + right y + { + def zsup right x { "+0.3f" @VShift 0.5f @Font @Space x } + + "-0.4f" @HShift { 1w @HShift { zsup x } } &0co sqrt y + } + def above precedence 52 left x diff --git a/include/langdefs b/include/langdefs index ec3ac3a..d23f4fd 100644 --- a/include/langdefs +++ b/include/langdefs @@ -10,6 +10,7 @@ langdef Hungarian Magyar { - . : ! ? .) ?) !) .' !' ?' } langdef Italian Italiano { italian . : ! ? .) ?) !) .' !' ?' } langdef Norwegian Norsk { norweg . : ! ? .) ?) !) .' !' ?' } langdef Polish Polski { polish . : ! ? .) ?) !) .' !' ?' } +langdef Portuguese "Português" { portugal . : ! ? .) ?) !) .' !' ?' } langdef Russian "\362\325\323\323\313\311\312" { russian . : ! ? .) ?) !) .' !' ?' } langdef Slovenian Slovenia Slovenija { slovenia . : ! ? .) ?) !) .' !' ?' } langdef Spanish "Espa\361ol" { spanish . : ! ? .) ?) !) .' !' ?' } diff --git a/include/picture b/include/picture index 55d2f3e..42c5c3f 100644 --- a/include/picture +++ b/include/picture @@ -102,9 +102,12 @@ # @TableNumbers { Arabic } # method of numbering tables # @FigureCaptionPos { Below } # Above or Below # @TableCaptionPos { Below } # Above or Below - # @CaptionFont { } # figure, table caption font - # @CaptionBreak { } # figure, table caption break - # @CaptionFormat { @B { number @DotSep @OneCol } } # figure, table caption format + # @FigureCaptionFont { -2p } # figure caption font + # @FigureCaptionBreak { adjust hyphen 1.2fx } # figure caption break + # @FigureCaptionFormat{ {@B { word @NumSep number. &2s }} @Insert caption } + # @TableCaptionFont { -2p } # table caption font + # @TableCaptionBreak { adjust hyphen 1.2fx } # table caption break + # @TableCaptionFormat { {@B { word @NumSep number. &2s }} @Insert caption } # @MakeFigureContents { No } # list of figures at start # @MakeTableContents { No } # list of tables at start # @MakeContents { No } # make contents? Yes or No diff --git a/include/progf b/include/progf new file mode 100644 index 0000000..5ca3f81 --- /dev/null +++ b/include/progf @@ -0,0 +1,259 @@ + +############################################################################### +# # +# Lout @ProgSetup package for formatting computer programs (Version 1.4) # +# # +# Version 1.0 by Jeffrey H. Kingston, February 2000. # +# Adapted from the original @CPrint package. # +# # +# This package uses a filtered body parameter to convert program source # +# code into Lout source. The filter program is prog2lout, which is # +# distributed with Lout and should be compiled and installed wherever # +# Lout itself is. # +# # +# This package is intended for use by prog2lout's stand-alone mode. # +# If you are adding a new language, a better place to start would be # +# files eiffelf and eiffel rather than progf. # +# # +############################################################################### + +export @Prog +def @ProgSetup + named language { "missing_language" } # programming language + named style + named @OrIfPlain left x right y + { @BackEnd @Case { PlainText @Yield y else @Yield x } } + { varying @OrIfPlain fixed } # print style + named pipe { } # pipe through this first + + named fixedfont { Courier } # font family if fixed + named fixedstrings { Base } # string face if fixed + named fixedidentifiers { Base } # identifier face if fixed + named fixedcomments { Base } # comment face if fixed + named fixedkeywords { Base } # keyword face if fixed + named fixednumbers { Base } # number face if fixed + named fixedoperators { Base } # operator face if fixed + named fixedsize { -1.0p } # font size if fixed + named fixedline { 1.0vx } # line-space if fixed + named fixedtabin { 8 } # tab interval if fixed + named fixedtabout { 8s } # tab width if fixed + + named varyingfont { } # font family if varying + named varyingstrings { Slope } # string face if varying + named varyingidentifiers { Slope } # identifier face if varying + named varyingcomments { Base } # comment face if varying + named varyingkeywords { Bold } # keyword face if varying + named varyingnumbers { Base } # number face if varying + named varyingoperators { Base } # operator face if varying + named varyingsize { 1.0f } # font size if varying + named varyingline { 1.0vx } # line-space if varying + named varyingtabin { 8 } # tab interval if varying + named varyingtabout { 3f } # tab width if varying + + named symbolfont { } # font family if symbol + named symbolstrings { Slope } # string face if symbol + named symbolidentifiers { Slope } # identifier face if symbol + named symbolcomments { Base } # comment face if symbol + named symbolkeywords { Bold } # keyword face if symbol + named symbolnumbers { Base } # number face if symbol + named symboloperators { Base } # operator face if symbol + named symbolsize { 1.0f } # font size if symbol + named symbolline { 1.0vx } # line-space if symbol + named symboltabin { 8 } # tab interval if symbol + named symboltabout { 3f } # tab width if symbol + +@Begin + + export + + "$>" @S @D @C @K @N @O @A @M + + def @Prog + named language { language } # language + named style { style } # style + named pipe { pipe } # pipe through this first + named font { dft } # font family + named strings { dft } # string font + named identifiers { dft } # ident. font + named comments { dft } # comment font + named keywords { dft } # keyword font + named numbers { dft } # number font + named operators { dft } # operator font + named size { dft } # font size + named line { dft } # line-space + named tabin { dft } # tab interval + named tabout { dft } # tab width + body @Body # filtered, see below + @Begin + + def @Test # returns x unless x is dft + left x + named iffixed {} + named ifvarying {} + named ifsymbol {} + { + x @Case { + dft @Yield { + style @Case { + fixed @Yield { iffixed } + varying @Yield { ifvarying } + symbol @Yield { ifsymbol } + } + } + else @Yield x + } + } + + def @InitTab + { + tabin @Test + iffixed { fixedtabin } + ifvarying { varyingtabin } + ifsymbol { symboltabin } + } + + def @InitTabWidth + { + tabout @Test + iffixed { fixedtabout } + ifvarying { varyingtabout } + ifsymbol { symboltabout } + } + + def @Filter + { + pipe @Case { + "" @Yield { + "prog2lout -r -l" language -i{@FilterIn} -o{@FilterOut} -e{@FilterErr} + -t{@InitTab} -T{@InitTabWidth} + } + else @Yield { + "cat" @FilterIn "|" pipe "|" + "prog2lout -r -l" language -o{@FilterOut} + -e{@FilterErr} -t{@InitTab} -T{@InitTabWidth} + } + } + } + + def @InitFontFamily + { + font @Test + iffixed { fixedfont } + ifvarying { varyingfont } + ifsymbol { symbolfont } + } + + def @InitSize + { + size @Test + iffixed { fixedsize } + ifvarying { varyingsize } + ifsymbol { symbolsize } + } + + def @InitLine + { + line @Test + iffixed { fixedline } + ifvarying { varyingline } + ifsymbol { symbolline } + } + + def @S # for formatting strings + right x + { + # "\"" & + strings @Test + iffixed { fixedstrings } + ifvarying { varyingstrings } + ifsymbol { symbolstrings } + @Font x + # & "\"" + } + +# def "`" +# { +# style @Case { +# symbol @Yield { "`" } +# else @Yield { "'" } +# } +# } + + def @D # for formatting identifiers + right x + { + identifiers @Test + iffixed { fixedidentifiers } + ifvarying { varyingidentifiers } + ifsymbol { symbolidentifiers } + @Font x + } + + def @C # for formatting comments + right x + { + comments @Test + iffixed { fixedcomments } + ifvarying { varyingcomments } + ifsymbol { symbolcomments } + @Font x + } + + def @K # for formatting keywords + right x + { + keywords @Test + iffixed { fixedkeywords } + ifvarying { varyingkeywords } + ifsymbol { symbolkeywords } + @Font x + } + + def @N # for formatting numbers + right x + { + numbers @Test + iffixed { fixednumbers } + ifvarying { varyingnumbers } + ifsymbol { symbolnumbers } + @Font x + } + + def @O # for formatting operators + named symb {} + right x + { + operators @Test + iffixed { fixedoperators } + ifvarying { varyingoperators } + ifsymbol { symboloperators } + @Font x + } + + def @A # get characters from the Adobe Symbol font + left sym + right x + { + style @Case { + symbol @Yield { { Symbol Base } @Font @Char sym } + else @Yield { x } + } + } + + macro "$>" { {} & } + + def @M right x + { + style @Case { + fixed @Yield "-" + varying @Yield { { Symbol Base } @Font @Char minus } + symbol @Yield { { Symbol Base } @Font @Char minus } + } + } + + { @InitFontFamily Base @InitSize } @Font + { @InitLine lines } @Break @Body + + @End @Prog + +@End @ProgSetup diff --git a/include/report b/include/report index 01fdcc6..4905980 100644 --- a/include/report +++ b/include/report @@ -107,9 +107,12 @@ # @TableNumbers { Arabic } # method of numbering tables # @FigureCaptionPos { Below } # Above or Below # @TableCaptionPos { Below } # Above or Below - # @CaptionFont { } # figure, table caption font - # @CaptionBreak { } # figure, table caption break - # @CaptionFormat { @B { number @DotSep @OneCol } } # figure, table caption format + # @FigureCaptionFont { -2p } # figure caption font + # @FigureCaptionBreak { adjust hyphen 1.2fx } # figure caption break + # @FigureCaptionFormat{ {@B { word @NumSep number. &2s }} @Insert caption } + # @TableCaptionFont { -2p } # table caption font + # @TableCaptionBreak { adjust hyphen 1.2fx } # table caption break + # @TableCaptionFormat { {@B { word @NumSep number. &2s }} @Insert caption } # @MakeFigureContents { No } # list of figures at start # @MakeTableContents { No } # list of tables at start # @MakeContents { No } # make contents? Yes or No @@ -248,9 +251,10 @@ @Use { @ReportSetup # @CoverSheet { Yes } # make cover sheet - # @DisplayAbstract { No } # abstract full width display # @ContentsSeparate { No } # contents on separate pages # @DateLine { No } # Yes, No, or a date + # @AbstractDisplay { No } # abstract full width display + # @AbstractTitle { dft } # abstract title (dft is @AbstractWord) # @ReferencesBeforeAppendices { No } # references before appendices # @AbstractWord { abstract } # word for "Abstract" # @ContentsWord { contents } # word for "Contents" diff --git a/include/reportf b/include/reportf index f1a62a9..06d45af 100644 --- a/include/reportf +++ b/include/reportf @@ -16,7 +16,7 @@ def @ReportSetup named @CoverSheet { Yes } named @ContentsSeparate { No } named @DateLine { No } - named @AbstractDisplay { Yes } + named @AbstractDisplay { No } named @AbstractTitle { dft } named @ReferencesBeforeAppendices { No } @@ -491,8 +491,8 @@ def @ReportSetup { Start @Runner - //@SectionGap @ContentsPart - //@SectionGap @SectionList @FirstSectionNumber + //@ContentsGap @ContentsPart + //@ContentsGap @SectionList @FirstSectionNumber //@SectionGap @ReferencesBeforeAppendices @Do { @MakeReferences @Do @ReferencesPart } diff --git a/include/slides b/include/slides index 7833f60..f740c84 100644 --- a/include/slides +++ b/include/slides @@ -105,9 +105,12 @@ # @TableNumbers { Arabic } # method of numbering tables # @FigureCaptionPos { Below } # Above or Below # @TableCaptionPos { Below } # Above or Below - # @CaptionFont { } # figure, table caption font - # @CaptionBreak { } # figure, table caption break - # @CaptionFormat { @B { number @DotSep @OneCol } } # figure, table caption format + # @FigureCaptionFont { -2p } # figure caption font + # @FigureCaptionBreak { adjust hyphen 1.2fx } # figure caption break + # @FigureCaptionFormat{ {@B { word @NumSep number. &2s }} @Insert caption } + # @TableCaptionFont { -2p } # table caption font + # @TableCaptionBreak { adjust hyphen 1.2fx } # table caption break + # @TableCaptionFormat { {@B { word @NumSep number. &2s }} @Insert caption } # @MakeFigureContents { No } # list of figures at start # @MakeTableContents { No } # list of tables at start # @MakeContents { No } # make contents? Yes or No diff --git a/include/tblf b/include/tblf index c8f0019..9a2da6e 100644 --- a/include/tblf +++ b/include/tblf @@ -1383,19 +1383,23 @@ def @TblSetup ctr @Yield @OneCol { |"0.5rt" x } right @Yield @OneCol { |"1.0rt" x } mctr @Yield @OneCol { |"0.5bx" x } - "" @Yield @OneCol x + align @Yield @OneCol x else @Yield @OneCol { |i x } } } def @VIndent right x { + # note: the default value "" gives top alignment, + # but that is not a problem because we are by + # default putting in a vertical strut + iv @Case { top @Yield @OneRow { / x } ctr @Yield @OneRow { /"0.5rt" x } foot @Yield @OneRow { /"1.0rt" x } mctr @Yield @OneRow { /"0.5bx" x } - "" @Yield @OneRow x + align @Yield @OneRow x else @Yield @OneRow { /iv x } } } @@ -1,14 +1,14 @@ ############################################################################### # # -# Make file for installing Basser Lout Version 3.17 # +# Make file for installing Basser Lout Version 3.18 # # # # Jeffrey H. Kingston # -# 17 September 1999 # +# 14 February 2000 # # # +# make prg2lout Compile a small auxiliary program called prg2lout # # make lout Compile the Lout source # -# make c2lout Compile a small auxiliary program called c2lout # -# make install Install the Lout and c2lout binaries and libraries # -# make installman Install the Lout and c2lout manual entries # +# make install Install the Lout and prg2lout binaries and libraries # +# make installman Install the Lout and prg2lout manual entries # # make installdoc Install the Lout documentation # # make installfr Install French error messages (optional) # # make installde Install German error messages (optional) # @@ -60,7 +60,7 @@ # can always specify safe or unsafe execution by means of the -S and # # -U options to lout when processing a document; SAFEDFT means that # # -S rather than -U is the default behaviour. Unsafe execution is # -# required when formatting C programs and verbatim text, so if in # +# required when formatting programs and verbatim text, so if in # # doubt, do not change the value of SAFEDFT. # # # # (5) Set the following four macros defined below to appropriate values: # @@ -75,7 +75,7 @@ # (written in Lout) go. This directory will be created (but # # its parent must exist already). # # # -# MANDIR Directory where the lout and c2lout online manual entries # +# MANDIR Directory where the lout and prg2lout online manual entries # # (in nroff -man) go. This directory is assumed to exist. # # # # (6) Set the following two macros defined below to appropriate values. # @@ -145,8 +145,8 @@ # based on the ISO codes of the characters. This defaul setting may # # be changed during individual runs of Lout by the -l and -L flags. # # # -# (9) Execute "make c2lout". This will compile the c2lout program, leaving # -# its binary in this directory. No changes to other directories. # +# (9) Execute "make prg2lout". This will compile the prg2lout program, # +# leaving its binary in this directory. Other directories unchanged. # # # # (10) If you want to be able to produce compressed PDF files, as opposed to # # uncompressed ones, you need to: # @@ -183,7 +183,7 @@ # # # (13) Execute "make install". This will do the following things: # # # -# (a) It will copy the lout and c2lout binaries into $(BINDIR); # +# (a) It will copy the lout and prg2lout binaries into $(BINDIR); # # # # (b) It will create $(LIBDIR) and copy all the library files into it; # # # @@ -208,8 +208,8 @@ # It is good to build the various files during installation because # # later runs will not have write permission in the library directories. # # # -# (14) Execute "make installman". This installs the manual entries for # -# lout and c2lout into directory $(MANDIR), which is assumed to exist. # +# (14) Execute "make installman". This installs the manual entries for lout # +# and prg2lout into directory $(MANDIR), which is assumed to exist. # # These entries are troff files; plain text versions are also available # # in directory ./man if you need them (install them yourself). # # # @@ -252,8 +252,6 @@ DBFIX = 0 USESTAT = 1 SAFEDFT = 0 -COLLATE = 1 - BINDIR = /usr/staff/jeff/bin LIBDIR = /usr/staff/jeff/lout.lib DOCDIR = /usr/staff/jeff/lout.doc @@ -273,6 +271,8 @@ USELOC = 1 LOC_FR = fr LOC_DE = de +COLLATE = 1 + PDF_COMPRESSION = 0 ZLIB = ZLIBPATH = @@ -281,6 +281,7 @@ CC = gcc RCOPY = cp -r +# COPTS = -ansi -pedantic -Wall -O3 COPTS = -ansi -pedantic -Wall CFLAGS = -DOS_UNIX=$(OSUNIX) \ @@ -320,17 +321,17 @@ $(OBJS): externs.h externs.h: -c2lout: c2lout.c - $(CC) $(COPTS) -o c2lout c2lout.c - chmod a+x c2lout +prg2lout: prg2lout.c + $(CC) $(COPTS) -o prg2lout prg2lout.c + chmod a+x prg2lout -install: lout c2lout +install: lout prg2lout @echo "" - @echo "(a) Installing lout and c2lout binaries into BINDIR $(BINDIR)" + @echo "(a) Installing lout and prg2lout binaries into BINDIR $(BINDIR)" cp lout $(BINDIR)/lout chmod 755 $(BINDIR)/lout - cp c2lout $(BINDIR)/c2lout - chmod 755 $(BINDIR)/c2lout + cp prg2lout $(BINDIR)/prg2lout + chmod 755 $(BINDIR)/prg2lout @echo "" @echo "(b) Installing library files into LIBDIR $(LIBDIR)" mkdir $(LIBDIR) @@ -378,8 +379,8 @@ installman: -e "s@<DOCDIR>@$(DOCDIR)@" -e "s@<MANDIR>@$(MANDIR)@" \ man/lout.1 > $(MANDIR)/lout.1 chmod 644 $(MANDIR)/lout.1 - cp man/c2lout.1 $(MANDIR)/c2lout.1 - chmod 644 $(MANDIR)/c2lout.1 + cp man/prg2lout.1 $(MANDIR)/prg2lout.1 + chmod 644 $(MANDIR)/prg2lout.1 installdoc: @echo "" @@ -414,12 +415,12 @@ installde: chmod 644 $(LIBDIR)/$(LIBLOCA)/$(LOC_DE)/LC_MESSAGES/* uninstall: - -rm -f $(BINDIR)/lout $(BINDIR)/c2lout + -rm -f $(BINDIR)/lout $(BINDIR)/prg2lout -rm -fr $(LIBDIR) -rm -fr $(DOCDIR) - -rm -f $(MANDIR)/lout.1 $(MANDIR)/c2lout.1 + -rm -f $(MANDIR)/lout.1 $(MANDIR)/prg2lout.1 clean: - -rm -f lout c2lout *.o + -rm -f lout prg2lout *.o restart: clean uninstall diff --git a/man/prg2lout.1 b/man/prg2lout.1 new file mode 100644 index 0000000..7014e46 --- /dev/null +++ b/man/prg2lout.1 @@ -0,0 +1,135 @@ +.TH PRG2LOUT 1 +.SH NAME +prg2lout - convert computer program text into Lout +.SH SYNOPSIS +\fBprg2lout\fR -l \fIlanguage\fR [ \fIoptions\fR ] \fIfiles\fR... +.SH DESCRIPTION +Reformat computer program text for input to the Lout document formatting +system, taking care of comments, character strings, tab characters, etc. +.LP +.B prg2lout +reads the named program source files and produces output +suitable for input to +.BR "lout -s" . +Thus, +.LP +.RS +.B "prg2lout -l C foo.c | lout -s | lpr" +.RE +.LP +will print the C program +.B foo.c +on a PostScript printer. Each file will start on a new page, preceded +by its name in bold. +.SH OPTIONS +.TP +.B \-llanguage +(Compulsory.) Files are written in this programmming language. Run +\fIprg2lout -u\fR to see the list of languages available. +.TP +.B \-pfixed +Use a fixed width font (the default for C). +.TP +.B \-pvarying +Use a varying-width italic font with non-italic bold keywords (the +default for Eiffel). +.TP +.B \-psymbol +Use a varying-width italic font with mathematical symbols and +non-italic bold keywords. +.TP +.B \-n +Do not print the file name before each source file. +.TP +.BI \-f " font" +Select a font family. +The default is +.B \-fCourier +for +.BR \-pfixed , +and +.B \-fTimes +for +.B \-pvarying +and +.BR \-psymbol . +.TP +.BI \-s " size" +Select a Lout font size. The default is +.B -s9p +(meaning 9 points) for +.BR \-pfixed , +and +.B \-s10p +for +.B \-pvarying +and +.BR \-psymbol . +These work well with 80-character-wide programs. +.TP +.BI \-v " vsize" +Select a Lout vertical inter-line gap. The default is +.B -v1.1fx +meaning 1.1 times the font size measured from baseline to baseline. +.TP +.BI \-t " num" +Set the tab interval to +.I num +characters (default is +.BR \-t8 ). +.TP +.BI \-T " width" +Without this option, +.B prg2lout +simulates tabs with spaces. With this option, +.B prg2lout +simulates tabs with Lout tabulation operators; +.I width +is the width of one tab interval in the final print, measured in Lout +units. This guarantees alignment of characters following tabs even +with varying-width fonts, provided +.I width +is sufficiently large. For example, +.B -T0.5i +produces half-inch tab intervals. +.TP +.B \-u +Print usage information on stderr, including available languages, and exit. +.TP +.B \-V +Print version information on stderr and exit. +.SS Raw Mode +There is a \(lq\&raw mode\(rq usage of +.B prg2lout +invoked by a +.B -r +flag (must be the first argument). This converts one program file into +Lout-readable source without any heading or trailing information. +Synopsis: +.LP +.RS +.B prg2lout +.B \-r +.BI \-i \ infile +.BI \-o \ out +.BI \-e \ err +.BI \-t \ num +.BI \-T \ width +.RE +.LP +Users should never need this mode; it is invoked automatically +from within Lout by symbols supplied with the standard configuration +(see reference). +.SH SEE ALSO +.BR lout (1), +.BR lpr (1), +.BR ghostview (1). +.SH REFERENCES +.LP +Jeffrey H. Kingston, +.I +\(lq\&A User's Guide to the Lout Document Formatting System\(rq\c +\&, Chapter 11. +.SH AUTHOR +.LP +Jeffrey H. Kingston diff --git a/man/prg2lout.txt b/man/prg2lout.txt new file mode 100644 index 0000000..991315d --- /dev/null +++ b/man/prg2lout.txt @@ -0,0 +1,96 @@ + + +NAME + prg2lout - convert computer program text into Lout + +SYNOPSIS + prg2lout -l language [ options ] files... + +DESCRIPTION + Reformat computer program text for input to the Lout docu- + ment formatting system, taking care of comments, character + strings, tab characters, etc. + + prg2lout reads the named program source files and produces + output suitable for input to lout -s. Thus, + + prg2lout -l C foo.c | lout -s | lpr + + will print the C program foo.c on a PostScript printer. + Each file will start on a new page, preceded by its name in + bold. + +OPTIONS + -llanguage + (Compulsory.) Files are written in this programmming + language. Run prg2lout -u to see the list of languages + available. + + -pfixed + Use a fixed width font (the default for C). + + -pvarying + Use a varying-width italic font with non-italic bold + keywords (the default for Eiffel). + + -psymbol + Use a varying-width italic font with mathematical sym- + bols and non-italic bold keywords. + + -n Do not print the file name before each source file. + + -f font + Select a font family. The default is -fCourier for + -pfixed, and -fTimes for -pvarying and -psymbol. + + -s size + Select a Lout font size. The default is -s9p (meaning + 9 points) for -pfixed, and -s10p for -pvarying and + -psymbol. These work well with 80-character-wide pro- + grams. + + -v vsize + Select a Lout vertical inter-line gap. The default is + -v1.1fx meaning 1.1 times the font size measured from + baseline to baseline. + + -t num + Set the tab interval to num characters (default is + -t8). + + -T width + Without this option, prg2lout simulates tabs with + spaces. With this option, prg2lout simulates tabs with + Lout tabulation operators; width is the width of one + tab interval in the final print, measured in Lout + units. This guarantees alignment of characters follow- + ing tabs even with varying-width fonts, provided width + is sufficiently large. For example, -T0.5i produces + half-inch tab intervals. + + -u Print usage information on stderr, including available + languages, and exit. + + -V Print version information on stderr and exit. + + Raw Mode + There is a raw mode usage of prg2lout invoked by a -r flag + (must be the first argument). This converts one program + file into Lout-readable source without any heading or trail- + ing information. Synopsis: + + prg2lout -r -i infile -o out -e err -t num -T width + + Users should never need this mode; it is invoked automati- + cally from within Lout by symbols supplied with the standard + configuration (see reference). + +SEE ALSO + lout(1), lpr(1), ghostview(1). + +REFERENCES + Jeffrey H. Kingston, A User's Guide to the Lout Document + Formatting System, Chapter 11. + +AUTHOR + Jeffrey H. Kingston diff --git a/maps/LtLatin2.LCM b/maps/LtLatin2.LCM index 458769f..3df229f 100644 --- a/maps/LtLatin2.LCM +++ b/maps/LtLatin2.LCM @@ -218,7 +218,7 @@ 172 254 Zacute LC zacute; UA Z; AC acute; 173 255 hyphen 174 256 Zcaron LC zcaron; UA Z; AC caron; -175 257 Zdotabove LC zdotabove; UA Z; AC dotaccent; +175 257 Zdotaccent LC zdotaccent; UA Z; AC dotaccent; 176 260 degree 177 261 aogonek UC Aogonek; UA a; AC ogonek; 178 262 ogonek @@ -234,7 +234,7 @@ 188 274 zacute UC Zacute; UA z; AC acute; 189 275 hungarumlaut 190 276 zcaron UC Zcaron; UA z; AC caron; -191 277 zdotabove UC Zdotabove; UA z; AC dotaccent; +191 277 zdotaccent UC Zdotaccent; UA z; AC dotaccent; 192 300 Racute LC racute; UA R; AC acute; 193 301 Aacute LC aacute; UA A; AC acute; 194 302 Acircumflex LC acircumflex; UA A; AC circumflex; diff --git a/prg2lout.c b/prg2lout.c new file mode 100644 index 0000000..4df2187 --- /dev/null +++ b/prg2lout.c @@ -0,0 +1,1832 @@ +/*****************************************************************************/ +/* */ +/* PROG2LOUT: A PROGRAM TO CONVERT PROGRAM SOURCES INTO LOUT (VERSION 1.0) */ +/* COPYRIGHT (C) 2000 Jeffrey H. Kingston */ +/* */ +/* Jeffrey H. Kingston (jeff@cs.su.oz.au) */ +/* Basser Department of Computer Science */ +/* The University of Sydney 2006 */ +/* AUSTRALIA */ +/* */ +/* This program is free software; you can redistribute it and/or modify */ +/* it under the terms of the GNU General Public License as published by */ +/* the Free Software Foundation; either version 2, or (at your option) */ +/* any later version. */ +/* */ +/* This program is distributed in the hope that it will be useful, */ +/* but WITHOUT ANY WARRANTY; without even the implied warranty of */ +/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */ +/* GNU General Public License for more details. */ +/* */ +/* You should have received a copy of the GNU General Public License */ +/* along with this program; if not, write to the Free Software */ +/* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ +/* */ +/*****************************************************************************/ +#include <stdio.h> +#include <stdlib.h> + +/*****************************************************************************/ +/* */ +/* How to add another language to prg2lout's list */ +/* */ +/* Step 1. Have a browse through the token declarations below, and work */ +/* out which of them you need for your language. If you need a token that */ +/* isn't there already, you'll have to define it; there are many examples */ +/* there to help you. */ +/* */ +/* Step 2. Browse through the language declarations, and declare your */ +/* language following those examples: first you give a set of one or more */ +/* alternative names for your language, then the default printing style for */ +/* it (either "fixed", "varying", or "symbol"), then you list the tokens */ +/* of the language, then you list the keywords. */ +/* */ +/* Step 3. Add your language variable to the list in the initializer of */ +/* variable languages, as you can see the others have been done. */ +/* */ +/* Step 4. If any lists of initializers now contain more than */ +/* MAX_ARRAY_LENGTH-1 elements, increase MAX_ARRAY_LENGTH until they don't. */ +/* */ +/* Step 5. Recompile and reinstall prg2lout, test "prg2lout -u" then */ +/* "prg2lout -l <mylanguage> <myfile> | lout -s > out.ps". */ +/* */ +/* Step 6. Send your tested and verified changes to jeff@cs.usyd.edu.au */ +/* for incorporation in the next Lout release. If you do this, please */ +/* try hard to ensure that your changes conform to the formal definition */ +/* of your language. */ +/* */ +/*****************************************************************************/ + + +/*****************************************************************************/ +/* */ +/* Character sets */ +/* */ +/* Here are prg2lout's definitions of various commonly needed sets of */ +/* characters. May need enhancement for Latin1 etc. */ +/* */ +/*****************************************************************************/ + +char AllPrintable[] = + " !\"#$%&'()*+,-./0123456789:;<=>?@[\\]^_`\\{|}~\ +ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz" ; + +char AllPrintablePlusNL[] = + " !\"#$%&'()*+,-./0123456789:;<=>?@[\\]^_`\\{|}~\ +ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz\n" ; + +char AllPrintableTabNL[] = + " !\"#$%&'()*+,-./0123456789:;<=>?@[\\]^_`\\{|}~\ +ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz\n\t" ; + +char NotDoubleQuote[] = + " !#$%&'()*+,-./0123456789:;<=>?@[\\]^_`\\{|}~\ +ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz" ; + +char NotQuote[] = + " !#$%&\"()*+,-./0123456789:;<=>?@[\\]^_`\\{|}~\ +ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz" ; + +char Letters[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz" ; + +char Letter_Digit[] = + "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz_0123456789" ; + +#define SepLetters \ +"A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", \ +"N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z", \ +"a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", \ +"n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z" + +#define SepDigits "0", "1", "2", "3", "4", "5", "6", "7", "8", "9" + + +/*****************************************************************************/ +/* */ +/* TOKEN - put your token declarations in this section */ +/* */ +/*****************************************************************************/ +#define MAX_CHAR 256 +#define MAX_STRING_LENGTH 101 +#define MAX_ARRAY_LENGTH 101 + + +typedef struct token_rec { + char *name; /* the name of this token, e.g. "string" */ + char *command; /* the Lout command for it, e.g. "@D" */ + char *alternate_command; /* the alternate command for it, e.g. "@K" */ + char *starts[MAX_ARRAY_LENGTH]; /* strings that start this token */ + char *legal; /* legal characters in this token */ + char *escape; /* the escape character e.g. "\\", or "" */ + char *escape_legal; /* legal characters after escape character */ + char *inner_escape; /* inner escape, e.g. "`", or else "" */ + char *end_inner_escape; /* end inner escape, e.g. "'" */ + char *end_delimiter; /* the end delimiter, else "" */ + + /* The following options are initialized by the program, so don't you */ + char chtype[MAX_CHAR]; /* character types within token */ + char escape_chtype[MAX_CHAR]; /* character types after escape */ +} TOKEN; + + +TOKEN CStringToken = { + "string", /* used by error messages involving this token */ + "@S", /* Lout command for formatting strings */ + "", /* No alternate command */ + { "\"" }, /* strings begin with a " character */ + NotDoubleQuote, /* inside, any printable except " is OK */ + "\\", /* within strings, \\ is the escape character */ + AllPrintablePlusNL, /* after escape char, any printable char or nl OK */ + "", /* strings do not permit "inner escapes" */ + "", /* and so there is no end innner escape either */ + "\"" /* strings end with a " character */ +}; + +TOKEN CCharacterToken = { + "character", /* used by error messages involving this token */ + "@C", /* Lout command for formatting characters */ + "", /* No alternate command */ + { "'" }, /* characters begin with a ' character */ + NotQuote, /* inside, any printable except ' is OK */ + "\\", /* within characters, \\ is the escape character */ + AllPrintable, /* after escape char, any printable char is OK */ + "", /* characters do not permit "inner escapes" */ + "", /* and so there is no end innner escape either */ + "'" /* characters end with a ' character */ +}; + +TOKEN EiffelStringToken = { + "string", /* used by error messages involving this token */ + "@S", /* Lout command for formatting strings */ + "", /* No alternate command */ + { "\"" }, /* strings begin with a " character */ + NotDoubleQuote, /* inside, any printable except " is OK */ + "%", /* within strings, % is the escape character */ + AllPrintable, /* after escape char, any printable char is OK */ + "", /* strings do not permit "inner escapes" */ + "", /* and so there is no end innner escape either */ + "\"" /* strings end with a " character */ +}; + +TOKEN EiffelCharacterToken = { + "character", /* used by error messages involving this token */ + "@C", /* Lout command for formatting characters */ + "", /* No alternate command */ + { "'" }, /* characters begin with a ' character */ + NotQuote, /* inside, any printable except ' is OK */ + "%", /* within characters, % is the escape character */ + AllPrintable, /* after escape char, any printable char is OK */ + "", /* characters do not permit "inner escapes" */ + "", /* and so there is no end innner escape either */ + "'" /* characters end with a ' character */ +}; + +TOKEN IdentifierToken = { + "identifier", /* used by error messages involving this token */ + "@D", /* Lout command for formatting identifiers */ + "@K", /* Alternate command (for keywords) */ + { SepLetters, "_" }, /* identifiers begin with any letter or _ */ + Letter_Digit, /* inside, letters, underscores, digits are OK */ + "", /* no escape character within identifiers */ + "", /* so nothing legal after escape char either */ + "", /* identifiers do not permit "inner escapes" */ + "", /* and so there is no end innner escape either */ + "" /* identifiers do not end with a delimiter */ +}; + +TOKEN NumberToken = { + "number", /* used by error messages involving this token */ + "@N", /* Lout command for formatting numbers */ + "", /* No alternate command */ + { SepDigits }, /* numbers must begin with a digit */ + "0123456789.eE", /* inside, digits, decimal point, exponent */ + "", /* no escape character within numbers */ + "", /* so nothing legal after escape char either */ + "", /* numbers do not permit "inner escapes" */ + "", /* and so there is no end innner escape either */ + "" /* numbers do not end with a delimiter */ +}; + +TOKEN CCommentToken = { + "comment", /* used by error messages involving this token */ + "@C", /* Lout command for formatting comments */ + "", /* No alternate command */ + { "/*" }, /* comments begin with this character pair */ + AllPrintableTabNL, /* inside, any printable char, tab, or nl is OK */ + "", /* no escape character within comments */ + "", /* so nothing legal after escape char either */ + "", /* C comments do not permit "inner escapes" */ + "", /* and so there is no end innner escape either */ + "*/" /* comments end with this character pair */ +}; + +TOKEN CCommentEscapeToken = { + "Lout escape", /* used by error messages involving this token */ + NULL, /* no Lout command since passed through unformatted */ + "", /* No alternate command */ + { "/*@" }, /* comments begin with this character pair */ + AllPrintableTabNL, /* inside, any printable char, tab, or nl is OK */ + "", /* no escape character within comments */ + "", /* so nothing legal after escape char either */ + "", /* no "inner escape" in escape comments */ + "", /* so no end of "inner escape" either */ + "*/" /* comments end with this character pair */ +}; + +TOKEN CPPCommentToken = { + "comment", /* used by error messages involving this token */ + "@C", /* Lout command for formatting comments */ + "", /* No alternate command */ + { "//" }, /* comments begin with this character pair */ + AllPrintable, /* inside, any printable char is OK (not NL) */ + "", /* no escape character within comments */ + "", /* so nothing legal after escape char either */ + "", /* C comments do not permit "inner escapes" */ + "", /* and so there is no end innner escape either */ + "" /* no end delimiter (end of line will end it) */ +}; + +TOKEN CPPCommentEscapeToken = { + "Lout escape", /* used by error messages involving this token */ + NULL, /* no Lout command since passed through unformatted */ + "", /* No alternate command */ + { "//@" }, /* comments begin with this character pair */ + AllPrintable, /* inside, any printable char is OK */ + "", /* no escape character within comments */ + "", /* so nothing legal after escape char either */ + "", /* no "inner escape" in escape comments */ + "", /* so no end of "inner escape" either */ + "" /* no end delimiter (end of line will end it) */ +}; + +TOKEN EiffelCommentToken = { + "comment", /* used by error messages involving this token */ + "@C", /* Lout command for formatting comments */ + "", /* No alternate command */ + { "--" }, /* comments begin with this character pair */ + AllPrintable, /* inside, any printable char is OK */ + "", /* no escape character within comments */ + "", /* so nothing legal after escape char either */ + "`", /* start of "inner escape" in Eiffel comment */ + "'", /* end of "inner escape" in Eiffel comment */ + "" /* no ending delimiter; end of line will end it */ +}; + +TOKEN EiffelCommentEscapeToken = { + "Lout escape", /* used by error messages involving this token */ + NULL, /* no Lout command since passed through unformatted */ + "", /* No alternate command */ + { "--@" }, /* comments begin with this character pair */ + AllPrintable, /* inside, any printable char is OK */ + "", /* no escape character within comments */ + "", /* so nothing legal after escape char either */ + "", /* no "inner escape" in escape comments */ + "", /* so no end of "inner escape" either */ + "" /* no ending delimiter; end of line will end it */ +}; + +TOKEN BlueCommentToken = { + "comment", /* used by error messages involving this token */ + "@C", /* Lout command for formatting comments */ + "", /* No alternate command */ + { "==", "--" }, /* comments begin with this character pair */ + AllPrintable, /* inside, any printable char is OK */ + "", /* no escape character within comments */ + "", /* so nothing legal after escape char either */ + "`", /* start of "inner escape" in Blue comment */ + "'", /* end of "inner escape" in Blue comment */ + "" /* no ending delimiter; end of line will end it */ +}; + +TOKEN BlueCommentEscapeToken = { + "Lout escape", /* used by error messages involving this token */ + NULL, /* no Lout command since passed through unformatted */ + "", /* No alternate command */ + { "==@", "--@" }, /* comments begin with this character pair */ + AllPrintable, /* inside, any printable char is OK */ + "", /* no escape character within comments */ + "", /* so nothing legal after escape char either */ + "", /* no "inner escape" in escape comments */ + "", /* so no end of "inner escape" either */ + "" /* no ending delimiter; end of line will end it */ +}; + + +#define FixedToken(str, command) /* define fixed-string token */ \ +{ \ + str, /* name used for debugging only */ \ + command, /* Lout command for formatting this */ \ + "", /* No alternate command */ \ + { str }, /* token begins (and ends!) with this */ \ + "", /* nothing inside, since no inside */ \ + "", /* no escape character */ \ + "", /* so nothing after escape character */ \ + "", /* no inner escape either */ \ + "", /* so no end inner escape */ \ + "" /* no ending delimiter */ \ +} + +TOKEN HashToken = FixedToken("#", "@O"); +TOKEN ExclamationToken = FixedToken("!", "@O"); +TOKEN PercentToken = FixedToken("%", "@O"); +TOKEN HatToken = FixedToken("^", "@O"); +TOKEN AmpersandToken = FixedToken("&", "@O"); +TOKEN StarToken = FixedToken("*", "@ST"); +TOKEN SlashToken = FixedToken("/", "@O"); +TOKEN ArrowToken = FixedToken("->", "arrowright @A @O"); +TOKEN BackSlashToken = FixedToken("\\", "@O"); +TOKEN LeftParenToken = FixedToken("(", "@O"); +TOKEN RightParenToken = FixedToken(")", "@O"); +TOKEN MinusToken = FixedToken("-", "@M"); +TOKEN PlusToken = FixedToken("+", "plus @A @O"); +TOKEN EqualToken = FixedToken("=", "equal @A @O"); +TOKEN LeftBraceToken = FixedToken("{", "@O"); +TOKEN RightBraceToken = FixedToken("}", "@O"); +TOKEN BarToken = FixedToken("|", "@O"); +TOKEN CircumToken = FixedToken("~", "@O"); +TOKEN LeftBracketToken = FixedToken("[", "@O"); +TOKEN RightBracketToken = FixedToken("]", "@O"); +TOKEN SemicolonToken = FixedToken(";", "@O"); +TOKEN ColonToken = FixedToken(":", "@O"); +TOKEN LessToken = FixedToken("<", "less @A @O"); +TOKEN GreaterToken = FixedToken(">", "greater @A @O"); +TOKEN QuestionToken = FixedToken("?", "@O"); +TOKEN CommaToken = FixedToken(",", "@O"); +TOKEN DotToken = FixedToken(".", "@O"); +TOKEN EiffelDotToken = FixedToken(".", "@ED"); +TOKEN LessEqualToken = FixedToken("<=", "lessequal @A @O"); +TOKEN GreaterEqualToken = FixedToken(">=", "greaterequal @A @O"); +TOKEN CNotEqualToken = FixedToken("!=", "notequal @A @O"); +TOKEN EiffelNotEqualToken = FixedToken("/=", "notequal @A @O"); +TOKEN BlueNotEqualToken = FixedToken("<>", "notequal @A @O"); +TOKEN AssignToken = FixedToken(":=", "@O"); +TOKEN QuestionAssignToken = FixedToken("?=", "@O"); +TOKEN DollarToken = FixedToken("$", "@O"); +TOKEN ImpliesToken = FixedToken("=>", "implies @A @O"); + + +/*****************************************************************************/ +/* */ +/* LANGUAGE - put your language declarations in this section. */ +/* */ +/*****************************************************************************/ + +typedef struct lang_rec { + char *names[MAX_ARRAY_LENGTH]; + char *default_style; + TOKEN *tokens[MAX_ARRAY_LENGTH]; + char *keywords[MAX_ARRAY_LENGTH]; +} LANGUAGE; + +LANGUAGE CLanguage = { + { "C", "c", "C++", "c++" }, + "fixed", + { + &CStringToken, &CCharacterToken, &IdentifierToken, &NumberToken, + &CCommentToken, &CCommentEscapeToken, + &CPPCommentToken, &CPPCommentEscapeToken, + &HashToken, &ExclamationToken, &PercentToken, &HatToken, + &AmpersandToken, &StarToken, &LeftParenToken, &RightParenToken, + &MinusToken, &PlusToken, &EqualToken, &LeftBraceToken, &RightBraceToken, + &BarToken, &CircumToken, &LeftBracketToken, &RightBracketToken, + &SemicolonToken, &ColonToken, &LessToken, &GreaterToken, + &QuestionToken, &CommaToken, &DotToken, &SlashToken, &BackSlashToken, + &ArrowToken, &LessEqualToken, &GreaterEqualToken, &CNotEqualToken + }, + + { "asm", "auto", "break", "case", "catch", "char", "class", "const", + "continue", "default", "delete", "do", "double", "else", "enum", + "extern", "float", "for", "friend", "goto", "if", "inline", "int", + "long", "new", "operator", "private", "protected", "public", "register", + "return", "short", "signed", "sizeof", "static", "struct", "switch", + "template", "this", "throw", "try", "typedef", "union", "unsigned", + "virtual", "void", "volatile", "while", + } +}; + + +LANGUAGE EiffelLanguage = { + { "Eiffel", "eiffel" }, + "varying", + { + &EiffelStringToken, &EiffelCharacterToken, &IdentifierToken, &NumberToken, + &EiffelCommentToken, &EiffelCommentEscapeToken, + &SemicolonToken, &CommaToken, &ColonToken, &EiffelDotToken, + &ExclamationToken, &EqualToken, &EiffelNotEqualToken, &LeftParenToken, + &RightParenToken, &LeftBracketToken, &RightBracketToken, &LeftBraceToken, + &RightBraceToken, &AssignToken, &QuestionAssignToken, &PlusToken, + &MinusToken, &DollarToken, &HatToken, &SlashToken, &BackSlashToken, + &LessToken, &GreaterToken, &LessEqualToken, &GreaterEqualToken + }, + + { "alias", "all", "and", "as", "check", "class", "creation", "debug", + "deferred", "do", "else", "elseif", "end", "ensure", "expanded", + "export", "external", "false", "feature", "from", "frozen", "if", + "implies", "indexing", "infix", "inherit", "inspect", "invariant", + "is", "like", "local", "loop", "obsolete", "old", "once", "or", + "prefix", "redefine", "rename", "require", "rescue", "retry", "select", + "separate", "strip", "then", "true", "undefine", "unique", "until", + "variant", "when", "xor", "not", "interface" + } +}; + + +LANGUAGE BlueLanguage = { + { "Blue", "blue" }, + "varying", + { + &CStringToken, &IdentifierToken, &NumberToken, + &BlueCommentToken, &BlueCommentEscapeToken, + &CommaToken, &LessToken, &GreaterToken, &ColonToken, &AssignToken, + &LeftParenToken, &RightParenToken, &LeftBracketToken, &RightBracketToken, + &QuestionAssignToken, &ExclamationToken, &EiffelDotToken, &ImpliesToken, + &EqualToken, &BlueNotEqualToken, &LeftBraceToken, &RightBraceToken, + &PlusToken, &MinusToken, &StarToken, &SlashToken, &HatToken, + &LessEqualToken, &GreaterEqualToken + + }, + + { "and", "assert", "builtin", "case", "class", "const", "create", + "creation", "deferred", "div", "do", "else", "elseif", "end", + "Enumeration", "enumeration", "exit", "if", "in", "interface", + "internal", "invariant", "is", "loop", "manifest", "mod", "not", + "of", "old", "on", "or", "post", "pre", "redefined", "return", + "routines", "super", "then", "uses", "var" + } +}; + + +LANGUAGE *languages[] = { + & CLanguage, + & EiffelLanguage, + & BlueLanguage, +}; + +/*****************************************************************************/ +/* */ +/* If you are adding a new language, you don't need to change anything */ +/* below this point. Just repeating: don't change anything below here. */ +/* */ +/*****************************************************************************/ + + +/*****************************************************************************/ +/* */ +/* Global constants and variables */ +/* */ +/*****************************************************************************/ +#define DEBUG_SETUP 0 +#define DEBUG_PROCESS 0 +#define DEBUG_TRIE 0 +#define DEBUG_NEXTCHAR 0 +#define DEBUG_PREFIXEQ 0 +#define DEBUG_EMIT 0 +#define DEBUG_MAIN 0 + +#define PROG2LOUT_VERSION "prg2lout Version 1.0 (February 2000)" +#define BOOLEAN unsigned +#define FALSE 0 +#define TRUE 1 +#define MAX_LINE 1024 + +/* print styles */ +#define NO_STYLE 0 +#define FIXED_STYLE 1 +#define VARYING_STYLE 2 +#define SYMBOL_STYLE 3 + +static char file_name[MAX_LINE]; /* current input file name */ +static char curr_line[MAX_LINE]; /* current input line */ +static int line_num; /* current input line number */ +static int line_pos; /* current input column number */ +static BOOLEAN raw_seen; /* TRUE if -r (raw mode) */ + +static BOOLEAN headers_option; /* TRUE if no -n option (headers) */ +static int style_option; /* value of -p option, or NO_STYLE */ +static char *font_option; /* value of -f option, else null */ +static char *size_option; /* value of -s option, else null */ +static char *line_option; /* value of -v option, else null */ +static char *tabin_option; /* value of -t option, else null */ +static char *tabout_option; /* value of -T option, else null */ +static char *language_option; /* value of -l option, else null */ + +static BOOLEAN tab_by_spacing; /* TRUE if using space chars to tab */ +static int tab_in; /* tab interval, value of -t option */ +static float tab_out; /* tab interval width (-T option) */ +static char tab_unit; /* unit of measurement for tab */ + +char *ErrorHeader() +{ static char buff[MAX_LINE]; + if( line_num == 0 ) + sprintf(buff, "prg2lout"); + else if( raw_seen ) + sprintf(buff, "prg2lout %d,%d", line_num, line_pos); + else + sprintf(buff, "prg2lout %s %d,%d", file_name, line_num, line_pos); + return buff; +} + +#define GetArg(arg, message, null_ok) \ +{ if( strcmp(argv[arg_pos]+2, "") != 0 ) \ + arg = argv[arg_pos]+2; \ + else if( !null_ok && arg_pos < argc-1 && *argv[arg_pos+1] != '-' ) \ + arg = argv[++arg_pos]; \ + else if( null_ok ) \ + arg = (char *) NULL; \ + else \ + { fprintf(err_fp, "%s: %s\n", ErrorHeader(), message); \ + exit(1); \ + } \ +} /* end GetArg */ + + +/*****************************************************************************/ +/* */ +/* char *EchoToken(TOKEN *t) */ +/* */ +/* Print a brief resume of token t */ +/* */ +/*****************************************************************************/ + +char *EchoToken(TOKEN *t) +{ static char buff[MAX_LINE]; + if( t == (TOKEN *) NULL ) + sprintf(buff, "(NULL)"); + else + sprintf(buff, "%s", t->name); + return buff; +} + + + +/*****************************************************************************/ +/* */ +/* TRIE */ +/* */ +/* We use a trie to match the input against the opening pattern of each */ +/* token, since some tokens (e.g. <=, // etc.) have multi-character */ +/* opening patterns. */ +/* */ +/*****************************************************************************/ + +typedef struct trie_node { + struct trie_node *sub[MAX_CHAR]; + TOKEN *value[MAX_CHAR]; +} *TRIE; + +/*****************************************************************************/ +/* */ +/* BOOLEAN TrieInsert(&T, str, val) */ +/* */ +/* Insert str into trie T. May need a new root so pass T by reference. */ +/* Return FALSE if the insertion failed, either because the string was */ +/* empty, or because it was the same as a previously inserted string. */ +/* */ +/*****************************************************************************/ + +BOOLEAN TrieInsert(TRIE *T, char *str, TOKEN *val) +{ BOOLEAN res; + if( DEBUG_TRIE ) + fprintf(stderr, "[ TrieInsert(T, %s, %s)\n", str, EchoToken(val)); + if( *str == '\0' ) + res = FALSE; + else + { + if( *T == (TRIE) NULL ) + *T = (TRIE) calloc(1, sizeof(struct trie_node)); /* will set all to 0 */ + if( *(str + 1) != '\0' ) + res = TrieInsert(&((*T)->sub[(int) *str]), str + 1, val); + else if( (*T)->value[(int) *str] != (TOKEN *) NULL ) + res = FALSE; + else + { + (*T)->value[(int) *str] = val; + res = TRUE; + } + } + if( DEBUG_TRIE ) + fprintf(stderr, "] TrieInsert(T, %s, %s) returning %s\n", str, + EchoToken(val), res ? "TRUE" : "FALSE"); + return res; +} + +/*****************************************************************************/ +/* */ +/* TOKEN *TrieRetrieve(T, str, &len) */ +/* */ +/* Find the longest prefix of string str in T. If this is empty, return */ +/* NULL. If non-empty, return the corresponding value as the result, and */ +/* the length of the prefix in *len. */ +/* */ +/*****************************************************************************/ + +TOKEN *TrieRetrieve(TRIE T, char *str, int *len) +{ TOKEN *res; int i; + if( DEBUG_TRIE ) + fprintf(stderr, "[ TrieRetrieve(T, %s, len)\n", str); + res = (TOKEN *) NULL; + *len = 0; + for( i = 0; T != (TRIE) NULL; T = T->sub[(int) str[i]], i++ ) + { + if( DEBUG_TRIE ) + fprintf(stderr, " i = %d, res = %s\n", i, EchoToken(res)); + if( T->value[(int) str[i]] != (TOKEN *) NULL ) + { + res = T->value[(int) str[i]]; + *len = i+1; + } + } + if( DEBUG_TRIE ) + fprintf(stderr, "] TrieRetrieve returning (*len = %d) %s\n", + *len, EchoToken(res)); + return res; +} + + +/*****************************************************************************/ +/* */ +/* HASH_TABLE */ +/* */ +/* We use a hash table to hold the keywords. There is no associated */ +/* value, we just want to know whether they are there or not. */ +/* */ +/* NB MAX_SYM must be somewhat larger than the number of keywords. */ +/* */ +/*****************************************************************************/ +#define MAX_SYM 309 + +static char *HashTable[MAX_SYM]; /* will initialze to NULL */ +static int HashTableCount = 0; /* number of entries */ + +static int hash(char *key) +{ int i, res; + res = 0; + for( i = 0; key[i] != '\0'; i++ ) + { res += key[i]; + } + return res % MAX_SYM; +} /* end hash */ + +void HashTableInsert(char *str, FILE *err_fp) +{ int i; + if( DEBUG_SETUP ) + fprintf(stderr, "[ HashTableInsert(%s)\n", str); + if( HashTableCount >= MAX_SYM - 20 ) + { + fprintf(err_fp, "%s internal error: full hash table (increase MAX_SYM)\n", + ErrorHeader()); + abort(); + } + for( i = hash(str); HashTable[i] != (char *) NULL; i = (i+1) % MAX_SYM ); + HashTable[i] = str; + HashTableCount++; + if( DEBUG_SETUP ) + fprintf(stderr, "] HashTableInsert(%s)\n", str); +} + +BOOLEAN HashTableRetrieve(char *str) +{ int i; + for( i = hash(str); HashTable[i] != (char *) NULL; i = (i+1) % MAX_SYM ) + if( strcmp(HashTable[i], str) == 0 ) + return TRUE; + return FALSE; +} + + +/*****************************************************************************/ +/* */ +/* BACK END */ +/* */ +/* This is the code that actually prints the output file. It accumulates */ +/* each token and only prints it at the end of the token, so that it can */ +/* check whether an alternative command ought to be printed (keywords). */ +/* */ +/*****************************************************************************/ + +static char save_token[MAX_LINE]; /* the token text */ +static int save_len; /* index of \0 in save_token */ +static BOOLEAN save_on = FALSE; /* TRUE when saving */ + +/*****************************************************************************/ +/* */ +/* EmitRaw(ch, out_fp, FILE *err_fp) */ +/* */ +/* Emit this character immediately. This is only legal when not saving. */ +/* All characters printed on the output file should pass through here, */ +/* since EmitRaw keeps track of where we are on the output line, in order */ +/* to handle tab characters correctly. */ +/* */ +/* NB out_linepos is the column where the *next* character will go, and */ +/* it counts the first column on the line as column zero. It understands */ +/* that a tab character always produces at least one space, and that the */ +/* character after a tab goes in a column whose number mod tab_in is zero. */ +/* */ +/*****************************************************************************/ + +void EmitRaw(char ch, FILE *out_fp, FILE *err_fp) +{ + static int out_linepos = 0; /* output line position */ + static BOOLEAN out_linestart = TRUE; /* TRUE if out line start */ + + if( DEBUG_EMIT ) + fprintf(stderr, "EmitRaw(%c); out_linepos %d, out_linestart %s\n", + ch, out_linepos, out_linestart ? "TRUE" : "FALSE"); + if( save_on ) + { + fprintf(err_fp, "%s internal error (EmitRaw save_on)\n", ErrorHeader()); + abort(); + } + if( ch == '\t' ) + { + if( tab_by_spacing ) + { putc(' ', out_fp); + out_linepos++; + while( out_linepos % tab_in != 0 ) + { putc(' ', out_fp); + out_linepos++; + } + } + else + { + out_linepos++; + while( out_linepos % tab_in != 0 ) + { out_linepos++; + } + if( out_linestart ) + { fprintf(out_fp, "$>%.1f%c {}", tab_out, tab_unit); + /* NB {} is required in case nothing follows on this line */ + } + else + { fprintf(out_fp, "$>%.1f%ct {}", (out_linepos/tab_in)*tab_out, tab_unit); + } + } + } + else if( ch == '\n' ) + { + fputc(ch, out_fp); + out_linepos = 0; + out_linestart = TRUE; + } + else + { + fputc(ch, out_fp); + out_linepos++; + if( ch != ' ' ) + out_linestart = FALSE; + } + if( DEBUG_EMIT ) + fprintf(stderr, "EmitRaw(%c) returning; out_linepos %d, out_linestart %s\n", + ch, out_linepos, out_linestart ? "TRUE" : "FALSE"); +} /* end EmitRaw */ + + +/*****************************************************************************/ +/* */ +/* StartEmit(FILE *err_fp) */ +/* */ +/* Start the emission of a token. */ +/* */ +/*****************************************************************************/ + +void StartEmit(FILE *err_fp) +{ + if( save_on ) + { + fprintf(err_fp, "%s internal error (StartEmit)\n", ErrorHeader()); + abort(); + } + save_on = TRUE; + save_len = 0; +} + + +/*****************************************************************************/ +/* */ +/* EndEmit(LANGUAGE *lang, TOKEN *current_token, FILE *out_fp, *err_fp) */ +/* */ +/* End emitting a token of this type on file out_fp. */ +/* */ +/*****************************************************************************/ + +void EndEmit(LANGUAGE *lang, TOKEN *current_token, FILE *out_fp, FILE *err_fp) +{ BOOLEAN altern; int i; + if( !save_on ) + { + fprintf(err_fp, "%s internal error (EndEmit)\n", ErrorHeader()); + abort(); + } + save_on = FALSE; + + if( save_len == 0 ) + { + /* nothing in token, must be resumed after a newline or tab */ + /* so emit nothing in this case */ + } + else if( current_token->command == (char *) NULL ) + { + /* no command, which means to emit this token without its delimiters */ + for( i = 0; i < save_len; i++ ) + EmitRaw(save_token[i], out_fp, err_fp); + } + else + { + /* if there is an alternate command in this language, check whether the */ + /* completed token is a keyword, and if so apply the alternate command. */ + altern = (lang != (LANGUAGE *) NULL + && current_token->alternate_command[0] != '\0' + && HashTableRetrieve(save_token)); + + putc('{', out_fp); + fputs(altern ? current_token->alternate_command : current_token->command, + out_fp); + putc('"', out_fp); + for( i = 0; i < save_len; i++ ) + { + if( save_token[i] == '"' || save_token[i] == '\\' ) + putc('\\', out_fp); + EmitRaw(save_token[i], out_fp, err_fp); + } + putc('"', out_fp); + putc('}', out_fp); + } +} /* end EndEmit */ + + +/*****************************************************************************/ +/* */ +/* Emit(char ch, TOKEN *current_token, FILE *out_fp, FILE *err_fp) */ +/* */ +/* Emit one character. */ +/* */ +/*****************************************************************************/ + +void Emit(char ch, TOKEN *current_token, FILE *out_fp, FILE *err_fp) +{ + if( !save_on ) + { + fprintf(err_fp, "%s internal error (EmitChar)\n", ErrorHeader()); + abort(); + } + if( ch == '\n' || ch == '\t' ) + { + EndEmit((LANGUAGE *) NULL, current_token, out_fp, err_fp); + EmitRaw(ch, out_fp, err_fp); + StartEmit(err_fp); + } + else + { + save_token[save_len++] = ch; + save_token[save_len] = '\0'; + } +} /* end Emit */ + + +/*****************************************************************************/ +/* */ +/* SetupTokens(LANGUAGE *lang) */ +/* */ +/* Set up the runtime token structures. This involves initializing the */ +/* chtype and escape_chtype fields for each token type in the chosen */ +/* language, and loading the trie with all the opening delimiters of all */ +/* the tokens. */ +/* */ +/*****************************************************************************/ +#define LEGAL 1 +#define ESCAPE 2 +#define INNER_ESCAPE 3 + +TRIE Trie = (TRIE) NULL; + +void SetupTokens(LANGUAGE *lang, FILE *err_fp) +{ TOKEN *t; int i, j; + if( DEBUG_SETUP ) + fprintf(stderr, "SetupTokens(%s)\n", lang->names[0]); + + /* set up each token in the language */ + for( i = 0; lang->tokens[i] != (TOKEN *) NULL; i++ ) + { + t = lang->tokens[i]; + if( DEBUG_SETUP ) + fprintf(stderr, "SetupTokens token starting %s\n", t->starts[0]); + + /* set up the chtype table for this token */ + for( j = 0; t->legal[j] != '\0'; j++ ) + t->chtype[(int) t->legal[j]] = LEGAL; + if( t->escape[0] != '\0' ) + t->chtype[(int) t->escape[0]] = ESCAPE; + if( t->inner_escape[0] != '\0' ) + t->chtype[(int) t->inner_escape[0]] = INNER_ESCAPE; + + /* set up the escape_chtype table for this token */ + for( j = 0; t->escape_legal[j] != '\0'; j++ ) + t->escape_chtype[(int) t->escape_legal[j]] = LEGAL; + + /* load the opening delimiters of this token into the trie */ + for( j = 0; t->starts[j] != (char *) NULL; j++ ) + { + if( !TrieInsert(&Trie, t->starts[j], t) ) + { + if( *(t->starts[j]) == '\0' ) + fprintf(err_fp, "%s: empty starting delimiter\n", ErrorHeader()); + else + fprintf(err_fp, "%s: starting delimiter %s appears twice\n", + ErrorHeader(), t->starts[j]); + } + } + + if( DEBUG_SETUP ) + fprintf(stderr, "SetupTokens token ending %s\n", t->starts[0]); + } + + /* load the keyword hash table */ + for( j = 0; lang->keywords[j] != (char *) NULL; j++ ) + HashTableInsert(lang->keywords[j], err_fp); + + if( DEBUG_SETUP ) + fprintf(stderr, "SetupTokens(%s) returning.\n", lang->names[0]); +} /* end SetupTokens */ + + +/*****************************************************************************/ +/* */ +/* BOOLEAN PrefixEq(char *str, char *prefix) */ +/* */ +/* Returns TRUE if str (unterminated) begins with prefix (terminated). */ +/* */ +/*****************************************************************************/ + +BOOLEAN PrefixEq(char *str, char *prefix) +{ char *p, *q; + for( p = str, q = prefix; *q != '\0' && *p == *q; p++, q++ ); + if( DEBUG_PREFIXEQ ) + fprintf(stderr, "PrefixEq(%s, %s) returning %s\n", + str, prefix, *q == '\0' ? "TRUE" : "FALSE"); + return (*q == '\0'); +} /* end PrefixEq */ + + +/*****************************************************************************/ +/* */ +/* NextChar(FILE *in_fp) */ +/* */ +/* Move to next character in the input file. This may involve changing */ +/* global variables curr_line, line_num, and line_pos; the new character */ +/* may be found in curr_line[line_pos]. */ +/* */ +/* NextChar does not skip any characters at all. When end of file is */ +/* reached, curr_line[line_pos] contains '\0'. */ +/* */ +/*****************************************************************************/ + +void NextChar(FILE *in_fp) +{ + if( curr_line[line_pos] == '\n' ) + { + /* need a new line */ + line_num++; + line_pos = 1; + if( fgets(&curr_line[1], MAX_LINE+2, in_fp) == (char *) NULL ) + curr_line[1] = '\0'; + } + else line_pos++; /* will yield '\0' as desired if EOF before end of line */ + if( DEBUG_NEXTCHAR ) + fprintf(stderr, "after NextChar, line_num %d, line_pos %d, curr_line %s", + line_num, line_pos, &curr_line[1]); +} /* end NextChar */ + + +/*****************************************************************************/ +/* */ +/* BOOLEAN Printable(char ch) */ +/* */ +/* TRUE if ch is a printable character. Used only by error messages so */ +/* can be slow. */ +/* */ +/*****************************************************************************/ + +BOOLEAN Printable(char ch) +{ char *p; + for( p = AllPrintable; *p != '\0' && *p != ch; p++ ); + return (*p == ch); +} /* end Printable */ + + +/*****************************************************************************/ +/* */ +/* Process(LANGUAGE*lang, FILE*in_fp, *out_fp, *err_fp, TOKEN *outer_token) */ +/* */ +/* Process a sequence of input tokens. If we are currently recursing */ +/* inside some other token, outer_token is non-null and is that token, */ +/* and we stop when we reach the ending delimiter of the inner escape */ +/* of that token. Otherwise, we stop at end of file. */ +/* */ +/*****************************************************************************/ +#define START 1 +#define IN_TOKEN 2 +#define IN_TOKEN_AFTER_ESCAPE 3 +#define IN_TOKEN_AFTER_INNER_ESCAPE 4 +#define STOP 5 + +void Process(LANGUAGE *lang, FILE *in_fp, FILE *out_fp, FILE *err_fp, +TOKEN *outer_token) +{ TOKEN *current_token; int len, i, state; + if( DEBUG_PROCESS ) + fprintf(stderr, "[ Process(%s, -, -, -, -)\n", lang->names[0]); + + state = START; + while( curr_line[line_pos] != '\0' && state != STOP ) + { + if( DEBUG_PROCESS ) + fprintf(stderr, " state %d, ch %c\n", state, curr_line[line_pos]); + switch( state ) + { + case START: /* between tokens */ + + /* check whether outer_token's delimiter is current */ + if( outer_token != (TOKEN *) NULL && + outer_token->end_inner_escape[0] != '\0' && + PrefixEq(&curr_line[line_pos], outer_token->end_inner_escape) ) + { + len = strlen(outer_token->end_inner_escape); + for( i = 0; i < len; i++ ) + NextChar(in_fp); + state = STOP; + } + else switch( curr_line[line_pos] ) + { + + case ' ': + + EmitRaw(' ', out_fp, err_fp); + NextChar(in_fp); + break; + + + case '\t': + + if( outer_token != (TOKEN *) NULL ) + { + fprintf(err_fp, "%s: replacing tab character in escape by space\n", + ErrorHeader()); + EmitRaw(' ', out_fp, err_fp); + NextChar(in_fp); + } + else + { + EmitRaw('\t', out_fp, err_fp); + NextChar(in_fp); + } + break; + + + case '\n': + + if( outer_token != (TOKEN *) NULL ) + { + fprintf(err_fp, "%s: inserting %s to fix unterminated escape\n", + ErrorHeader(), outer_token->end_inner_escape); + state = STOP; + } + else + { + EmitRaw('\n', out_fp, err_fp); + NextChar(in_fp); + } + break; + + + case '\f': + + if( outer_token != (TOKEN *) NULL ) + { + fprintf(err_fp, "%s: replacing formfeed character in escape by space\n", + ErrorHeader()); + EmitRaw(' ', out_fp, err_fp); + NextChar(in_fp); + } + else + { + fprintf(out_fp, "\n@NP"); + EmitRaw('\n', out_fp, err_fp); + NextChar(in_fp); + } + break; + + + default: + + /* look up the trie to see which token we are starting */ + current_token = TrieRetrieve(Trie, &curr_line[line_pos], &len); + if( current_token == (TOKEN *) NULL ) + { + /* error; no token starts here, so print error message and skip */ + if( Printable(curr_line[line_pos]) ) + fprintf(err_fp, "%s: skipping unexpected %c character\n", + ErrorHeader(), curr_line[line_pos]); + else + fprintf(err_fp, + "%s: skipping unexpected unprintable character (octal %o)\n", + ErrorHeader(), (int) curr_line[line_pos]); + NextChar(in_fp); + } + else + { + /* have a token, so start emitting it */ + if( DEBUG_PROCESS ) + { + fprintf(stderr, "current_token (len = %d): %s\n", + len, EchoToken(current_token)); + } + StartEmit(err_fp); + for( i = 0; i < len; i++ ) + { + /* *** + if( DEBUG_PROCESS ) + fprintf(stderr, " emitting delim (i %d, len %d)\n", i, len); + *** */ + if( current_token->command != (char *) NULL ) + Emit(curr_line[line_pos], current_token, out_fp, err_fp); + NextChar(in_fp); + } + state = IN_TOKEN; + } + } + break; + + + case IN_TOKEN: /* within a token; current_token says which kind */ + + /* check for ending delimiter if there is one */ + if( current_token->end_delimiter[0] != '\0' && + PrefixEq(&curr_line[line_pos], current_token->end_delimiter) ) + { + if( DEBUG_PROCESS ) + fprintf(stderr, " PrefixEq(-, %s) so finishing token\n", + current_token->end_delimiter); + len = strlen(current_token->end_delimiter); + for( i = 0; i < len; i++ ) + { if( current_token->command != (char *) NULL ) + Emit(curr_line[line_pos], current_token, out_fp, err_fp); + NextChar(in_fp); + } + EndEmit(lang, current_token, out_fp, err_fp); + state = START; + } + else switch( current_token->chtype[(int) curr_line[line_pos]] ) + { + + case LEGAL: + + Emit(curr_line[line_pos], current_token, out_fp, err_fp); + NextChar(in_fp); + break; + + + case ESCAPE: + + NextChar(in_fp); + state = IN_TOKEN_AFTER_ESCAPE; + break; + + + case INNER_ESCAPE: + + EndEmit(lang, current_token, out_fp, err_fp); + NextChar(in_fp); + Process(lang, in_fp, out_fp, err_fp, current_token); + state = IN_TOKEN_AFTER_INNER_ESCAPE; + break; + + + default: + + if( current_token->end_delimiter[0] != '\0' ) + { + /* error: token ends at delimiter, not at unexpected character */ + if( Printable(curr_line[line_pos]) ) + fprintf(err_fp, "%s: skipping unexpected %c character in %s\n", + ErrorHeader(), curr_line[line_pos], current_token->name); + else + fprintf(err_fp, + "%s: skipping unexpected unprintable character (octal %o) in %s\n", + ErrorHeader(), (int) curr_line[line_pos], current_token->name); + NextChar(in_fp); + } + else + { + /* normal termination after last legal character */ + EndEmit(lang, current_token, out_fp, err_fp); + state = START; + } + break; + + + } + break; + + + case IN_TOKEN_AFTER_ESCAPE: + + if( current_token->escape_chtype[(int) curr_line[line_pos]] == LEGAL ) + { + Emit(current_token->escape[0], current_token, out_fp, err_fp); + Emit(curr_line[line_pos], current_token, out_fp, err_fp); + } + else + { + if( Printable(curr_line[line_pos]) ) + fprintf(err_fp, "%s: skipping %c%c in %s, since %c not legal here\n", + ErrorHeader(), current_token->escape[0], curr_line[line_pos], + current_token->name, curr_line[line_pos]); + else + fprintf(err_fp, + "%s: skipping %c and unprintable unexpected character (octal %o)\n", + ErrorHeader(), current_token->escape[0], (int) curr_line[line_pos]); + } + NextChar(in_fp); + state = IN_TOKEN; + break; + + + case IN_TOKEN_AFTER_INNER_ESCAPE: + + /* ending delimiter of inner escape has been read over */ + StartEmit(err_fp); + state = IN_TOKEN; + break; + + + default: + + fprintf(err_fp, "%s internal error (state = %d)\n", + ErrorHeader(), state); + abort(); + break; + } + } + + /* at end, need to tidy up any residual messiness */ + switch( state ) + { + + case START: + case STOP: + + /* we stopped outside any token, or after an escape */ + break; + + + case IN_TOKEN: + + /* we stopped in a token (only a problem if it ends with a delimiter) */ + if( current_token->end_delimiter[0] != '\0' ) + { + if( outer_token == (TOKEN *) NULL ) + fprintf(err_fp, "%s: program text ended within %s\n", + ErrorHeader(), current_token->name); + else + fprintf(err_fp, "%s: %s escape ended within %s\n", + ErrorHeader(), outer_token->name, current_token->name); + EndEmit(lang, current_token, out_fp, err_fp); + } + break; + + + case IN_TOKEN_AFTER_ESCAPE: + + /* we stopped after the escape character */ + fprintf(err_fp, "%s: skipping %c at end of program text\n", + ErrorHeader(), current_token->escape[0]); + EndEmit(lang, current_token, out_fp, err_fp); + break; + + + case IN_TOKEN_AFTER_INNER_ESCAPE: + + /* we stopped after an inner escape (NB no EndEmit in this case) */ + if( current_token->end_delimiter[0] != '\0' ) + { + if( outer_token == (TOKEN *) NULL ) + fprintf(err_fp, "%s: program text ended within %s after escape\n", + ErrorHeader(), current_token->name); + else + fprintf(err_fp, "%s: %s escape ended within %s after escape\n", + ErrorHeader(), outer_token->name, current_token->name); + } + break; + + + default: + + fprintf(err_fp, "%s: internal error (state %d)\n", + ErrorHeader(), state); + abort(); + break; + + } +} /* end Process */ + + +/*****************************************************************************/ +/* */ +/* PrintUsage(fp) */ +/* */ +/* Print usage message on file fp. */ +/* */ +/*****************************************************************************/ + +void PrintUsage(FILE *fp) +{ int i; + fprintf(fp, "\n"); + fprintf(fp, "usage: prg2lout <options> <files>\n\n"); + fprintf(fp, " where <options> can be\n"); + fprintf(fp, "\n"); + fprintf(fp, " -r raw mode (used within Lout only)\n"); + fprintf(fp, " -i<file> take input from <file>\n"); + fprintf(fp, " -o<file> send output to <file>\n"); + fprintf(fp, " -e<file> send error messages to <file>\n"); + fprintf(fp, " -l<language> input is in this programming language\n"); + fprintf(fp, " -p<style> print style: fixed, varying, symbol\n"); + fprintf(fp, " -f<family> font family (e.g. Times)\n"); + fprintf(fp, " -s<size> font size (e.g. 10p or 12p)\n"); + fprintf(fp, " -v<space> line spacing (e.g. 1.1fx)\n"); + fprintf(fp, " -t<num> tab interval (e.g. 8 is default)\n"); + fprintf(fp, " -T<dist> output tab interval (e.g. 0.5i)\n"); + fprintf(fp, " -n no file names as page headers\n"); + fprintf(fp, " -V print version information and exit\n"); + fprintf(fp, " -u print this usage message and exit\n"); + fprintf(fp, "\n"); + fprintf(fp, " and <language> (which is compulsory) can be any one of:\n"); + for( i = 0; languages[i] != (LANGUAGE *) NULL; i++ ) + fprintf(fp, " %s\n", languages[i]->names[0]); + fprintf(fp, "\n"); +} /* end PrintUsage */ + + +/*****************************************************************************/ +/* */ +/* main(argc, argv) */ +/* */ +/* Read command line and either process each file in turn, or, in the */ +/* raw case, do the actual conversion of one file. */ +/* */ +/*****************************************************************************/ + +int main(int argc, char *argv[]) +{ FILE *in_fp, *out_fp, *err_fp; + BOOLEAN stdin_seen; int i, j, arg_pos; + char *infilename, *outfilename, *errfilename, *str; + LANGUAGE *language = (LANGUAGE *) NULL; + char *file_names[1024]; int file_count = 0; + + /* echo command line */ + if( DEBUG_MAIN ) + { + for( i = 0; i < argc; i++ ) + fprintf(stderr, i == 0 ? "%s" : " %s", argv[i]); + fprintf(stderr, "\n\n"); + } + + /* read command line */ + in_fp = out_fp = (FILE *) NULL; + err_fp = stderr; + line_num = 0; + stdin_seen = raw_seen = FALSE; + tab_by_spacing = TRUE; + style_option = NO_STYLE; + tab_in = 8; + tab_out = 3; + tab_unit = 'f'; + headers_option = TRUE; + font_option = size_option = line_option = tabin_option = + tabout_option = language_option = (char *) NULL; + if( argc == 1 ) + { PrintUsage(err_fp); + exit(1); + } + for( arg_pos = 1; arg_pos < argc; arg_pos++ ) + { + if( DEBUG_SETUP ) + fprintf(stderr, "examining argument %d = \"%s\"\n", + arg_pos, argv[arg_pos]); + if( *argv[arg_pos] == '-' ) switch( *(argv[arg_pos]+1) ) + { + case 'r': + + if( arg_pos > 1 ) + { fprintf(err_fp, "%s: -r must be first if it occurs at all\n", + ErrorHeader()); + exit(1); + } + raw_seen = TRUE; + break; + + + case 'i': + + /* read name of input file */ + if( !raw_seen ) + { fprintf(err_fp, "%s: -i illegal with -r\n", ErrorHeader()); + exit(1); + } + if( in_fp != NULL ) + { fprintf(err_fp, "%s: -i seen twice\n", ErrorHeader()); + exit(1); + } + GetArg(infilename, "usage: -i<filename>", FALSE); + + /* open the file */ + in_fp = fopen(infilename, "r"); + if( in_fp == NULL ) + { fprintf(err_fp, "%s: cannot open input file %s\n", + ErrorHeader(), infilename); + exit(1); + } + + /* initialize file position */ + strcpy(file_name, infilename); + line_num = 1; + line_pos = 0; + break; + + + case 'o': + + /* read name of output file */ + if( out_fp != NULL ) + { fprintf(err_fp, "%s: -o seen twice\n", ErrorHeader()); + exit(1); + } + GetArg(outfilename, "usage: -o<filename>", FALSE); + out_fp = fopen(outfilename, "w"); + if( out_fp == NULL ) + { fprintf(err_fp, "%s: cannot open output file %s\n", + ErrorHeader(), outfilename); + exit(1); + } + break; + + + case 'e': + + /* read name of error file */ + GetArg(errfilename, "usage: -e<filename>", FALSE); + err_fp = fopen(errfilename, "w"); + if( err_fp == NULL ) + { fprintf(stderr, "%s: cannot open error file %s", + ErrorHeader(), errfilename); + exit(1); + } + break; + + + case 'p': + + /* read print style */ + if( raw_seen ) + { fprintf(err_fp, "%s: -p illegal with -r option\n", ErrorHeader()); + exit(1); + } + GetArg(str, "usage: -p<printstyle>", FALSE); + /* *** -l can set style, so don't do this now + if( style_option != NO_STYLE ) + { fprintf(err_fp, "%s: -p option appears twice!\n", ErrorHeader()); + exit(1); + } + else + *** */ + if( strcmp(str, "fixed") == 0 ) + { style_option = FIXED_STYLE; + } + else if( strcmp(str, "varying") == 0 ) + { style_option = VARYING_STYLE; + tab_by_spacing = FALSE; + } + else if( strcmp(str, "symbol") == 0 ) + { style_option = SYMBOL_STYLE; + tab_by_spacing = FALSE; + } + else + { fprintf(err_fp, "%s: unknown -p option %s\n", ErrorHeader(), str); + exit(1); + } + break; + + + case 'f': + + /* read font family */ + if( raw_seen ) + { fprintf(err_fp, "%s: -f illegal with -r option\n", ErrorHeader()); + exit(1); + } + GetArg(font_option, "usage: -f<font_family>", FALSE); + break; + + + case 's': + + /* read font size */ + if( raw_seen ) + { fprintf(err_fp, "%s: -s illegal with -r option\n", ErrorHeader()); + exit(1); + } + GetArg(size_option, "usage: -s<size>", FALSE); + break; + + + case 'v': + + /* read line spacing */ + if( raw_seen ) + { fprintf(err_fp, "%s: -v illegal with -r option\n", ErrorHeader()); + exit(1); + } + GetArg(line_option, "usage: -v<line_spacing>", FALSE); + break; + + + case 't': + + /* read tab interval */ + GetArg(tabin_option, "usage: -t<number>", TRUE); + if( tabin_option != NULL && sscanf(tabin_option,"%d",&tab_in) != 1 ) + { fprintf(err_fp, "%s usage: -t<number>\n", ErrorHeader()); + exit(1); + } + if( tab_in <= 0 ) + { fprintf(err_fp, "%s -t: tab interval must be greater than 0\n", + ErrorHeader()); + exit(1); + } + break; + + + case 'T': + + /* read tab_out and tab_unit */ + GetArg(tabout_option, "usage: -T<number><unit>", TRUE); + if( tabout_option != NULL ) + { if( sscanf(tabout_option, "%f%c",&tab_out,&tab_unit) != 2 ) + { fprintf(err_fp, "%s usage: -T<number><unit>\n", ErrorHeader()); + exit(1); + } + if( tab_out <= 0 || tab_out >= 50 ) + { fprintf(err_fp, "%s -T: unreasonably large or small tab interval\n", + ErrorHeader()); + exit(1); + } + if( tab_unit != 'c' && tab_unit != 'i' && tab_unit != 'p' && + tab_unit != 'm' && tab_unit != 'f' && tab_unit != 's' && + tab_unit != 'v' ) + { fprintf(err_fp, "%s -T: tab unit must be one of cipmfsv\n", + ErrorHeader()); + exit(1); + } + tab_by_spacing = FALSE; + } + break; + + + case 'n': + + if( raw_seen ) + { fprintf(err_fp, "%s: -n illegal with -r option\n", ErrorHeader()); + exit(1); + } + headers_option = FALSE; + break; + + + case 'V': + + if( raw_seen ) + { fprintf(err_fp, "%s: -V illegal with -r option\n", ErrorHeader()); + exit(1); + } + fprintf(err_fp, "%s\n", PROG2LOUT_VERSION); + exit(0); + break; + + + case 'u': + + if( raw_seen ) + { fprintf(err_fp, "%s: -u illegal with -r option\n", ErrorHeader()); + exit(1); + } + PrintUsage(err_fp); + exit(0); + break; + + + case 'l': + + if( language_option != (char *) NULL ) + { fprintf(err_fp, "%s: -l seen twice\n", ErrorHeader()); + exit(1); + } + GetArg(language_option, "usage: -l<language>", FALSE); + for( i = 0; languages[i] != (LANGUAGE *) NULL; i++ ) + { + for( j = 0; languages[i]->names[j] != (char *) NULL; j++ ) + { + if( strcmp(languages[i]->names[j], language_option) == 0 ) + break; + } + if( languages[i]->names[j] != (char *) NULL ) + break; + } + if( languages[i] != (LANGUAGE *) NULL ) + { + language = languages[i]; + } + else + { + fprintf(err_fp, "%s: unknown language %s\n", ErrorHeader(), + language_option); + exit(1); + } + + /* set style unless already done by a -p flag */ + if( style_option == NO_STYLE ) + { + if( strcmp(language->default_style, "fixed") == 0 ) + { style_option = FIXED_STYLE; + } + else if( strcmp(language->default_style, "varying") == 0 ) + { style_option = VARYING_STYLE; + tab_by_spacing = FALSE; + } + else if( strcmp(language->default_style, "symbol") == 0 ) + { style_option = SYMBOL_STYLE; + tab_by_spacing = FALSE; + } + else + { fprintf(err_fp, + "%s internal error: bad default print style for language %s\n", + ErrorHeader(), language_option); + abort(); + } + } + break; + + + default: + + fprintf(err_fp, "%s: unknown command line flag %s\n", ErrorHeader(), + argv[i]); + exit(1); + break; + + } + else + { + if( raw_seen ) + { fprintf(err_fp, "%s: file parameter illegal with -r flag\n", + ErrorHeader()); + exit(1); + } + if( DEBUG_SETUP ) + fprintf(stderr, "file_names[%d++] = argv[%d] = %s\n", + file_count, arg_pos, argv[arg_pos]); + file_names[file_count++] = argv[arg_pos]; + } + } /* for */ + + /* make sure we have a language */ + if( language == (LANGUAGE *) NULL ) + { + fprintf(err_fp, "%s: missing -l option\n", ErrorHeader()); + exit(0); + } + + /* do the actual work */ + if( raw_seen ) + { + /* check that input and output files are open */ + if( in_fp == NULL ) + in_fp = stdin; + if( out_fp == NULL ) + { fprintf(err_fp, "%s -r: missing -o option\n", ErrorHeader()); + exit(1); + } + + /* process the file */ + SetupTokens(language, err_fp); + line_pos = 1; + curr_line[line_pos] = '\n'; /* forces line read */ + line_num = 0; + NextChar(in_fp); + Process(language, in_fp, out_fp, err_fp, (TOKEN *) NULL); + } + else if( file_count > 0 ) + { + int ch; + char *style_str, *font_str, *size_str, *line_str, *face_str; + char *tabin_str, *tabout_str; + + /* sort out the options' values */ + switch( style_option ) + { + + case FIXED_STYLE: + + style_str = "fixed"; + face_str = "Base"; + font_str = font_option != NULL ? font_option : "Courier"; + size_str = size_option != NULL ? size_option : "9p"; + line_str = line_option != NULL ? line_option : "1.1fx"; + tabin_str = tabin_option != NULL ? tabin_option : "8"; + tabout_str = tabout_option != NULL ? tabout_option : "8s"; + break; + + + case NO_STYLE: + case VARYING_STYLE: + + style_str = "varying"; + face_str = "Slope"; + font_str = font_option != NULL ? font_option : "Times"; + size_str = size_option != NULL ? size_option : "10p"; + line_str = line_option != NULL ? line_option : "1.1fx"; + tabin_str = tabin_option != NULL ? tabin_option : "8"; + tabout_str = tabout_option != NULL ? tabout_option : "3f"; + break; + + + case SYMBOL_STYLE: + + style_str = "symbol"; + face_str = "Slope"; + font_str = font_option != NULL ? font_option : "Times"; + size_str = size_option != NULL ? size_option : "10p"; + line_str = line_option != NULL ? line_option : "1.1fx"; + tabin_str = tabin_option != NULL ? tabin_option : "8"; + tabout_str = tabout_option != NULL ? tabout_option : "3f"; + break; + + + default: + + fprintf(err_fp, "%s internal error in -p option\n", ErrorHeader()); + abort(); + break; + } + + /* make sure we have an output file */ + if( out_fp == (FILE *) NULL ) + out_fp = stdout; + + /* print the initial @Use clauses etc.*/ + fprintf(out_fp, "%s%s\n", "@Sy", "sInclude { progf }"); + fprintf(out_fp, "%s%s\n", "@Sy", "sInclude { doc }"); + fprintf(out_fp, "@Use { @ProgSetup\n"); + fprintf(out_fp, " language { %s }\n", language_option); + fprintf(out_fp, " style { %s }\n", style_str); + fprintf(out_fp, " %sfont { %s }\n", style_str, font_str); + fprintf(out_fp, " %ssize { %s }\n", style_str, size_str); + fprintf(out_fp, " %sline { %s }\n", style_str, line_str); + fprintf(out_fp, " %stabin { %s }\n", style_str, tabin_str); + fprintf(out_fp, " %stabout { %s }\n", style_str, tabout_str); + fprintf(out_fp, "}\n"); + fprintf(out_fp, "@Document\n"); + fprintf(out_fp, " @InitialFont { \"%s\" \"%s\" \"%s\" }\n", + font_str, face_str, size_str); + fprintf(out_fp, " @InitialBreak { lines \"%s\" nohyphen }\n", line_str); + fprintf(out_fp, "//\n"); + fprintf(out_fp, "%s%s\n", "@Text @Be", "gin"); + + /* print each file, possibly with a header */ + for( i = 0; i < file_count; i++ ) + { + /* open file and initialize file position */ + in_fp = fopen(file_names[i], "r"); + if( in_fp == NULL ) + { fprintf(err_fp, "%s: skipping input file %s (cannot open)\n", + ErrorHeader(), file_names[i]); + continue; + } + strcpy(file_name, file_names[i]); + + /* print @NP if not first, and header if required */ + if( i > 0 ) + fprintf(out_fp, "\n\n@NP\n\n"); + if( headers_option ) + fprintf(out_fp, "{ Times Bold \"+3p\" } @Font \"%s\"\n@DP\n", + file_names[i]); + + /* print file name and contents (don't format, let Lout call back) */ + /* this string has been disguised so as not to fool progwlout! */ + fprintf(out_fp, "%s%s%s\n", "@P", "rog @Be", "gin"); + while( (ch = getc(in_fp)) != EOF ) + putc(ch, out_fp); + fprintf(out_fp, "%s%s%s\n", "@E", "nd @P", "rog"); + } + + /* finish off whole input */ + fprintf(out_fp, "%s%s%s\n", "@E", "nd @T", "ext"); + + } + exit(0); +} /* end main */ diff --git a/software/lout.eiffel b/software/lout.eiffel index 4e876fc..5247607 100644 --- a/software/lout.eiffel +++ b/software/lout.eiffel @@ -1,34 +1,8 @@ LOUT.EIFFEL - EIFFEL PROGRAM PRINTING IN LOUT DOCUMENTS (VERSION 1.1) -This software allows you to print programs and program fragments -from the Eiffel programming language with Lout. The typeset output -conforms with the style guidelines in the standard reference (Eiffel: -The Language, by Bertrand Meyer). +The package known as lout.eiffel has now been folded into the main +distribution. If you have Version 3.18 of Lout you can already +format Eiffel. -When installed, the only change you have to make is to replace the -@SysInclude { doc } at the top of the document by @SysInclude { edoc }, -then enclose your Eiffel parts in @Eiffel { ... }. - -Lout.eiffel is distributed as follows: - - ftp://ftp.cs.su.oz.au/jeff/lout.eiffel.1.1.tar.gz - -In other words, in a gzipped tar file called "lout.eiffel.1.1.tar.gz" -in the "jeff" subdirectory of the home directory of "ftp ftp.cs.su.oz.au" -with login name "ftp" or "anonymous" using any non-empty password. -The distribution contains - - * Source code for the eif2lout program - - * A manual entry for the eif2lout program - - * Six Lout library files (edoc, etc.) - - * A makefile and installation instructions (very easy) - -User documentation is contained in the Lout User's Guide distributed -with Lout itself. - -Lout.eiffel was designed and implemented by Jeffrey H. Kingston -(jeff@cs.su.oz.au) of the Basser Department of Computer Science at the -University of Sydney. +Jeff Kingston +26 February 2000 @@ -217,10 +217,24 @@ Changes and new features introduced in Version 3.17 [13 September 1999] @Euro symbol added for getting a European Currency symbol Document OBJECT struct declaration in externs.h (for gurus only) +Changes and new features introduced in Version 3.18 [26 February 2000] + + Bug fixes (more than usual, somehow) + New @CurrYUnit and @CurrZUnit symbols (expert users) + @Diag enhancement: node types, similar to row types in @Tbl + @Diag enhancement: new features for drawing syntax diagrams + Portuguese (thanks to Jose Roberto B. de A. Monteiro) + Slight change to @Tbl spec (affects aligned columns) + Replaced c2lout with prg2lout (computer program formatting) + @Outline symbol for printing words in outline rather than filled + A few extra @Eq symbols: filledcircle, small, trieq + Things that ought to be done but haven't been done yet - pdfmark in PostScript output + PDF-like features in PostScript output + Various improvements/bug fixes for PDF output Review Uwe's proposal for moving word row marks to the baseline + Running headers for tables [much more feasible than previously thought] Jeff Kingston -17 September 1999 +23 February 2000 @@ -1,7 +1,7 @@ /*@z01.c:Supervise:StartSym, AllowCrossDb, Encapsulated, etc.@****************/ /* */ -/* THE LOUT DOCUMENT FORMATTING SYSTEM (VERSION 3.17) */ -/* COPYRIGHT (C) 1991, 1999 Jeffrey H. Kingston */ +/* THE LOUT DOCUMENT FORMATTING SYSTEM (VERSION 3.18) */ +/* COPYRIGHT (C) 1991, 2000 Jeffrey H. Kingston */ /* */ /* Jeffrey H. Kingston (jeff@cs.usyd.edu.au) */ /* Basser Department of Computer Science */ @@ -745,10 +745,13 @@ int main(int argc, char *argv[]) load(KW_UNDERLINE, UNDERLINE, FALSE, TRUE, FALSE, DEFAULT_PREC); load(KW_COLOUR, COLOUR, TRUE, TRUE, FALSE, DEFAULT_PREC); load(KW_COLOR, COLOUR, TRUE, TRUE, FALSE, DEFAULT_PREC); + load(KW_OUTLINE, OUTLINE, FALSE, TRUE, FALSE, DEFAULT_PREC); load(KW_LANGUAGE, LANGUAGE, TRUE, TRUE, FALSE, DEFAULT_PREC); load(KW_CURR_LANG, CURR_LANG, FALSE, FALSE, FALSE, DEFAULT_PREC); load(KW_CURR_FAMILY, CURR_FAMILY, FALSE, FALSE, FALSE, DEFAULT_PREC); load(KW_CURR_FACE, CURR_FACE, FALSE, FALSE, FALSE, DEFAULT_PREC); + load(KW_CURR_YUNIT, CURR_YUNIT, FALSE, FALSE, FALSE, DEFAULT_PREC); + load(KW_CURR_ZUNIT, CURR_ZUNIT, FALSE, FALSE, FALSE, DEFAULT_PREC); load(KW_COMMON, COMMON, TRUE, TRUE, FALSE, DEFAULT_PREC); load(KW_RUMP, RUMP, TRUE, TRUE, FALSE, DEFAULT_PREC); load(KW_MELD, MELD, TRUE, TRUE, FALSE, DEFAULT_PREC); @@ -1,7 +1,7 @@ /*@z02.c:Lexical Analyser:Declarations@***************************************/ /* */ -/* THE LOUT DOCUMENT FORMATTING SYSTEM (VERSION 3.17) */ -/* COPYRIGHT (C) 1991, 1999 Jeffrey H. Kingston */ +/* THE LOUT DOCUMENT FORMATTING SYSTEM (VERSION 3.18) */ +/* COPYRIGHT (C) 1991, 2000 Jeffrey H. Kingston */ /* */ /* Jeffrey H. Kingston (jeff@cs.usyd.edu.au) */ /* Basser Department of Computer Science */ @@ -841,6 +841,7 @@ FILE *fp; BOOLEAN end_stop; FILE_POS *err_pos; BOOLEAN lessskip; case CSPACE: case TAB: + case FORMFEED: if( !skipping ) hold(*(p-1)); break; @@ -861,7 +862,7 @@ FILE *fp; BOOLEAN end_stop; FILE_POS *err_pos; BOOLEAN lessskip; if( fp == NULL ) Error(2, 22, "end of file reached while reading %s", - FATAL, err_pos, lessskip ? KW_VERBATIM : KW_RAWVERBATIM); + FATAL, err_pos, lessskip ? KW_RAWVERBATIM : KW_VERBATIM); else Error(2, 17, "end of file reached while reading filter parameter", FATAL, err_pos); @@ -945,6 +946,7 @@ FILE *fp; BOOLEAN end_stop; FILE_POS *err_pos; BOOLEAN lessskip; default: + Error(2, 22, "unreadable character (octal %o)",INTERN,&file_pos,*(p-1)); assert(FALSE, "LexScanVerbatim: bad chtbl[]"); break; @@ -1,7 +1,7 @@ /*@z03.c:File Service:Declarations, no_fpos@******************************** */ /* */ -/* THE LOUT DOCUMENT FORMATTING SYSTEM (VERSION 3.17) */ -/* COPYRIGHT (C) 1991, 1999 Jeffrey H. Kingston */ +/* THE LOUT DOCUMENT FORMATTING SYSTEM (VERSION 3.18) */ +/* COPYRIGHT (C) 1991, 2000 Jeffrey H. Kingston */ /* */ /* Jeffrey H. Kingston (jeff@cs.usyd.edu.au) */ /* Basser Department of Computer Science */ @@ -1,7 +1,7 @@ /*@z04.c:Token Service:NewToken(), CopyTokenList()@***************************/ /* */ -/* THE LOUT DOCUMENT FORMATTING SYSTEM (VERSION 3.17) */ -/* COPYRIGHT (C) 1991, 1999 Jeffrey H. Kingston */ +/* THE LOUT DOCUMENT FORMATTING SYSTEM (VERSION 3.18) */ +/* COPYRIGHT (C) 1991, 2000 Jeffrey H. Kingston */ /* */ /* Jeffrey H. Kingston (jeff@cs.usyd.edu.au) */ /* Basser Department of Computer Science */ @@ -191,10 +191,13 @@ FULL_CHAR *EchoToken(OBJECT x) case BREAK: case UNDERLINE: case COLOUR: + case OUTLINE: case LANGUAGE: case CURR_LANG: case CURR_FAMILY: case CURR_FACE: + case CURR_YUNIT: + case CURR_ZUNIT: case COMMON: case RUMP: case MELD: @@ -1,7 +1,7 @@ /*@z05.c:Read Definitions:ReadFontDef()@**************************************/ /* */ -/* THE LOUT DOCUMENT FORMATTING SYSTEM (VERSION 3.17) */ -/* COPYRIGHT (C) 1991, 1999 Jeffrey H. Kingston */ +/* THE LOUT DOCUMENT FORMATTING SYSTEM (VERSION 3.18) */ +/* COPYRIGHT (C) 1991, 2000 Jeffrey H. Kingston */ /* */ /* Jeffrey H. Kingston (jeff@cs.usyd.edu.au) */ /* Basser Department of Computer Science */ @@ -283,10 +283,13 @@ static void ReadTokenList(OBJECT token, OBJECT res) case BREAK: case UNDERLINE: case COLOUR: + case OUTLINE: case LANGUAGE: case CURR_LANG: case CURR_FAMILY: case CURR_FACE: + case CURR_YUNIT: + case CURR_ZUNIT: case COMMON: case RUMP: case MELD: @@ -1,7 +1,7 @@ /*@z06.c:Parser:PushObj(), PushToken(), etc.@*********************************/ /* */ -/* THE LOUT DOCUMENT FORMATTING SYSTEM (VERSION 3.17) */ -/* COPYRIGHT (C) 1991, 1999 Jeffrey H. Kingston */ +/* THE LOUT DOCUMENT FORMATTING SYSTEM (VERSION 3.18) */ +/* COPYRIGHT (C) 1991, 2000 Jeffrey H. Kingston */ /* */ /* Jeffrey H. Kingston (jeff@cs.usyd.edu.au) */ /* Basser Department of Computer Science */ @@ -434,10 +434,13 @@ static BOOLEAN Reduce(void) case BREAK: case UNDERLINE: case COLOUR: + case OUTLINE: case LANGUAGE: case CURR_LANG: case CURR_FAMILY: case CURR_FACE: + case CURR_YUNIT: + case CURR_ZUNIT: case COMMON: case RUMP: case MELD: @@ -476,9 +479,9 @@ static BOOLEAN Reduce(void) if( has_lpar(actual(op)) ) { s1 = PopObj(); Link(Down(op), s1); - } - if( type(s1) == BACKEND ) - { op = OptimizeCase(op); + if( type(s1) == BACKEND ) + { op = OptimizeCase(op); + } } PushObj(op); break; @@ -1011,10 +1014,13 @@ BOOLEAN defs_allowed, BOOLEAN transfer_allowed) case BREAK: case UNDERLINE: case COLOUR: + case OUTLINE: case LANGUAGE: case CURR_LANG: case CURR_FAMILY: case CURR_FACE: + case CURR_YUNIT: + case CURR_ZUNIT: case COMMON: case RUMP: case MELD: @@ -1,7 +1,7 @@ /*@z07.c:Object Service:SplitIsDefinite(), DisposeObject()@*******************/ /* */ -/* THE LOUT DOCUMENT FORMATTING SYSTEM (VERSION 3.17) */ -/* COPYRIGHT (C) 1991, 1999 Jeffrey H. Kingston */ +/* THE LOUT DOCUMENT FORMATTING SYSTEM (VERSION 3.18) */ +/* COPYRIGHT (C) 1991, 2000 Jeffrey H. Kingston */ /* */ /* Jeffrey H. Kingston (jeff@cs.usyd.edu.au) */ /* Basser Department of Computer Science */ @@ -218,10 +218,13 @@ OBJECT CopyObject(OBJECT x, FILE_POS *pos) case BREAK: case UNDERLINE: case COLOUR: + case OUTLINE: case LANGUAGE: case CURR_LANG: case CURR_FAMILY: case CURR_FACE: + case CURR_YUNIT: + case CURR_ZUNIT: case COMMON: case RUMP: case MELD: @@ -296,6 +299,7 @@ OBJECT CopyObject(OBJECT x, FILE_POS *pos) default: assert1(FALSE, "CopyObject:", Image(type(x))); + res = nilobj; break; } /* end switch */ @@ -1,7 +1,7 @@ /*@z08.c:Object Manifest:ReplaceWithSplit()@**********************************/ /* */ -/* THE LOUT DOCUMENT FORMATTING SYSTEM (VERSION 3.17) */ -/* COPYRIGHT (C) 1991, 1999 Jeffrey H. Kingston */ +/* THE LOUT DOCUMENT FORMATTING SYSTEM (VERSION 3.18) */ +/* COPYRIGHT (C) 1991, 2000 Jeffrey H. Kingston */ /* */ /* Jeffrey H. Kingston (jeff@cs.usyd.edu.au) */ /* Basser Department of Computer Science */ @@ -626,6 +626,7 @@ OBJECT *enclose, BOOLEAN fcr) x = *enclose; *enclose = nilobj; debug1(DHY, DD, " Manifest/enclose: %s", EchoObject(x)); + debug1(DOM, DD, " Manifest/enclose: %s", EchoObject(x)); x = Manifest(x, env, style, bthr, fthr, target, crs, ok, FALSE, enclose, fcr); debug0(DOM, DD, " ] returning from manifesting closure (enclose)"); return x; @@ -870,7 +871,7 @@ OBJECT *enclose, BOOLEAN fcr) /* UNDER_UNDEF. */ /* */ /*****************************************************************************/ -#define MAX_DEPTH 500 +#define MAX_DEPTH 1000 OBJECT Manifest(OBJECT x, OBJECT env, STYLE *style, OBJECT bthr[2], OBJECT fthr[2], OBJECT *target, OBJECT *crs, BOOLEAN ok, BOOLEAN need_expand, @@ -1001,6 +1002,7 @@ OBJECT *enclose, BOOLEAN fcr) if( !ok || *crs == nilobj ) { word_font(x) = font(*style); word_colour(x) = colour(*style); + word_outline(x) = outline(*style); word_language(x) = language(*style); word_hyph(x) = hyph_style(*style) == HYPH_ON; debug3(DOM, DDD, " manfifest/WORD underline() := %s for %s %s", @@ -1032,6 +1034,7 @@ OBJECT *enclose, BOOLEAN fcr) if( is_word(type(y)) ) { word_font(y) = font(*style); word_colour(y) = colour(*style); + word_outline(y) = outline(*style); word_language(y) = language(*style); word_hyph(y) = hyph_style(*style) == HYPH_ON; if( small_caps(*style) && ok ) y = MapSmallCaps(y, style); @@ -1068,6 +1071,7 @@ OBJECT *enclose, BOOLEAN fcr) if( is_word(type(y)) ) { word_font(y) = font(*style); word_colour(y) = colour(*style); + word_outline(y) = outline(*style); word_language(y) = language(*style); word_hyph(y) = hyph_style(*style) == HYPH_ON; if( small_caps(*style) && ok ) y = MapSmallCaps(y, style); @@ -1198,6 +1202,7 @@ OBJECT *enclose, BOOLEAN fcr) prev != nilobj && is_word(type(prev)) && !mark(gap(g)) && word_font(prev) == word_font(y) && word_colour(prev) == word_colour(y) && + word_outline(prev) == word_outline(y) && word_language(prev) == word_language(y) ) /* no need to compare underline() since both are false */ { unsigned typ; @@ -1211,6 +1216,7 @@ OBJECT *enclose, BOOLEAN fcr) y = MakeWordTwo(typ, string(prev), string(y), &fpos(prev)); word_font(y) = word_font(prev); word_colour(y) = word_colour(prev); + word_outline(y) = word_outline(prev); word_language(y) = word_language(prev); word_hyph(y) = word_hyph(prev); underline(y) = UNDER_OFF; @@ -1275,6 +1281,7 @@ OBJECT *enclose, BOOLEAN fcr) { z = MakeWord(WORD, STR_EMPTY, &fpos(g)); word_font(z) = font(*style); word_colour(z) = colour(*style); + word_outline(z) = outline(*style); word_language(z) = language(*style); word_hyph(z) = hyph_style(*style) == HYPH_ON; underline(z) = UNDER_OFF; @@ -1583,6 +1590,22 @@ OBJECT *enclose, BOOLEAN fcr) break; + case CURR_YUNIT: + case CURR_ZUNIT: + + { FULL_CHAR buff[20]; + if( type(x) == CURR_YUNIT ) + sprintf( (char *) buff, "%dp", yunit(*style) / PT); + else + sprintf( (char *) buff, "%dp", zunit(*style) / PT); + res = MakeWord(WORD, buff, &fpos(x)); + } + ReplaceNode(res, x); + DisposeObject(x); + x = Manifest(res, env, style, bthr, fthr, target, crs, ok, FALSE, enclose, fcr); + break; + + case FONT: case SPACE: case YUNIT: @@ -1628,12 +1651,14 @@ OBJECT *enclose, BOOLEAN fcr) break; + case OUTLINE: case PADJUST: case HADJUST: case VADJUST: StyleCopy(new_style, *style); - if( type(x) == VADJUST ) vadjust(new_style) = TRUE; + if( type(x) == OUTLINE ) outline(new_style) = TRUE; + else if( type(x) == VADJUST ) vadjust(new_style) = TRUE; else if( type(x) == HADJUST ) hadjust(new_style) = TRUE; else padjust(new_style) = TRUE; Child(y, Down(x)); @@ -1652,8 +1677,9 @@ OBJECT *enclose, BOOLEAN fcr) padjust(*style) = FALSE; StyleCopy(save_style(x), *style); Child(y, Down(x)); - y = Manifest(y, env, style, bthr, fthr, target, crs, ok, FALSE, enclose, fcr); + y = Manifest(y, env, style, nbt, nft, target, crs, ok, FALSE, enclose, fcr); SetUnderline(x); + ReplaceWithSplit(x, bthr, fthr); break; @@ -1,7 +1,7 @@ /*@z09.c:Closure Expansion:SearchEnv()@***************************************/ /* */ -/* THE LOUT DOCUMENT FORMATTING SYSTEM (VERSION 3.17) */ -/* COPYRIGHT (C) 1991, 1999 Jeffrey H. Kingston */ +/* THE LOUT DOCUMENT FORMATTING SYSTEM (VERSION 3.18) */ +/* COPYRIGHT (C) 1991, 2000 Jeffrey H. Kingston */ /* */ /* Jeffrey H. Kingston (jeff@cs.usyd.edu.au) */ /* Basser Department of Computer Science */ @@ -180,12 +180,12 @@ OBJECT *crs, OBJECT *res_env) if( type(par) == PAR && actual(par) == actual(x) ) { assert( Down(par) != par, "ExpandCLosure: Down(par)!"); Child(res, Down(par)); - if( dirty(enclosing(actual(par))) ) - { debug2(DSU, DD, "c %s %s", SymName(actual(par)), EchoObject(res)); + if( dirty(enclosing(actual(par))) || is_enclose(actual(par)) ) + { debug2(DCE, DD, "copy %s %s", SymName(actual(par)), EchoObject(res)); res = CopyObject(res, no_fpos); } else - { debug2(DCE, DDD, "l %s %s", + { debug2(DCE, DD, "link %s %s", FullSymName(actual(par), AsciiToFull(".")), EchoObject(res)); DeleteLink(Down(par)); y = MakeWord(WORD, STR_NOCROSS, &fpos(res)); @@ -1,7 +1,7 @@ /*@z10.c:Cross References:CrossInit(), CrossMake()@***************************/ /* */ -/* THE LOUT DOCUMENT FORMATTING SYSTEM (VERSION 3.17) */ -/* COPYRIGHT (C) 1991, 1999 Jeffrey H. Kingston */ +/* THE LOUT DOCUMENT FORMATTING SYSTEM (VERSION 3.18) */ +/* COPYRIGHT (C) 1991, 2000 Jeffrey H. Kingston */ /* */ /* Jeffrey H. Kingston (jeff@cs.usyd.edu.au) */ /* Basser Department of Computer Science */ @@ -1,7 +1,7 @@ /*@z11.c:Style Service:EchoStyle()@*******************************************/ /* */ -/* THE LOUT DOCUMENT FORMATTING SYSTEM (VERSION 3.17) */ -/* COPYRIGHT (C) 1991, 1999 Jeffrey H. Kingston */ +/* THE LOUT DOCUMENT FORMATTING SYSTEM (VERSION 3.18) */ +/* COPYRIGHT (C) 1991, 2000 Jeffrey H. Kingston */ /* */ /* Jeffrey H. Kingston (jeff@cs.usyd.edu.au) */ /* Basser Department of Computer Science */ @@ -1,7 +1,7 @@ /*@z12.c:Size Finder:MinSize()@***********************************************/ /* */ -/* THE LOUT DOCUMENT FORMATTING SYSTEM (VERSION 3.17) */ -/* COPYRIGHT (C) 1991, 1999 Jeffrey H. Kingston */ +/* THE LOUT DOCUMENT FORMATTING SYSTEM (VERSION 3.18) */ +/* COPYRIGHT (C) 1991, 2000 Jeffrey H. Kingston */ /* */ /* Jeffrey H. Kingston (jeff@cs.usyd.edu.au) */ /* Basser Department of Computer Science */ @@ -322,7 +322,7 @@ void SpannerAvailableSpace(OBJECT y, int dim, FULL_LENGTH *resb, OBJECT MinSize(OBJECT x, int dim, OBJECT *extras) { OBJECT y, z, link, prev, t, g, full_name; - FULL_LENGTH b, f, dble_fwd, llx, lly, urx, ury; int status; + FULL_LENGTH b, f, dble_fwd, llx, lly, urx, ury; int status, read_status; float fllx, flly, furx, fury; BOOLEAN dble_found, found, will_expand, first_line, cp; FILE *fp; FULL_CHAR buff[MAX_BUFF]; @@ -842,6 +842,7 @@ OBJECT MinSize(OBJECT x, int dim, OBJECT *extras) mode(gap(g)) == EDGE_MODE && !mark(gap(g)) && word_font(prev) == word_font(y) && word_colour(prev) == word_colour(y) && + word_outline(prev) == word_outline(y) && word_language(prev) == word_language(y) && underline(prev) == underline(y) && NextDown(NextDown(Up(prev))) == link @@ -858,6 +859,7 @@ OBJECT MinSize(OBJECT x, int dim, OBJECT *extras) y = MakeWordTwo(typ, string(prev), string(y), &fpos(prev)); word_font(y) = word_font(prev); word_colour(y) = word_colour(prev); + word_outline(y) = word_outline(prev); word_language(y) = word_language(prev); word_hyph(y) = word_hyph(prev); underline(y) = underline(prev); @@ -1123,8 +1125,17 @@ OBJECT MinSize(OBJECT x, int dim, OBJECT *extras) fp = OpenIncGraphicFile(string(y), type(x), &full_name, &fpos(y), &cp); if( fp == NULL ) status = IG_NOFILE; first_line = TRUE; + /* *** while( status == IG_LOOKING && StringFGets(buff, MAX_BUFF, fp) != NULL ) + *** */ + while( status == IG_LOOKING ) { + read_status = fscanf(fp, "%[^\n\r]%*c", (char *) buff); + if( read_status == 0 || read_status == EOF ) + { + /* end of input and no luck */ + break; + } if( first_line && !StringBeginsWith(buff, AsciiToFull("%!")) ) status = IG_BADFILE; else @@ -1,7 +1,7 @@ /*@z13.c:Object Breaking:BreakJoinedGroup()@**********************************/ /* */ -/* THE LOUT DOCUMENT FORMATTING SYSTEM (VERSION 3.17) */ -/* COPYRIGHT (C) 1991, 1999 Jeffrey H. Kingston */ +/* THE LOUT DOCUMENT FORMATTING SYSTEM (VERSION 3.18) */ +/* COPYRIGHT (C) 1991, 2000 Jeffrey H. Kingston */ /* */ /* Jeffrey H. Kingston (jeff@cs.usyd.edu.au) */ /* Basser Department of Computer Science */ @@ -437,8 +437,9 @@ static OBJECT BreakTable(OBJECT x, CONSTRAINT *c) OBJECT BreakObject(OBJECT x, CONSTRAINT *c) { OBJECT link, y; CONSTRAINT yc; FULL_LENGTH f; BOOLEAN junk; - debug3(DOB, DD, "[ BreakObject(x (%s,%s), %s), x =", - EchoLength(back(x, COLM)), EchoLength(fwd(x, COLM)), EchoConstraint(c)); + debug4(DOB, DD, "[ BreakObject(%s (%s,%s), %s), x =", + Image(type(x)), EchoLength(back(x, COLM)), EchoLength(fwd(x, COLM)), + EchoConstraint(c)); ifdebug(DOB, DD, DebugObject(x)); /* if constraint is negative (should really be never), replace with empty */ @@ -528,6 +529,7 @@ OBJECT BreakObject(OBJECT x, CONSTRAINT *c) small_caps(save_style(y)) = FALSE; font(save_style(y)) = word_font(x); colour(save_style(y)) = word_colour(x); + outline(save_style(y)) = word_outline(x); language(save_style(y)) = word_language(x); debug3(DOF, DD, " in BreakObject y %s %s %s", EchoStyle(&save_style(y)), Image(type(y)), EchoObject(y)); @@ -1,7 +1,7 @@ /*@z14.c:Fill Service:Declarations@*******************************************/ /* */ -/* THE LOUT DOCUMENT FORMATTING SYSTEM (VERSION 3.17) */ -/* COPYRIGHT (C) 1991, 1999 Jeffrey H. Kingston */ +/* THE LOUT DOCUMENT FORMATTING SYSTEM (VERSION 3.18) */ +/* COPYRIGHT (C) 1991, 2000 Jeffrey H. Kingston */ /* */ /* Jeffrey H. Kingston (jeff@cs.usyd.edu.au) */ /* Basser Department of Computer Science */ @@ -220,6 +220,7 @@ typedef struct { { hyph_word = MakeWord(WORD, STR_HYPHEN, &fpos(x)); \ word_font(hyph_word) = 0; \ word_colour(hyph_word) = colour(save_style(x)); \ + word_outline(hyph_word) = outline(save_style(x)); \ word_language(hyph_word) = language(save_style(x)); \ word_hyph(hyph_word) = hyph_style(save_style(x))==HYPH_ON; \ } \ @@ -549,6 +550,7 @@ OBJECT FillObject(OBJECT x, CONSTRAINT *c, OBJECT multi, BOOLEAN can_hyphenate, res = MakeWord(WORD, STR_EMPTY, &fpos(x)); word_font(res) = font(save_style(x)); word_colour(res) = colour(save_style(x)); + word_outline(res) = outline(save_style(x)); word_language(res) = language(save_style(x)); word_hyph(res) = hyph_style(save_style(x)) == HYPH_ON; back(res, COLM) = fwd(res, COLM) = 0; @@ -568,6 +570,7 @@ OBJECT FillObject(OBJECT x, CONSTRAINT *c, OBJECT multi, BOOLEAN can_hyphenate, back(tmp, COLM) = fwd(tmp, COLM) = back(tmp, ROWM) = fwd(tmp, ROWM) = 0; word_font(tmp) = 0; word_colour(tmp) = 0; + word_outline(tmp) = 0; word_language(tmp) = 0; word_hyph(tmp) = 0; underline(tmp) = UNDER_OFF; @@ -686,7 +689,17 @@ OBJECT FillObject(OBJECT x, CONSTRAINT *c, OBJECT multi, BOOLEAN can_hyphenate, } ); - if( I.llink == x ) + if( can_hyphenate && IntervalBadness(BestI) > HYPH_BAD ) + { + /* the result is bad enough to justify the cost of a second attempt, */ + /* with hyphenation turned on this time */ + x = Hyphenate(x); + can_hyphenate = FALSE; + hyph_allowed = TRUE; + *hyph_used = TRUE; + goto RESTART; + } + else if( I.llink == x ) { /* The result has only one line. Since the line did not fit initially, */ /* this must mean either that a large word was discarded or else that */ /* the line was only slightly tight */ @@ -701,13 +714,6 @@ OBJECT FillObject(OBJECT x, CONSTRAINT *c, OBJECT multi, BOOLEAN can_hyphenate, Link(res, x); } } - else if( can_hyphenate && IntervalBadness(BestI) > HYPH_BAD ) - { x = Hyphenate(x); - can_hyphenate = FALSE; - hyph_allowed = TRUE; - *hyph_used = TRUE; - goto RESTART; - } else { OBJECT lgap, llink; New(res, VCAT); @@ -738,6 +744,7 @@ OBJECT FillObject(OBJECT x, CONSTRAINT *c, OBJECT multi, BOOLEAN can_hyphenate, back(t1, COLM) = fwd(t1, COLM) = back(t1, ROWM) = fwd(t1, ROWM) = 0; word_font(t1) = 0; word_colour(t1) = 0; + word_outline(t1) = 0; word_language(t1) = 0; word_hyph(t1) = 0; underline(t1) = UNDER_OFF; @@ -778,6 +785,7 @@ OBJECT FillObject(OBJECT x, CONSTRAINT *c, OBJECT multi, BOOLEAN can_hyphenate, z = MakeWord(WORD, STR_HYPHEN, &fpos(y)); word_font(z) = font(save_style(x)); word_colour(z) = colour(save_style(x)); + word_outline(z) = outline(save_style(x)); word_language(z) = language(save_style(x)); word_hyph(z) = hyph_style(save_style(x)) == HYPH_ON; underline(z) = under; @@ -872,6 +880,7 @@ OBJECT FillObject(OBJECT x, CONSTRAINT *c, OBJECT multi, BOOLEAN can_hyphenate, if( is_word(type(prev)) && is_word(type(next)) && word_font(prev) == word_font(next) && word_colour(prev) == word_colour(next) && + word_outline(prev) == word_outline(next) && word_language(prev) == word_language(next) && underline(prev) == underline(next) ) { @@ -881,6 +890,7 @@ OBJECT FillObject(OBJECT x, CONSTRAINT *c, OBJECT multi, BOOLEAN can_hyphenate, tmp = MakeWordTwo(typ, string(prev), string(next), &fpos(prev)); word_font(tmp) = word_font(prev); word_colour(tmp) = word_colour(prev); + word_outline(tmp) = word_outline(prev); word_language(tmp) = word_language(prev); word_hyph(tmp) = word_hyph(prev); FontWordSize(tmp); @@ -1,7 +1,7 @@ /*@z15.c:Size Constraints:MinConstraint(), EnlargeToConstraint()@*************/ /* */ -/* THE LOUT DOCUMENT FORMATTING SYSTEM (VERSION 3.17) */ -/* COPYRIGHT (C) 1991, 1999 Jeffrey H. Kingston */ +/* THE LOUT DOCUMENT FORMATTING SYSTEM (VERSION 3.18) */ +/* COPYRIGHT (C) 1991, 2000 Jeffrey H. Kingston */ /* */ /* Jeffrey H. Kingston (jeff@cs.usyd.edu.au) */ /* Basser Department of Computer Science */ @@ -1,7 +1,7 @@ /*@z16.c:Size Adjustment:SetNeighbours(), CatAdjustSize()@********************/ /* */ -/* THE LOUT DOCUMENT FORMATTING SYSTEM (VERSION 3.17) */ -/* COPYRIGHT (C) 1991, 1999 Jeffrey H. Kingston */ +/* THE LOUT DOCUMENT FORMATTING SYSTEM (VERSION 3.18) */ +/* COPYRIGHT (C) 1991, 2000 Jeffrey H. Kingston */ /* */ /* Jeffrey H. Kingston (jeff@cs.usyd.edu.au) */ /* Basser Department of Computer Science */ @@ -1,7 +1,7 @@ /*@z17.c:Gap Widths:GetGap()@*************************************************/ /* */ -/* THE LOUT DOCUMENT FORMATTING SYSTEM (VERSION 3.17) */ -/* COPYRIGHT (C) 1991, 1999 Jeffrey H. Kingston */ +/* THE LOUT DOCUMENT FORMATTING SYSTEM (VERSION 3.18) */ +/* COPYRIGHT (C) 1991, 2000 Jeffrey H. Kingston */ /* */ /* Jeffrey H. Kingston (jeff@cs.usyd.edu.au) */ /* Basser Department of Computer Science */ @@ -68,7 +68,7 @@ void GetGap(OBJECT x, STYLE *style, GAP *res_gap, unsigned *res_inc) /* make sure we have a WORD or QWORD argument */ if( !is_word(type(x)) ) { Error(17, 1, "gap is not a simple word", WARN, &fpos(x)); - debug1(DGW, DD, "GetGap failing (type(x) = %s)", Image(type(x))); + debug1(DGW, DD, "GetGap failing (x = %s)", EchoObject(x)); return; } str = string(x); @@ -369,11 +369,11 @@ FULL_LENGTH ActualGap(FULL_LENGTH prevf, FULL_LENGTH b, FULL_LENGTH f, #if DEBUG_ON FULL_CHAR *EchoGap(GAP *xgap) -{ char *letter = "?ehxokt"; char c; FULL_CHAR *res; +{ char *letter = "?ehxoktH"; char c; FULL_CHAR *res; char *u; static int i = 0; static char buff[3][20]; - assert( mode(*xgap) <= 6, "EchoGap: mode(*xgap)" ); + c = mode(*xgap) <= 7 ? letter[mode(*xgap)] : '?'; c = letter[mode(*xgap)]; u = nobreak(*xgap) ? "u" : ""; switch( units(*xgap) ) @@ -1,7 +1,7 @@ /*@z18.c:Galley Transfer:Declarations@****************************************/ /* */ -/* THE LOUT DOCUMENT FORMATTING SYSTEM (VERSION 3.17) */ -/* COPYRIGHT (C) 1991, 1999 Jeffrey H. Kingston */ +/* THE LOUT DOCUMENT FORMATTING SYSTEM (VERSION 3.18) */ +/* COPYRIGHT (C) 1991, 2000 Jeffrey H. Kingston */ /* */ /* Jeffrey H. Kingston (jeff@cs.usyd.edu.au) */ /* Basser Department of Computer Science */ @@ -80,6 +80,7 @@ void TransferInit(OBJECT InitEnv) small_caps(InitialStyle) = SMALL_CAPS_OFF; font(InitialStyle) = 0; /* i.e. undefined */ colour(InitialStyle) = 0; /* i.e. undefined */ + outline(InitialStyle) = FALSE; /* i.e. not outlined */ language(InitialStyle) = 0; /* i.e. undefined */ yunit(InitialStyle) = 0; /* i.e. zero */ zunit(InitialStyle) = 0; /* i.e. zero */ @@ -1,7 +1,7 @@ /*@z19.c:Galley Attaching:DetachGalley()@*************************************/ /* */ -/* THE LOUT DOCUMENT FORMATTING SYSTEM (VERSION 3.17) */ -/* COPYRIGHT (C) 1991, 1999 Jeffrey H. Kingston */ +/* THE LOUT DOCUMENT FORMATTING SYSTEM (VERSION 3.18) */ +/* COPYRIGHT (C) 1991, 2000 Jeffrey H. Kingston */ /* */ /* Jeffrey H. Kingston (jeff@cs.usyd.edu.au) */ /* Basser Department of Computer Science */ @@ -1,7 +1,7 @@ /*@z20.c:Galley Flushing:DebugInnersNames()@**********************************/ /* */ -/* THE LOUT DOCUMENT FORMATTING SYSTEM (VERSION 3.17) */ -/* COPYRIGHT (C) 1991, 1999 Jeffrey H. Kingston */ +/* THE LOUT DOCUMENT FORMATTING SYSTEM (VERSION 3.18) */ +/* COPYRIGHT (C) 1991, 2000 Jeffrey H. Kingston */ /* */ /* Jeffrey H. Kingston (jeff@cs.usyd.edu.au) */ /* Basser Department of Computer Science */ @@ -1,7 +1,7 @@ /*@z21.c:Galley Maker:SizeGalley()@*******************************************/ /* */ -/* THE LOUT DOCUMENT FORMATTING SYSTEM (VERSION 3.17) */ -/* COPYRIGHT (C) 1991, 1999 Jeffrey H. Kingston */ +/* THE LOUT DOCUMENT FORMATTING SYSTEM (VERSION 3.18) */ +/* COPYRIGHT (C) 1991, 2000 Jeffrey H. Kingston */ /* */ /* Jeffrey H. Kingston (jeff@cs.usyd.edu.au) */ /* Basser Department of Computer Science */ @@ -289,6 +289,7 @@ OBJECT *dest_index, OBJECT *recs, OBJECT *inners, OBJECT enclose) back(tmp, COLM) = fwd(tmp, COLM) = 0; back(tmp, ROWM) = fwd(tmp, ROWM) = 0; word_font(tmp) = word_colour(tmp) = word_language(tmp) = 0; + word_outline(tmp) = FALSE; word_hyph(tmp) = FALSE; ReplaceNode(tmp, t); DisposeObject(t); @@ -1,7 +1,7 @@ /*@z22.c:Galley Service:Interpose()@******************************************/ /* */ -/* THE LOUT DOCUMENT FORMATTING SYSTEM (VERSION 3.17) */ -/* COPYRIGHT (C) 1991, 1999 Jeffrey H. Kingston */ +/* THE LOUT DOCUMENT FORMATTING SYSTEM (VERSION 3.18) */ +/* COPYRIGHT (C) 1991, 2000 Jeffrey H. Kingston */ /* */ /* Jeffrey H. Kingston (jeff@cs.usyd.edu.au) */ /* Basser Department of Computer Science */ @@ -461,6 +461,7 @@ void Promote(OBJECT hd, OBJECT stop_link, OBJECT dest_index, BOOLEAN join_after) fwd(last, COLM) = fwd(y, gall_dir(hd)); word_font(last) = word_font(y); word_colour(last) = word_colour(y); + word_outline(last) = word_outline(y); word_language(last) = word_language(y); word_hyph(last) = word_hyph(y); Link(opt_components(hd), last); @@ -1,7 +1,7 @@ /*@z23.c:Galley Printer:ScaleFactor()@****************************************/ /* */ -/* THE LOUT DOCUMENT FORMATTING SYSTEM (VERSION 3.17) */ -/* COPYRIGHT (C) 1991, 1999 Jeffrey H. Kingston */ +/* THE LOUT DOCUMENT FORMATTING SYSTEM (VERSION 3.18) */ +/* COPYRIGHT (C) 1991, 2000 Jeffrey H. Kingston */ /* */ /* Jeffrey H. Kingston (jeff@cs.usyd.edu.au) */ /* Basser Department of Computer Science */ @@ -668,6 +668,10 @@ void FixAndPrintObject(OBJECT x, FULL_LENGTH xmk, FULL_LENGTH xb, if( (type(x) == VCAT) == (dim == ROWM) ) { + debug6(DGP, DD, "[ FAPO-CAT %s (%s,%s): xmk %s, xb %s, xf %s", + Image(type(x)), EchoLength(back(x, dim)), EchoLength(fwd(x, dim)), + EchoLength(xmk), EchoLength(xb), EchoLength(xf)); + FirstDefinite(x, link, prev, jn); if( link != x ) { @@ -699,10 +703,6 @@ void FixAndPrintObject(OBJECT x, FULL_LENGTH xmk, FULL_LENGTH xb, inc = FindAdjustIncrement(x, frame_size, dim); else inc = 0; - debug6(DGP, DD, "[ FAPO-CAT %s (%s,%s): xmk %s, xb %s, xf %s", - Image(type(x)), EchoLength(back(x, dim)), EchoLength(fwd(x, dim)), - EchoLength(xmk), EchoLength(xb), EchoLength(xf)); - mk = back_edge + back(prev, dim); debug4(DGP, DD, " FAPO-CAT back_edge %s, mk %s, framesize %s, inc %s", EchoLength(back_edge), EchoLength(mk), EchoLength(frame_size), @@ -1,7 +1,7 @@ /*@z24.c:Print Service:PrintInit()@*******************************************/ /* */ -/* THE LOUT DOCUMENT FORMATTING SYSTEM (VERSION 3.17) */ -/* COPYRIGHT (C) 1991, 1999 Jeffrey H. Kingston */ +/* THE LOUT DOCUMENT FORMATTING SYSTEM (VERSION 3.18) */ +/* COPYRIGHT (C) 1991, 2000 Jeffrey H. Kingston */ /* */ /* Jeffrey H. Kingston (jeff@cs.usyd.edu.au) */ /* Basser Department of Computer Science */ @@ -174,6 +174,61 @@ If you are trying to compile this you have the wrong CHAR_OUT value! #endif }; +/*****************************************************************************/ +/* */ +/* char *MediaName(int h, int v) */ +/* */ +/* Return the PostScript MediaName attribute appropriate to a page of */ +/* width h and height v. */ +/* */ +/* Communicated by Valeriy E. Ushakov, who wrote: */ +/* */ +/* "Attached is a patch to recognize known paper sizes and emit them as */ +/* media name in DocumentMedia comment. GhostView and other PostScript */ +/* viewers recognize these names and display them to the user. Thus user */ +/* knows what paper size document uses without having to know the magic */ +/* numbers." */ +/* */ +/*****************************************************************************/ + +static const char *MediaName(int h, int v) +{ + struct paper { + const char *name; + FULL_LENGTH width, height; + }; + + /* names for known paper sizes */ + static const struct paper paper_map[] = { + { "Letter", 612*PT, 792*PT }, + { "Tabloid", 792*PT, 1224*PT }, + { "Ledger", 1224*PT, 792*PT }, + { "Legal", 612*PT, 1008*PT }, + { "Statement", 396*PT, 612*PT }, + { "Executive", 540*PT, 720*PT }, + { "A3", 842*PT, 1190*PT }, + { "A4", 595*PT, 842*PT }, + { "A5", 420*PT, 595*PT }, + { "B4", 729*PT, 1032*PT }, + { "B5", 516*PT, 729*PT }, + { "Folio", 612*PT, 936*PT }, + { "Quarto", 610*PT, 780*PT }, + { "10x14", 720*PT, 1008*PT }, + { NULL, 0, 0 } + }; + + /* default media name */ + static const char *user_defined = "Plain"; + + const struct paper *p; + for (p = paper_map; p->name; ++p) { + if ((h == p->width) && (v == p->height)) { + return p->name; + } + } + return user_defined; +} + /*****************************************************************************/ /* */ @@ -267,8 +322,10 @@ void PrintBeforeFirst(FULL_LENGTH h, FULL_LENGTH v, FULL_CHAR *label) fprintf(out_fp, "%%%%CreationDate: %s", TimeString()); fprintf(out_fp, "%%%%DocumentData: Binary\n"); fprintf(out_fp, "%%%%DocumentNeededResources: (atend)\n"); - fprintf(out_fp, "%%%%DocumentMedia: Plain %d %d 0 white ()\n", h/PT, v/PT); fprintf(out_fp, "%%%%DocumentSuppliedResources: (atend)\n"); + fprintf(out_fp, "%%%%DocumentMedia: %s %d %d 0 white ()\n", + MediaName(h, v), h/PT, v/PT); + fprintf(out_fp, "%%%%PageOrder: Ascend\n"); fprintf(out_fp, "%%%%Pages: (atend)\n"); fprintf(out_fp, "%%%%BoundingBox: 0 0 %d %d\n", h/PT, v/PT); fprintf(out_fp, "%%%%EndComments\n\n"); @@ -277,8 +334,11 @@ void PrintBeforeFirst(FULL_LENGTH h, FULL_LENGTH v, FULL_CHAR *label) fprintf(out_fp, "%%%%BeginProlog\n"); fprintf(out_fp, "%%%%BeginResource: procset %s\n", StartUpResource); fprintf(out_fp, "/m { 3 1 roll moveto show } bind def\n"); + fprintf(out_fp, "/mo { 3 1 roll moveto true charpath stroke } bind def\n"); fprintf(out_fp, "/s { exch currentpoint exch pop moveto show } bind def\n"); + fprintf(out_fp, "/so { exch currentpoint exch pop moveto true charpath stroke } bind def\n"); fprintf(out_fp, "/k { exch neg 0 rmoveto show } bind def\n"); + fprintf(out_fp, "/ko { exch neg 0 rmoveto true charpath stroke } bind def\n"); fprintf(out_fp, "/ul { gsave setlinewidth dup 3 1 roll\n"); fprintf(out_fp, " moveto lineto stroke grestore } bind def\n"); fprintf(out_fp, "/in { %d mul } def\n", IN); @@ -554,10 +614,11 @@ void PrintBetween(FULL_LENGTH h, FULL_LENGTH v, FULL_CHAR *label) void PrintWord(OBJECT x, int hpos, int vpos) { FULL_CHAR *p, *q, *a, *b, *lig, *unacc; - int i, h, v, ksize; char command; MAPPING m; + int i, h, v, ksize; char *command; MAPPING m; - debug5(DGP, DD, "PrintWord( %s, %d, %d ) font %d colour %d", string(x), - hpos, vpos, word_font(x), word_colour(x)); + debug6(DGP, DD, "PrintWord( %s, %d, %d ) font %d colour %d%s", string(x), + hpos, vpos, word_font(x), word_colour(x), + word_outline(x) ? " outline" : ""); TotalWordCount++; switch( BackEnd ) @@ -618,14 +679,14 @@ void PrintWord(OBJECT x, int hpos, int vpos) vpos = vpos - currentxheight2; if( cpexists && currenty == vpos ) { printnum(hpos, out_fp); - command = 's'; + command = word_outline(x) ? "so" : "s"; } else { currenty = vpos; printnum(hpos, out_fp); fputs(" ", out_fp); printnum(currenty, out_fp); - command = 'm'; + command = word_outline(x) ? "mo" : "m"; cpexists = TRUE; } @@ -668,17 +729,21 @@ void PrintWord(OBJECT x, int hpos, int vpos) for( p++; *p; p++ ) { KernLength(word_font(x), unacc, *(p-1), *p, ksize); if( ksize != 0 ) - { fprintf(out_fp, ")%c %d(", command, -ksize); + { fprintf(out_fp, ")%s %d(", command, -ksize); ++wordcount; - command = 'k'; + command = word_outline(x) ? "ko" : "k"; } fputs(EightBitToPrintForm[*p], out_fp); } if( ++wordcount >= 5 ) - { fprintf(out_fp, ")%c\n", command); + { fprintf(out_fp, ")%s\n", command); wordcount = 0; } - else fprintf(out_fp, ")%c ", command); + else fprintf(out_fp, ")%s ", command); + + /* ordinary printing moves current point; outlining destroys it */ + if( word_outline(x) ) + cpexists = FALSE; break; @@ -716,7 +781,7 @@ void PrintWord(OBJECT x, int hpos, int vpos) vpos = vpos - currentxheight2; if( cpexists && (currenty == vpos) && PDFHasValidTextMatrix() ) { /* printnum(hpos, out_fp); */ - command = 's'; + command = "s"; /* Note: I calculate the width of the space char here in case the font has changed. This prevents subtle spacing errors from occurring. @@ -725,7 +790,7 @@ void PrintWord(OBJECT x, int hpos, int vpos) fnt = finfo[currentfont].size_table; if ( (next_hpos + fnt[' '].right /* width of space char */ ) == hpos ) - command = ' '; + command = " "; #endif } else @@ -733,7 +798,7 @@ void PrintWord(OBJECT x, int hpos, int vpos) /* printnum(hpos, out_fp); fputs(" ", out_fp); printnum(currenty, out_fp); */ - command = 'm'; + command = "m"; cpexists = TRUE; } @@ -769,7 +834,7 @@ void PrintWord(OBJECT x, int hpos, int vpos) /* show string(x) */ /* FontWordSize(x); - this should not be necessary */ - switch (command) + switch (command[0]) { case 'm': @@ -811,7 +876,7 @@ void PrintWord(OBJECT x, int hpos, int vpos) /* acc = MapTable[m]->map[MAP_ACCENT]; */ for( p++; *p; p++ ) { - KernLength(word_font(x), unacc, *(p-1), *p, ksize); + /* KernLength(word_font(x), unacc, *(p-1), *p, ksize); */ KernLength(font_num(finfo[word_font(x)].original_font), unacc, *(p-1), *p, ksize); if ( ksize != 0 ) @@ -1,7 +1,7 @@ /*@z25.c:Object Echo:aprint(), cprint(), printnum()@**************************/ /* */ -/* THE LOUT DOCUMENT FORMATTING SYSTEM (VERSION 3.17) */ -/* COPYRIGHT (C) 1991, 1999 Jeffrey H. Kingston */ +/* THE LOUT DOCUMENT FORMATTING SYSTEM (VERSION 3.18) */ +/* COPYRIGHT (C) 1991, 2000 Jeffrey H. Kingston */ /* */ /* Jeffrey H. Kingston (jeff@cs.usyd.edu.au) */ /* Basser Department of Computer Science */ @@ -713,6 +713,7 @@ static void echo(OBJECT x, unsigned outer_prec, int count) case BREAK: case UNDERLINE: case COLOUR: + case OUTLINE: case LANGUAGE: case OPEN: case TAGGED: @@ -767,6 +768,8 @@ static void echo(OBJECT x, unsigned outer_prec, int count) case CURR_LANG: case CURR_FAMILY: case CURR_FACE: + case CURR_YUNIT: + case CURR_ZUNIT: case BACKEND: case PAGE_LABEL: case HSPAN: @@ -1,7 +1,7 @@ /*@z26.c:Echo Service:BeginString()@******************************************/ /* */ -/* THE LOUT DOCUMENT FORMATTING SYSTEM (VERSION 3.17) */ -/* COPYRIGHT (C) 1991, 1999 Jeffrey H. Kingston */ +/* THE LOUT DOCUMENT FORMATTING SYSTEM (VERSION 3.18) */ +/* COPYRIGHT (C) 1991, 2000 Jeffrey H. Kingston */ /* */ /* Jeffrey H. Kingston (jeff@cs.usyd.edu.au) */ /* Basser Department of Computer Science */ @@ -224,10 +224,13 @@ FULL_CHAR *Image(unsigned int c) case BREAK: return KW_BREAK; case UNDERLINE: return KW_UNDERLINE; case COLOUR: return KW_COLOUR; + case OUTLINE: return KW_OUTLINE; case LANGUAGE: return KW_LANGUAGE; case CURR_LANG: return KW_CURR_LANG; case CURR_FAMILY: return KW_CURR_FAMILY; case CURR_FACE: return KW_CURR_FACE; + case CURR_YUNIT: return KW_CURR_YUNIT; + case CURR_ZUNIT: return KW_CURR_ZUNIT; case COMMON: return KW_COMMON; case RUMP: return KW_RUMP; case MELD: return KW_MELD; @@ -1,7 +1,7 @@ /*@z27.c:Debug Service:Debug flags@*******************************************/ /* */ -/* THE LOUT DOCUMENT FORMATTING SYSTEM (VERSION 3.17) */ -/* COPYRIGHT (C) 1991, 1999 Jeffrey H. Kingston */ +/* THE LOUT DOCUMENT FORMATTING SYSTEM (VERSION 3.18) */ +/* COPYRIGHT (C) 1991, 2000 Jeffrey H. Kingston */ /* */ /* Jeffrey H. Kingston (jeff@cs.usyd.edu.au) */ /* Basser Department of Computer Science */ @@ -1,7 +1,7 @@ /*@z28.c:Error Service:ErrorInit(), ErrorSeen()@******************************/ /* */ -/* THE LOUT DOCUMENT FORMATTING SYSTEM (VERSION 3.17) */ -/* COPYRIGHT (C) 1991, 1999 Jeffrey H. Kingston */ +/* THE LOUT DOCUMENT FORMATTING SYSTEM (VERSION 3.18) */ +/* COPYRIGHT (C) 1991, 2000 Jeffrey H. Kingston */ /* */ /* Jeffrey H. Kingston (jeff@cs.usyd.edu.au) */ /* Basser Department of Computer Science */ @@ -1,7 +1,7 @@ /*@z29.c:Symbol Table:Declarations, hash()@***********************************/ /* */ -/* THE LOUT DOCUMENT FORMATTING SYSTEM (VERSION 3.17) */ -/* COPYRIGHT (C) 1991, 1999 Jeffrey H. Kingston */ +/* THE LOUT DOCUMENT FORMATTING SYSTEM (VERSION 3.18) */ +/* COPYRIGHT (C) 1991, 2000 Jeffrey H. Kingston */ /* */ /* Jeffrey H. Kingston (jeff@cs.usyd.edu.au) */ /* Basser Department of Computer Science */ @@ -304,7 +304,7 @@ unsigned xpredefined, OBJECT xenclosing, OBJECT xbody) uses_count(s) = 0; dirty(s) = FALSE; if( enclosing(s) != nilobj && type(enclosing(s)) == NPAR ) - dirty(enclosing(s)) = TRUE; + dirty(s) = dirty(enclosing(s)) = TRUE; has_par(s) = FALSE; has_lpar(s) = FALSE; @@ -1,7 +1,7 @@ /*@z30.c:Symbol uses:InsertUses()@********************************************/ /* */ -/* THE LOUT DOCUMENT FORMATTING SYSTEM (VERSION 3.17) */ -/* COPYRIGHT (C) 1991, 1999 Jeffrey H. Kingston */ +/* THE LOUT DOCUMENT FORMATTING SYSTEM (VERSION 3.18) */ +/* COPYRIGHT (C) 1991, 2000 Jeffrey H. Kingston */ /* */ /* Jeffrey H. Kingston (jeff@cs.usyd.edu.au) */ /* Basser Department of Computer Science */ @@ -1,7 +1,7 @@ /*@z31.c:Memory Allocator:DebugMemory()@**************************************/ /* */ -/* THE LOUT DOCUMENT FORMATTING SYSTEM (VERSION 3.17) */ -/* COPYRIGHT (C) 1991, 1999 Jeffrey H. Kingston */ +/* THE LOUT DOCUMENT FORMATTING SYSTEM (VERSION 3.18) */ +/* COPYRIGHT (C) 1991, 2000 Jeffrey H. Kingston */ /* */ /* Jeffrey H. Kingston (jeff@cs.usyd.edu.au) */ /* Basser Department of Computer Science */ @@ -228,10 +228,13 @@ void MemInit(void) zz_lengths[ BREAK ] = zz_lengths[ UNDERLINE ] = zz_lengths[ COLOUR ] = + zz_lengths[ OUTLINE ] = zz_lengths[ LANGUAGE ] = zz_lengths[ CURR_LANG ] = zz_lengths[ CURR_FAMILY ] = zz_lengths[ CURR_FACE ] = + zz_lengths[ CURR_YUNIT ] = + zz_lengths[ CURR_ZUNIT ] = zz_lengths[ COMMON ] = zz_lengths[ RUMP ] = zz_lengths[ MELD ] = @@ -1,7 +1,7 @@ /*@z32.c:Counter Service:Next()@**********************************************/ /* */ -/* THE LOUT DOCUMENT FORMATTING SYSTEM (VERSION 3.17) */ -/* COPYRIGHT (C) 1991, 1999 Jeffrey H. Kingston */ +/* THE LOUT DOCUMENT FORMATTING SYSTEM (VERSION 3.18) */ +/* COPYRIGHT (C) 1991, 2000 Jeffrey H. Kingston */ /* */ /* Jeffrey H. Kingston (jeff@cs.usyd.edu.au) */ /* Basser Department of Computer Science */ @@ -61,6 +61,7 @@ OBJECT Next(OBJECT x, int inc, BOOLEAN *done) y = MakeWord(type(x), buff, &fpos(x)); word_font(y) = word_font(x); word_colour(y) = word_colour(x); + word_outline(y) = word_outline(x); word_language(y) = word_language(x); word_hyph(y) = word_hyph(x); underline(y) = underline(x); @@ -1,7 +1,7 @@ /*@z33.c:Database Service:OldCrossDb(), NewCrossDb(), SymToNum()@*************/ /* */ -/* THE LOUT DOCUMENT FORMATTING SYSTEM (VERSION 3.17) */ -/* COPYRIGHT (C) 1991, 1999 Jeffrey H. Kingston */ +/* THE LOUT DOCUMENT FORMATTING SYSTEM (VERSION 3.18) */ +/* COPYRIGHT (C) 1991, 2000 Jeffrey H. Kingston */ /* */ /* Jeffrey H. Kingston (jeff@cs.usyd.edu.au) */ /* Basser Department of Computer Science */ @@ -1,7 +1,7 @@ /*@z34.c:Rotation Service:Declarations@***************************************/ /* */ -/* THE LOUT DOCUMENT FORMATTING SYSTEM (VERSION 3.17) */ -/* COPYRIGHT (C) 1991, 1999 Jeffrey H. Kingston */ +/* THE LOUT DOCUMENT FORMATTING SYSTEM (VERSION 3.18) */ +/* COPYRIGHT (C) 1991, 2000 Jeffrey H. Kingston */ /* */ /* Jeffrey H. Kingston (jeff@cs.usyd.edu.au) */ /* Basser Department of Computer Science */ @@ -1,7 +1,7 @@ /*@z35.c:Time Keeper: MomentSym(), TimeString()@******************************/ /* */ -/* THE LOUT DOCUMENT FORMATTING SYSTEM (VERSION 3.17) */ -/* COPYRIGHT (C) 1991, 1999 Jeffrey H. Kingston */ +/* THE LOUT DOCUMENT FORMATTING SYSTEM (VERSION 3.18) */ +/* COPYRIGHT (C) 1991, 2000 Jeffrey H. Kingston */ /* */ /* Jeffrey H. Kingston (jeff@cs.usyd.edu.au) */ /* Basser Department of Computer Science */ @@ -1,7 +1,7 @@ /*@z36.c:Hyphenation: Declarations@*******************************************/ /* */ -/* THE LOUT DOCUMENT FORMATTING SYSTEM (VERSION 3.17) */ -/* COPYRIGHT (C) 1991, 1999 Jeffrey H. Kingston */ +/* THE LOUT DOCUMENT FORMATTING SYSTEM (VERSION 3.18) */ +/* COPYRIGHT (C) 1991, 2000 Jeffrey H. Kingston */ /* */ /* Jeffrey H. Kingston (jeff@cs.usyd.edu.au) */ /* Basser Department of Computer Science */ @@ -1080,6 +1080,7 @@ OBJECT Hyphenate(OBJECT x) z = MakeWord(WORD, &key[stop+1], &fpos(y)); word_font(z) = word_font(y); word_colour(z) = word_colour(y); + word_outline(z) = word_outline(y); word_language(z) = word_language(y); word_hyph(z) = word_hyph(y); underline(z) = underline(y); @@ -1194,6 +1195,7 @@ OBJECT Hyphenate(OBJECT x) { z = MakeWord(WORD, &key[start+i-1], &fpos(y)); word_font(z) = word_font(y); word_colour(z) = word_colour(y); + word_outline(z) = word_outline(y); word_language(z) = word_language(y); word_hyph(z) = word_hyph(y); underline(z) = underline(y); @@ -1,7 +1,7 @@ /*@z37.c:Font Service:Declarations@*******************************************/ /* */ -/* THE LOUT DOCUMENT FORMATTING SYSTEM (VERSION 3.17) */ -/* COPYRIGHT (C) 1991, 1999 Jeffrey H. Kingston */ +/* THE LOUT DOCUMENT FORMATTING SYSTEM (VERSION 3.18) */ +/* COPYRIGHT (C) 1991, 2000 Jeffrey H. Kingston */ /* */ /* Jeffrey H. Kingston (jeff@cs.usyd.edu.au) */ /* Basser Department of Computer Science */ @@ -1,7 +1,7 @@ /*@z38.c:Character Mappings:Declarations@*************************************/ /* */ -/* THE LOUT DOCUMENT FORMATTING SYSTEM (VERSION 3.17) */ -/* COPYRIGHT (C) 1991, 1999 Jeffrey H. Kingston */ +/* THE LOUT DOCUMENT FORMATTING SYSTEM (VERSION 3.18) */ +/* COPYRIGHT (C) 1991, 2000 Jeffrey H. Kingston */ /* */ /* Jeffrey H. Kingston (jeff@cs.usyd.edu.au) */ /* Basser Department of Computer Science */ @@ -301,7 +301,7 @@ void MapPrintEncodings(FILE *fp) { case POSTSCRIPT: - fprintf(fp, "%%%%BeginResource encoding %s\n", string(map->name)); + fprintf(fp, "%%%%BeginResource: encoding %s\n", string(map->name)); fprintf(fp, "/%s [\n", string(map->name)); for( i = 0; i < MAX_CHARS; i++ ) fprintf(fp, "/%s%c", string(map->vector[i]), (i+1) % 8 != 0 ? ' ' : '\n'); @@ -353,6 +353,7 @@ static OBJECT DoWord(FULL_CHAR *buff, FULL_CHAR *q, OBJECT x, FONT_NUM fnum) res = MakeWord(type(x), buff, &fpos(x)); word_font(res) = fnum; word_colour(res) = word_colour(x); + word_outline(res) = word_outline(x); word_language(res) = word_language(x); word_hyph(res) = word_hyph(x); underline(res) = UNDER_OFF; @@ -1,7 +1,7 @@ /*@z39.c:String Handler:AsciiToFull(), StringEqual(), etc.@*******************/ /* */ -/* THE LOUT DOCUMENT FORMATTING SYSTEM (VERSION 3.17) */ -/* COPYRIGHT (C) 1991, 1999 Jeffrey H. Kingston */ +/* THE LOUT DOCUMENT FORMATTING SYSTEM (VERSION 3.18) */ +/* COPYRIGHT (C) 1991, 2000 Jeffrey H. Kingston */ /* */ /* Jeffrey H. Kingston (jeff@cs.usyd.edu.au) */ /* Basser Department of Computer Science */ @@ -1,7 +1,7 @@ /*@z40.c:Filter Handler:FilterInit()@*****************************************/ /* */ -/* THE LOUT DOCUMENT FORMATTING SYSTEM (VERSION 3.17) */ -/* COPYRIGHT (C) 1991, 1999 Jeffrey H. Kingston */ +/* THE LOUT DOCUMENT FORMATTING SYSTEM (VERSION 3.18) */ +/* COPYRIGHT (C) 1991, 2000 Jeffrey H. Kingston */ /* */ /* Jeffrey H. Kingston (jeff@cs.usyd.edu.au) */ /* Basser Department of Computer Science */ @@ -1,7 +1,7 @@ /*@z41.c:Object Input-Output:AppendToFile, ReadFromFile@**********************/ /* */ -/* THE LOUT DOCUMENT FORMATTING SYSTEM (VERSION 3.17) */ -/* COPYRIGHT (C) 1991, 1999 Jeffrey H. Kingston */ +/* THE LOUT DOCUMENT FORMATTING SYSTEM (VERSION 3.18) */ +/* COPYRIGHT (C) 1991, 2000 Jeffrey H. Kingston */ /* */ /* Jeffrey H. Kingston (jeff@cs.usyd.edu.au) */ /* Basser Department of Computer Science */ @@ -526,10 +526,13 @@ static void WriteObject(OBJECT x, int outer_prec, int *linecount, FILE_NUM fnum) case BREAK: name = KW_BREAK; goto SETC; case UNDERLINE: name = KW_UNDERLINE; goto SETC; case COLOUR: name = KW_COLOUR; goto SETC; + case OUTLINE: name = KW_OUTLINE; goto SETC; case LANGUAGE: name = KW_LANGUAGE; goto SETC; case CURR_LANG: name = KW_CURR_LANG; goto SETC; case CURR_FAMILY: name = KW_CURR_FAMILY; goto SETC; case CURR_FACE: name = KW_CURR_FACE; goto SETC; + case CURR_YUNIT: name = KW_CURR_YUNIT; goto SETC; + case CURR_ZUNIT: name = KW_CURR_ZUNIT; goto SETC; case COMMON: name = KW_COMMON; goto SETC; case RUMP: name = KW_RUMP; goto SETC; case MELD: name = KW_MELD; goto SETC; @@ -1,7 +1,7 @@ /*@z42.c:Colour Service:ColourChange, ColourCommand@**************************/ /* */ -/* THE LOUT DOCUMENT FORMATTING SYSTEM (VERSION 3.17) */ -/* COPYRIGHT (C) 1991, 1999 Jeffrey H. Kingston */ +/* THE LOUT DOCUMENT FORMATTING SYSTEM (VERSION 3.18) */ +/* COPYRIGHT (C) 1991, 2000 Jeffrey H. Kingston */ /* */ /* Jeffrey H. Kingston (jeff@cs.usyd.edu.au) */ /* Basser Department of Computer Science */ @@ -1,7 +1,7 @@ /*@z43.c:Language Service:LanguageChange, LanguageString@*********************/ /* */ -/* THE LOUT DOCUMENT FORMATTING SYSTEM (VERSION 3.17) */ -/* COPYRIGHT (C) 1991, 1999 Jeffrey H. Kingston */ +/* THE LOUT DOCUMENT FORMATTING SYSTEM (VERSION 3.18) */ +/* COPYRIGHT (C) 1991, 2000 Jeffrey H. Kingston */ /* */ /* Jeffrey H. Kingston (jeff@cs.usyd.edu.au) */ /* Basser Department of Computer Science */ @@ -1,7 +1,7 @@ /*@z44.c:Vertical Hyphenation:VerticalHyphenate()@****************************/ /* */ -/* THE LOUT DOCUMENT FORMATTING SYSTEM (VERSION 3.17) */ -/* COPYRIGHT (C) 1991, 1999 Jeffrey H. Kingston */ +/* THE LOUT DOCUMENT FORMATTING SYSTEM (VERSION 3.18) */ +/* COPYRIGHT (C) 1991, 2000 Jeffrey H. Kingston */ /* */ /* Jeffrey H. Kingston (jeff@cs.usyd.edu.au) */ /* Basser Department of Computer Science */ @@ -506,7 +506,7 @@ OBJECT ConvertGalleyList(OBJECT x) OBJECT BuildEnclose(OBJECT hd) { OBJECT sym, parsym, x, y, link, par, val, env, res; - debug1(DHY, D, "BuildEnclose(%s)", SymName(actual(hd))); + debug1(DOM, D, "BuildEnclose(%s)", SymName(actual(hd))); /* find @Enclose symbol and check that it has just one parameter */ for( link = Down(actual(hd)); link != actual(hd); link = NextDown(link) ) @@ -567,6 +567,6 @@ OBJECT BuildEnclose(OBJECT hd) Link(res, x); Link(res, env); - debug1(DHY, D, "BuildEnclose returning %s", EchoObject(res)); + debug1(DOM, D, "BuildEnclose returning %s", EchoObject(res)); return res; } /* end BuildEnclose */ @@ -1,7 +1,7 @@ /*@z45.c:External Sort:SortFile()@********************************************/ /* */ -/* THE LOUT DOCUMENT FORMATTING SYSTEM (VERSION 3.17) */ -/* COPYRIGHT (C) 1991, 1999 Jeffrey H. Kingston */ +/* THE LOUT DOCUMENT FORMATTING SYSTEM (VERSION 3.18) */ +/* COPYRIGHT (C) 1991, 2000 Jeffrey H. Kingston */ /* */ /* Jeffrey H. Kingston (jeff@cs.usyd.edu.au) */ /* Basser Department of Computer Science */ @@ -1,7 +1,7 @@ /*@z46.c:Optimal Galleys:FindOptimize()@**************************************/ /* */ -/* THE LOUT DOCUMENT FORMATTING SYSTEM (VERSION 3.17) */ -/* COPYRIGHT (C) 1991, 1999 Jeffrey H. Kingston */ +/* THE LOUT DOCUMENT FORMATTING SYSTEM (VERSION 3.18) */ +/* COPYRIGHT (C) 1991, 2000 Jeffrey H. Kingston */ /* */ /* Jeffrey H. Kingston (jeff@cs.usyd.edu.au) */ /* Basser Department of Computer Science */ @@ -243,6 +243,7 @@ void GazumpOptimize(OBJECT hd, OBJECT dest) back(tmp, COLM) = fwd(tmp, COLM) = 0; back(tmp, ROWM) = fwd(tmp, ROWM) = 0; word_font(tmp) = word_colour(tmp) = 0; + word_outline(tmp) = FALSE; word_language(tmp) = word_hyph(tmp) = 0; Link(opt_components(hd), tmp); @@ -1,7 +1,7 @@ /*@z47.c:Environment Table:EnvReadRetrieve()@*********************************/ /* */ -/* THE LOUT DOCUMENT FORMATTING SYSTEM (VERSION 3.17) */ -/* COPYRIGHT (C) 1991, 1999 Jeffrey H. Kingston */ +/* THE LOUT DOCUMENT FORMATTING SYSTEM (VERSION 3.18) */ +/* COPYRIGHT (C) 1991, 2000 Jeffrey H. Kingston */ /* */ /* Jeffrey H. Kingston (jeff@cs.usyd.edu.au) */ /* Basser Department of Computer Science */ @@ -1,7 +1,7 @@ /*@z48.c:PDF back end@********************************************************/ /* */ -/* THE LOUT DOCUMENT FORMATTING SYSTEM (VERSION 3.17) */ -/* COPYRIGHT (C) 1991, 1999 Jeffrey H. Kingston */ +/* THE LOUT DOCUMENT FORMATTING SYSTEM (VERSION 3.18) */ +/* COPYRIGHT (C) 1991, 2000 Jeffrey H. Kingston */ /* */ /* Jeffrey H. Kingston (jeff@cs.usyd.edu.au) */ /* Basser Department of Computer Science */ @@ -1135,7 +1135,8 @@ static void PDFPage_FlushRawBuffer(FILE* in_fp) /* always compress to the point where the raw buffer is empty */ do { err = deflate(&g_comp_stream, Z_NO_FLUSH); - if (err != Z_OK) + /* bug fix from newman-andy@yale.edu Feb 23 2000 if (err != Z_OK) */ + if ( err != Z_OK && g_comp_stream.avail_in != 0 ) Error(48, 11, "PDFPage_FlushRawBuffer: zlib error occurred",FATAL,no_fpos); /* IF compressed output buffer is full THEN flush it to disk and reset it */ |