home *** CD-ROM | disk | FTP | other *** search
/ Oakland CPM Archive / oakcpm.iso / sigm / vol166 / prgrm.rec < prev    next >
Encoding:
Text File  |  1984-04-29  |  7.8 KB  |  165 lines

  1.  
  2. [PRGRM.REC]
  3. [CNVRT Program and Function Definition compiler for "C"]
  4. [Harold V. McIntosh, 10 June 1983]
  5.  
  6. {
  7.                    {
  8.     [find/make FCB]        (Jj'TTY:'EQZD;(':'UQD':'ED\64-%;0%;)
  9.                  ('.'U<(8a;@b;)Q|D>;Z'.DAT'IJj:)
  10.                   '.'FJDZ(3a;@b;)Q|JZDI
  11.                  32(dpGm$r0=npGpGd0&$Sm@znpGQ&$rrS0;
  12.                  r12wQmwnEn;n:)D;) f
  13.     [blank fill by count]    (Zz(d' 'I:;)JZ;) b
  14.     [zero fill]            (cmpw0%(f:;)w;) 0
  15.     [zero FCB & buffer]        ($m33@0130@0nn&0||pLnS;) z
  16.     [set default input file]    (0,30$S'5C'H12wA' 'Ew4@0n0|0|pL31$S
  17.                  'TTY:'31$rrS; B9aQD(3a'   'E
  18.                  'DAT';Q;)|mw31@zn31$rrS31@r;) i
  19.     [open for read]        (@hr15K(255='NO FILE'I;L;)L;) r
  20.     [open for write]        (@hpGpG4+1&SrpG19k22k^^r128&S;) w
  21.     [set DMA address]        ($rpG^^r^^26k;) h
  22.     [open]            (m@f0=n@@;nLL;) O
  23.     [read]            (''(AL@f(0=pG@r;'TTY:'(='T');))
  24.                  ('T'='';L31pG$rr12w'TTY:'Ew;w)
  25.                  L@&'> 'TL(@#I;:);
  26.                  $r(pG^^rpGmr(0=(npGpGm128&S^^26kpGr
  27.                  20K0=L;LL1npGpGm129+26%&SS;)npGmr;;)
  28.                  pG130&-n+&dm(u13%=;10%(=)pGI(26%=;
  29.                  L);ndm:)L^^rn&S;LpG^^r0&S:);) R
  30.     [write]            (Jj'='U<(A@f'TTY:'(=)(0=pG@w;;))>'='ED
  31.                  ZqtD; >'='EDZ<@g;) W
  32.     [write to disk]        ($r(pG^^rpGpGmrpGm- 130+n&maQD>Z<nSn^^
  33.                  26kpGr21kpG^^r128&S:JZQD>nSnSL;);) g
  34.     [close all files]        (31pGm($r0=;pG4+r(0=L;LJj26%I<npGm@gpG
  35.                  ^^rpGr127(N^^26kpGr21k;L;)r16k;)ndpGm:)
  36.                  nL;;) c
  37.     [PVR]            (pG@&#'= '|TL$r(0='undef';yG;)TL;) _
  38.     [cr, lf]            (2573TL;)&
  39.     [insert cr, lf]        (2573I;)|
  40.     [read console]        (R13%='';08%(=)(T@#|;08%T' 'TLTLL@#;);)#
  41.     [type comment]        (@TD;)C
  42.     [display at logon]        ('cnvrt/icuap/1983'TL@&;)D
  43.     [write workspace]        (@&JZqt;)T
  44.                 (@@;) }%
  45.     [integer arithmetic]    {(+;)+ (-;)- (*;)* (/&L;)/
  46.                 (pGm/L1=nL1;0=n;n&:)|
  47.                  ((pGmJj(U);QD(O)I;npGmEDZQD(O)IjnpGmI;
  48.                  n@@#I)nLJZ;;) } #
  49.     [save & init variables]    (pGpGm$rm0&$S;) (
  50.     [reinitialize variable]    (pG$r0=L;LnL0&$S;) :
  51.     [undefine variable]        ($r0=;LnL;) )
  52.     [compare/define variable]    (pG$r0=ZQzml&$S;&LyGEz;) ]
  53.     [body of variable search]    (pG$r(0=)yG(E;&L)z&L@=L;pG$r(0=;LL)
  54.                   Z<((&pGm&n(F;''mZz<)jJQmpGl&$S
  55.                   zZ<@=>;J>);nLA:0&$SL>)>LL;) >
  56.     [body of variable search]    (pG$r(0=)yGEz@=L;pG$r(0=;LL)
  57.                   Z<((jJQmpGl&$S
  58.                   zZ<@=>;J>);nLA:0&$S>)>L;) <
  59.     [insert variable]        ($ryGI;) [
  60.                 
  61. [compile programs and functions]
  62. {
  63.   [program]      (@1 [or] Z<(@0; J;>)> [or] ;) 0
  64.   [ext defn]      ( [or] Z<(@~; J@2;>)> [or] ;) 1
  65.   [funct def]      ( [or] Z<(@X; J;>)> [or] @!@%;) 2
  66.   [beware of a function of no arguments - M tries to pick it up]
  67.   [funct declr]      (@M [or] Z<('('Ez@$')'Ez; J;>)> [or] ;) !
  68.   [param list]      (@I [or] Z<(', 'Ez@$; J;>)> [or] ;) $
  69.   [funct body]      (@.@^;) %
  70.   [declr list]      ( [or] Z<(@Z@.; J;>)> [or] ;) .
  71.   [stmnt list]      ( [or] Z<('statement'Ez@-; J;>)> [or] ;) -
  72.   [funct stmnt]      ('{'Ez@.@-'}'Ez;) ^
  73.   [data defn]      ( [or] Z<('extern'Ez; J'static'Ez;>)> [or]  [or] Z<(' 'Ez@X; J;>)> [or]  [or] Z<(' 'Ez@V; J;>)> [or] ';'Ez;) ~
  74.  
  75.     (0@( 1@( 2@( {(0@: 1@: 2@: ;); (
  76.         @;(J@0JZD'yes'I;);
  77.         @;(JJZD'no'I;);
  78.   ;)} 0@) 1@) 2@)   nn$S nn$S nn$S;)} u
  79.  
  80. [compile declaration]
  81. {
  82.   [declaration]      (@Y [or] Z<(' 'Ez@V; J;>)> [or] ';'Ez;) Z
  83.   [decl spec]      ( [or] Z<(@X [or] Z<(' 'Ez@W; J;>)> [or] ; J@W [or] Z<(' 'Ez@X; J;>)> [or] ;>)> [or] ;) Y
  84.   [s. c. spec]      ( [or] Z<('char'Ez; J [or] Z<('long 'Ez; J'short 'Ez; J'unsigned 'Ez; J;>)> [or] 'int'Ez; J [or] Z<('long 'Ez; J;>)> [or] 'float'Ez; J'double'Ez; J@H; J'tdefname'Ez;>)> [or] ;) X
  85.   [type spec]      ( [or] Z<('auto'Ez; J'static'Ez; J'extern'Ez; J'register'Ez; J'typedef'Ez;>)> [or] ;) W
  86.   [in dcl lst]      (@U [or] Z<(', 'Ez@V; J;>)> [or] ;) V
  87.   [init decl]      (@M [or] Z<(' 'Ez@6; J;>)> [or] ;) U
  88.   [d-extender]      ( [or] Z<('()'Ez; J'['Ez@o']'Ez; J'[]'Ez;>)> [or] ;) Q
  89.   [d-extender*]      ( [or] Z<(@Q@S; J;>)> [or] ;) S
  90.   [declarator]      ( [or] Z<(@I; J'('Ez@M')'Ez; J'*'Ez@M;>)> [or] @S;) M
  91.   [s or u spec]      ( [or] Z<('struct'Ez; J'union'Ez;>)> [or]  [or] Z<(' 'Ez@I; J;>)> [or]  [or] Z<(' {'Ez@G'}'Ez; J;>)> [or] ;) H
  92.   [st decl lst]      (@9 [or] Z<(' 'Ez@G; J;>)> [or] ;) G
  93.   [st decl]      (@X@8';'Ez;) 9
  94.   [st dcl list]      (' 'Ez@7 [or] Z<(','Ez@8; J;>)> [or] ;) 8
  95.   [str. declr]      ( [or] Z<(@M':'Ez@o; J@M; J':'Ez@o;>)> [or] ;) 7
  96.   [initializer]      ('= 'Ez [or] Z<(@E; J'{'Ez@5 [or] Z<(','Ez; J;>)> [or] '}'Ez;>)> [or] ;) 6
  97.   [init. list]      ( [or] Z<(@E; J'{'Ez@5'}'Ez;>)> [or]  [or] Z<(', 'Ez@5; J;>)> [or] ;) 5
  98.   [type-name]      (@X@3;) 4
  99.   [abst. decl]      ( [or] Z<('('Ez@3')'Ez; J'*'Ez@3;>)> [or] @S','Ez;) 3
  100.  
  101.   )(0@( 1@( 2@( {(0@: 1@: 2@: ;); (
  102.  
  103.   [prnt WS]      @;(J2573TLZqtj(A)JZD;);
  104.         @;(J0@]JZDz<0@[@uZ>;);
  105.           @;(J [and] Z<(@Y jJ><0@](A);>)> [and]  [and] Z<( [or] Z<(' 'Ez@V; J;>)> [or]  jJ><1@](A);>)> [and] ';'EzJZD'/definition 'Iz<1@[','I@zZ>' %%% 'I0@['/initialize 'Iz<1@[','I@yZ>;);
  106.           @;(J@ZJZD'yes'I;);
  107.           @;(JJZD'no'I;);
  108.   ;)} 0@) 1@) 2@)   nn$S nn$S nn$S;)} w
  109.  
  110. [token compilation of expressions]
  111. {(0@( {(0@: ;); (
  112.         @;(J0@]JZD'/compiled 'I0@[;);
  113.   ;)} 0@)   nn$S;)} x
  114.  
  115. [split out initializations]
  116. {(0@( 1@( 2@( {(0@: 1@: 2@: ;); (
  117.         @;(J [and] Z<(' 'Ez@M' 'Ez@6','Ez jJ><0@](A);>)> [and] 1@]JZD0@[z<1@[@yZ>;);
  118.         @;(J' 'Ez@M','Ez0@]JZD0@[;):
  119.   ;)} 0@) 1@) 2@)   nn$S nn$S nn$S;)} y
  120.  
  121. [remove initializations leaving definitions]
  122. {(0@( 1@( 2@( {(0@: 1@: 2@: ;); (
  123.         @;(J [and] Z<(' 'Ez@M jJ><' 'Ez0@](A);>)> [and]  [or] Z<(' 'Ez@6; J;>)> [or] ','Ez1@]JZD' 'I0@[','Iz<1@[@zZ>;);
  124.   ;)} 0@) 1@) 2@)   nn$S nn$S nn$S;)} z
  125.  
  126. [main program including syntactic elements]
  127.   [alfanum]   ( [and] Z<(1(a;L)z jJ><' ''~'Mz(A);>)> [and] ;) a
  128.   [letter]    ( [and] Z<(1(a;L)z jJ>< [or] Z<('A''Z'Mz; J'a''z'Mz; J'_'Ez;>)> [or] (A);>)> [and] ;) b
  129.   [odigit]    ( [and] Z<(1(a;L)z jJ><'0''7'Mz(A);>)> [and] ;) c
  130.   [ddigit]    ( [and] Z<(1(a;L)z jJ><'0''9'Mz(A);>)> [and] ;) d
  131.   [hdigit]    ( [and] Z<(1(a;L)z jJ>< [or] Z<('0''9'Mz; J'A''F'Mz; J'a''f'Mz;>)> [or] (A);>)> [and] ;) e
  132.   [astring]   ( [or] Z<( [or] Z<('\'Ez@a; J [and] Z<(@a jJ><[not] (Z<  [or] Z<(34%Ez; J39%Ez; J'\'Ez;>)> [or] J>)J>[not] Zz(A);>)> [and] ;>)> [or] @f; J;>)> [or] ;) f
  133.   [ostring]   ( [or] Z<(@c@g; J;>)> [or] ;) g
  134.   [dstring]   ( [or] Z<(@d@h; J;>)> [or] ;) h
  135.   [hstring]   ( [or] Z<(@e@i; J;>)> [or] ;) i
  136.   [cconst]    ( [or] Z<('\'Ez@a; J39%Ez@a39%Ez;>)> [or] ;) j
  137.   [iconst]    ( [or] Z<('0'Ez [or] Z<('X'Ez; J'x'Ez;>)> [or] @i; J'0'Ez@g; J@d@h;>)> [or] ;) k
  138.   [fconst]    (@h'.'Ez@h [or] Z<( [or] Z<('E'Ez; J'e'Ez;>)> [or]  [or] Z<('+'Ez; J'-'Ez; J;>)> [or] @h; J;>)> [or] ;) l
  139.   [sconst]    (34%Ez@f34%Ez;) m
  140.   [cstring]   ( [or] Z<( [or] Z<(@b; J@d;>)> [or] @n; J;>)> [or] ;) n
  141.   [constant]  ( [or] Z<(@l; J@k; J@j; J@m;>)> [or] ;) o
  142.   [identifier](@b@n;) I
  143.   [aoperator] ( [or] Z<('='Ez; J'+='Ez; J'-='Ez; J'*='Ez; J'/='Ez; J'%='Ez; J'>>='Ez; J'<<='Ez; J'&='Ez; J'^='Ez; J'|='Ez;>)> [or] ;) p
  144.   [boperator] ( [or] Z<('*'Ez; J'/'Ez; J'%'Ez; J'+'Ez; J'-'Ez; J'>>'Ez; J'<<'Ez; J'<='Ez; J'>='Ez; J'<'Ez; J'>'Ez; J'=='Ez; J'!='Ez; J'&&'Ez; J'^'Ez; J'||'Ez; J'&'Ez; J'|'Ez;>)> [or] ;) q
  145.   [uoperator] ( [or] Z<('*'Ez; J'&'Ez; J'-'Ez; J'!'Ez; J'~'Ez; J'sizeof'Ez; J'(typename)'Ez;>)> [or] ;) r
  146.   [uoper*]      ( [or] Z<(@r@s; J;>)> [or] ;) s
  147.   [lvalue]    ( [or] Z<( [and] Z<(@P jJ><(('['(Fz;Zz<)Z<@E']'Ez(A)>;J>);A:)(A);>)> [and] ; J [and] Z<(@P jJ><(('-'(Fz;Zz<)Z<'>'Ez@I(A)>;J>);A:)(A);>)> [and] ; J [and] Z<(@P jJ><(('.'(Fz;Zz<)Z<@I(A)>;J>);A:)(A);>)> [and] ; J@I; J'*'Ez@E; J'('Ez@L')'Ez;>)> [or] ;) L
  148.   [pexten]    ( [or] Z<('['Ez@E']'Ez; J'('Ez@F')'Ez; J'->'Ez@I; J'.'Ez@I;>)> [or] ;) N
  149.   [pextn*]    ( [or] Z<(@N@O; J;>)> [or] ;) O
  150.   [primary]   ( [or] Z<(@I; J@o; J'('Ez@E')'Ez;>)> [or] @O;) P
  151.   [eroot]     ( [or] Z<(@r@A; J'++'Ez@L; J'--'Ez@L; J@L'++'Ez; J@L'--'Ez; J@P;>)> [or] ;) A
  152.   [bexpr]     (@A [or] Z<(@q@B; J;>)> [or] ;) B
  153.   [cexpr]     (@B [or] Z<('?'Ez@K':'Ez@K; J;>)> [or] ;) K
  154.   [aexpr]     ( [or] Z<(@L@p@D; J@K;>)> [or] ;) D
  155.   [expression](@D [or] Z<(','Ez@E; J;>)> [or] ;) E
  156.   [e-list]    ( [or] Z<(@E@F; J;>)> [or] ;) F
  157.     (0@( {(0@: ;); (  
  158.     @;(J';'EzJZD'done'I;);
  159.     @;(J0@]JZDz<z<0@[@wZ>'C'@%Z>z<'R'@%Z>;):
  160.   ;)} 0@)   nn$S;)} ~
  161. ('i'@%'D'@%'R'@%@~JZqt'c'@%;)  }
  162.  
  163. [end]
  164.