diff options
author | Jeffrey H. Kingston <jeff@it.usyd.edu.au> | 2010-09-14 20:36:01 +0000 |
---|---|---|
committer | Jeffrey H. Kingston <jeff@it.usyd.edu.au> | 2010-09-14 20:36:01 +0000 |
commit | 2f4268e5e02216be53cd85816362191373512463 (patch) | |
tree | 57165bf2889337044bc3633854e5aa38f7d89e6b /include/cprintf | |
parent | 73d840b9f14b65166b92e6b43f930fd0ef7b8267 (diff) | |
download | lout-2f4268e5e02216be53cd85816362191373512463.tar.gz |
Lout 3.20.
git-svn-id: http://svn.savannah.nongnu.org/svn/lout/trunk@9 9365b830-b601-4143-9ba8-b4a8e2c3339c
Diffstat (limited to 'include/cprintf')
-rw-r--r-- | include/cprintf | 327 |
1 files changed, 203 insertions, 124 deletions
diff --git a/include/cprintf b/include/cprintf index 313b110..5a2ce50 100644 --- a/include/cprintf +++ b/include/cprintf @@ -1,11 +1,13 @@ ############################################################################### # # -# Lout @CPSetup package for formatting C programs # +# Lout @CPSetup package for formatting C and C++ programs # # # -# Version 2.0 by Jeffrey H. Kingston, February 2000. # +# Version 3.0 # +# Jeffrey H. Kingston # +# 5 April 2000 # # # -# This package uses a filtered body parameter to convert C source # +# This package uses a filtered body parameter to convert program 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. # @@ -14,69 +16,96 @@ export @CP def @CPSetup + named pipe { } # pipe through this first 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 - 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 + named @OrIfPlain left x right y + { @BackEnd @Case { PlainText @Yield y else @Yield x } } + { fixed } # print style + + # the following options apply when style is "fixed" + named fixedfont { Courier }# font family + named fixedsize { -1.0p } # font size + named fixedline { 1.0vx } # line-space + named fixedtabin { 8 } # tab interval + named fixedtabout { 8s } # tab width + + named fixedidentifiers { Base } # identifier face + named fixedkeywords { Base } # keyword face + named fixedoperators { Base } # operator face + named fixednumbers { Base } # number face + named fixedstrings { Base } # string face + named fixedcomments { Base } # comment face + + named fixedidentifiersformat right @Body { @Body } # identifier format + named fixedkeywordsformat right @Body { @Body } # keyword format + named fixedoperatorsformat right @Body { @Body } # operators format + named fixednumbersformat right @Body { @Body } # number format + named fixedstringsformat right @Body { @Body } # string format + named fixedcommentsformat right @Body { @Body } # comment format + + # the following options apply when style is "varying" + named varyingfont { } # font family + named varyingsize { 1.0f } # font size + named varyingline { 1.0vx } # line-space + named varyingtabin { 8 } # tab interval + named varyingtabout { 3f } # tab width + + named varyingidentifiers { Slope } # identifier face + named varyingkeywords { Bold } # keyword face + named varyingoperators { Base } # operator face + named varyingnumbers { Base } # number face + named varyingstrings { Slope } # string face + named varyingcomments { Base } # comment face + + named varyingidentifiersformat right @Body { @Body } # identifier format + named varyingkeywordsformat right @Body { @Body } # keyword format + named varyingoperatorsformat right @Body { @Body } # operators format + named varyingnumbersformat right @Body { @Body } # number format + named varyingstringsformat right @Body { @Body } # string format + named varyingcommentsformat right @Body { @Body } # comment format + + # the following options apply when style is "symbol" + named symbolfont { } # font family + named symbolsize { 1.0f } # font size + named symbolline { 1.0vx } # line-space + named symboltabin { 8 } # tab interval + named symboltabout { 3f } # tab width + + named symbolidentifiers { Slope } # identifier face + named symbolkeywords { Bold } # keyword face + named symboloperators { Base } # operator face + named symbolnumbers { Base } # number face + named symbolstrings { Slope } # string face + named symbolcomments { Base } # comment face + + named symbolidentifiersformat right @Body { @Body } # identifier format + named symbolkeywordsformat right @Body { @Body } # keyword format + named symboloperatorsformat right @Body { @Body } # operators format + named symbolnumbersformat right @Body { @Body } # number format + named symbolstringsformat right @Body { @Body } # string format + named symbolcommentsformat right @Body { @Body } # comment format @Begin export - "$>" @S @D @C @K @N @O @A @ST @ED @M + @PI @PK @PO @PN @PS @PC @PA @PM @PD + @A "$>" 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 - 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 + named identifiers { dft } # ident. font + named keywords { dft } # keyword font + named operators { dft } # operator font + named numbers { dft } # number font + named strings { dft } # string font + named comments { dft } # comment font body @Body # filtered, see below @Begin @@ -98,6 +127,18 @@ def @CPSetup } } + + def @Else # returns x, or y if x is dft + left x + right y + { + x @Case { + dft @Yield y + else @Yield x + } + } + + def @InitTab { tabin @Test @@ -106,6 +147,7 @@ def @CPSetup ifsymbol { symboltabin } } + def @InitTabWidth { tabout @Test @@ -114,6 +156,7 @@ def @CPSetup ifsymbol { symboltabout } } + def @Filter { pipe @Case { @@ -129,6 +172,7 @@ def @CPSetup } } + def @InitFontFamily { font @Test @@ -137,6 +181,7 @@ def @CPSetup ifsymbol { symbolfont } } + def @InitSize { size @Test @@ -145,6 +190,7 @@ def @CPSetup ifsymbol { symbolsize } } + def @InitLine { line @Test @@ -153,120 +199,153 @@ def @CPSetup ifsymbol { symbolline } } - def @S # for formatting strings + + def @PI # for formatting identifiers right x { - # "\"" & - strings @Test - iffixed { fixedstrings } - ifvarying { varyingstrings } - ifsymbol { symbolstrings } - @Font x - # & "\"" + style @Case { + fixed @Yield fixedidentifiersformat { + { identifiers @Else fixedidentifiers } @Font x + } + varying @Yield varyingidentifiersformat { + { identifiers @Else varyingidentifiers } @Font x + } + symbol @Yield symbolidentifiersformat { + { identifiers @Else symbolidentifiers } @Font x + } + } } -# def "`" -# { -# style @Case { -# symbol @Yield { "`" } -# else @Yield { "'" } -# } -# } - def @D # for formatting identifiers + def @PK # for formatting keywords right x { - identifiers @Test - iffixed { fixedidentifiers } - ifvarying { varyingidentifiers } - ifsymbol { symbolidentifiers } - @Font x + style @Case { + fixed @Yield fixedkeywordsformat { + { keywords @Else fixedkeywords } @Font x + } + varying @Yield varyingkeywordsformat { + { keywords @Else varyingkeywords } @Font x + } + symbol @Yield symbolkeywordsformat { + { keywords @Else symbolkeywords } @Font x + } + } } - def @C # for formatting comments + + def @PO # for formatting operators right x { - comments @Test - iffixed { fixedcomments } - ifvarying { varyingcomments } - ifsymbol { symbolcomments } - @Font x + style @Case { + fixed @Yield fixedoperatorsformat { + { operators @Else fixedoperators } @Font x + } + varying @Yield varyingoperatorsformat { + { operators @Else varyingoperators } @Font x + } + symbol @Yield symboloperatorsformat { + { operators @Else symboloperators } @Font x + } + } } - def @K # for formatting keywords + + def @PN # for formatting numbers right x { - keywords @Test - iffixed { fixedkeywords } - ifvarying { varyingkeywords } - ifsymbol { symbolkeywords } - @Font x + style @Case { + fixed @Yield fixednumbersformat { + { numbers @Else fixednumbers } @Font x + } + varying @Yield varyingnumbersformat { + { numbers @Else varyingnumbers } @Font x + } + symbol @Yield symbolnumbersformat { + { numbers @Else symbolnumbers } @Font x + } + } } - def @N # for formatting numbers + + def @PS # for formatting strings right x { - numbers @Test - iffixed { fixednumbers } - ifvarying { varyingnumbers } - ifsymbol { symbolnumbers } - @Font x + style @Case { + fixed @Yield fixedstringsformat { + { strings @Else fixedstrings } @Font x + } + varying @Yield varyingstringsformat { + { strings @Else varyingstrings } @Font x + } + symbol @Yield symbolstringsformat { + { strings @Else symbolstrings } @Font x + } + } } - def @O # for formatting operators + + def @PC # for formatting comments right x { - operators @Test - iffixed { fixedoperators } - ifvarying { varyingoperators } - ifsymbol { symboloperators } - @Font x + style @Case { + fixed @Yield fixedcommentsformat { + { comments @Else fixedcomments } @Font x + } + varying @Yield varyingcommentsformat { + { comments @Else varyingcomments } @Font x + } + symbol @Yield symbolcommentsformat { + { comments @Else symbolcomments } @Font x + } + } } - def @A # get characters from the Adobe Symbol font - left sym - right x + + def @PA # for formatting asterisks { - style @Case { - symbol @Yield { { Symbol Base } @Font @Char sym } - else @Yield { x } + @PO @BackEnd @Case { + PlainText @Yield "*" + else @Yield { "0.5w" @VShift "*" } } } - def @ST # for formatting asterisks - right x + + def @PM # for formatting minus signs { - operators @Test - iffixed { fixedoperators } - ifvarying { varyingoperators } - ifsymbol { symboloperators } - @Font "0.5w" @VShift x + @PO @BackEnd @Case { + PlainText @Yield "-" + else @Yield style @Case { + fixed @Yield "-" + else @Yield { { Symbol Base } @Font @Char "minus" } + } + } } - - def @ED # for formatting larger dots (not used in C) - right x + + + def @PD # for formatting dots, if wanted larger { - 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" } + @PO @BackEnd @Case { + PlainText @Yield "." + else @Yield { "1.4f" @Font "+0.04f" @VShift "." &"0.05f" } } } - macro "$>" { {} & } - def @M right x + def @A # get characters from the Adobe Symbol font + left sym + right x { style @Case { - fixed @Yield "-" - varying @Yield { { Symbol Base } @Font @Char minus } - symbol @Yield { { Symbol Base } @Font @Char minus } + symbol @Yield { { Symbol Base } @Font @Char sym } + else @Yield { x } } } + + macro "$>" { {} & } + + { @InitFontFamily Base @InitSize } @Font { @InitLine lines } @Break @Body |