home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 22 gnu / 22-gnu.zip / fweb153.zip / fweb-1.53 / web / typedefs.web < prev    next >
Text File  |  1995-09-23  |  63KB  |  2,283 lines

  1. @z --- typedefs.web ---
  2.  
  3. FWEB version 1.53 (September 23, 1995)
  4.  
  5. Based on version 0.5 of S. Levy's CWEB [copyright (C) 1987 Princeton University]
  6.  
  7. @x-----------------------------------------------------------------------------
  8.  
  9. @Lv[-Tv] @% This file can't be processed by \FWEAVE\ in it's present form!
  10.  
  11. @* COMMON DEFINITIONS and TYPEDEFS. Here are definitions and typedefs
  12. common to all of \.{common.web}, \.{tangle.web}, and \.{weave.web}.
  13.  
  14. @a
  15. @o typedefs.hweb
  16. @<Macro definitions@>@;
  17.  
  18. @ Write a header at the top of \.{typedefs.h}.
  19. @a
  20. /* Created automatically from typedefs.web. */
  21. #include "os.h"
  22.  
  23. @ The debug mode includes some extra code, but it probably doesn't slow
  24. things down too much.
  25.  
  26. @d DEBUG 1
  27.  
  28. @<Mac...@>=
  29. @@I formats.hweb
  30.  
  31. @@ The actual names of the processors.
  32.  
  33. @@m TANGLE "FTANGLE"
  34. @@m WEAVE "FWEAVE"
  35.  
  36. @<Mac...@>=
  37. @@ Some compilers can't handle files as large as \.{ftangle} or \.{fweave}.
  38. Therefore, if the C~preprocessor macros |part| are defined from the
  39. compiler's command line to have the value~1, 2, or~3, the other parts of
  40. those files are commented out.
  41.  
  42. @@<Possibly split into parts@@>=
  43.  
  44. #ifndef part
  45.     #define part 0 /* Standard value, when the files aren't split. */
  46. #else
  47.     #if(part != 1 && part != 2 && part != 3)
  48.         #define part 1 /* Should issue error message here. */
  49.     #endif
  50. #endif /* |part| */
  51.  
  52. @ Now we have macros that ensure that stuff needed for \FTANGLE\ or \FWEAVE\
  53. is defined and allocated in only one place.
  54.  
  55. @f EXTERN extern
  56.  
  57. @f com $_COMMA_
  58. @D com ,
  59.  
  60. @a
  61.  
  62. #ifdef _FWEB_h
  63.     #define EXTERN part1_or_extern /* This is further redefined below,
  64.                 depending on the setting of |part|. */
  65.     #define SET SET1
  66. #else
  67.     #define EXTERN extern
  68.     #define SET(stuff)
  69. #endif
  70.  
  71. @
  72. @<Mac...@>=
  73. @@
  74. @@F EXTERN extern
  75.  
  76. @@f IN_TANGLE extern
  77. @@f IN_COMMON extern
  78. @@f IN_RATFOR extern
  79. @@f IN_EVAL extern
  80. @@f IN_MACS extern
  81. @@f IN_PROD extern
  82. @@f IN_STYLE extern
  83.  
  84.  
  85. @@f SET $_EXPR
  86. @@f CSET $_EXPR
  87.  
  88. @@<Possibly split...@@>=
  89.  
  90. #if(part == 0 || part == 1)
  91.     #define part1_or_extern 
  92.     #define SET1(stuff) @@e = stuff
  93.     #define TSET1(stuff) @@e = stuff
  94. #else 
  95.     #define part1_or_extern extern
  96.     #define SET1(stuff)
  97.     #define TSET1(stuff)
  98. #endif
  99.  
  100. @ Next, we have some macros to help us allocate and define stuff in just one
  101. place. The philosophy here is that there should be no explicit |extern|
  102. statements; they should be replaced by something like |IN_COMMON| to remind
  103. one exactly where that variable is defined.
  104.  
  105. @f IN_TANGLE extern
  106. @f IN_COMMON extern
  107. @f IN_RATFOR extern
  108. @f IN_EVAL extern
  109. @f IN_MACS extern
  110. @f IN_PROD extern
  111. @f IN_STYLE extern
  112.  
  113. @f SET $_EXPR
  114. @f CSET $_EXPR
  115.  
  116. @a
  117.  
  118. #ifdef _FTANGLE_h
  119.     #define IN_TANGLE part1_or_extern
  120.     #define TSET TSET1
  121. #else
  122.     #define IN_TANGLE extern
  123.     #define TSET(stuff)
  124. #endif /* |_TANGLE_h| */
  125.  
  126. #ifdef _COMMON_h
  127.     #define IN_COMMON part1_or_extern
  128.     #define CSET SET1
  129. #else
  130.     #define IN_COMMON extern
  131.     #define CSET(stuff)
  132. #endif /* |_COMMON_h| */
  133.  
  134. #ifdef _PROD_h
  135.     #define IN_PROD part1_or_extern
  136.     #define PSET SET1
  137. #else
  138.     #define IN_PROD extern
  139.     #define PSET(stuff)
  140. #endif /* |_PROD_h| */
  141.  
  142. #ifdef _RATFOR_h
  143.     #define IN_RATFOR part1_or_extern
  144.     #define RSET SET1
  145. #else
  146.     #define IN_RATFOR extern
  147.     #define RSET(stuff)
  148. #endif /* |_RATFOR_h| */
  149.  
  150. #ifdef _EVAL_h
  151.     #define IN_EVAL
  152.     #define ESET(stuff) = stuff
  153. #else
  154.     #define IN_EVAL extern
  155.     #define ESET(stuff)
  156. #endif /* |_EVAL_h| */
  157.  
  158. #ifdef _MACS_h
  159.     #define IN_MACS
  160. #else
  161.     #define IN_MACS extern
  162. #endif /* |_MACS_h| */
  163.  
  164. #ifdef _STYLE_h
  165.     #define IN_STYLE
  166.     #define SSET(stuff) = stuff
  167. #else
  168.     #define IN_STYLE extern
  169.     #define SSET(stuff)
  170. #endif /* |_STYLE_h| */
  171.  
  172. @ We have an enumerated type for the kind of machine.
  173.  
  174. @<Unused@>=
  175.  
  176. @#if 0
  177. typedef enum{Unknown,Apollo,Dsu,IBMPc,Mac,Misc,Sgi,Sun,Vax} MACHINE;
  178.  
  179. IN_COMMON MACHINE Machine
  180. @#ifdef _COMMON_
  181.   =
  182.     @#if APOLLO
  183.         Apollo    /* Apollo/UNIX */
  184.     @#elif DSU
  185.         Dsu    /* DECstation/ULTRIX */
  186.     @#elif IBMPC
  187.         IBMPc    /* IBM-PC/DOS */
  188.     @#elif MAC
  189.         Mac    /* Macintosh */
  190.     @#elif MISC
  191.         Misc    /* Vanilla */
  192.     @#elif SGI
  193.         Sgi    /* Silicon Graphics/IRIX */
  194.     @#elif SUN
  195.         Sun    /* SunOS/UNIX */
  196.     @#elif VAX
  197.         Vax    /* VAX/VMS */
  198.     @#else
  199.         Unknown
  200.     @#endif /* |APOLLO| */
  201. @#endif /* |_COMMON_| */
  202. ;
  203. @#endif
  204.  
  205. @ Various miscellaneous definitions, and the fundamental typedefs.
  206.  
  207. /* True and false. */
  208. @D YES 1
  209. @D NO 0
  210.  
  211. /* Infinite loop. */
  212. @D WHILE() for(;;) /* Use ``|for(;;)|'' instead of ``|while(1)|'' to avoid
  213.             warnings from Microsoft compiler. */
  214. @f WHILE while
  215.  
  216. /* Minima and maxima. */
  217. @D MAX(a,b) ((a)>(b) ? (a) : (b))
  218. @D MIN(a,b) ((a)<(b) ? (a) : (b))
  219.  
  220. @d SAVE_MACRO(text) save_macro(OC("m"),(outer_char *)text)
  221. @d CHK_ARGS(name,num) chk_args(OC(name),num,n,pargs) 
  222.     /* Right \# of arguments? */
  223.  
  224. @D tab_mark @'\t' /* The |ASCII| tab. */
  225.  
  226. /* Subtraction of huge pointers; needed for pc's. We first cast to |long|,
  227. then to the final target type. */
  228. @d PTR_DIFF(type,p,q) ((type)(long)((p) - (q)))
  229. @d SUB_PTRS(p,q) PTR_DIFF(unsigned long,p,q) /* Used in the statistics
  230.                         output. */
  231.  
  232. /* Here are some macros to determine the identifier number in the name
  233. directory. */ 
  234. @d ID_NUM_ptr(ptr,start,end) ID_NUM0(ptr = @e,start,end) /* Set a
  235.     pointer as well as the number. */
  236. @d ID_NUM(start,end) ID_NUM0(DUMMY,start,end) /* Just the number. */
  237. @d DUMMY /* This kludge for an empty argument shouldn't be necessary, but
  238.     Microsoft didn't like the construction |ID_NUM0(,start,end)|. */
  239.  
  240. /* Set both a pointer and the number. */
  241. @f ptr_equals $EXPR_
  242. @d ID_NUM0(ptr_equals,start,end) PTR_DIFF(sixteen_bits,
  243.     (ptr_equals id_lookup(start,end,0)),name_dir)
  244.  
  245. /* Terminate a string. */
  246. @d TERMINATE(p,offset) *(p+offset) = '\0'
  247.  
  248. @d BOOLEAN(b) ((boolean)(b)) /* Explicit cast to make some compilers happy. */
  249.  
  250. @d CHOICE(flag,yes,no) (((int)(flag)) ? yes : no)
  251.  
  252. @
  253.  
  254. @m OCTAL0(n)$ASCII(#'n) 
  255. @m OCTAL(n)(eight_bits)OCTAL0(\@&n) /* Make octal constant. */
  256.  
  257. @<Mac...@>=
  258. @@ Here's a somewhat sophisticated use of \WEB\ macros.
  259. @@f WHILE while
  260. @@f ptr_equals $EXPR_
  261. @@m @!OCTAL0(n) @!$ASCII(#'n) /* Single-quote the argument and send to
  262.                 \.{\@!$ASCII}. */ 
  263. @@m @!OCTAL(n) (eight_bits)@!OCTAL0(\@@&n) /* Make octal constant. */
  264. @@m @!HEX(n) (eight_bits)@!OCTAL0(\@@&x##n) /* Make hex constant. */
  265.  
  266. @
  267. @a
  268.  
  269. typedef unsigned char eight_bits; /* The fundamental single-byte token. If
  270.     your machine does not support |unsigned char| you should change 
  271.     the definition of |eight_bits| to |unsigned short|. */ 
  272. @^system dependencies@>
  273.  
  274. typedef unsigned short sixteen_bits; /* Identifiers and similar things take
  275.                     up two bytes. */
  276.  
  277. typedef unsigned char outer_char; /* Type of characters outside \.{WEB}. */
  278.  
  279. typedef eight_bits boolean; /* The logical type. (\CWEB\ had |short| here.
  280.     Indeed, some compilers give warnings about type conversions because the
  281.     result of logical operations is an |int|, not a |char|.) */
  282.  
  283. typedef unsigned long BUF_SIZE; /* Size of dynamic arrays. */
  284.  
  285. typedef long STMT_LBL; /* \Fortran\ statement label.  (Negative is allowed.) */
  286.  
  287. typedef unsigned short LINE_NUMBER; /* Line number of \WEB\ source or output.*/
  288.  
  289. typedef long CASE_TYPE; /* The type for |case| values in \Ratfor.  */
  290.  
  291. /* For |web_strcmp|. {\bfit Web's convention differs from C's}!
  292.     If you don't pay attention to this, you'll get bugs that are
  293.     hard to track down. */
  294. typedef enum {LESS=0, /* first name is lexicographically less than the second*/
  295.     EQUAL=1, /* the first name is equal to the second */
  296.     GREATER=2, /* first name is lexicographically greater than the
  297. second */
  298.     PREFIX=3, /* the first name is a proper prefix of the second */
  299.     EXTENSION=4} LEXI; /* first name is a proper extension of the
  300. second. */
  301.  
  302. @ In certain cases \.{TANGLE} and \.{WEAVE} should do almost, but not
  303. quite, the same thing.  In these case we've written common code for
  304. both, differentiating between the two by means of the global variable
  305. |program|.
  306.  
  307. @a
  308. typedef enum {tangle=0,weave=1} PROGRAM; /* The two processors. */
  309.  
  310. IN_COMMON PROGRAM program;
  311.  
  312. @ The \FWEB\ version number, and the system name.
  313.  
  314. @a
  315.  
  316. IN_COMMON outer_char version[] CSET(VERSION); /* \FWEB\ version number. */
  317. IN_COMMON outer_char release_date[] CSET(RELEASE); 
  318.     /* Release date for this version. */
  319. IN_COMMON outer_char *the_system, *local_banner; /* Name of the
  320.     machine/operating system; and a possible additional local banner. */
  321.  
  322. @ \.{WEAVE} operates in three phases: first it inputs the source file and
  323. stores cross-reference data, then it inputs the source once again and
  324. produces the \TeX\ output file, and finally it sorts and outputs the index.
  325. Similarly, \.{TANGLE} operates in two phases.  The global variable |phase|
  326. tells which phase we are in.
  327.  
  328. @a
  329.  
  330. IN_COMMON short phase CSET(0); /* Which phase are we in? */
  331.  
  332. @ Especially in \RATFOR, we distinguish between warning and error messages.
  333.  
  334. @d EAT_AUTO_SEMI {if(auto_semi && next_byte() != @';') BACK_UP@;}
  335. @d BACK_UP {saved_token = NO; cur_byte -= last_bytes;}
  336.  
  337. @d NOT_BEFORE OCTAL(177)
  338. @d NOT_AFTER NOT_BEFORE
  339.  
  340. @d SAVE_BEFORE(pp,nmax,r_before) save_out(pp,nmax,r_before,NOT_AFTER)
  341. @d SAVE_AFTER(pp,nmax,r_after) save_out(pp,nmax,NOT_BEFORE,r_after)
  342.  
  343. @<Mac...@>=
  344. @@
  345. @@m IS_NEXT(c0,keyword)
  346. {
  347. eight_bits c;
  348.  
  349. if((c=next_byte()) != c0)
  350.     {
  351.     didnt_expand(c0,c,#*keyword);
  352.     return;
  353.     }
  354. }
  355.  
  356. @@m IS_NEXT_PAREN(keyword) IS_NEXT(@'(',keyword)
  357.  
  358. @
  359. @a
  360. typedef enum {OK,WARNING,ERROR} ERR_TYPE;
  361.  
  362. @ A major extension to \.{CWEB} is support for the syntaxes of several
  363. languages. We need to know what language we're dealing with at the moment.
  364.  
  365. @d NUM_LANGUAGES 8 /* |C|, |RATFOR|, |FORTRAN|, |TEX|, |LITERAL|,
  366.         |C_PLUS_PLUS|, |RATFOR_90|, |FORTRAN_90| */
  367. @d NUM_DISTINCT_LANGUAGES (NUM_LANGUAGES-2)
  368.  
  369. @d GLOBAL_LANGUAGE FORTRAN
  370. @d global_language global_params.Language /* The language in force at the
  371.                     beginning of each module. */
  372.  
  373. @d is_C_(Language) (Language==C)
  374. @d is_RATFOR_(Language) (Language==RATFOR || Language==RATFOR_90)
  375. @d is_FORTRAN_(Language) (Language==FORTRAN || Language==FORTRAN_90)
  376.  
  377. @d FORTRAN_LIKE(Language) (is_RATFOR_(Language) || is_FORTRAN_(Language))
  378. @d C_LIKE(Language) (Language==C || Language==C_PLUS_PLUS)
  379.  
  380. @d R66 (is_RATFOR_(language) && !Ratfor77) /* Non-expandable \Ratfor;
  381. obsolete. */
  382. @d R77 (Ratfor77 && is_RATFOR_(language) && xpn_Ratfor) /* Expandable
  383. \Ratfor. */
  384. @d R77_or_F (R77 || is_FORTRAN_(language)) /* Expandable \Ratfor\ or
  385. \Fortran. */
  386.  
  387. @d IS_WHITE(a) ((a) == @' ' || (a) == tab_mark)
  388.  
  389. @d LANGUAGE_CODE(l) OC(lang_codes[lan_num(l)]) /*  String
  390.     abbreviation for the language name. */
  391.  
  392. @a
  393.  
  394.  /* The highest bit sets the basic language. */
  395. typedef enum
  396.     {
  397.     NO_LANGUAGE =     0,
  398.  
  399.     C =         0x1,
  400.     RATFOR =    0x2,
  401.     FORTRAN =     0x4,
  402.     TEX =         0x8,
  403.     LITERAL =    0x10,
  404.  
  405.     C_PLUS_PLUS =    0x20,
  406.     RATFOR_90 =    0x40,
  407.     FORTRAN_90 =    0x80,
  408.  
  409.     NUWEB_OFF =    0xF0, /* Not a language, but used in |send_single|. */
  410.     NUWEB_ON =    0xF1
  411.     } LANGUAGE;
  412.  
  413. IN_COMMON LANGUAGE cmd_language CSET(NO_LANGUAGE);/* To check against
  414. override. */
  415. IN_COMMON boolean column_mode CSET(NO);
  416.  
  417. IN_COMMON CONST char HUGE *languages[NUM_LANGUAGES] 
  418. #ifdef _COMMON_h
  419. #if(part == 0 || part == 1)
  420.     = {"C","RATFOR","FORTRAN","TEX","VERBATIM",
  421.       "C++","RATFOR--90","FORTRAN--90"}
  422. #endif /* |part == 1| */
  423. #endif /* |defined _COMMON_h| */
  424. ;
  425.  
  426. IN_COMMON CONST char HUGE *lang_codes[NUM_LANGUAGES] 
  427. #ifdef _COMMON_h
  428. #if(part == 0 || part == 1)
  429.     = {"C","R","N","X","V","C++","R90","N90",}
  430. #endif
  431. #endif
  432. ;
  433.  
  434. @ The following sets the delimiters for the module number stuff in the
  435. code output.
  436.  
  437. @a
  438.  
  439. IN_COMMON outer_char begin_comment_char[NUM_LANGUAGES]
  440. #ifdef _COMMON_h
  441. #if(part == 0 || part == 1)
  442.      = {'/','#','C','%','/', '/','#','C'}
  443. #endif
  444. #endif
  445. ; /* |C|, |RATFOR|, |FORTRAN|, |TEX|, |LITERAL|, \dots. */
  446.  
  447. IN_COMMON CONST outer_char end_comment_char[NUM_LANGUAGES]
  448. #ifdef _COMMON_h
  449. #if(part == 0 || part == 1)
  450.     = {'/',' ',' ',' ','/', '/',' ',' '}
  451. #endif
  452. #endif
  453. ;
  454.  
  455. @
  456. @<Mac...@>=
  457. @@
  458. @@<Specific language cases@@>=
  459.  
  460. case begin_C:
  461. case begin_RATFOR:
  462. case begin_FORTRAN:
  463. case begin_LITERAL@@: @@;
  464.  
  465. @ The following readably abbreviate the control letters for language
  466. switches.  These are just the basic languages; dialects are set by the
  467. optional arguments.  We need to worry about the distinction between |ASCII|
  468. and |outer_char|.
  469.  
  470. @<Mac...@>=
  471.  
  472. @@ 
  473. @@f @@<|ASCII| cases for |C|@@> case
  474. @@f @@<|ASCII| cases for |RATFOR|@@> case
  475. @@f @@<|ASCII| cases for |FORTRAN|@@> case
  476. @@f @@<|ASCII| cases for |TEX|@@> case
  477. @@f @@<|ASCII| cases for |LITERAL|@@> case
  478. @@<|ASCII| cases for |C|@@>=
  479. case @@'c': case @@'C'@@: @@;
  480.  
  481. @@ @@<|ASCII| cases for |RATFOR|@@>=
  482. case @@'r': case @@'R'@@: @@;
  483.  
  484. @@ @@<|ASCII| cases for |FORTRAN|@@>=
  485. case @@'n': case @@'N'@@: @@;
  486.  
  487. @@ @@<|ASCII| cases for |TEX|@@>=
  488. case @@'x': case @@'X'@@: @@;
  489.  
  490. @@ @@<|ASCII| cases for |LITERAL|@@>=
  491. case @@'v': case @@'V'@@: @@;
  492.  
  493. @ Same stuff for |outer_char|.
  494.  
  495. @<Mac...@>=
  496.  
  497. @@ 
  498. @@f @@<|outer_char| cases for |C|@@> case
  499. @@f @@<|outer_char| cases for |RATFOR|@@> case
  500. @@f @@<|outer_char| cases for |FORTRAN|@@> case
  501. @@f @@<|outer_char| cases for |TEX|@@> case
  502. @@f @@<|outer_char| cases for |LITERAL|@@> case
  503. @@<|outer_char| cases for |C|@@>=
  504. case 'c': case 'C'@@: @@;
  505.  
  506. @@ @@<|outer_char| cases for |RATFOR|@@>=
  507. case 'r': case 'R'@@: @@;
  508.  
  509. @@ @@<|outer_char| cases for |FORTRAN|@@>=
  510. case 'n': case 'N'@@: @@;
  511.  
  512. @@ @@<|outer_char| cases for |TEX|@@>=
  513. case 'x': case 'X'@@: @@;
  514.  
  515. @@ @@<|outer_char| cases for |LITERAL|@@>=
  516. case 'v': case 'V'@@: @@;
  517.  
  518.  
  519. @<Mac...@>=
  520.  
  521. @@ Read the basic language letter and set the language.  We must check for
  522. dialects before we call |opt_args| because the first thing that does is
  523. to set the language based on the values of the dialect flags. 
  524.  
  525. @@<Set |language|@@>=
  526. {
  527. ASCII l = *loc++; /* The basic language letter. */
  528.  
  529. switch(l)
  530.     {
  531.    @@<|ASCII| cases for |C|@@>:
  532.     Cpp = BOOLEAN(*loc == @@'+');
  533.     break;
  534.  
  535.    @@<|ASCII| cases for |RATFOR|@@>:
  536.    @@<|ASCII| cases for |FORTRAN|@@>:
  537.     Fortran88 = BOOLEAN(*loc == @@'9');
  538.     break;
  539.  
  540.    @@<|ASCII| cases for |LITERAL|@@>:
  541.    @@<|ASCII| cases for |TEX|@@>:
  542.     break;
  543.  
  544.    default:
  545.     err_print(C,"! Invalid language command `@@@@L%c' ignored",XCHR(l));
  546.     break;
  547.     }
  548.  
  549. opt_args(l); /* Set the language, and parse optional arguments after
  550.         language command. */ 
  551. }
  552.  
  553. @ Dynamic memory allocation.
  554.  
  555. @d SET_VAL(val,abbrev) val = find_abbrev((outer_char *)abbrev)->nunits
  556. @d MAX_VAL(abbrev) find_abbrev((outer_char *)abbrev)->max
  557.  
  558. @
  559. @<Mac...@>=
  560. @@ 
  561. @@m UPPER(var) smin0(MAX_VAL(ABBREV(var))),ABBREV(var)
  562.  
  563. @
  564. @a
  565.  
  566. typedef struct
  567.     {
  568.     outer_char abbrev[3]; /* Two-character abbreviation for the
  569. variable. */
  570.     short bytes;    /* Number of bytes in one unit. */
  571.     BUF_SIZE min,    /* Minimum possible value. */
  572.         nunits, /* How many units to allocate, or the default
  573. value. */
  574.         max;     /* Maximum possible value. */
  575.     } MEM;
  576.  
  577. @ Masks for \FWEAVE\ stuff that may not want to be printed.
  578.  
  579. @a
  580.  
  581. typedef struct
  582.     {
  583.     unsigned@/
  584.         formats:1, Formats:1, /* Print \.{@@f}, \.{@@F}. */
  585.         limbo:1, /* Print \.{@@l}. */
  586.         macros:1, /* Print \.{@@m}. */
  587.         outer_macros:1, /* Print \.{@@d}. */
  588.         v:1, /* Print \.{@@v}. */
  589.         w:1 /* Print \.{@@w}. */
  590.         ;
  591.     } DEFN_MASK;
  592.  
  593. @ A number of unrelated parameters need to be saved simultaneously at
  594. various points. Thus, we collect them into a structure, |params|. Since we
  595. also need to be able to refer to them effectively, we use macro definitions
  596. to help us.
  597.  
  598. @d LN lan_num
  599.  
  600. @D language params.Language
  601. @D language_index params.Language_index
  602. @D language_num params.Language_num
  603.  
  604. @D in_format params.In_format
  605. @D in_data params.In_data
  606. @D intermingle params.Intermingle
  607. @%@D sharp_include_line params.Include_line
  608.  
  609. @D active_brackets params.Active_brackets
  610. @D all_cmnts_verbatim params.All_cmnts_verbatim
  611. @D all_includes params.All_includes
  612. @D auto_app_semi params.Auto_app_semi
  613. @D auto_semi params.Auto_semi[language_num]
  614. @D auto_line params.Auto_line
  615. @D beeps params.Beeps
  616. @D block_nums params.Block_nums[language_num]
  617. @D bslash_continued_strings params.Bslash_continued_strings
  618. @D chk_ifelse params.Chk_ifelse
  619. @D chk_stmts params.Chk_stmts
  620. @D compare_outfiles params.Compare_outfiles
  621. @D compound_assignments params.Compound_assignments
  622. @D Cpp params.CPP
  623. @D Cpp_comments params.CPP_comments[language_num]
  624. @D dbg_output params.Dbg_output
  625. @D deferred_macros params.Deferred_macros
  626. @D defn_mask params.Defn_mask
  627. @D dot_constants params.Dot_constants
  628. @D Fortran88 params.ForTran88
  629. @D Fortran_label params.Fortran_Label
  630. @D free_form_input params.Free_form_input[language_num]
  631. @D in_escape params.In_escape[language_num]
  632. @D index_hidden params.Index_hidden
  633. @D input_macros params.Input_macros
  634. @D keep_trailing_comments params.Keep_trailing_comments
  635. @D lc_keywords params.Lc_keywords
  636. @D line_info params.Line_info
  637. @D lowercase_tokens params.Lowercase_tokens
  638. @D m4 params.M4
  639. @D no_xref params.No_xref
  640. @D number_dos params.Number_dos
  641. @D nuweb_mode params.Nuweb_mode
  642. @D overload_ops params.Overload_ops
  643. @D point_comments params.Point_comments[language_num]
  644. @D prn_input_lines params.Prn_input_lines
  645. @D prn_input_addresses params.Prn_input_addresses
  646. @D prn_contents params.Prn_contents
  647. @D prn_index params.Prn_index
  648. @D prn_modules params.Prn_modules
  649. @D prn_semis params.Prn_semis
  650. @D quoted_includes params.Quoted_includes
  651. @D Ratfor77 params.RatFor77
  652. @D read_iformats params.Read_iformats
  653. @D reverse_indices params.Reverse_indices[language_num]
  654. @D rmv_files params.Rmv_files
  655. @D skip_ifiles params.Skip_ifiles
  656. @D skip_includes params.Skip_includes
  657. @D statistics params.Statistics
  658. @D subscript_fcns params.Subscript_fcns
  659. @D suppress_cmds params.Suppress_cmds
  660. @D TeX_processor params.TeX_Processor
  661. @D toggle_includes params.Toggle_includes
  662. @D top_version params.Top_version
  663. @D translate_ASCII params.Translate_ASCII
  664. @D translate_brackets params.Translate_brackets
  665. @D truncate_ids params.Truncate_ids
  666. @D try_extensions params.Try_extensions
  667. @D xref_unnamed params.Xref_unnamed
  668.  
  669. @a
  670.  
  671. typedef enum {TeX_p,LaTeX_p} TeX_PROCESSOR; /* What to use with \FWEAVE. */
  672.  
  673. typedef struct
  674.     {
  675.     LANGUAGE Language; /* The current language. May be set by encountering
  676. a module name, or by explicit \.{@@n}, \.{@@r}, or \.{@@c} commands. */
  677.     short Language_num,Language_index; /* These are set by
  678. |ini_language|. */
  679.  
  680. boolean@/
  681. /* Flags for really current state. */
  682.     In_format, /* Inside a |@@r format| statement. */
  683.     In_data, /* Inside a |@@r data| statement. */
  684.     Intermingle, /* Inside something like a |@@r data|
  685. statement. */
  686.     Include_line, /* Inside an \&{include} line. */
  687.  
  688. /* Options flags.  Some of these apply to all languages, others differ from
  689. language to language and are thus arrays. */
  690.     Active_brackets, /* Special array handling? */
  691.     All_cmnts_verbatim, /* Should \.{TANGLE} copy all comments? . */
  692.     All_includes, /* Cross-reference all include files? */
  693.     Auto_app_semi, /* For \.{WEAVE}, automatically
  694. append a pseudo-semi to the end of \.{WEB} macro definitions? */
  695.     Auto_semi[NUM_LANGUAGES], /* Fill in semicolon at end of source line? */
  696.     Auto_line, /* Auto-insert line number after \.{@@\%}? */
  697.     Beeps, /* Do we beep the terminal for certain errors? */
  698.     Block_nums[NUM_LANGUAGES], /* */
  699.     Bslash_continued_strings, /* Do the continuations of
  700. strings require a starting backslash? */ 
  701.     Chk_ifelse, /* Protect parenthesized strings? */
  702.     Chk_stmts, /* Check statement syntax in \Ratfor? */
  703.     Compare_outfiles, /* Check new (temporary) vs.\ old output? */
  704.     Compound_assignments, /* Do we allow things like \.{+=}? */
  705.     CPP, /* Do we recognize \.{C++}? */
  706.     CPP_comments[NUM_LANGUAGES], /* Allow short comments? */
  707.     Dbg_output, /* Print each character fired at output? */
  708.     Deferred_macros, /* Allow deferred macros? */
  709.     Dot_constants, /* Recognize dot constants like `\.{.eq.}'? */
  710.     ForTran88, /* Turn on stuff for Fortran-88? */
  711.     Fortran_Label, /* Label on same line? */
  712.     Free_form_input[NUM_LANGUAGES], /* Free-form syntax. */
  713.     In_escape[NUM_LANGUAGES], /* (|outer_char|) continuation character
  714. for end-of-lines. */
  715.     Index_hidden, /* Index skipped include files. */
  716.     Input_macros, /* Generate the default ``\.{\\input fwebmac}'' line? */
  717.     Keep_trailing_comments, /* For \TeX, retain comments that don't
  718. start a line. */
  719.     Lc_keywords, /* Lower-case \Fortran\ and \Ratfor\ I/O keywords? */
  720.     Line_info, /* Should \FTANGLE\ print out line information? */ 
  721.     Lowercase_tokens, /* Output lower-case tokens (\Ratfor). */
  722.     M4, /* Recognize \.{M4} preprocessor commands? */
  723.     No_xref, /* Should \.{WEAVE} print an index? */
  724.     Number_dos, /* */
  725.     Nuweb_mode, /* Emulate \.{nuweb}? */
  726.     Overload_ops, /* Is operator overloading allowed? */
  727.     Point_comments[NUM_LANGUAGES], /* Does \.! signify a \Fortran\ or
  728. \Ratfor\ comment? */
  729.     Prn_contents, /* Print table of contents? */
  730.     Prn_index, /* Print index? */
  731.     Prn_input_lines, /* Used in |input_ln| to print out the lines sent
  732. back. */ 
  733.     Prn_input_addresses, /* Print out the buffer addresses. */
  734.     Prn_modules, /* Print module list? */
  735.     Prn_semis, /* Print semicolons in \Fortran\ output. */
  736.     Quoted_includes, /* Cross-reference quoted include files? */
  737.     RatFor77, /* Expand \Ratfor\ code directly to \Fortran-77? */  
  738.     Read_iformats, /* Read include files for formats. */
  739.     Reverse_indices[NUM_LANGUAGES], /* C-style indexing in \Fortran? */
  740.     Rmv_files, /* Remove temporary files related to \.{-H}? */
  741.     Skip_ifiles, /* \.{-j} --- skip files already included. */
  742.     Skip_includes, /* For \.{WEAVE}, don't read in \.{@@I} commands.
  743. (Uppercase '\.{I}' only.) */ 
  744.     Statistics, /* Print statistics about memory usage? */
  745.     Subscript_fcns, /* Put module references on functions? */
  746.     Suppress_cmds, /* ??? */
  747.     Toggle_includes, /* For \.{WEAVE}, read in \.{@@I} commands, but
  748. don't print them out. */ 
  749.     Top_version, /* Header info at top of output? */
  750.     Translate_ASCII, /* Do we bother with the |xchr|--|xord|
  751. conversions? */ 
  752.     Translate_brackets, /* Brackets to parentheses in \Fortran? */
  753.     Truncate_ids, /* Shorten identifiers? */
  754.     Try_extensions, /* Search through list of possible file names? */
  755.     Xref_unnamed; /* Cross-reference unnamed references? */
  756.  
  757. DEFN_MASK Defn_mask; /* What defn's to print by \FWEAVE. */
  758. TeX_PROCESSOR TeX_Processor; /* Processor to be used with \FWEAVE. */
  759.  
  760. outer_char HUGE*outp_nm[NUM_LANGUAGES]; /* Current output file names. */
  761. FILE *outp_file[NUM_LANGUAGES]; /* File ptrs associated with above. */
  762.     } PARAMS;
  763.  
  764. IN_COMMON PARAMS params,global_params;
  765. IN_COMMON boolean stop_the_scan;
  766.  
  767. @ We need to know what kind of construction is being parsed, so the
  768. |get_line| routine can distinguish various input formats (for \FORTRAN). 
  769.  
  770. @a
  771.  
  772. typedef enum {OUTER,INNER} PARSING_MODE;
  773.  
  774. IN_COMMON PARSING_MODE parsing_mode CSET(OUTER);
  775.  
  776. @ More stuff related to parsing the input line.
  777.  
  778. @d preprocessing parse_params.Preprocessing
  779. @d at_beginning parse_params.At_beginning
  780. @d sharp_include_line parse_params.Sharp_include_line
  781. @d sharp_pragma_line parse_params.Sharp_pragma_line
  782.  
  783. @a
  784.  
  785. typedef struct
  786.     {
  787.     boolean Preprocessing; /* Are we scanning a preprocessor command? */
  788.     boolean At_beginning;  /* Are we at logical beginning of line? */
  789.     boolean Sharp_include_line; /* Does line start with ``|#include|''? */
  790.     boolean Sharp_pragma_line; /* Starts with ``|#pragma|''? */
  791.     } PARSE_PARAMS;
  792.  
  793. IN_COMMON PARSE_PARAMS parse_params 
  794. #ifdef _COMMON_h
  795. #if(part == 0 || part == 1)
  796.     = {NO,YES}
  797. #endif
  798. #endif
  799. ;
  800.  
  801. @ On an |ASCII| machine, we can speed things up by not bothering with the
  802. translations. (The flag |TRANSLATE_ASCII| is set in \.{os.hweb}.)
  803.  
  804. /* |ASCII| case changes. */
  805. @d isAupper(c) (c<=@'Z' && c>=@'A')
  806. @d isAlower(c) (c<=@'z' && c>=@'a')
  807.  
  808. @d SET_CASE(c) upper_case_code = BOOLEAN(isAupper(c))
  809.      /* Watch out for side effects. */
  810. @d lower_case_code BOOLEAN(!upper_case_code)
  811.  
  812. @d A_TO_LOWER(c) (ASCII)(isAupper(c) ? (int)c+040 : c)
  813. @d A_TO_UPPER(c) (ASCII)(isAlower(c) ? (int)c-040 : c)
  814.  
  815. /* Handle the difference between |ASCII| and |outer_char|. */
  816. @d isAlpha(c) isalpha(XCHR(c))
  817. @d isDigit(c) isdigit(XCHR(c)) /* We're working on |ASCII| input. */
  818. @d isBdigit(c) ((c)==@'0' || (c)==@'1') /* Is it a binary numeral? */
  819. @d isOdigit(c) (isDigit(c) && c!=@'8' && c!=@'9') /* Octal numeral? */
  820. @d isXdigit(c) isxdigit(XCHR(c)) /* Hex numeral? */
  821.  
  822. @a
  823.  
  824. EXTERN boolean upper_case_code SET(NO);
  825.  
  826. /* For debugging of target machines with a different character set than
  827. that of the present machine, use the |DEBUG_XCHR| flag to force the
  828. internal representation to be ``scrambled |ASCII|'', which replaces the
  829. array~|xchr| with |wt_style.xchr|. */
  830. #if(DEBUG_XCHR)
  831.     #define XCHR_ wt_style.xchr /* Scrambled mapping. */
  832. #else
  833.     #define XCHR_ xchr /* The mapping for this machine. */
  834. #endif /* |DEBUG_XCHR| */
  835.  
  836. #if(TRANSLATE_ASCII)
  837.     #define XORD(outer) xord[outer]
  838.     #define XCHR(inner) XCHR_[inner]
  839. #else /* Don't bother with the translations. */
  840.     #define XORD(outr) (outr) /* Funny spelling from Dethier's changes. */
  841.     #define XCHR(innr) (innr)
  842. #endif /* |TRANSLATE_ASCII| */
  843.  
  844. typedef unsigned char ASCII; /* Type of characters inside \.{WEB}. */
  845.  
  846. @ Here is how reserved words are stored.
  847.  
  848. @a
  849.  
  850. typedef struct
  851.     {
  852.     CONST char HUGE *reserved_word;
  853.     eight_bits type;
  854.     } RESERVED_WORD;
  855.  
  856. @ A global variable called |history| will contain one of four values
  857. at the end of every run: |spotless| means that no unusual messages were
  858. printed; |harmless_message| means that a message of possible interest
  859. was printed but no serious errors were detected; |error_message| means that
  860. at least one error was found; |fatal_message| means that the program
  861. terminated abnormally. The value of |history| does not influence the
  862. behavior of the program; it is simply computed for the convenience
  863. of systems that might want to use such information.
  864.  
  865. @d mark_harmless 
  866.     {SET_COLOR(ordinary); 
  867.     if (history==spotless) history=harmless_message;} 
  868.  
  869. @d mark_error 
  870.     {SET_COLOR(ordinary);
  871.     history=error_message;
  872.     }
  873.  
  874.  
  875. @a
  876.  
  877. typedef enum
  878.     {
  879.     spotless, /*  Normal jobs */
  880.     harmless_message, /*  Non-serious info was printed */ 
  881.     error_message, /*  An error was noted */
  882.     fatal_message /*  We had to stop prematurely */
  883.     } HISTORY;
  884.  
  885. IN_COMMON HISTORY history CSET(spotless); /* indicates how bad this run was */
  886.  
  887.  
  888. @<Mac...@>=
  889. @@ A simple error message with no arguments is used frequently.  Error
  890. messages now carry an indication of their origin.
  891.  
  892. @@m err_print(origin,msg,...) 
  893.     err0_print(ERR_##origin,OC(msg),#0,#.)
  894. @@m ERR_PRINT(origin,msg) err_print(origin,msg) 
  895.  
  896. @@m MACRO_ERR(msg,trail,...) 
  897.     macro_err(OC(msg),trail,#.)
  898.  
  899. @
  900. @a
  901.  
  902. typedef enum {ERR_NULL,ERR_C,ERR_T,ERR_W,ERR_R,ERR_M,ERR_S} ERR_ORIGIN;
  903. IN_COMMON boolean err_happened CSET(NO);
  904.  
  905.  
  906. @ Code related to file handling. The open input files are maintained on a
  907. stack, with the |WEB_FILE| at the top~(0).  For every input file, there is
  908. an associated change file.
  909.  
  910. @f line x /* Make |line| an unreserved word. */
  911.  
  912. @d OUTPUT_LINE outp_line[lan_num(language)]
  913. @d OUTPUT_FILE_NAME outp_nm[lan_num(out_language)]
  914. @d OUT_LANGUAGE(language)
  915.     (R77_or_F ? (Fortran88 ? FORTRAN_90 : FORTRAN) : language)
  916. @d OUT_FILE_NAME outp_nm[lan_num(OUT_LANGUAGE(language))]
  917.  
  918. @D PUTC(c) 
  919.     {
  920.     CHECK_OPEN;
  921.     if(putc((int)(c),out_file) == EOF) 
  922.         out_error(OC("putc"));
  923.     }
  924.  
  925. @d MAX_FILE_NAME_LENGTH 200
  926.  
  927. @D WEB_FILE 0
  928. @D web_file_name prms[WEB_FILE].web.File_name /* Main source file name. */
  929. @D web_file prms[WEB_FILE].web.File /* Main source file. */
  930.  
  931. @D CUR_FILE incl_depth
  932. @D cur_file_name prms[CUR_FILE].web.File_name /* Current input file name. */
  933. @D cur_file prms[CUR_FILE].web.File /* Current input file. */
  934.  
  935. @D cur_line cur0_prms->Line /* Number of current line in current file. */
  936.  
  937. @D change_file_name prms[CUR_FILE].change.File_name
  938. @D change_file prms[CUR_FILE].change.File
  939. @D change_line prms[CUR_FILE].change.Line
  940.  
  941. /* --- Stuff used mostly within |input_ln| --- */
  942. @D num_in_buffer cur0_prms->Num_in_buffer
  943. @D comment_in_buffer cur0_prms->Comment_in_buffer
  944. @D scanning_C_cmnt cur0_prms->Scanning_C_cmnt
  945. @D start_C cur0_prms->Start_C
  946. @D last_was_empty cur0_prms->Last_was_empty
  947. @D continuing_line cur0_prms->Continuing_line
  948. @D last_was_continued cur0_prms->Last_was_continued
  949.  
  950. /* The following are used as arguments to |input_ln|. */
  951. @D INPUT_FILE &prms[CUR_FILE].web
  952. @D CHANGE_FILE &prms[CUR_FILE].change
  953.  
  954. /* --- Buffers --- */
  955. @D cur_buffer cur0_prms->Buffer
  956. @D buffer_end cur0_prms->Buffer_end
  957. @D limit cur0_prms->Limit /* points to the last character in the buffer. */
  958.  
  959. @D change_buffer (cur_prms.change)->Buffer
  960. @D change_buffer_end (cur_prms.change)->Buffer_end
  961. @D change_limit (cur_prms.change)->Limit
  962.  
  963. @a
  964.  
  965. IN_COMMON LANGUAGE out_language; /* Current language for output file. */
  966. IN_COMMON FILE *out_file; /* Current output file pointer. */
  967. IN_COMMON int incl_depth; /* Current level of file nesting. */
  968.  
  969. typedef struct
  970.     {
  971.     FILE *File;    /* Pointer to file. */
  972.     LINE_NUMBER Line;     /* Line number. */
  973.     ASCII HUGE *Buffer; /* Input buffer. */
  974.     ASCII HUGE *Buffer_end;
  975.     ASCII HUGE *K0;
  976.     ASCII HUGE *Limit; /* Next unfilled position. */
  977.     int Num_in_buffer; /* Number remaining to be read. */
  978.     boolean Comment_in_buffer; 
  979.     boolean Found_at,At_line;
  980.     boolean Scanning_C_cmnt,Start_C,Last_was_empty;
  981.     boolean Continuing_line,Last_was_continued;
  982.     outer_char File_name[MAX_FILE_NAME_LENGTH]; 
  983.     } INPUT_PRMS0;
  984.  
  985. IN_COMMON INPUT_PRMS0 HUGE *cur0_prms; /* Pointer to current parameters. */
  986.  
  987. typedef struct
  988.     {
  989.     INPUT_PRMS0 HUGE *web,HUGE *change;
  990.     } CUR_PRMS;
  991.  
  992. IN_COMMON CUR_PRMS cur_prms; /* Address of current input parameters. */
  993.  
  994. typedef struct
  995.  
  996.     {
  997.     LANGUAGE Language;
  998.     PARSING_MODE Parsing_mode;
  999.     boolean Column_mode;
  1000.     } INPUT_PARAMS;
  1001.  
  1002. typedef struct
  1003.     {
  1004.     INPUT_PRMS0 web,change;
  1005.     INPUT_PARAMS input_params;
  1006.     } INPUT_PRMS;
  1007.  
  1008. IN_COMMON BUF_SIZE max_include_depth;
  1009. IN_COMMON INPUT_PRMS *prms; /* Stack of |max_include_depth+1| open files. */
  1010.  
  1011. IN_COMMON outer_char HUGE *tex_fname; /* Name of |tex_file|. */
  1012. #define tex_file out_file /* Where output of \.{WEAVE} goes. */
  1013.  
  1014. IN_COMMON outer_char HUGE *fwebmac; /* The default macro package. */
  1015.  
  1016. IN_COMMON boolean input_has_ended; /* If there is no more input. */
  1017. IN_COMMON boolean changing; /* If the current line is from |change_file|. */
  1018.  
  1019. typedef struct
  1020.     {
  1021.     outer_char HUGE *name; /* The ultimate output file name. */
  1022.     outer_char HUGE *tmp_name; /* Temporary file name, so new results
  1023.                     can be compared with old ones. */
  1024.     FILE *ptr; /* A pointer to |tmp_name|. */
  1025.     eight_bits previously_opened; /* Possibly opened, but now closed. */
  1026.     eight_bits global_scope; /* To control closing at end of each sectn. */
  1027.     } OPEN_FILE; /* Info about previously opened files. */
  1028.  
  1029. @ Short-hand for arguments to built-in functions.
  1030.  
  1031. @a
  1032. typedef eight_bits HUGE *PARGS[];
  1033.  
  1034. @
  1035. To recognize the various built-in functions, we must search through
  1036. a list.  
  1037.  
  1038. @d MAX_DOT_LENGTH 31 /* Don't have to scan farther than this to see if it's
  1039.             a dot constant. The~31 is a \FORTRAN-90 limit. */
  1040.  
  1041. @a
  1042.  
  1043. IN_COMMON ASCII HUGE *id_first; /* Where the current identifier begins in
  1044.                     the buffer */  
  1045. IN_COMMON ASCII HUGE *id_loc; /* Just after the current identifier in the
  1046.                     buffer */  
  1047.  
  1048. typedef struct
  1049.     {
  1050.     ASCII *name;
  1051.     int n;
  1052.     } BUILT_IN;
  1053.  
  1054. IN_COMMON BUILT_IN incl_likes[]
  1055. #ifdef _COMMON_h
  1056. #if(part == 0 || part == 1)
  1057.     = {
  1058.     {(ASCII *)"changequote",11},
  1059.     {(ASCII *)"ifelse",6},
  1060.     {(ASCII *)"include",7},
  1061.     {(ASCII *)"index",5},
  1062.     {(ASCII *)"len",3},
  1063.     {(ASCII *)"maketemp",8},
  1064.     {(ASCII *)"sinclude",8},
  1065.     {(ASCII *)"substr",6},
  1066.     {(ASCII *)"syscmd",6},
  1067.     {(ASCII *)"translit",8},
  1068.     {(ASCII *)"",0}
  1069.     }
  1070. #endif
  1071. #endif
  1072. ;
  1073.  
  1074. IN_COMMON BUILT_IN WEB_incl_likes[]
  1075. #ifdef _COMMON_h
  1076. #if(part == 0 || part == 1)
  1077.     = {
  1078.     {(ASCII *)"@!$COMMENT",8},
  1079.     {(ASCII *)"@!$DEFINE",7},
  1080.     {(ASCII *)"@!$ERROR",6},
  1081.     {(ASCII *)"@!$IF",3},
  1082.     {(ASCII *)"@!$IFCASE",7},
  1083.     {(ASCII *)"@!$IFELSE",7},
  1084.     {(ASCII *)"@!$LEN",4},
  1085.     {(ASCII *)"@!$M",2},
  1086.     {(ASCII *)"@!_COMMENT",8},
  1087.     {(ASCII *)"@!_DEFINE",7},
  1088.     {(ASCII *)"@!_ERROR",6},
  1089.     {(ASCII *)"@!_IF",3},
  1090.     {(ASCII *)"@!_IFCASE",7},
  1091.     {(ASCII *)"@!_IFELSE",7},
  1092.     {(ASCII *)"@!_LEN",4},
  1093.     {(ASCII *)"@!_M",2},
  1094.     {(ASCII *)"",0}
  1095.     }
  1096. #endif
  1097. #endif
  1098. ;
  1099.  
  1100. @ A similar list takes care of \Ratfor-90 statements that mustn't be
  1101. considered as statement labels.
  1102.  
  1103. @a
  1104.  
  1105. IN_COMMON BUILT_IN non_labels[]
  1106. #ifdef _COMMON_h
  1107. #if(part == 0 || part == 1)
  1108.     = {
  1109.     {(ASCII *)"contains",8},
  1110.     {(ASCII *)"default",7},
  1111.     {(ASCII *)"private",7},
  1112.     {(ASCII *)"protected",9},
  1113.     {(ASCII *)"public",6},
  1114.     {(ASCII *)"sequence",8},
  1115.     {(ASCII *)"",0}
  1116.     }
  1117. #endif
  1118. #endif
  1119. ;
  1120.  
  1121.  
  1122. @D dot_const OCTAL(23)
  1123.  
  1124. @<Mac...@>=
  1125. @@ FORTRAN uses constructions such as~|@@r .true.| or~|@@r .and.|, which we
  1126. have to parse separately.
  1127.  
  1128. @@m PREDEFINED_DOTS 14 /* \# of pre-initialized entries in the |dots| table. */
  1129.  
  1130. @
  1131. @a
  1132.  
  1133. typedef struct
  1134.     {
  1135.     ASCII *symbol;
  1136.     short len;
  1137.     eight_bits code; /* Something like |dot_const|. */
  1138.     eight_bits cat; /* Category code for special constants and
  1139. operators. */
  1140.     eight_bits token; /* The tokenized meaning of this operator. */
  1141.     } DOTS;
  1142.  
  1143. typedef struct
  1144.     {
  1145.     ASCII name[MAX_DOT_LENGTH+3]; /* Holds the macro name to be
  1146. appended. */ 
  1147.     eight_bits cat; /* Category of the operator. */
  1148.     eight_bits num; /* Position in the table. */
  1149.     } DOT_OP;
  1150.  
  1151. IN_COMMON DOT_OP dot_op 
  1152. #ifdef _COMMON_h
  1153. #if(part == 0 || part == 1)
  1154.     = {"\\",0,0}
  1155. #endif
  1156. #endif
  1157. ;
  1158.  
  1159. @ The |macrobuf| is a character buffer used for expanding macros, or for
  1160. holding macros defined from the input line. The present position in the
  1161. |macrobuf| is~|mp|.  For |macrobuf|, see \.{stacks.hweb} (\FTANGLE) or \FWEAVE.
  1162.  
  1163. @a
  1164.  
  1165. IN_COMMON boolean in_macro CSET(NO);
  1166.     
  1167. IN_COMMON BUF_SIZE mbuf_size; /* Set dynamically. */
  1168. IN_COMMON eight_bits HUGE *mp; /* Next available position in |macrobuf|. */
  1169.  
  1170. IN_COMMON boolean from_buffer CSET(NO); /* Are we reading from a buffer? */
  1171.  
  1172. @ Stuff related to command-line arguments.
  1173.  
  1174. @a
  1175.  
  1176. IN_COMMON int argc; /* copy of |ac| parameter to |main| */
  1177. IN_COMMON outer_char **argv; /* copy of |av| parameter to |main| */
  1178. IN_COMMON outer_char HUGE *pa; /* Current value of |*argv|. */
  1179.  
  1180. @ Defaults for |boolean| flags, etc.
  1181.  
  1182. /* MACROS here. */
  1183. @d ACTIVE_BRACKETS NO
  1184. @d ALL_CMNTS_VERBATIM NO
  1185. @d ALL_INCLUDES NO
  1186. @d AUTO_APP_SEMI NO
  1187. @d AUTO_LINE YES
  1188. @d BEEPS YES
  1189. @d BLOCK_NUMS NO
  1190. @d BSLASH_CONTINUED_STRINGS NO
  1191. @d CHK_IFELSE NO
  1192. @d CHK_STMTS NO
  1193. @d COMPARE_OUTFILES NO
  1194. @d COMPOUND_ASSIGNMENTS YES
  1195. @d CPP_COMMENTS YES
  1196. @d DBG_OUTPUT NO
  1197. @d DEFERRED_MACROS NO
  1198. @d DOT_CONSTANTS YES
  1199. @d FORTRAN88 NO    /* By default, it's \FORTRAN-77. */
  1200. @d FORTRAN_LABEL YES
  1201. @d FREE_FORM_INPUT YES
  1202. @d FREE_FORTRAN NO
  1203. @d IN_ESCAPE '\\'
  1204. @d INDEX_HIDDEN NO
  1205. @d INPUT_MACROS YES
  1206. @d KEEP_TRAILING_COMMENTS YES
  1207. @d LC_KEYWORDS NO
  1208. @d LINE_INFO YES
  1209. @d LOWERCASE_TOKENS NO
  1210. @d M4_ NO
  1211. @d NO_XREF NO
  1212. @d NUMBER_DOS NO
  1213. @d NUWEB_MODE NO
  1214. @d OVERLOAD_OPS YES
  1215. @d POINT_COMMENTS NO
  1216. @d PRN_CONTENTS YES
  1217. @d PRN_OUTER_MACROS YES
  1218. @d PRN_fORMATS YES
  1219. @d PRN_FORMATS YES
  1220. @d PRN_LIMBO YES
  1221. @d PRN_INDEX YES
  1222. @d PRN_MACROS YES
  1223. @d PRN_MODULES YES
  1224. @d PRN_SEMIS NO
  1225. @d PRN_V YES
  1226. @d PRN_W YES
  1227. @d QUOTED_INCLUDES NO
  1228. @d RATFOR77 YES
  1229. @d READ_IFORMATS NO
  1230. @d REVERSE_INDICES NO
  1231. @d RMV_FILES YES
  1232. @d SKIP_IFILES NO
  1233. @d SKIP_INCLUDES NO
  1234. @d STATISTICS NO
  1235. @d SUBSCRIPT_FCNS YES
  1236. @d TOGGLE_INCLUDES NO
  1237. @d TOP_VERSION YES
  1238. @d TRANSLATE_ASCII0 NO
  1239. @d TRANSLATE_BRACKETS YES
  1240. @d TRY_EXTENSIONS NO
  1241. @d TEX_PROCESSOR LaTeX_p
  1242. @d XREF_UNNAMED YES
  1243.  
  1244. @d CCHAR '&' /* Default \FORTRAN\ continuation character. */
  1245.  
  1246. @d NUM_RATFOR_CMDS 20 /* The total number of reserved \RATFOR\ keywords.
  1247.     This is used for an array size later on. */
  1248.  
  1249. @ A structure used for |see_reserved| and |id_info|.
  1250. @a
  1251.  
  1252. typedef struct
  1253.     {
  1254.     outer_char HUGE *args;
  1255.     boolean intrinsics, keywords, reserveds;
  1256.     } RSRVD;
  1257.  
  1258. @
  1259. @a
  1260.  
  1261. IN_COMMON outer_char cchar CSET(CCHAR); /* Fortran's continuation
  1262. character. */
  1263.  
  1264. IN_COMMON ASCII cont_char CSET(@'\\'); /* Current continuation char for eol. */
  1265. IN_COMMON boolean free_Fortran CSET(NO); /* Free-form syntax in \Fortran.  */
  1266. IN_COMMON boolean free_90 CSET(NO); /* \Fortran/Ratfor-90 and free-form 
  1267. syntax. */
  1268.  
  1269. IN_COMMON unsigned short tr_max[NUM_LANGUAGES]
  1270. #ifdef _COMMON_h
  1271. #if(part == 0 || part == 1)
  1272.     = {0,0,0,0,0,0,0,0}
  1273. #endif
  1274. #endif
  1275. ;
  1276.  
  1277. IN_COMMON CONST char HUGE *filter_char[NUM_LANGUAGES] 
  1278. #ifdef _COMMON_h
  1279. #if(part == 0 || part == 1)
  1280.     = {"","_","_","","", "","_","_"}
  1281. #endif
  1282. #endif
  1283. ;
  1284.  
  1285. IN_COMMON outer_char abbrev_cmds[NUM_RATFOR_CMDS+1] CSET(""); /* Nothing
  1286.     suppressed by default. */ 
  1287.  
  1288. @ Holds the command-line arguments, after expansion from the ini file.
  1289. @a
  1290.  
  1291. IN_COMMON outer_char HUGE *cmd_ln_buf;
  1292.  
  1293. @ The global variable |word_type| holds the type of identifier that
  1294. |id_lookup| will work on next. This comes into play when the |last|
  1295. argument to |id_lookup| is |NULL|. In this case, |id_lookup| finds its own
  1296. end of the identifier.
  1297.  
  1298. @D mod_info info.mod
  1299. @D mod_ilk mod_info->Ilk
  1300. @D macro_type info.Macro_type
  1301.  
  1302. @D defined_in(languag) dummy.defined_info[lan_num(languag)].section
  1303. @D defined_type(languag) dummy.defined_info[lan_num(languag)].type
  1304. @D ilk Ilk[language_num]
  1305. @D expandable dummy.RX.Expandable
  1306. @D rlink dummy.RX.Rlink
  1307. @D x_translate dummy.RX.Expand
  1308.  
  1309. @f HUGE_FCN_PTR huge
  1310.  
  1311. @a
  1312.  
  1313. typedef enum {ORDINARY_ID,RESERVED_WD,INTRINSIC_FCN,KEYWD} WORD_TYPE;
  1314.  
  1315. IN_COMMON WORD_TYPE word_type CSET(ORDINARY_ID);
  1316.  
  1317. #define X_FCN SRTN    /* |typedef| didn't work on the VAX. */
  1318.  
  1319. typedef struct RX_link
  1320.     {
  1321.     struct name_info HUGE *Rlink; /* right link in binary search tree for
  1322.                     module names */  
  1323.     X_FCN (HUGE_FCN_PTR * HUGE *Expand)(VOID); /* Array of functions
  1324. for keyword expansion (one for each language). */
  1325.     boolean Expandable; /* For which language is this expandable? */
  1326.     } RX_LINK;
  1327.  
  1328. typedef struct
  1329.     {
  1330.     char Ilk;
  1331.     PARAMS params;    
  1332.     } MOD_INFO;
  1333.  
  1334. IN_COMMON boolean index_flag; /* Print identifier in index? */
  1335.  
  1336. typedef boolean NAME_TYPE; /* Type of identifier, enumerated below. */
  1337.  
  1338. enum {NEVER_DEFINED=0,
  1339.     GENERIC_NAME,FUNCTION_NAME,M_MACRO,D_MACRO,IMPLICIT_RESERVED,
  1340.     TYPEDEF_NAME,
  1341.     NEVER_DEFINED0=0x80,
  1342.     GENERIC_NAME0,FUNCTION_NAME0,M_MACRO0,D_MACRO0,IMPLICIT_RESERVED0,
  1343.     TYPEDEF_NAME0};
  1344.  
  1345. /* Maybe the |defined_type| is already marked to not appear in the index.
  1346. (It's $> 128$.)  To properly set a new type, we use a macro to keep the
  1347. flag and attach it to the new type. */ 
  1348. #define SET_TYPE(p,type) p->defined_type(language) =\
  1349.      ((boolean)(type) | (boolean)((p->defined_type(language) & 0x80)))
  1350.  
  1351. /* To recover the base type, use the following, which strips off the flag: */
  1352. #define DEFINED_TYPE(p) (p->defined_type(language) & 0x7F)
  1353.  
  1354. typedef struct
  1355.     {
  1356.     sixteen_bits section; /* Section number where identifier defined. */
  1357.     NAME_TYPE type; /* Kind of identifier, such as function name. */
  1358.     } DEFINED_INFO;
  1359.  
  1360. typedef struct
  1361.     {
  1362.     ASCII HUGE *text; /* The replacement text for the macro. */
  1363.     unsigned int len; /* Length of replacement text. */
  1364.     eight_bits cat; /* Category code. */
  1365.     } WV_MACRO;
  1366.  
  1367. typedef struct name_info 
  1368.     {
  1369.     ASCII HUGE *byte_start; /* Beginning of the name in |byte_mem|. */
  1370.     struct name_info HUGE *link; /* Used for hashing. */
  1371.     union 
  1372.         {
  1373.         struct RX_link RX; /* For \FTANGLE. */
  1374.         DEFINED_INFO defined_info[NUM_LANGUAGES]; /* For \FWEAVE. */
  1375.         } dummy;
  1376.     boolean reserved_word,intrinsic_word,keyword;
  1377.     boolean Language;
  1378.     union
  1379.         {
  1380.         char Macro_type; /* For \FTANGLE. */
  1381.         boolean upper_case; /* For \FWEAVE\ identifiers. */
  1382.         MOD_INFO HUGE *mod; /* For \FWEAVE\ module names */
  1383.         } info;
  1384.     eight_bits Ilk[NUM_LANGUAGES];/* Used by ident.'s in \WEAVE\ only. */
  1385.     ASCII HUGE *equiv_or_xref; /* Info corresponding to names. */
  1386.     WV_MACRO HUGE *wv_macro; /* For fancy identifiers. */
  1387.     } NAME_INFO; /* Contains information about an identifier or mod
  1388. name. */
  1389.  
  1390. typedef NAME_INFO HUGE *name_pointer; /* pointer into array of |name_info|s. */
  1391.  
  1392. @
  1393. @<Mac...@>=
  1394. @@
  1395. @@f HUGE_FCN_PTR huge
  1396. @@<Initialize |mod_info| and |Language|@@>=
  1397. {
  1398. /* We allocate |MOD_INFO| structures only for module names, not for
  1399.     identifiers. */
  1400. node->mod_info = GET_MEM("mod_info",1,MOD_INFO);
  1401.  
  1402. node->mod_info->Ilk = expr;
  1403. node->mod_info->params = params; /* Freeze parameters at this point in time. */
  1404.  
  1405. node->Language = (boolean)language; /* Redundant. */
  1406. }
  1407.  
  1408. @
  1409. @<Globals@>=
  1410.  
  1411. IN_COMMON BUF_SIZE max_bytes;
  1412. IN_COMMON ASCII HUGE *byte_mem; /* Dynamic array: characters of names. */
  1413. IN_COMMON ASCII HUGE *byte_end; /* End of |byte_mem|. */
  1414.  
  1415. IN_COMMON BUF_SIZE max_names;
  1416. IN_COMMON NAME_INFO HUGE *name_dir; /* Dynamic array: information about
  1417. names. */
  1418. IN_COMMON name_pointer name_end; /* End of |name_dir|. */
  1419. IN_COMMON name_pointer npmax; /* |name_ptr - 1|. */
  1420.  
  1421. IN_COMMON BUF_SIZE longest_name;
  1422. IN_COMMON ASCII HUGE *mod_text; /* Dynamic array: name being sought for. */
  1423. IN_COMMON ASCII HUGE *mod_end; /* End of |mod_text|. */
  1424.  
  1425.  
  1426.  
  1427. @d USED_BY_NEITHER ((eight_bits)0xFF)
  1428. @d USED_BY_OTHER ignore
  1429.  
  1430. @<Mac...@>=
  1431. @@ For initializing |ccodes|.
  1432.  
  1433. @@m INI_CCODE(defaults,code)
  1434.     ini_ccode((outer_char *)#code,(outer_char *)defaults,code)
  1435.         /* We use the same keyword name as the \FWEB\ code. */
  1436.  
  1437. @@m REASSIGNABLE(d,c) INI_CCODE(d,c) /* For stuff that must later be
  1438. reassigned for     \FTANGLE. */
  1439.  
  1440. @@m SAME_CCODE(d,c) INI_CCODE(d,c)
  1441.  
  1442.  
  1443. @<Mac...@>=
  1444. @@ Macros to guard against overflow during |sprintf| or |vprintf|. The function
  1445. |nsprintf| is defined in \.{common.web} to handle non-ANSI return values from
  1446. |sprintf|. 
  1447.  
  1448. @@m NSPRINTF(buf_name,fmt,...) 
  1449.     nsprintf(buf_name,OC(fmt),#0,#.)
  1450. @@m NVSPRINTF(buf_name,fmt,...) 
  1451.     nvsprintf(buf_name,OC(fmt),#0,#.)
  1452.  
  1453. @@m SPRINTF(nmax,buf_name,args) 
  1454.     if(NSPRINTF(buf_name,args) >= (int)(nmax)) OVERFLW(#buf_name,"")@@;
  1455.  
  1456. @@m VSPRINTF(nmax,buf_name,args) 
  1457.     if(NVSPRINTF(buf_name,args) >= (int)(nmax)) OVERFLW(#buf_name,"")@@;
  1458.  
  1459. @@m vsprintf_(out,fmt,arg_ptr) 
  1460.     @!$P if(NUM_VA_ARGS == 1)
  1461.         {
  1462.         char *fmt0 = va_arg(arg_ptr,char *);
  1463.  
  1464.         va_arg(arg_ptr,int); /* Skip over~$n$. */
  1465.         vsprintf((char *)out,fmt0,arg_ptr);
  1466.         }
  1467.     @!$P else
  1468.         vsprintf(out,fmt,arg_ptr);
  1469.     @!$P endif
  1470.  
  1471. @@m vprintf_(fmt,arg_ptr) 
  1472.     @!$P if(NUM_VA_ARGS == 1)
  1473.         {
  1474.         char *fmt0 = va_arg(arg_ptr,char *);
  1475.  
  1476.         va_arg(arg_ptr,int);
  1477.         vprintf(out,fmt0,arg_ptr);
  1478.         }
  1479.     @!$P else
  1480.         vprintf(fmt,arg_ptr);
  1481.     @!$P endif
  1482.  
  1483. @@f VA_ARGS $_EXPR
  1484. @@f VA_DECL int
  1485. @@f VA_LIST int
  1486.  
  1487.  
  1488. @<Mac...@>=
  1489. @@ Abbreviations for buffer allocations.
  1490.  
  1491. @@m ABBREV(name) V_##name
  1492.  
  1493. @@m V_buf_size "bs"
  1494. @@m V_C_buf_size "cb"
  1495. @@m V_cmd_fsize "cf"
  1496. @@m V_cmd_size "cg"
  1497. @@m V_delta_dots "d"
  1498. @@m V_line_length "ll"
  1499. @@m V_longest_name "ln"
  1500. @@m V_max_bytes "b"
  1501. @@m V_dtexts_max "dx"
  1502. @@m V_max_dtoks "dt"
  1503. @@m V_max_expr_chars "lx"
  1504. @@m V_max_lbls "lb"
  1505. @@m V_max_margs "ma"
  1506. @@m V_max_ifiles "if"
  1507. @@m V_max_include_depth "id"
  1508. @@m V_max_modules "m"
  1509. @@m V_max_names "n"
  1510. @@m V_max_refs "r"
  1511. @@m V_max_scraps "s"
  1512. @@m V_max_texts "x"
  1513. @@m V_max_toks_t "tt"
  1514. @@m V_max_toks_w "tw"
  1515. @@m V_mbuf_size "mb"
  1516. @@m V_op_entries "op"
  1517. @@m V_num_files "nf"
  1518. @@m V_sbuf_len "sb"
  1519. @@m V_stck_size_t "kt"
  1520. @@m V_stck_size_w "kw"
  1521. @@m V_X_buf_size "xb"
  1522.  
  1523. @ Operator overloading.
  1524. @a
  1525.  
  1526. /* Information for each language. */
  1527. typedef struct
  1528.     {
  1529.     CONST outer_char *op_macro; /* The default \FWEB\ macro. */
  1530.     boolean overloaded; /* Has it been overloaded? */
  1531.     eight_bits cat;    /* Category code for this operator. */
  1532.     outer_char HUGE *defn; /* Replacement text for the \Fortran\ macro. */
  1533.     } OP_INFO;
  1534.  
  1535. /* The description of an operator. */
  1536. typedef struct
  1537.     {
  1538.     ASCII HUGE *op_name; /* \Fortran-like name of operator. Not |const|
  1539. because it's converted to |ASCII|. */
  1540.     OP_INFO info[NUM_LANGUAGES];
  1541.     } OPERATOR;
  1542.  
  1543. @ Colors.
  1544.  
  1545. @D ESC 0x1b
  1546. @D MD "[1m" /* High intensity */
  1547. @D US "[4m" /* Underline */
  1548. @D MR "[7m" /* Reverse video */
  1549. @D MO "[m"  /* Revert to normal */
  1550.  
  1551. @d SET_COLOR(field) set_color(wt_style.color.field.value)
  1552. @d CLR_PRINTF(field,args) SET_COLOR(field); printf args; fflush(stdout);
  1553.         set_color(color0.last)
  1554.  
  1555. @a
  1556.  
  1557. typedef enum
  1558.     {
  1559.     NORMAL,RED,GREEN,BLUE,YELLOW,ORANGE,HIGHEST_COLOR
  1560.     } COLOR;
  1561.  
  1562. IN_STYLE CONST char *clr_name[]
  1563. #ifdef _STYLE_h
  1564.     = {"NORMAL","RED","GREEN","BLUE","YELLOW","ORANGE"}
  1565. #endif
  1566. ;
  1567.  
  1568. typedef struct
  1569.     {
  1570.     COLOR last,present;
  1571.     } COLOR0;
  1572.  
  1573. IN_COMMON COLOR0 color0
  1574. #ifdef _COMMON_h
  1575. #if(part == 0 || part == 1)
  1576.     = {NORMAL,NORMAL}
  1577. #endif
  1578. #endif
  1579. ;
  1580.  
  1581. typedef struct
  1582.     {
  1583.     short n;    /* Number of escape sequences attached to this color. */
  1584.     outer_char **string;    /* Array of pointers to those sequences. */
  1585.     } SEQUENCES;
  1586.  
  1587. @* \TeX\ MODE.
  1588.  
  1589. @a
  1590.  
  1591. typedef enum
  1592.     {
  1593.     TeX_escape,TeX_bgroup,TeX_egroup,TeX_math_shift,TeX_alignment_tab,
  1594.     TeX_eol,TeX_parameter,TeX_superscript,TeX_subscript,TeX_ignored,
  1595.     TeX_space,TeX_letter,TeX_other,TeX_active,TeX_comment,TeX_invalid
  1596.     } TeX_CATEGORY; 
  1597.  
  1598. IN_COMMON TeX_CATEGORY TeX[128];
  1599.  
  1600. @ Because we must compare tokens to see if they're the special ones, and we
  1601. don't know where they are in the table, we'll initialize individual
  1602. variables with the appropriate values returned from |id_lookup|.
  1603.  
  1604. @f X_FCN void
  1605.  
  1606. @a
  1607.  
  1608. EXTERN sixteen_bits id_defined;
  1609.  
  1610. typedef struct
  1611.     {
  1612.     CONST char HUGE *name; /* Identifier. */
  1613.     int len;    /* Length of identifier. */
  1614.     X_FCN (HUGE_FCN_PTR *expand)(VOID); /* Function that expands this
  1615. token. */ 
  1616.     sixteen_bits HUGE *pid; /* Address of the |sixteen_bits| that is to be
  1617. initialized. */
  1618.     } SPEC;
  1619.  
  1620. @ Here we define the text that may be inserted automatically after a
  1621. \Ratfor\ program unit.
  1622.  
  1623. @a
  1624.  
  1625. typedef struct
  1626.     {
  1627.     eight_bits *start; /* Macro to be inserted. */
  1628.     eight_bits *end; /* End of |start|. */
  1629.     } INSERT_TEXT;
  1630.  
  1631. typedef struct
  1632.     {
  1633.     INSERT_TEXT program,module,subroutine,function,blockdata,interface;
  1634.     } INSERT_MATERIAL;
  1635.  
  1636. @
  1637. @a
  1638.  
  1639. boolean Rat_OK PROTO((outer_char *msg));
  1640. IN_COMMON boolean Rat_is_loaded; /* Set by call to |is_Rat_present|. */
  1641. IN_COMMON boolean xpn_Ratfor CSET(YES);
  1642.  
  1643. IN_TANGLE int spcs_after_cmnt TSET(0);/* Turned on for Ratfor error
  1644. messages. */
  1645. IN_TANGLE int brace_level TSET(0);
  1646. IN_TANGLE boolean checking_label TSET(NO);
  1647. IN_TANGLE INSERT_MATERIAL insert; /* For automatic insertions. */
  1648.  
  1649. @ The following structure is used to remember where loops etc.\ began.
  1650.  
  1651. When we encounter the beginning of a program, module, subroutine, or
  1652. function, we store the identifier token of the program unit's name in
  1653. |cur_fcn|. This can be used by the built-in |$ROUTINE|, or in various error
  1654. messages.
  1655.  
  1656. @D cur_fcn begun[rlevel-1].name
  1657. @D NO_FCN (sixteen_bits)0
  1658.     /* Value of |cur_fcn| when function name is unknown. */
  1659.  
  1660. @D cur_struct begun[rlevel-1].name
  1661. @D is_function begun[rlevel-1].function
  1662. @D symbolic_label begun[rlevel-1].symbolic
  1663.  
  1664. @<Typedefs@>=
  1665.  
  1666. typedef enum
  1667.     {
  1668.     _DO_CMD,
  1669.     block_CMD,blockdata_CMD,
  1670.     break_CMD,case_CMD,contains_CMD,
  1671.     default_CMD,do_CMD,for_CMD,function_CMD,
  1672.     if_CMD,interface_CMD,module_CMD,next_CMD,program_CMD,
  1673.     repeat_CMD,return_CMD,type_CMD,subroutine_CMD,switch_CMD,until_CMD,
  1674.     where_CMD,while_CMD
  1675.     } CMD;
  1676.  
  1677. typedef struct
  1678.     {
  1679.     CMD cmd; /* Type of keyword being expanded. */
  1680.     sixteen_bits name; /* Identifier for this program unit. */
  1681.     sixteen_bits symbolic; /* Symbolic loop label. */
  1682.     boolean function; /* Is this a function? */
  1683.     LINE_NUMBER line; /* Line number at which expansion started. */
  1684.     int level; /* Expansion level. */
  1685.     } BEGUN;
  1686.  
  1687. IN_TANGLE BEGUN HUGE *begun; /* Dynamic array. */
  1688. IN_TANGLE int rlevel TSET(0); /* Current level of \Ratfor\ expansion.  This is
  1689.         incremented for each expandable \Ratfor\ keyword. */
  1690.  
  1691. @ The routine |prsw_regular_code| has various nifty branches that the
  1692. outside world needs to access.
  1693. @<Typedef...@>=
  1694.  
  1695. @#ifdef MVS
  1696. /* The C370 compiler will do strange integer promotions, if we
  1697.     don't force it to do better.  (Thorsten Ohl.) */
  1698. typedef enum 
  1699.     {MORE_PARSE=-1,GOTO_MISTAKE=-2,GOTO_GET_IDENTIFIER=-3,
  1700.       GOTO_GET_A_STRING=-4,GOTO_SKIP_A_COMMENT=-5,GOTO_MVS_KLUDGE=32000}
  1701.              @[GOTO_CODE;
  1702. @#else /* Not |MVS|. */
  1703. typedef enum 
  1704.      {MORE_PARSE=-1,GOTO_MISTAKE=-2,GOTO_GET_IDENTIFIER=-3,
  1705.      GOTO_GET_A_STRING=-4,GOTO_SKIP_A_COMMENT=-5} @[GOTO_CODE;
  1706. @#endif /* Not |MVS|. */
  1707.   
  1708.  
  1709. @ Here we identify which part of the code we're dealing with.
  1710.  
  1711. @d mark_defined w_style.misc.mark
  1712.  
  1713. @<Typedef...@>=
  1714.  
  1715. typedef enum {LIMBO,TEX_,DEFINITION,CODE} PART;
  1716.  
  1717. IN_COMMON PART the_part CSET(LIMBO);
  1718.  
  1719. typedef struct
  1720.     {
  1721.     int generic_name,fcn_name,WEB_macro,outer_macro,imp_reserved_name,
  1722.         typedef_name;
  1723.     } MARK_DEFINED;
  1724.  
  1725. @ What macros to use to format identifiers.
  1726.  
  1727. @<Typedef...@>=
  1728.  
  1729. typedef struct
  1730.     {
  1731.     outer_char *reserved, *RESERVED;
  1732.     outer_char *short_id;
  1733.     outer_char *id, *ID;
  1734.     outer_char *id_outer, *ID_OUTER;
  1735.     outer_char *id_inner, *ID_INNER;
  1736.     outer_char *intrinsic;
  1737.     outer_char *keyword, *KEYWORD;
  1738.     outer_char *typewritr;
  1739.     outer_char *wildcrd;
  1740.     } FORMAT;
  1741.  
  1742. @ Options for \LaTeX.
  1743.  
  1744. @<Typedef...@>=
  1745.  
  1746. typedef struct
  1747. {
  1748. outer_char *options;
  1749. outer_char *file;
  1750. } OPTIONS_FILE;
  1751.  
  1752. typedef struct
  1753.     {
  1754.     OPTIONS_FILE class, package;
  1755.     } LATEX;
  1756.  
  1757. @ Stuff for the style file.
  1758. @<Typedef...@>=
  1759.  
  1760. typedef char CC_BUF[2][40]; /*  One line of output for the control codes. */
  1761.  
  1762. @
  1763. @<Glob...@>=
  1764.  
  1765. IN_STYLE outer_char HUGE *sbuf, HUGE *sbuf_end;/* One line of style file. */
  1766. IN_STYLE CONST outer_char HUGE *sloc; /* Position in |sbuffer|. */
  1767. IN_STYLE outer_char HUGE *slimit; /* Next available position in buffer. */
  1768. IN_STYLE LINE_NUMBER s_line SSET(0); /* Input line number. */
  1769.  
  1770. @ Additional macros for compatibility between |char| and |outer_char|.
  1771. @d OC(s) ((outer_char HUGE *)(s))
  1772.  
  1773. @d STAT0(name,size,num,max_num,abs_max_num,abbrev,ctrl_chars)
  1774.     stat0(OC(name),size,num,max_num,abs_max_num,
  1775.         OC(abbrev),OC(ctrl_chars))
  1776.  
  1777. @d OVERFLW(msg,abbrev) overflow(OC(msg),OC(abbrev))
  1778. @d NEW_SPRM(name, value) new_sprm(OC(name), value)
  1779.  
  1780. @d FATAL(origin, msg1, msg2) fatal(ERR_##origin, OC(msg1), OC(msg2))
  1781.  
  1782. @d CONFUSION(msg1,msg2) confusion(OC(msg1),OC(msg2))
  1783.  
  1784. @d RAT_OK(msg) Rat_OK(OC(msg))
  1785.  
  1786. @
  1787.  
  1788. @d APP_STR(s) app_str(OC(s))
  1789.  
  1790. @<Mac...@>=
  1791. @@
  1792. @@f X_FCN void
  1793. @@m RAT_ERROR(err_type,msg,n,...) 
  1794.     RAT_error(err_type,OC(msg),n,#.)
  1795.  
  1796. @* DEFINITIONS for TANGLE and WEAVE. Here's stuff required for
  1797. \.{tangle.web} and \.{weave.web}. 
  1798.  
  1799. @ As much as possible, we adhere to ANSI conventions. However, to support
  1800. pre-ANSI compilers such as \.{gcc}, we must make some modifications. It is
  1801. assumed that the compilers predefine macros such as |vax|, |sun|, or |mac|,
  1802. in \It{lower case}; if they do not, then these macros must be defined from
  1803. the command line. In addition, the \WEB\ files must be tangled with
  1804. \It{upper case} macros such as |VAX|, |SUN|, or |MAC| defined from the
  1805. command line, as in \.{ftangle tangle -m"SUN"}. It is conventional to put
  1806. the machine macro command into the ini file \.{.fweb}, as in ``\.{+mSUN}''.
  1807.  
  1808. @ The following flag is used for \Cpp. (??)
  1809. @%@<Common...@>=
  1810. @a
  1811. EXTERN boolean long_comment;
  1812.  
  1813. @ Code related to the character set. \It{Mess around here only at your own
  1814. risk.} 
  1815.  
  1816. @D and_and OCTAL(4) /* `|&&|'.*/
  1817. @D star_star OCTAL(5) /* `|@@r x**y|' .*/
  1818.  
  1819. /* The next two only occur in different languages, so they can have the same
  1820. value. */  
  1821. @D neqv OCTAL(10) /* `|@@r .neqv.|'.*/
  1822. @D ellipsis neqv /* `|...|'.*/
  1823.  
  1824. @D stmt_label OCTAL(30)
  1825.  
  1826. @D slash_slash OCTAL(26)  /* Concatenation `|@@r \/|' .*/
  1827.  
  1828. @D bell OCTAL(7) /* |ASCII| code for ringing the bell.*/
  1829. @D tab_mark @'\t' /* |ASCII| code used as tab-skip.*/
  1830. @D line_feed OCTAL(12) /* |ASCII| code thrown away at end of line; $\equiv$
  1831.             \.{'\\n'}. */
  1832. @D form_feed OCTAL(14) /* |ASCII| code used at end of page.*/
  1833. @D carriage_return OCTAL(15) /* |ASCII| code used at end of line.*/
  1834.  
  1835. @D gt_gt OCTAL(20) /* `|>>|'; this doesn't exist in MIT.*/
  1836. @D lt_lt OCTAL(22) /* `|<<|'; this doesn't exist in MIT.*/
  1837.  
  1838. @D plus_plus OCTAL(13) /* `|++|'; this corresponds to MIT's up-arrow.*/
  1839. @D minus_minus OCTAL(1) /* `|--|'; this corresponds to MIT's down-arrow.*/
  1840.  
  1841. @D minus_gt OCTAL(31) /* `|->|'.*/
  1842. @D eqv minus_gt /* `|@@r .eqv.|'.*/
  1843.  
  1844. @D not_eq OCTAL(32) /* `|!=|'.*/
  1845.  
  1846. @D paste OCTAL(33) /* `|##|'.*/
  1847.  
  1848. @D lt_eq OCTAL(34) /* `|<=|'.*/
  1849. @D gt_eq OCTAL(35) /* `|>=|'.*/
  1850.  
  1851. @D eq_eq OCTAL(36) /* `|==|'.*/
  1852.  
  1853. @D or_or OCTAL(37) /* `||| |'.*/
  1854.  
  1855. @D begin_language OCTAL(16) /* Mark a language switch.*/
  1856.  
  1857. @D left_array OCTAL(21)  /* `$\LS$'.*/
  1858. @D right_array OCTAL(25) /* `$\SR$'.*/
  1859.  
  1860. @D interior_semi OCTAL(24) /* `\.;'.  In \Fortran, a semicolon that's already
  1861.     present in the input line, as opposed to one that's inserted by
  1862.     \FWEB. */
  1863.  
  1864. @
  1865. @a
  1866.  
  1867. IN_COMMON ASCII xord[]; /* specifies conversion of input characters. */
  1868. #ifdef scramble_ASCII
  1869.     IN_COMMON ASCII xxord[];
  1870. #endif
  1871. IN_COMMON outer_char xchr[]; /* specifies conversion of output characters. */
  1872.  
  1873. @ Code related to input routines:
  1874.  
  1875. @a
  1876.  
  1877. IN_COMMON BUF_SIZE buf_size; /* Used for \FWEAVE; see \.{common.web}. */
  1878. IN_COMMON ASCII HUGE *loc; /* points to the next character to be read from the
  1879.                 buffer*/ 
  1880.  
  1881. typedef struct
  1882.     {
  1883.     unsigned size; /* Length of |list|. */
  1884.     outer_char HUGE *list; /* List of include files. */
  1885.     } INCL_PATHS;
  1886.  
  1887. @ Code related to identifier and module name storage:
  1888.  
  1889. @d ID_FLAG 10240 /* \bf DON'T MONKEY WITH THIS NUMBER!. */
  1890.  
  1891. @d length(c) ((c+1)->byte_start-(c)->byte_start) /* the length of a name. */
  1892.  
  1893. @d llink link /* left link in binary search tree for module names. */
  1894. @d root CAST(name_pointer,name_dir)->rlink /* the root of the binary search
  1895.                         tree  for module names */
  1896.  
  1897. @d is_intrinsic(n) (n->intrinsic_word & (boolean)language)
  1898. @d is_keyword(n) (n->keyword & (boolean)language)
  1899.  
  1900. @a
  1901.  
  1902. IN_COMMON name_pointer name_ptr; /* first unused position in |byte_start|. */
  1903. IN_COMMON ASCII HUGE *byte_ptr; /* first unused position in |byte_mem|. */
  1904.  
  1905. typedef name_pointer HUGE *hash_pointer;
  1906. IN_COMMON hash_pointer hash, /* heads of hash lists */
  1907.     hash_end, /* end of |hash| */
  1908.     h; /* index into hash-head array */
  1909.  
  1910.  
  1911. @ To distinguish between the constructions \.{@@<\dots@@>} and
  1912. \.{\#<\dots@@>}, both of which return |module_name|, we introduce the flag
  1913. |mac_mod_name|. 
  1914.  
  1915. @a
  1916.  
  1917. EXTERN boolean mac_mod_name;
  1918.  
  1919. @ Code related to module numbers:
  1920.  
  1921. @d BTRANS mod_trans(OC("beginning in module"),module_count)
  1922. @d MTRANS mod_trans(OC("module"),module_count) /* String including section and
  1923.                         page info. */ 
  1924. @d MTRANS0 mod_trans(OC(""),module_count)
  1925. @d MOD_TRANS(mnum) mod_trans(OC("module"), mnum)
  1926.  
  1927. @a
  1928.  
  1929. IN_COMMON sixteen_bits module_count; /* The current module number. */
  1930. IN_COMMON boolean HUGE *chngd_module; /* Dynamic array: Is the module/
  1931.                     changed? */
  1932. IN_COMMON boolean prn_where; /* Tells \.{TANGLE} to print line and file
  1933.                     info. */
  1934.  
  1935. @ Code relating to output:
  1936.  
  1937. @d UPDATE_TERMINAL fflush(stdout) /* Empty the terminal output buffer. */
  1938. @d new_line putchar('\n') @d putxchar putchar
  1939. @d ASCII_write(p0,n) fflush(stdout),
  1940.         ASCII_file_write(stdout,p0,(int)(n))@;
  1941.     /* Write on the standard output, converting from |ASCII|. */ 
  1942.  
  1943. @ For FORTRAN, \&{format} commands are annoying, because the use of slashes
  1944. doesn't fit with the rest of the \Fortran\ syntax. Thus, we'll deal with the
  1945. |format| statement something like a preprocessor statement, in that we'll
  1946. raise a special flag when we're inside it, and issue special tokens to
  1947. indicate the start and the end of the statement.
  1948.  
  1949. @D begin_format_stmt OCTAL(171)
  1950. @D end_format_stmt OCTAL(172)
  1951.  
  1952.  
  1953. @d is_identifier(c) (isAlpha(c) || c==@'_' || c==@'$' ||
  1954.     (c==@'%' && !C_LIKE(language) && !Fortran88) ) 
  1955.         /* This defines the starting character of an identifier. */ 
  1956.  
  1957. @d is_kind(c) (isDigit(c) || isAlpha(c) || c==@'_' || c==@'$') 
  1958.     /* \Fortran-90 kind parameter. */
  1959.  
  1960. @<Mac...@>=
  1961. @@ For~C, getting an identifier is simple. For FORTRAN, we treat \&{format}
  1962. statements much like C's preprocessor statement. However, there's no
  1963. special character to start a \&{format} line; we have to actually check the
  1964. identifier. Furthermore, it looks nicer if constructions such as \\{f6.2}
  1965. are treated as one identifier, so when we're inside a \&{format} statement
  1966. we allow the period to be an acceptable (internal) character for an
  1967. identifier.
  1968.  
  1969. @@<Get an identifier@@>= 
  1970. {
  1971. IN_COMMON ASCII HUGE *pformat, HUGE *pdata;
  1972.  
  1973. get_identifier:
  1974.     @@<Make |id_first| and |id_loc| point to the identifier@@>@@;
  1975.  
  1976. if(FORTRAN_LIKE(language))
  1977.     {
  1978.     if(web_strcmp(pformat,pformat+6,id_first,id_loc) == EQUAL)
  1979.         { /* Raise special flag to say we're inside a |@@r format|
  1980. statement. */ 
  1981.         in_format = YES;
  1982.         return begin_format_stmt; 
  1983.         }
  1984.     else if(program==weave)
  1985.         {
  1986.         if(web_strcmp(pdata,pdata+4,id_first,id_loc) == EQUAL)
  1987.             { /* Inside a |@@r data| statement. */
  1988.             in_data = YES;
  1989.             return identifier;
  1990.             }
  1991.         else if(at_beginning && *loc==@':' &&
  1992.                 !is_in(non_labels,id_first,id_loc))
  1993.             return stmt_label;  
  1994.         }
  1995.     }
  1996.  
  1997. if(is_include_like()) sharp_include_line = YES;
  1998. return identifier;
  1999. }
  2000.  
  2001. @
  2002. @<Mac...@>=
  2003. @@ 
  2004. @@<Make |id_first|...@@>=
  2005. {
  2006. id_first = --loc;
  2007.  
  2008. /* Scan over subsequent elements of an identifier. */
  2009. for(++loc; isAlpha(*loc) || isDigit(*loc)
  2010.     || *loc==@@'_' || *loc==@@'$' || (in_format && *loc==@@'.'); loc++)
  2011.         ;
  2012.  
  2013. id_loc = loc;  /* End plus one of the identifier.*/
  2014. }
  2015.  
  2016. @<Mac...@>=
  2017. @@ Here we obtain the file name after an \.{@@@@o}~command.
  2018. @@<Scan the output file name@@>=
  2019. {
  2020. while(*loc == @' ' || *loc == tab_mark)
  2021.     {
  2022.     loc++;
  2023.     if(loc > limit) return ignore;
  2024.     }
  2025.  
  2026. id_first = loc;
  2027. while(*loc != @' ' && *loc != tab_mark) loc++; /* Absorb file name. */
  2028. id_loc = loc;
  2029. if(*id_first == @'"') id_first++;
  2030. if(*(id_loc-1) == @'"') id_loc--;
  2031. if(id_loc - id_first >= MAX_FILE_NAME_LENGTH)
  2032.     {
  2033.     err_print(T,"Output file name too long; allowed only %d characters",
  2034.         MAX_FILE_NAME_LENGTH - 1);
  2035.     id_loc = id_first + MAX_FILE_NAME_LENGTH - 1;
  2036.     }
  2037. }
  2038.  
  2039. @ These tables are initialized during |common_init|.
  2040.  
  2041. @a
  2042.  
  2043. #undef expr
  2044. #define expr 1
  2045.  
  2046. #undef unop
  2047. #define unop 2
  2048.  
  2049. #undef binop
  2050. #define binop 3
  2051.  
  2052. extern DOTS HUGE *dots; /* The dynamic table; see \.{common.web}. */
  2053.  
  2054. #ifdef _FWEB_h
  2055.  
  2056.     EXTERN DOTS dots0[]
  2057.    #if(part == 0 || part == 1)
  2058.         = {
  2059.         {(ASCII *)"@@@@@@",3,dot_const,expr,0}, /* Dummy */
  2060.         {(ASCII *)"AND",3,dot_const,binop,and_and}, /* |and_and| */
  2061.         {(ASCII *)"EQ",2,dot_const,binop,eq_eq}, /* |eq_eq| */
  2062.         {(ASCII *)"EQV",3,dot_const,binop,eqv}, /* |eqv| */
  2063.         {(ASCII *)"FALSE",5,dot_const,expr,0},
  2064.         {(ASCII *)"GE",2,dot_const,binop,gt_eq}, /* |gt_eq| */
  2065.         {(ASCII *)"GT",2,dot_const,binop,@'>'}, /* |@'>'| */
  2066.         {(ASCII *)"LE",2,dot_const,binop,lt_eq}, /* |lt_eq| */
  2067.         {(ASCII *)"LT",2,dot_const,binop,@'<'}, /* |@'<'| */
  2068.         {(ASCII *)"NE",2,dot_const,binop,not_eq}, /* |not_eq| */
  2069.         {(ASCII *)"NEQV",4,dot_const,binop,neqv}, /* |neqv| */
  2070.         {(ASCII *)"NOT",3,dot_const,unop,@'!'}, /* |@'!'| */
  2071.         {(ASCII *)"OR",2,dot_const,binop,or_or}, /* |or_or| */
  2072.         {(ASCII *)"TRUE",4,dot_const,expr,1},
  2073.         {(ASCII *)"XOR",3,dot_const,binop,neqv}, /* |neqv| */
  2074.         {(ASCII *)"",0,0,0,0}
  2075.         }
  2076.     #endif /* |part == 1| */
  2077.         ;
  2078. #endif /* |_FWEB_h| */
  2079.  
  2080. @ The preprocessor commands have a similar format.
  2081. @a
  2082.  
  2083. #ifdef _FWEB_h
  2084.  
  2085.     EXTERN DOTS mcmds[] 
  2086.    #if(part ==0 || part == 1)
  2087.      = {
  2088.         {(ASCII *)"define",6,WEB_definition},
  2089.         {(ASCII *)"elif",4,m_elif},
  2090.         {(ASCII *)"elseif",6,m_elif},
  2091.         {(ASCII *)"else",4,m_else},
  2092.         {(ASCII *)"endfor",6,m_endfor},
  2093.         {(ASCII *)"endif",5,m_endif},
  2094.         {(ASCII *)"for",3,m_for},
  2095.         {(ASCII *)"if",2,m_if},
  2096.         {(ASCII *)"ifdef",5,m_ifdef},
  2097.         {(ASCII *)"ifndef",6,m_ifndef},
  2098.         {(ASCII *)"line",4,m_line},
  2099.         {(ASCII *)"undef",5,m_undef},
  2100.         {(ASCII *)"",0,0}
  2101.         }
  2102.     #endif /* |part == 1| */
  2103.         ;
  2104. #endif /* |_FWEB_h| */
  2105.  
  2106. @<Mac...@>=
  2107. @@ The preprocessor commands are piggy-backed on the \.{@@@@\#} command. If
  2108. there's text after that command, then we hunt through the above table.
  2109. If we find a processor command, any subsequent white space is skipped.
  2110. (This was added for nuweb mode, which otherwise takes each blank one at a
  2111. time.)  Otherwise, it's a |big_line_break|.
  2112.  
  2113. @@<Process possible preprocessor command@@>=
  2114. {
  2115. boolean mcode;
  2116.  
  2117. *limit = @' '; /* Terminator for identifier search. */
  2118. id_first = loc;
  2119.  
  2120. while(isAlpha(*loc)) loc++; /* Find end of identifier. */
  2121.  
  2122. if((mcode=is_mcmd(mcmds,id_first,loc)) != 0) 
  2123.     {
  2124.     while(loc < limit && (*loc == @@' ' || *loc == tab_mark))
  2125.         loc++;
  2126.  
  2127.     return mcode;
  2128.     }
  2129.  
  2130. loc = id_first; /* Failed to recognize preprocessor command. */
  2131. }
  2132.  
  2133. @ Here are macros for use with memory allocation.
  2134.  
  2135. @d GET_MEM(why,nunits,type) 
  2136.     (type HUGE *)get_mem0((outer_char *)why,(unsigned long)(nunits),
  2137.         sizeof(type)) 
  2138.  
  2139. @d FREE_MEM(p,why,nunits,type) 
  2140.     free_mem0((void HUGE *)p,(outer_char *)why,(unsigned long)(nunits),
  2141.         sizeof(type))
  2142.  
  2143. @d ALLOC(type,ptr,abbrev,nunits,dn) 
  2144.     ptr = (type HUGE *)alloc((outer_char *)abbrev,(BUF_SIZE HUGE *)&nunits,
  2145.         sizeof(*ptr),dn)
  2146.  
  2147.  
  2148. @a
  2149.  
  2150. IN_COMMON sixteen_bits HUGE *args; /* For macro processing. */
  2151. IN_COMMON BUF_SIZE max_margs;
  2152.  
  2153. @ Miscellaneous definitions.
  2154.  
  2155.     @D MCHECK0(n,reason) mcheck0((unsigned long)(n),(outer_char *)reason)
  2156.  
  2157.     @d EVALUATE(val,p0,p1) 
  2158.       {unsigned long nbytes;
  2159.       val_ptr = val_heap = 
  2160.       GET_MEM("val_heap",nbytes=2*((p1)-(p0)),VAL); 
  2161.         evaluate(&val,p0,p1); 
  2162.       if(val_heap) FREE_MEM(val_heap,"val_heap",nbytes,VAL);
  2163.       }
  2164.  
  2165.     @d DONE_LEVEL (cur_byte >= cur_end) /* Do we need to pop? */
  2166.  
  2167. @<Mac...@>=
  2168. @@
  2169. @@<Glob...@@>=
  2170.  
  2171. /* The shorter length here is primarily to keep the stack under control.
  2172. Now that |N_MSGBUF| is used  dynamically, maybe this statement isn't
  2173. necessary. */ 
  2174. #ifdef SMALL_MEMORY
  2175.     #define N_MSGBUF 2000
  2176. #else
  2177.     #define N_MSGBUF 10000
  2178. #endif 
  2179.  
  2180.  
  2181. @ The following helps insert spaces in the output.
  2182. @<Typedef...@>=
  2183.  
  2184. typedef enum
  2185.     {
  2186.     MISCELLANEOUS, /* ``normal'' state */
  2187.     NUM_OR_ID, /* state associated with numbers and identifiers */
  2188.     UNBREAKABLE, /* state associated with \.{@@\&} */
  2189.     VERBATIM /* state in the middle of a string */
  2190.     } OUTPUT_STATE;
  2191.  
  2192. @ For debugging and error messages, we need a routine that gives the name
  2193. of a control code.
  2194.  
  2195. @A
  2196. #ifdef _FWEB_h
  2197. #if(part == 0 || part == 1)
  2198.  
  2199. @[outer_char *ccode_name FCN((code))
  2200.     eight_bits code C1("")@;
  2201. {
  2202. switch(code)
  2203.     {
  2204.    case begin_FORTRAN: return (outer_char *)"begin_FORTRAN";
  2205.    case begin_RATFOR: return (outer_char *)"begin_RATFOR";
  2206.    case begin_C: return (outer_char *)"begin_C";
  2207.    case ascii_constant: return (outer_char *)"ascii_constant";
  2208.    case big_line_break: return (outer_char *)"big_line_break";
  2209.    case begin_meta: return (outer_char *)"begin_meta";
  2210.    case end_meta: return (outer_char *)"end_meta";
  2211.    case TeX_string: return (outer_char *)"TeX_string";
  2212.    case xref_roman: return (outer_char *)"xref_roman";
  2213.    case xref_typewriter: return (outer_char *)"xref_typewriter";
  2214.    case xref_wildcard: return (outer_char *)"xref_wildcard";
  2215.    case formatt: return (outer_char *)"formatt";
  2216.    case definition: return (outer_char *)"definition";
  2217.    case WEB_definition: return (outer_char *)"WEB_definition";
  2218.    case begin_code: return (outer_char *)"begin_code";
  2219.    case module_name: return (outer_char *)"module_name";
  2220.    case new_module: return (outer_char *)"new_module";
  2221.    case m_ifdef: return (outer_char *)"m_ifdef";
  2222.    case m_ifndef: return (outer_char *)"m_ifndef";
  2223.    case m_if: return (outer_char *)"m_if";
  2224.    case m_else: return (outer_char *)"m_else";
  2225.    case m_elif: return (outer_char *)"m_elif";
  2226.    case m_endif: return (outer_char *)"m_endif";
  2227.    case m_undef: return (outer_char *)"m_undef";
  2228.    case m_line: return (outer_char *)"m_line";
  2229.  
  2230. #ifdef _FTANGLE_h
  2231.    case begin_vcmnt: return (outer_char *)"begin_vcmnt";
  2232.    case begin_bp: return (outer_char *)"begin_bp";
  2233.    case insert_bp: return (outer_char *)"insert_bp";
  2234.    case control_text: return (outer_char *)"control_text";
  2235. #endif /* |_FTANGLE_h| */
  2236.  
  2237. #ifdef _FWEAVE_h
  2238.    case dont_expand: return (outer_char *)"dont_expand";
  2239.    case auto_label: return (outer_char *)"auto_label";
  2240.    case macro_module_name: return (outer_char *)"macro_module_name";
  2241.    case switch_math_flag: return (outer_char *)"switch_math_flag";
  2242.    case underline: return (outer_char *)"underline";
  2243.    case thin_space: return (outer_char *)"thin_space";
  2244.    case math_break: return (outer_char *)"math_break";
  2245.    case line_break: return (outer_char *)"line_break";
  2246.    case no_line_break: return (outer_char *)"no_line_break";
  2247.    case pseudo_semi: return (outer_char *)"pseudo_semi";
  2248.    case macro_space: return (outer_char *)"macro_space";
  2249.    case copy_mode: return (outer_char *)"copy_mode";
  2250.    case toggle_output: return (outer_char *)"toggle_output";
  2251.    case pseudo_expr: return (outer_char *)"pseudo_expr";
  2252.    case pseudo_colon: return (outer_char *)"pseudo_colon";
  2253.    case trace: return (outer_char *)"trace";
  2254. #endif /* |_FWEAVE_h| */
  2255.    default: return OC("UNKNOWN");
  2256.     }    
  2257. }
  2258. #endif /* |part == 1| */
  2259. #endif /* |_FWEB_h| */
  2260.  
  2261. @ Wrapping it up.
  2262. @a
  2263. @<Glob...@>@;
  2264. @<Typedef...@>@;
  2265.  
  2266. @
  2267. @<Mac...@>=
  2268. @@
  2269. @@<Include...@@>=
  2270. #include "typedefs.h"
  2271.  
  2272. @* INDEX.
  2273.