home *** CD-ROM | disk | FTP | other *** search
/ The CDPD Public Domain Collection for CDTV 3 / CDPDIII.bin / pd / programming / utils / cweb / amiga / cweave.ch < prev    next >
Text File  |  1993-01-22  |  8KB  |  297 lines

  1. % If the user specifies "-i" formal parameter declarations won't be indented.
  2. % Therefore we have to set |indent_param_decl| to |TRUE|.
  3. @x
  4.   argc=ac; argv=av;
  5.   program=weave;
  6.   make_xrefs=force_lines=1; /* controlled by command-line options */
  7.   common_init();
  8. @y
  9.   argc=ac; argv=av;
  10.   program=weave;
  11.   indent_param_decl=1; /* indent formal parameter declarations by default */
  12.   make_xrefs=force_lines=1; /* controlled by command-line options */
  13.   common_init();
  14. @z
  15.  
  16.  
  17.  
  18.  
  19.  
  20. % Make 'a' and 'g' command line flags.
  21. @x
  22. @d show_banner flags['b'] /* should the banner line be printed? */
  23. @d show_progress flags['p'] /* should progress reports be printed? */
  24. @d show_happiness flags['h'] /* should lack of errors be announced? */
  25. @y
  26. @d show_banner flags['b'] /* should the banner line be printed? */
  27. @d show_progress flags['p'] /* should progress reports be printed? */
  28. @d show_happiness flags['h'] /* should lack of errors be announced? */
  29. @d use_amiga_keywords flags['a'] /* should Amiga/SAS C Keywords be used? */
  30. @d use_german_macros flags['g'] /* should the output be german? */
  31. @d indent_param_decl flags['i'] /* should formal parameter declarations be indented? */
  32. @z
  33.  
  34.  
  35.  
  36.  
  37.  
  38. % Insert the Amiga specific keywords into the id-table.
  39. @x
  40. id_lookup("NULL",NULL,quoted);
  41. id_lookup("TeX",NULL,custom);
  42. @y
  43. id_lookup("NULL",NULL,quoted);
  44. id_lookup("TeX",NULL,custom);
  45. if (use_amiga_keywords) {
  46.   id_lookup("signed",NULL,int_like);
  47.   id_lookup("defined",NULL,sizeof_like);
  48.   id_lookup("volatile",NULL,int_like);
  49.   id_lookup("pragma",NULL,if_like);
  50.   id_lookup("__near",NULL,int_like);
  51.   id_lookup("__far",NULL,int_like);
  52.   id_lookup("__chip",NULL,int_like);
  53.   id_lookup("__regargs",NULL,int_like);
  54.   id_lookup("__stdargs",NULL,int_like);
  55.   id_lookup("__asm",NULL,int_like);
  56.   id_lookup("__saveds",NULL,int_like);
  57.   id_lookup("__interrupt",NULL,int_like);
  58.   id_lookup("__aligned",NULL,int_like);
  59.   id_lookup("__inline",NULL,int_like);
  60.   id_lookup("__stackext",NULL,int_like);
  61.   id_lookup("__d0",NULL,int_like);
  62.   id_lookup("__d1",NULL,int_like);
  63.   id_lookup("__d2",NULL,int_like);
  64.   id_lookup("__d3",NULL,int_like);
  65.   id_lookup("__d4",NULL,int_like);
  66.   id_lookup("__d5",NULL,int_like);
  67.   id_lookup("__d6",NULL,int_like);
  68.   id_lookup("__d7",NULL,int_like);
  69.   id_lookup("__a0",NULL,int_like);
  70.   id_lookup("__a1",NULL,int_like);
  71.   id_lookup("__a2",NULL,int_like);
  72.   id_lookup("__a3",NULL,int_like);
  73.   id_lookup("__a4",NULL,int_like);
  74.   id_lookup("__a5",NULL,int_like);
  75.   id_lookup("__a6",NULL,int_like);
  76.   id_lookup("__a7",NULL,int_like);
  77.   id_lookup("__fp0",NULL,int_like);
  78.   id_lookup("__fp1",NULL,int_like);
  79.   id_lookup("__fp2",NULL,int_like);
  80.   id_lookup("__fp3",NULL,int_like);
  81.   id_lookup("__fp4",NULL,int_like);
  82.   id_lookup("__fp5",NULL,int_like);
  83.   id_lookup("__fp6",NULL,int_like);
  84.   id_lookup("__fp7",NULL,int_like);
  85.   id_lookup("GLOBAL",NULL,int_like);
  86.   id_lookup("IMPORT",NULL,int_like);
  87.   id_lookup("STATIC",NULL,int_like);
  88.   id_lookup("REGISTER",NULL,int_like);
  89.   id_lookup("VOID",NULL,int_like);
  90.   id_lookup("LONG",NULL,int_like);
  91.   id_lookup("ULONG",NULL,int_like);
  92.   id_lookup("LONGBITS",NULL,int_like);
  93.   id_lookup("WORD",NULL,int_like);
  94.   id_lookup("UWORD",NULL,int_like);
  95.   id_lookup("WORDBITS",NULL,int_like);
  96.   id_lookup("BYTE",NULL,int_like);
  97.   id_lookup("UBYTE",NULL,int_like);
  98.   id_lookup("BYTEBITS",NULL,int_like);
  99.   id_lookup("STRPTR",NULL,int_like);
  100.   id_lookup("APTR",NULL,int_like);
  101.   id_lookup("CPTR",NULL,int_like);
  102.   id_lookup("SHORT",NULL,int_like);
  103.   id_lookup("USHORT",NULL,int_like);
  104.   id_lookup("FLOAT",NULL,int_like);
  105.   id_lookup("DOUBLE",NULL,int_like);
  106.   id_lookup("COUNT",NULL,int_like);
  107.   id_lookup("UCOUNT",NULL,int_like);
  108.   id_lookup("BOOL",NULL,int_like);
  109.   id_lookup("TEXT",NULL,int_like);
  110.   id_lookup("PLANEPTR",NULL,int_like);
  111.   id_lookup("BPTR",NULL,int_like);
  112.   id_lookup("BSTR",NULL,int_like);
  113.   id_lookup("Tag",NULL,int_like);
  114.   id_lookup("RPTR",NULL,int_like);
  115.   id_lookup("DisplayInfoHandle",NULL,int_like);
  116.   id_lookup("Object",NULL,int_like);
  117.   id_lookup("ClassID",NULL,int_like);
  118.   id_lookup("Msg",NULL,int_like);
  119.   id_lookup("BPTR",NULL,int_like);
  120.   id_lookup("Class",NULL,int_like);
  121.   id_lookup("CxObj",NULL,int_like);
  122.   id_lookup("CxMsg",NULL,int_like);
  123.   id_lookup("PFL",NULL,int_like);
  124.   id_lookup("IX",NULL,int_like);
  125. }
  126. @z
  127.  
  128.  
  129.  
  130.  
  131.  
  132. % If "+g" is specified, use the german cweb macros.
  133. @x
  134. out_ptr=out_buf+1; out_line=1; *out_ptr='c'; tex_printf("\\input cwebma");
  135. @y
  136. if (use_german_macros) {
  137.   out_ptr=out_buf+1; out_line=1; *out_ptr='g'; tex_printf("\\input cwebmac");
  138. } else {
  139.   out_ptr=out_buf+1; out_line=1; *out_ptr='c'; tex_printf("\\input cwebma");
  140. }
  141. @z
  142.  
  143.  
  144.  
  145.  
  146.  
  147. % Cosmetic correction (see below).
  148. % Not included anymore. Default behaviour is the original behaviour.
  149. %@x
  150. %& |exp| \altt|lbrace| |int_like| |decl|
  151. %    & |fn_decl| \altt|lbrace| |int_like| |decl|
  152. %        \hfill $F=E^*\,|in|\,|in|$ & \malt {\\{main}()$\{$} 
  153. %           {\\{main}$(\\{ac},\\{av})$ \&{int} \\{ac};} \cr
  154. %@y
  155. %& |exp| \altt|lbrace| |int_like| |decl|
  156. %    & |fn_decl| \altt|lbrace| |int_like| |decl|
  157. %        \hfill $F=E^*$ & \malt {\\{main}()$\{$} 
  158. %           {\\{main}$(\\{ac},\\{av})$ \&{int} \\{ac};} \cr
  159. %@z
  160.  
  161.  
  162.  
  163.  
  164.  
  165. % Cosmetic correction (see below).
  166. % Not included anymore. Default behaviour is the original behaviour.
  167. %@x
  168. %& |decl_head| \altt|int_like| |lbrace| |decl| & |fn_decl| 
  169. %                   \altt|int_like| |lbrace| |decl| \hfill $F=D\,|in|\,|in|$
  170. %                             & |long time () {|\cr
  171. %@y
  172. %& |decl_head| \altt|int_like| |lbrace| |decl| & |fn_decl| 
  173. %                   \altt|int_like| |lbrace| |decl| \hfill $F=D$
  174. %                             & |long time () {|\cr
  175. %@z
  176.  
  177.  
  178.  
  179.  
  180.  
  181. % Cosmetic correction (see below).
  182. % Not included anymore. Default behaviour is the original behaviour.
  183. %@x
  184. %& |fn_decl| |stmt| & |function| \hfill $F\,|out|\,|out|\,|force|\,S$
  185. %                                       & \\{main}() {\dots}\cr
  186. %@y
  187. %& |fn_decl| |stmt| & |function| \hfill $F\,|force|\,S$
  188. %                                       & \\{main}() {\dots}\cr
  189. %@z
  190.  
  191.  
  192.  
  193.  
  194.  
  195. % Cweave 2.1 (and higher) indents parameters in function declarations.
  196. % I think this looks rather awful. So provide the option "-i" to switch
  197. % this indenting off.
  198. @x
  199. @<Cases for |exp|@>=
  200. if (cat1==lbrace || cat1==int_like || cat1==decl) {
  201.   make_underlined(pp); big_app1(pp); big_app(indent); app(indent);
  202.   reduce(pp,1,fn_decl,0,1);
  203. }
  204. @y
  205. @<Cases for |exp|@>=
  206. if (cat1==lbrace || cat1==int_like || cat1==decl) {
  207.   make_underlined(pp); big_app1(pp);
  208.   if (indent_param_decl) {
  209.     big_app(indent); app(indent);
  210.   }
  211.   reduce(pp,1,fn_decl,0,1);
  212. }
  213. @z
  214.  
  215.  
  216.  
  217.  
  218.  
  219. % See above.
  220. @x
  221. @ @<Cases for |decl_head|@>=
  222. if (cat1==comma) {
  223.   big_app2(pp); big_app(' '); reduce(pp,2,decl_head,-1,22);
  224. }
  225. else if (cat1==unorbinop) {
  226.   big_app1(pp); big_app('{'); big_app1(pp+1); big_app('}');
  227.   reduce(pp,2,decl_head,-1,23);
  228. }
  229. else if (cat1==exp && cat2!=lpar && cat2!=exp) {
  230.   make_underlined(pp+1); squash(pp,2,decl_head,-1,24);
  231. }
  232. else if ((cat1==binop||cat1==colon) && cat2==exp && (cat3==comma || cat3==semi))
  233.   squash(pp,3,decl_head,-1,25);
  234. else if (cat1==lbrace || cat1==int_like || cat1==decl) {
  235.   big_app1(pp); big_app(indent); app(indent); reduce(pp,1,fn_decl,0,26);
  236. }
  237. @y
  238. @ @<Cases for |decl_head|@>=
  239. if (cat1==comma) {
  240.   big_app2(pp); big_app(' '); reduce(pp,2,decl_head,-1,22);
  241. }
  242. else if (cat1==unorbinop) {
  243.   big_app1(pp); big_app('{'); big_app1(pp+1); big_app('}');
  244.   reduce(pp,2,decl_head,-1,23);
  245. }
  246. else if (cat1==exp && cat2!=lpar && cat2!=exp) {
  247.   make_underlined(pp+1); squash(pp,2,decl_head,-1,24);
  248. }
  249. else if ((cat1==binop||cat1==colon) && cat2==exp && (cat3==comma || cat3==semi))
  250.   squash(pp,3,decl_head,-1,25);
  251. else if (cat1==lbrace || cat1==int_like || cat1==decl) {
  252.   big_app1(pp);
  253.   if (indent_param_decl) {
  254.     big_app(indent); app(indent);
  255.   }
  256.   reduce(pp,1,fn_decl,0,26);
  257. }
  258. @z
  259.  
  260.  
  261.  
  262.  
  263.  
  264. % See above.
  265. @x
  266. @ @<Cases for |fn_decl|@>=
  267. if (cat1==decl) {
  268.   big_app1(pp); big_app(force); big_app1(pp+1); reduce(pp,2,fn_decl,0,36);
  269. }
  270. else if (cat1==stmt) {
  271.   big_app1(pp); app(outdent); app(outdent); big_app(force);
  272.   big_app1(pp+1); reduce(pp,2,function,-1,37);
  273. }
  274. @y
  275. @ @<Cases for |fn_decl|@>=
  276. if (cat1==decl) {
  277.   big_app1(pp); big_app(force); big_app1(pp+1); reduce(pp,2,fn_decl,0,36);
  278. }
  279. else if (cat1==stmt) {
  280.   big_app1(pp);
  281.   if (indent_param_decl) {
  282.     app(outdent); app(outdent);
  283.   }
  284.   big_app(force);
  285.   big_app1(pp+1); reduce(pp,2,function,-1,37);
  286. }
  287. @z
  288.  
  289.  
  290.  
  291.  
  292. @x
  293. hash_pointer h; /* index into |hash| */
  294. @y
  295. extern hash_pointer h; /* index into |hash| */
  296. @z
  297.