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

  1.  
  2. [STMNT.CNV]
  3. [CNVRT compiler for "C" Statements]
  4. [Harold V. McIntosh, 10 June 1983]
  5.  
  6.  
  7.  
  8. [compile statement]
  9. ((
  10.   [statement]    ((or,<<
  11.   [if-else]      >>if <(><:E:><)> <:S:> else <:S:>,<<
  12.   [if]          >>if <(><:E:><)> <:S:>,<<
  13.   [while]      >>while <(><:E:><)> <:S:>,<<
  14.   [do-while]      >>do <:S:> while <(><:E:><)>;,<<
  15.   [for]          >>for <(><:F:>; <:F:>; <:F:><)> <:S:>,<<
  16.   [switch]      >>switch <(><:E:><)> <:S:>,<<
  17.   [case]      >>case <:E:>: <:S:>,<<
  18.   [default]      >>default: <:S:>,<<
  19.   [break]      >>break;,<<
  20.   [continue]      >>continue;,<<
  21.   [return]      >>return <:F:>;,<<
  22.   [goto]      >>goto <:I:>;,<<
  23.   [label]      >><:I:>: <:S:>,<<
  24.   [expression]      >><:F:>;,<<
  25.   [composite]      >>{(ITR,<:S:>)}<<
  26.         >>)) S
  27.  
  28.         ((and,<:E:>,<1>)) 1
  29.         ((and,<:S:>,<2>)) 2
  30.         ((and,<:S:>,<3>)) 3
  31.         ((and,<:F:>,<4>)) 4
  32.         ((and,<:F:>,<5>)) 5
  33.         ((and,<:F:>,<6>)) 6
  34.  
  35.     )()(0 1 2 3 4 5 6)(
  36.  
  37.   [prnt WS]      ((PWS)<>,);
  38.   [if-then]      (<0>@if (and,<(><:E:><)> <:S:> else <:S:>,<<
  39.             >><(><:1:><)> <:2:> else <:3:>),<<
  40.             >>(x,<1>)<<
  41.             >>/jnz beta<0><<
  42.             >>(w,(#+,<0>+1)@<2>)<<
  43.             >>/jmp gama<0><<
  44.             >>/beta<0>:<<
  45.             >>(w,(#+,<0>+1)@<3>)<<
  46.             >>/gama<0>:<<
  47.             >>);
  48.   [if]          (<0>@if <(><:1:><)> <:2:>,<<
  49.             >>(x,<1>)<<
  50.             >>/jnz beta<0><<
  51.             >>(w,(#+,<0>+1)@<2>)<<
  52.             >>/beta<0>:<<
  53.             >>);
  54.   [while]      (<0>@while <(><:1:><)> <:2:>,<<
  55.             >>/alfa<0>:<<
  56.             >>(x,<1>)<<
  57.             >>/jz break<0><<
  58.             >>(w,(#+,<0>+1)@<2>)<<
  59.             >>/contin<0>:<<<
  60.             >>/jmp alfa<0><<
  61.             >>/break<0>:<<
  62.             >>);
  63.   [do-while]      (<0>@do <:2:> while <(><:1:><)>;,<<
  64.             >>/alfa<0>:<<
  65.             >>(w,(#+,<0>+1)@<2>)<<
  66.             >>/contin<0>:<<
  67.             >>(x,<1>)<<
  68.             >>/jnz alfa<0><<
  69.             >>/break<0>:<<
  70.             >>);
  71.   [for]          (<0>@for <(><:4:>; <:5:>; <:6:><)> <:2:>,<<
  72.             >>(x,<4>)<<
  73.             >>/alfa<0>:<<
  74.             >>(y,<5>)<<
  75.             >>/jz break<0><<
  76.             >>(w,(#+,<0>+1)@<2>)<<
  77.             >>/contin<0>:<<<
  78.             >>(x,<6>)<<
  79.             >>/jmp alfa<0><<
  80.             >>/break<0>:<<
  81.             >>);
  82.   [switch]      (<0>@switch <(><:1:><)> <:2:>,<<
  83.             >>(x,<1>)<<
  84.             >>(w,(#+,<0>+1)@<2>)<<
  85.             >>/break<0>:<<
  86.             >>);
  87.   [case]      (<0>@case <:1:>: <:2:>,<<
  88.             >>(x,<1>)<<
  89.             >>/compare alfa<0><<
  90.             >>(w,(#+,<0>+1)@<2>)<<
  91.             >>/alfa<0>:<<
  92.             >>);
  93.   [default]      (<0>@default: <:2:>,<<
  94.             >>(w,(#+,<0>+1)@<2>)<<
  95.             >>);
  96.   [break]      (<0>@break;,<<
  97.             >>/gobreak <0><<
  98.             >>);
  99.   [continue]      (<0>@continue;,<<
  100.             >>/gocontin <0><<
  101.             >>);
  102.   [return]      (<0>@return <:1:>;,<<
  103.             >>(x,<1>)<<
  104.             >>/return<<
  105.             >>);
  106.   [return]      (<0>@return;,<<
  107.             >>/return<<
  108.             >>);
  109.   [goto]      (<0>@goto (and,<:I:>,<1>);,<<
  110.             >>/goto <1><<
  111.             >>);
  112.   [label]      (<0>@(and,<:I:>:,<1>:) <:2:>,<<
  113.             >>/<1>: (w,0@<2>)<<
  114.             >>);
  115.   [expression]      (<0>@(and,<:E:>;,<1>;<>),(x,<1>));
  116.   [compound]      (<0>@{<:2:><1>}<>,(w,<0>@<2>)(w,<0>@{<1>}));
  117.   [compound]      (<0>@{},);
  118.           (,other);
  119.   )) w
  120.  
  121. [token compilation of expressions]
  122. (()()(0 1 2)(
  123.         (<0>,/compiled <0>);
  124.   )) x
  125.  
  126. [1 for null program]
  127. (()()(0)(
  128.         (<>,/ db 1);
  129.         (<0>,(x,<0>));
  130.   )) y
  131.  
  132. [main program including syntactic elements]
  133. ( (
  134.   [alfanum]   ((and,<[1]>,(IVL, ,~,))) a
  135.   [letter]    ((and,<[1]>,(or,(IVL,A,Z,),(IVL,a,z,),_))) b
  136.   [odigit]    ((and,<[1]>,(IVL,0,7,))) c
  137.   [ddigit]    ((and,<[1]>,(IVL,0,9,))) d
  138.   [hdigit]    ((and,<[1]>,(or,(IVL,0,9,),(IVL,A,F,),(IVL,a,f,)))) e
  139.   [cconst]    ((or,\<:a:>,<'><:a:><'>)) j
  140.   [iconst]    ((or,0(or,X,x)(ITR,<:e:>),0(ITR,<:c:>),<:d:>(ITR,<:d:>))) k
  141.   [fconst]    ((ITR,<:d:>).(ITR,<:d:>)(or,(or,E,e)(or,+,-,)(ITR,<:d:>),)) l
  142.   [sconst]    (<">(ITR,<:a:>)<">) m
  143.   [constant]  ((or,<:l:>,<:k:>,<:j:>,<:m:>)) o
  144.   [identifier](<:b:>(ITR,(or,<:b:>,<:d:>))) I
  145.   [aoperator] ((or,=,+=,-=,*=,/=,%=,(QUO/>>=/),(QUO/<<=/),&=,^=,|=)) p
  146.   [boperator] ((or,*,/,%,+,-,(QUO/>>/),(QUO/<</),(QUO/<=/),<<
  147.         >>(QUO/>=/),(<),(>),==,!=,&&,^,||,&,|)) q
  148.   [uoperator] ((or,*,&,-,!,~,sizeof,<(>typename<)>)) r
  149.   [lvalue]    ((or,<<
  150.         >>(and,<:P:>,<-->[<:E:>]<>),<<
  151.         >>(and,<:P:>,<-->-(>)<:I:><>),<<
  152.         >>(and,<:P:>,<-->.<:I:><>),<<
  153.         >><:I:>,<<
  154.         >>*<:E:>,<<
  155.         >><(><:L:><)>)) L
  156.   [pexten]    ((or,[<:E:>],<(>(ITR,<:E:>)<)>,-(>)<:I:>,.<:I:>)) N
  157.   [primary]   ((or,<:I:>,<:o:>,<(><:E:><)>)(ITR,<:N:>)) P
  158.   [eroot]     ((or,<<
  159.         >><:r:><:A:>,<<
  160.         >>++<:L:>,<<
  161.         >>--<:L:>,<<
  162.         >><:L:>++,<<
  163.         >><:L:>--,<<
  164.         >><:P:>)) A
  165.   [bexpr]     (<:A:>(or,<:q:><:B:>,)) B
  166.   [cexpr]     (<:B:>(or,?<:K:>:<:K:>,)) K
  167.   [aexpr]     ((or,<:L:><:p:><:D:>,<:K:>)) D
  168.   [expression](<:D:>(or,<,><:E:>,)) E
  169.           ((or,<:E:>,)) F
  170.   )  ()(0)(  
  171.     (;,done);
  172.     (<0>,(%C,(w,1@<0>))(%R)):
  173.   ))
  174.  
  175. [end]
  176.