[BACK]Return to smacro.sm1 CVS log [TXT][DIR] Up to [local] / OpenXM / src / kan96xx / Kan

Annotation of OpenXM/src/kan96xx/Kan/smacro.sm1, Revision 1.3

1.3     ! takayama    1: %% $OpenXM: OpenXM/src/kan96xx/Kan/smacro.sm1,v 1.2 2000/01/16 07:55:41 takayama Exp $
1.1       maekawa     2: %%%%%% global control variables
                      3: %%  /@@@.quiet 0 def  It is defined in scanner().
                      4: /@@@.Dsymbol (D) def
                      5: /@@@.diffEsymbol (E) def
                      6: /@@@.Qsymbol (Q) def
                      7: /@@@.hsymbol (h) def
                      8: /@@@.esymbol (e_) def
                      9: /@@@.Esymbol (E) def
1.3     ! takayama   10: /@@@.Hsymbol (H) def
1.1       maekawa    11:
                     12: %%% pointer to the StandardContext.
                     13: /StandardContextp [(CurrentContextp)] system_variable def
                     14: /null 0 (null) data_conversion def
                     15:
                     16: %%%%%%%%%%%%%%%%%%%%%%  usages %%%%%%%%%%%%%%%%%%%%
                     17: /@.usages [[( ) [(gate keeper)]] ] def
                     18: /putUsages {
                     19:    /arg1 set
                     20:    /@.usages @.usages [ arg1 ] join def
                     21: } def
                     22:
                     23: /showKeywords {
                     24:   @.usages { 0 get } map shell @@@.printSVector
                     25:   ( ) message
                     26: } def
                     27:
                     28: /usage {
                     29:   /arg1 set
                     30:   [/name /flag /n /k /slist /m /i] pushVariables
                     31:   [
                     32:     /name arg1 def
                     33:     /flag true def
                     34:    @.usages length /n set
                     35:    0 1 << n 1 sub >>
                     36:    {
                     37:       /k set
                     38:       name << @.usages k get 0 get >> eq
                     39:       {
                     40:         /slist @.usages k get 1 get def
                     41:         /m slist length def
                     42:         0 1 << m 1 sub >> {
                     43:           /i set
                     44:           slist i get message
                     45:         } for
                     46:         /flag false def
                     47:       }
                     48:       { }
                     49:       ifelse
                     50:    } for
                     51:
                     52:    flag
                     53:    {name Usage}
                     54:    { }
                     55:    ifelse
                     56:    ] pop
                     57:    popVariables
                     58: } def
                     59:
                     60:
                     61: %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
                     62:
                     63: /; %%% prompt of the sm1
                     64: {  [ $PrintDollar$ [$PrintDollar$] system_variable %% save value
                     65:      [$PrintDollar$ 0] system_variable pop
                     66:      @@@.quiet 0 eq
                     67:      {$sm1>$ print} { } ifelse
                     68:    ] system_variable pop
                     69: } def
                     70:
                     71: /?
                     72: {
                     73:    show_systemdictionary
                     74:    (-- ?? : to see macro dictionary --)
                     75:    message
                     76:    $-- (keyWord) usage  to see the usages. Data type of (xxxyyy) is string.--$
                     77:      message
                     78:    $Main data types: 1:integer(machine integer), 2:literal, 5:string, 6:array,$
                     79:      message
                     80:    $ 7:poly, 13:file, 14:ring, 15:number(bignum,universalNumber), 16:rational, 17:class. $ message
                     81:
                     82: } def
                     83:
                     84: /??
                     85: {  (------------ Macros ------------------------------------------------)
                     86:     message
                     87:    showKeywords
                     88:    $------------ Use (keyWord) usage  to see the usages. ---------------$
                     89:      message
                     90: } def
                     91:
                     92: /::
                     93: {
                     94:    print  newline ;
                     95: } def
                     96:
                     97: /. {expand} def
                     98:
                     99: /, {   } def
                    100:
                    101: /false 0 def
                    102:
                    103: %% You cannot use the variable arg1 in expand.
                    104: /expand {
                    105:   /@@@expand.arg1 set
                    106:   [/in-expand /f-expand /f-ans] pushVariables
                    107:   [
                    108:     /f-expand @@@expand.arg1 def
                    109:     f-expand isArray {
                    110:       f-expand { expand } map /f-ans set
                    111:     }{
                    112:       f-expand  $poly$ data_conversion /f-ans set
                    113:     } ifelse
                    114:     /@@@expand.arg1 f-ans def
                    115:   ] pop
                    116:   popVariables
                    117:   @@@expand.arg1
                    118: } def
                    119:
                    120: /<< {  } def
                    121: />> {  } def
                    122:
                    123: % v1 v2 join
                    124: /join {
                    125:  /arg2 set /arg1 set
                    126:  [/v1 /v2] pushVariables
                    127:  /v1 arg1 def /v2 arg2 def
                    128:  [
                    129:    [v1 aload pop v2 aload pop] /arg1 set
                    130:  ] pop
                    131:  popVariables
                    132:  arg1
                    133: } def
                    134:
                    135: /n.map 0 def  /i.map 0 def /ar.map 0 def /res.map 0 def  %% declare variables
                    136: /map.old {  %% recursive
                    137:  /arg1.map set %%  arg1.map = {   }
                    138:  /arg2.map set %%  arg2.map = [   ]
                    139:  %%%debug: /arg1.map load print arg2.map print
                    140:  [n.map /com.map load i.map ar.map %% local variables.  Don't push com!
                    141:   %%It's better to use load for all variables.
                    142:  /com.map /arg1.map load def
                    143:  /ar.map arg2.map def %% set variables
                    144:  /n.map ar.map length 1 sub def
                    145:  [
                    146:    0 1 n.map {
                    147:      /i.map set
                    148:      << ar.map i.map get >> com.map
                    149:    } for
                    150:  ] /res.map set
                    151:  /ar.map set /i.map set /com.map set /n.map set ] pop %% pop local variables
                    152:  res.map %% push the result
                    153: } def
                    154:
                    155: /message {
                    156:   [$PrintDollar$ [$PrintDollar$] system_variable
                    157:    [$PrintDollar$ 0] system_variable pop
                    158:    4 -1 roll
                    159:    print newline
                    160:   ] system_variable pop
                    161: } def
                    162:
                    163: /messagen {
                    164:   [$PrintDollar$ [$PrintDollar$] system_variable
                    165:    [$PrintDollar$ 0] system_variable pop
                    166:    4 -1 roll
                    167:    print
                    168:   ] system_variable pop
                    169: } def
                    170:
                    171: /newline {
                    172:   [$PrintDollar$ [$PrintDollar$] system_variable
                    173:    [$PrintDollar$ 0] system_variable pop
                    174:    10 $string$ data_conversion print
                    175:   ] system_variable pop
                    176:    %% flush stdout
                    177:   [(flush)] extension pop
                    178: } def
                    179:
                    180: /pushVariables {
                    181:   { dup [ 3 1 roll load ] } map
                    182: } def
                    183:
                    184: /popVariables {
                    185:   % dup print
                    186:   { aload pop def } map pop
                    187: } def
                    188:
                    189:
                    190:
                    191: /timer {
                    192:   [(TimerOn)] system_variable 1 eq
                    193:   {  [(TimerOn) 0] system_variable pop set_timer } { } ifelse
                    194:   set_timer
                    195:   exec
                    196:   set_timer
                    197: } def
                    198:
                    199: /true 1 def
                    200:
                    201:
                    202:
                    203:
                    204: %%% prompter
                    205: ;
                    206:
                    207:
                    208:
                    209:

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>