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

  1. #define DEBUG 1 \
  2.  
  3. #define com , \
  4.  
  5. #define YES 1
  6. #define NO 0 \
  7.  \
  8. /* Infinite loop. */
  9. #define WHILE() for(;;) /* Use ``|for(;;)|'' instead of ``|while(1)|'' to avoid 
  10. \
  11.             warnings from Microsoft compiler. */
  12. #define MAX(a,b) ((a)>(b) ? (a) : (b))
  13. #define MIN(a,b) ((a)<(b) ? (a) : (b)) \
  14.  
  15. #define SAVE_MACRO(text) save_macro(OC("m"),(outer_char *)text)
  16. #define CHK_ARGS(name,num) chk_args(OC(name),num,n,pargs) \
  17.     /* Right \# of arguments? */ \
  18.  
  19. #define tab_mark 9 /* The |ASCII| tab. */ \
  20.  \
  21. /* Subtraction of huge pointers; needed for pc's. We first cast to |long|, \
  22. then to the final target type. */
  23. #define PTR_DIFF(type,p,q) ((type)(long)((p) - (q)))
  24. #define SUB_PTRS(p,q) PTR_DIFF(unsigned long,p,q) /* Used in the statistics \
  25.                         output. */ \
  26.  \
  27. /* Here are some macros to determine the identifier number in the name \
  28. directory. */
  29. #define ID_NUM_ptr(ptr,start,end) ID_NUM0(ptr = ,start,end) /* Set a \
  30.     pointer as well as the number. */
  31. #define ID_NUM(start,end) ID_NUM0(DUMMY,start,end) /* Just the number. */
  32. #define DUMMY /* This kludge for an empty argument shouldn't be necessary, but 
  33. \
  34.     Microsoft didn't like the construction |ID_NUM0(,start,end)|. */ \
  35.  \
  36. /* Set both a pointer and the number. */
  37. #define ID_NUM0(ptr_equals,start,end) PTR_DIFF(sixteen_bits, \
  38.     (ptr_equals id_lookup(start,end,0)),name_dir) \
  39.  \
  40. /* Terminate a string. */
  41. #define TERMINATE(p,offset) *(p+offset) = '\0' \
  42.  
  43. #define BOOLEAN(b) ((boolean)(b)) /* Explicit cast to make some compilers 
  44. happy. */ \
  45.  
  46. #define CHOICE(flag,yes,no) (((int)(flag)) ? yes : no) \
  47.  
  48. #define EAT_AUTO_SEMI {if(auto_semi && next_byte() != 59) BACK_UP}
  49. #define BACK_UP {saved_token = NO; cur_byte -= last_bytes;} \
  50.  
  51. #define NOT_BEFORE (eight_bits)127 /* Make octal constant. */
  52. #define NOT_AFTER NOT_BEFORE \
  53.  
  54. #define SAVE_BEFORE(pp,nmax,r_before) save_out(pp,nmax,r_before,NOT_AFTER)
  55. #define SAVE_AFTER(pp,nmax,r_after) save_out(pp,nmax,NOT_BEFORE,r_after) \
  56.  
  57. #define NUM_LANGUAGES 8 /* |C|, |RATFOR|, |FORTRAN|, |TEX|, |LITERAL|, \
  58.         |C_PLUS_PLUS|, |RATFOR_90|, |FORTRAN_90| */
  59. #define NUM_DISTINCT_LANGUAGES (NUM_LANGUAGES-2) \
  60.  
  61. #define GLOBAL_LANGUAGE FORTRAN
  62. #define global_language global_params.Language /* The language in force at the 
  63. \
  64.                     beginning of each module. */ \
  65.  
  66. #define is_C_(Language) (Language==C)
  67. #define is_RATFOR_(Language) (Language==RATFOR || Language==RATFOR_90)
  68. #define is_FORTRAN_(Language) (Language==FORTRAN || Language==FORTRAN_90) \
  69.  
  70. #define FORTRAN_LIKE(Language) (is_RATFOR_(Language) || is_FORTRAN_(Language))
  71. #define C_LIKE(Language) (Language==C || Language==C_PLUS_PLUS) \
  72.  
  73. #define R66 (is_RATFOR_(language) && !Ratfor77) /* Non-expandable \Ratfor; \
  74. obsolete. */
  75. #define R77 (Ratfor77 && is_RATFOR_(language) && xpn_Ratfor) /* Expandable \
  76. \Ratfor. */
  77. #define R77_or_F (R77 || is_FORTRAN_(language)) /* Expandable \Ratfor\ or \
  78. \Fortran. */ \
  79.  
  80. #define IS_WHITE(a) ((a) == 32 || (a) == tab_mark) \
  81.  
  82. #define LANGUAGE_CODE(l) OC(lang_codes[lan_num(l)]) /*  String \
  83.     abbreviation for the language name. */ \
  84.  
  85. #define SET_VAL(val,abbrev) val = find_abbrev((outer_char *)abbrev)->nunits
  86. #define MAX_VAL(abbrev) find_abbrev((outer_char *)abbrev)->max \
  87.  
  88. #define LN lan_num \
  89.  
  90. #define language params.Language
  91. #define language_index params.Language_index
  92. #define language_num params.Language_num \
  93.  
  94. #define in_format params.In_format
  95. #define in_data params.In_data
  96. #define intermingle params.Intermingle \
  97.  
  98. #define active_brackets params.Active_brackets
  99. #define all_cmnts_verbatim params.All_cmnts_verbatim
  100. #define all_includes params.All_includes
  101. #define auto_app_semi params.Auto_app_semi
  102. #define auto_semi params.Auto_semi[language_num]
  103. #define auto_line params.Auto_line
  104. #define beeps params.Beeps
  105. #define block_nums params.Block_nums[language_num]
  106. #define bslash_continued_strings params.Bslash_continued_strings
  107. #define chk_ifelse params.Chk_ifelse
  108. #define chk_stmts params.Chk_stmts
  109. #define compare_outfiles params.Compare_outfiles
  110. #define compound_assignments params.Compound_assignments
  111. #define Cpp params.CPP
  112. #define Cpp_comments params.CPP_comments[language_num]
  113. #define dbg_output params.Dbg_output
  114. #define deferred_macros params.Deferred_macros
  115. #define defn_mask params.Defn_mask
  116. #define dot_constants params.Dot_constants
  117. #define Fortran88 params.ForTran88
  118. #define Fortran_label params.Fortran_Label
  119. #define free_form_input params.Free_form_input[language_num]
  120. #define in_escape params.In_escape[language_num]
  121. #define index_hidden params.Index_hidden
  122. #define input_macros params.Input_macros
  123. #define keep_trailing_comments params.Keep_trailing_comments
  124. #define lc_keywords params.Lc_keywords
  125. #define line_info params.Line_info
  126. #define lowercase_tokens params.Lowercase_tokens
  127. #define m4 params.M4
  128. #define no_xref params.No_xref
  129. #define number_dos params.Number_dos
  130. #define nuweb_mode params.Nuweb_mode
  131. #define overload_ops params.Overload_ops
  132. #define point_comments params.Point_comments[language_num]
  133. #define prn_input_lines params.Prn_input_lines
  134. #define prn_input_addresses params.Prn_input_addresses
  135. #define prn_contents params.Prn_contents
  136. #define prn_index params.Prn_index
  137. #define prn_modules params.Prn_modules
  138. #define prn_semis params.Prn_semis
  139. #define quoted_includes params.Quoted_includes
  140. #define Ratfor77 params.RatFor77
  141. #define read_iformats params.Read_iformats
  142. #define reverse_indices params.Reverse_indices[language_num]
  143. #define rmv_files params.Rmv_files
  144. #define skip_ifiles params.Skip_ifiles
  145. #define skip_includes params.Skip_includes
  146. #define statistics params.Statistics
  147. #define subscript_fcns params.Subscript_fcns
  148. #define suppress_cmds params.Suppress_cmds
  149. #define TeX_processor params.TeX_Processor
  150. #define toggle_includes params.Toggle_includes
  151. #define top_version params.Top_version
  152. #define translate_ASCII params.Translate_ASCII
  153. #define translate_brackets params.Translate_brackets
  154. #define truncate_ids params.Truncate_ids
  155. #define try_extensions params.Try_extensions
  156. #define xref_unnamed params.Xref_unnamed \
  157.  
  158. #define preprocessing parse_params.Preprocessing
  159. #define at_beginning parse_params.At_beginning
  160. #define sharp_include_line parse_params.Sharp_include_line
  161. #define sharp_pragma_line parse_params.Sharp_pragma_line \
  162.  
  163. #define isAupper(c) (c<=90 && c>=65)
  164. #define isAlower(c) (c<=122 && c>=97) \
  165.  
  166. #define SET_CASE(c) upper_case_code = BOOLEAN(isAupper(c)) \
  167.      /* Watch out for side effects. */
  168. #define lower_case_code BOOLEAN(!upper_case_code) \
  169.  
  170. #define A_TO_LOWER(c) (ASCII)(isAupper(c) ? (int)c+040 : c)
  171. #define A_TO_UPPER(c) (ASCII)(isAlower(c) ? (int)c-040 : c) \
  172.  \
  173. /* Handle the difference between |ASCII| and |outer_char|. */
  174. #define isAlpha(c) isalpha(XCHR(c))
  175. #define isDigit(c) isdigit(XCHR(c)) /* We're working on |ASCII| input. */
  176. #define isBdigit(c) ((c)==48 || (c)==49) /* Is it a binary numeral? */
  177. #define isOdigit(c) (isDigit(c) && c!=56 && c!=57) /* Octal numeral? */
  178. #define isXdigit(c) isxdigit(XCHR(c)) /* Hex numeral? */ \
  179.  
  180. #define mark_harmless \
  181.     {SET_COLOR(ordinary); \
  182.     if (history==spotless) history=harmless_message;} \
  183.  
  184. #define mark_error \
  185.     {SET_COLOR(ordinary); \
  186.     history=error_message; \
  187.     } \
  188.  \
  189.  
  190. #define OUTPUT_LINE outp_line[lan_num(language)]
  191. #define OUTPUT_FILE_NAME outp_nm[lan_num(out_language)]
  192. #define OUT_LANGUAGE(language) \
  193.     (R77_or_F ? (Fortran88 ? FORTRAN_90 : FORTRAN) : language)
  194. #define OUT_FILE_NAME outp_nm[lan_num(OUT_LANGUAGE(language))] \
  195.  
  196. #define PUTC(c) \
  197.     { \
  198.     CHECK_OPEN; \
  199.     if(putc((int)(c),out_file) == EOF) \
  200.         out_error(OC("putc")); \
  201.     } \
  202.  
  203. #define MAX_FILE_NAME_LENGTH 200 \
  204.  
  205. #define WEB_FILE 0
  206. #define web_file_name prms[WEB_FILE].web.File_name /* Main source file name. */
  207. #define web_file prms[WEB_FILE].web.File /* Main source file. */ \
  208.  
  209. #define CUR_FILE incl_depth
  210. #define cur_file_name prms[CUR_FILE].web.File_name /* Current input file name. 
  211. */
  212. #define cur_file prms[CUR_FILE].web.File /* Current input file. */ \
  213.  
  214. #define cur_line cur0_prms->Line /* Number of current line in current file. */ 
  215. \
  216.  
  217. #define change_file_name prms[CUR_FILE].change.File_name
  218. #define change_file prms[CUR_FILE].change.File
  219. #define change_line prms[CUR_FILE].change.Line \
  220.  \
  221. /* --- Stuff used mostly within |input_ln| --- */
  222. #define num_in_buffer cur0_prms->Num_in_buffer
  223. #define comment_in_buffer cur0_prms->Comment_in_buffer
  224. #define scanning_C_cmnt cur0_prms->Scanning_C_cmnt
  225. #define start_C cur0_prms->Start_C
  226. #define last_was_empty cur0_prms->Last_was_empty
  227. #define continuing_line cur0_prms->Continuing_line
  228. #define last_was_continued cur0_prms->Last_was_continued \
  229.  \
  230. /* The following are used as arguments to |input_ln|. */
  231. #define INPUT_FILE &prms[CUR_FILE].web
  232. #define CHANGE_FILE &prms[CUR_FILE].change \
  233.  \
  234. /* --- Buffers --- */
  235. #define cur_buffer cur0_prms->Buffer
  236. #define buffer_end cur0_prms->Buffer_end
  237. #define limit cur0_prms->Limit /* points to the last character in the buffer. 
  238. */ \
  239.  
  240. #define change_buffer (cur_prms.change)->Buffer
  241. #define change_buffer_end (cur_prms.change)->Buffer_end
  242. #define change_limit (cur_prms.change)->Limit \
  243.  
  244. #define MAX_DOT_LENGTH 31 /* Don't have to scan farther than this to see if 
  245. it's \
  246.             a dot constant. The~31 is a \FORTRAN-90 limit. */ \
  247.  
  248. #define dot_const (eight_bits)19 /* Make octal constant. */ \
  249.  
  250. #define ACTIVE_BRACKETS NO
  251. #define ALL_CMNTS_VERBATIM NO
  252. #define ALL_INCLUDES NO
  253. #define AUTO_APP_SEMI NO
  254. #define AUTO_LINE YES
  255. #define BEEPS YES
  256. #define BLOCK_NUMS NO
  257. #define BSLASH_CONTINUED_STRINGS NO
  258. #define CHK_IFELSE NO
  259. #define CHK_STMTS NO
  260. #define COMPARE_OUTFILES NO
  261. #define COMPOUND_ASSIGNMENTS YES
  262. #define CPP_COMMENTS YES
  263. #define DBG_OUTPUT NO
  264. #define DEFERRED_MACROS NO
  265. #define DOT_CONSTANTS YES
  266. #define FORTRAN88 NO    /* By default, it's \FORTRAN-77. */
  267. #define FORTRAN_LABEL YES
  268. #define FREE_FORM_INPUT YES
  269. #define FREE_FORTRAN NO
  270. #define IN_ESCAPE '\\'
  271. #define INDEX_HIDDEN NO
  272. #define INPUT_MACROS YES
  273. #define KEEP_TRAILING_COMMENTS YES
  274. #define LC_KEYWORDS NO
  275. #define LINE_INFO YES
  276. #define LOWERCASE_TOKENS NO
  277. #define M4_ NO
  278. #define NO_XREF NO
  279. #define NUMBER_DOS NO
  280. #define NUWEB_MODE NO
  281. #define OVERLOAD_OPS YES
  282. #define POINT_COMMENTS NO
  283. #define PRN_CONTENTS YES
  284. #define PRN_OUTER_MACROS YES
  285. #define PRN_fORMATS YES
  286. #define PRN_FORMATS YES
  287. #define PRN_LIMBO YES
  288. #define PRN_INDEX YES
  289. #define PRN_MACROS YES
  290. #define PRN_MODULES YES
  291. #define PRN_SEMIS NO
  292. #define PRN_V YES
  293. #define PRN_W YES
  294. #define QUOTED_INCLUDES NO
  295. #define RATFOR77 YES
  296. #define READ_IFORMATS NO
  297. #define REVERSE_INDICES NO
  298. #define RMV_FILES YES
  299. #define SKIP_IFILES NO
  300. #define SKIP_INCLUDES NO
  301. #define STATISTICS NO
  302. #define SUBSCRIPT_FCNS YES
  303. #define TOGGLE_INCLUDES NO
  304. #define TOP_VERSION YES
  305. #define TRANSLATE_ASCII0 NO
  306. #define TRANSLATE_BRACKETS YES
  307. #define TRY_EXTENSIONS NO
  308. #define TEX_PROCESSOR LaTeX_p
  309. #define XREF_UNNAMED YES \
  310.  
  311. #define CCHAR '&' /* Default \FORTRAN\ continuation character. */ \
  312.  
  313. #define NUM_RATFOR_CMDS 20 /* The total number of reserved \RATFOR\ keywords. \
  314.     This is used for an array size later on. */ \
  315.  
  316. #define mod_info info.mod
  317. #define mod_ilk mod_info->Ilk
  318. #define macro_type info.Macro_type \
  319.  
  320. #define defined_in(languag) dummy.defined_info[lan_num(languag)].section
  321. #define defined_type(languag) dummy.defined_info[lan_num(languag)].type
  322. #define ilk Ilk[language_num]
  323. #define expandable dummy.RX.Expandable
  324. #define rlink dummy.RX.Rlink
  325. #define x_translate dummy.RX.Expand \
  326.  
  327. #define USED_BY_NEITHER ((eight_bits)0xFF)
  328. #define USED_BY_OTHER ignore \
  329.  
  330. #define ESC 0x1b
  331. #define MD "[1m" /* High intensity */
  332. #define US "[4m" /* Underline */
  333. #define MR "[7m" /* Reverse video */
  334. #define MO "[m"  /* Revert to normal */ \
  335.  
  336. #define SET_COLOR(field) set_color(wt_style.color.field.value)
  337. #define CLR_PRINTF(field,args) SET_COLOR(field); printf args; fflush(stdout); \
  338.         set_color(color0.last) \
  339.  
  340. #define cur_fcn begun[rlevel-1].name
  341. #define NO_FCN (sixteen_bits)0 \
  342.     /* Value of |cur_fcn| when function name is unknown. */ \
  343.  
  344. #define cur_struct begun[rlevel-1].name
  345. #define is_function begun[rlevel-1].function
  346. #define symbolic_label begun[rlevel-1].symbolic \
  347.  
  348. #define mark_defined w_style.misc.mark \
  349.  
  350. #define OC(s) ((outer_char HUGE *)(s)) \
  351.  
  352. #define STAT0(name,size,num,max_num,abs_max_num,abbrev,ctrl_chars) \
  353.     stat0(OC(name),size,num,max_num,abs_max_num, \
  354.         OC(abbrev),OC(ctrl_chars)) \
  355.  
  356. #define OVERFLW(msg,abbrev) overflow(OC(msg),OC(abbrev))
  357. #define NEW_SPRM(name, value) new_sprm(OC(name), value) \
  358.  
  359. #define FATAL(origin, msg1, msg2) fatal(ERR_##origin, OC(msg1), OC(msg2)) \
  360.  
  361. #define CONFUSION(msg1,msg2) confusion(OC(msg1),OC(msg2)) \
  362.  
  363. #define RAT_OK(msg) Rat_OK(OC(msg)) \
  364.  
  365. #define APP_STR(s) app_str(OC(s)) \
  366.  
  367. #define and_and (eight_bits)4 /* Make octal constant. */ /* `|&&|'.*/
  368. #define star_star (eight_bits)5 /* Make octal constant. */ /* `|@r x**y|' .*/ \
  369.  \
  370. /* The next two only occur in different languages, so they can have the same \
  371. value. */
  372. #define neqv (eight_bits)8 /* Make octal constant. */ /* `|@r .neqv.|'.*/
  373. #define ellipsis neqv /* `|...|'.*/ \
  374.  
  375. #define stmt_label (eight_bits)24 /* Make octal constant. */ \
  376.  
  377. #define slash_slash (eight_bits)22 /* Make octal constant. */  /* Concatenation 
  378. `|@r \/|' .*/ \
  379.  
  380. #define bell (eight_bits)7 /* Make octal constant. */ /* |ASCII| code for 
  381. ringing the bell.*/
  382. #define tab_mark 9 /* |ASCII| code used as tab-skip.*/
  383. #define line_feed (eight_bits)10 /* Make octal constant. */ /* |ASCII| code 
  384. thrown away at end of line; $\equiv$ \
  385.             \.{'\\n'}. */
  386. #define form_feed (eight_bits)12 /* Make octal constant. */ /* |ASCII| code 
  387. used at end of page.*/
  388. #define carriage_return (eight_bits)13 /* Make octal constant. */ /* |ASCII| 
  389. code used at end of line.*/ \
  390.  
  391. #define gt_gt (eight_bits)16 /* Make octal constant. */ /* `|>>|'; this doesn't 
  392. exist in MIT.*/
  393. #define lt_lt (eight_bits)18 /* Make octal constant. */ /* `|<<|'; this doesn't 
  394. exist in MIT.*/ \
  395.  
  396. #define plus_plus (eight_bits)11 /* Make octal constant. */ /* `|++|'; this 
  397. corresponds to MIT's up-arrow.*/
  398. #define minus_minus (eight_bits)1 /* Make octal constant. */ /* `|--|'; this 
  399. corresponds to MIT's down-arrow.*/ \
  400.  
  401. #define minus_gt (eight_bits)25 /* Make octal constant. */ /* `|->|'.*/
  402. #define eqv minus_gt /* `|@r .eqv.|'.*/ \
  403.  
  404. #define not_eq (eight_bits)26 /* Make octal constant. */ /* `|!=|'.*/ \
  405.  
  406. #define paste (eight_bits)27 /* Make octal constant. */ /* `|##|'.*/ \
  407.  
  408. #define lt_eq (eight_bits)28 /* Make octal constant. */ /* `|<=|'.*/
  409. #define gt_eq (eight_bits)29 /* Make octal constant. */ /* `|>=|'.*/ \
  410.  
  411. #define eq_eq (eight_bits)30 /* Make octal constant. */ /* `|==|'.*/ \
  412.  
  413. #define or_or (eight_bits)31 /* Make octal constant. */ /* `||| |'.*/ \
  414.  
  415. #define begin_language (eight_bits)14 /* Make octal constant. */ /* Mark a 
  416. language switch.*/ \
  417.  
  418. #define left_array (eight_bits)17 /* Make octal constant. */  /* `$\LS$'.*/
  419. #define right_array (eight_bits)21 /* Make octal constant. */ /* `$\SR$'.*/ \
  420.  
  421. #define interior_semi (eight_bits)20 /* Make octal constant. */ /* `\.;'.  In 
  422. \Fortran, a semicolon that's already \
  423.     present in the input line, as opposed to one that's inserted by \
  424.     \FWEB. */ \
  425.  
  426. #define ID_FLAG 10240 /* \bf DON'T MONKEY WITH THIS NUMBER!. */ \
  427.  
  428. #define length(c) ((c+1)->byte_start-(c)->byte_start) /* the length of a name. 
  429. */ \
  430.  
  431. #define llink link /* left link in binary search tree for module names. */
  432. #define root CAST(name_pointer,name_dir)->rlink /* the root of the binary 
  433. search \
  434.                         tree  for module names */ \
  435.  
  436. #define is_intrinsic(n) (n->intrinsic_word & (boolean)language)
  437. #define is_keyword(n) (n->keyword & (boolean)language) \
  438.  
  439. #define BTRANS mod_trans(OC("beginning in module"),module_count)
  440. #define MTRANS mod_trans(OC("module"),module_count) /* String including section 
  441. and \
  442.                         page info. */
  443. #define MTRANS0 mod_trans(OC(""),module_count)
  444. #define MOD_TRANS(mnum) mod_trans(OC("module"), mnum) \
  445.  
  446. #define UPDATE_TERMINAL fflush(stdout) /* Empty the terminal output buffer. */
  447. #define new_line putchar('\n') 
  448. #define putxchar putchar
  449. #define ASCII_write(p0,n) fflush(stdout), \
  450.         ASCII_file_write(stdout,p0,(int)(n)) \
  451.     /* Write on the standard output, converting from |ASCII|. */ \
  452.  
  453. #define begin_format_stmt (eight_bits)121 /* Make octal constant. */
  454. #define end_format_stmt (eight_bits)122 /* Make octal constant. */ \
  455.  
  456. #define is_identifier(c) (isAlpha(c) || c==95 || c==36 || \
  457.     (c==37 && !C_LIKE(language) && !Fortran88) ) \
  458.         /* This defines the starting character of an identifier. */ \
  459.  
  460. #define is_kind(c) (isDigit(c) || isAlpha(c) || c==95 || c==36) \
  461.     /* \Fortran-90 kind parameter. */ \
  462.  
  463. #define GET_MEM(why,nunits,type) \
  464.     (type HUGE *)get_mem0((outer_char *)why,(unsigned long)(nunits), \
  465.         sizeof(type)) \
  466.  
  467. #define FREE_MEM(p,why,nunits,type) \
  468.     free_mem0((void HUGE *)p,(outer_char *)why,(unsigned long)(nunits), \
  469.         sizeof(type)) \
  470.  
  471. #define ALLOC(type,ptr,abbrev,nunits,dn) \
  472.     ptr = (type HUGE *)alloc((outer_char *)abbrev,(BUF_SIZE HUGE *)&nunits, \
  473.         sizeof(*ptr),dn) \
  474.  \
  475.  
  476. #define MCHECK0(n,reason) mcheck0((unsigned long)(n),(outer_char *)reason) \
  477.  \
  478.     
  479. #define EVALUATE(val,p0,p1) \
  480.       {unsigned long nbytes; \
  481.       val_ptr = val_heap = \
  482.       GET_MEM("val_heap",nbytes=2*((p1)-(p0)),VAL); \
  483.         evaluate(&val,p0,p1); \
  484.       if(val_heap) FREE_MEM(val_heap,"val_heap",nbytes,VAL); \
  485.       } \
  486.  \
  487.     
  488. #define DONE_LEVEL (cur_byte >= cur_end) /* Do we need to pop? */ \
  489.  
  490.  
  491.  
  492. /* Created automatically from typedefs.web. */
  493. #include "os.h"
  494.  
  495.  
  496.  
  497. #ifdef _FWEB_h
  498.     #define EXTERN part1_or_extern /* This is further redefined below,
  499.                 depending on the setting of |part|. */
  500.     #define SET SET1
  501. #else
  502.     #define EXTERN extern
  503.     #define SET(stuff)
  504. #endif
  505.  
  506.  
  507.  
  508. #ifdef _FTANGLE_h
  509.     #define IN_TANGLE part1_or_extern
  510.     #define TSET TSET1
  511. #else
  512.     #define IN_TANGLE extern
  513.     #define TSET(stuff)
  514. #endif /* |_TANGLE_h| */
  515.  
  516. #ifdef _COMMON_h
  517.     #define IN_COMMON part1_or_extern
  518.     #define CSET SET1
  519. #else
  520.     #define IN_COMMON extern
  521.     #define CSET(stuff)
  522. #endif /* |_COMMON_h| */
  523.  
  524. #ifdef _PROD_h
  525.     #define IN_PROD part1_or_extern
  526.     #define PSET SET1
  527. #else
  528.     #define IN_PROD extern
  529.     #define PSET(stuff)
  530. #endif /* |_PROD_h| */
  531.  
  532. #ifdef _RATFOR_h
  533.     #define IN_RATFOR part1_or_extern
  534.     #define RSET SET1
  535. #else
  536.     #define IN_RATFOR extern
  537.     #define RSET(stuff)
  538. #endif /* |_RATFOR_h| */
  539.  
  540. #ifdef _EVAL_h
  541.     #define IN_EVAL
  542.     #define ESET(stuff) = stuff
  543. #else
  544.     #define IN_EVAL extern
  545.     #define ESET(stuff)
  546. #endif /* |_EVAL_h| */
  547.  
  548. #ifdef _MACS_h
  549.     #define IN_MACS
  550. #else
  551.     #define IN_MACS extern
  552. #endif /* |_MACS_h| */
  553.  
  554. #ifdef _STYLE_h
  555.     #define IN_STYLE
  556.     #define SSET(stuff) = stuff
  557. #else
  558.     #define IN_STYLE extern
  559.     #define SSET(stuff)
  560. #endif /* |_STYLE_h| */
  561.  
  562.  
  563.  
  564. typedef unsigned char eight_bits; /* The fundamental single-byte token. If
  565.     your machine does not support |unsigned char| you should change
  566.     the definition of |eight_bits| to |unsigned short|. */
  567.  
  568.  
  569. typedef unsigned short sixteen_bits; /* Identifiers and similar things take
  570.                     up two bytes. */
  571.  
  572. typedef unsigned char outer_char; /* Type of characters outside \.{WEB}. */
  573.  
  574. typedef eight_bits boolean; /* The logical type. (\CWEB\ had |short| here.
  575.     Indeed, some compilers give warnings about type conversions because the
  576.     result of logical operations is an |int|, not a |char|.) */
  577.  
  578. typedef unsigned long BUF_SIZE; /* Size of dynamic arrays. */
  579.  
  580. typedef long STMT_LBL; /* \Fortran\ statement label.  (Negative is allowed.) */
  581.  
  582. typedef unsigned short LINE_NUMBER; /* Line number of \WEB\ source or output.*/
  583.  
  584. typedef long CASE_TYPE; /* The type for |case| values in \Ratfor.  */
  585.  
  586. /* For |web_strcmp|. {\bfit Web's convention differs from C's}!
  587.     If you don't pay attention to this, you'll get bugs that are
  588.     hard to track down. */
  589. typedef enum {LESS=0, /* first name is lexicographically less than the second*/
  590.     EQUAL=1, /* the first name is equal to the second */
  591.     GREATER=2, /* first name is lexicographically greater than the
  592. second */
  593.     PREFIX=3, /* the first name is a proper prefix of the second */
  594.     EXTENSION=4} LEXI; /* first name is a proper extension of the
  595. second. */
  596.  
  597.  
  598. typedef enum {tangle=0,weave=1} PROGRAM; /* The two processors. */
  599.  
  600. IN_COMMON PROGRAM program;
  601.  
  602.  
  603.  
  604. IN_COMMON outer_char version[] CSET(VERSION); /* \FWEB\ version number. */
  605. IN_COMMON outer_char release_date[] CSET(RELEASE);
  606.     /* Release date for this version. */
  607. IN_COMMON outer_char *the_system, *local_banner; /* Name of the
  608.     machine/operating system; and a possible additional local banner. */
  609.  
  610.  
  611.  
  612. IN_COMMON short phase CSET(0); /* Which phase are we in? */
  613.  
  614.  
  615. typedef enum {OK,WARNING,ERROR} ERR_TYPE;
  616.  
  617.  
  618.  
  619.  /* The highest bit sets the basic language. */
  620. typedef enum
  621.     {
  622.     NO_LANGUAGE =     0,
  623.  
  624.     C =         0x1,
  625.     RATFOR =    0x2,
  626.     FORTRAN =     0x4,
  627.     TEX =         0x8,
  628.     LITERAL =    0x10,
  629.  
  630.     C_PLUS_PLUS =    0x20,
  631.     RATFOR_90 =    0x40,
  632.     FORTRAN_90 =    0x80,
  633.  
  634.     NUWEB_OFF =    0xF0, /* Not a language, but used in |send_single|. */
  635.     NUWEB_ON =    0xF1
  636.     } LANGUAGE;
  637.  
  638. IN_COMMON LANGUAGE cmd_language CSET(NO_LANGUAGE);/* To check against
  639. override. */
  640. IN_COMMON boolean column_mode CSET(NO);
  641.  
  642. IN_COMMON CONST char HUGE *languages[NUM_LANGUAGES]
  643. #ifdef _COMMON_h
  644. #if(part == 0 || part == 1)
  645.     = {"C","RATFOR","FORTRAN","TEX","VERBATIM",
  646.       "C++","RATFOR--90","FORTRAN--90"}
  647. #endif /* |part == 1| */
  648. #endif /* |defined _COMMON_h| */
  649. ;
  650.  
  651. IN_COMMON CONST char HUGE *lang_codes[NUM_LANGUAGES]
  652. #ifdef _COMMON_h
  653. #if(part == 0 || part == 1)
  654.     = {"C","R","N","X","V","C++","R90","N90",}
  655. #endif
  656. #endif
  657. ;
  658.  
  659.  
  660.  
  661. IN_COMMON outer_char begin_comment_char[NUM_LANGUAGES]
  662. #ifdef _COMMON_h
  663. #if(part == 0 || part == 1)
  664.      = {'/','#','C','%','/', '/','#','C'}
  665. #endif
  666. #endif
  667. ; /* |C|, |RATFOR|, |FORTRAN|, |TEX|, |LITERAL|, \dots. */
  668.  
  669. IN_COMMON CONST outer_char end_comment_char[NUM_LANGUAGES]
  670. #ifdef _COMMON_h
  671. #if(part == 0 || part == 1)
  672.     = {'/',' ',' ',' ','/', '/',' ',' '}
  673. #endif
  674. #endif
  675. ;
  676.  
  677.  
  678.  
  679. typedef struct
  680.     {
  681.     outer_char abbrev[3]; /* Two-character abbreviation for the
  682. variable. */
  683.     short bytes;    /* Number of bytes in one unit. */
  684.     BUF_SIZE min,    /* Minimum possible value. */
  685.         nunits, /* How many units to allocate, or the default
  686. value. */
  687.         max;     /* Maximum possible value. */
  688.     } MEM;
  689.  
  690.  
  691.  
  692. typedef struct
  693.     {
  694.     unsigned
  695.         formats:1, Formats:1, /* Print \.{@f}, \.{@F}. */
  696.         limbo:1, /* Print \.{@l}. */
  697.         macros:1, /* Print \.{@m}. */
  698.         outer_macros:1, /* Print \.{@d}. */
  699.         v:1, /* Print \.{@v}. */
  700.         w:1 /* Print \.{@w}. */
  701.         ;
  702.     } DEFN_MASK;
  703.  
  704.  
  705.  
  706. typedef enum {TeX_p,LaTeX_p} TeX_PROCESSOR; /* What to use with \FWEAVE. */
  707.  
  708. typedef struct
  709.     {
  710.     LANGUAGE Language; /* The current language. May be set by encountering
  711. a module name, or by explicit \.{@n}, \.{@r}, or \.{@c} commands. */
  712.     short Language_num,Language_index; /* These are set by
  713. |ini_language|. */
  714.  
  715. boolean
  716. /* Flags for really current state. */
  717.     In_format, /* Inside a |@r format| statement. */
  718.     In_data, /* Inside a |@r data| statement. */
  719.     Intermingle, /* Inside something like a |@r data|
  720. statement. */
  721.     Include_line, /* Inside an \&{include} line. */
  722.  
  723. /* Options flags.  Some of these apply to all languages, others differ from
  724. language to language and are thus arrays. */
  725.     Active_brackets, /* Special array handling? */
  726.     All_cmnts_verbatim, /* Should \.{TANGLE} copy all comments? . */
  727.     All_includes, /* Cross-reference all include files? */
  728.     Auto_app_semi, /* For \.{WEAVE}, automatically
  729. append a pseudo-semi to the end of \.{WEB} macro definitions? */
  730.     Auto_semi[NUM_LANGUAGES], /* Fill in semicolon at end of source line? */
  731.     Auto_line, /* Auto-insert line number after \.{@\%}? */
  732.     Beeps, /* Do we beep the terminal for certain errors? */
  733.     Block_nums[NUM_LANGUAGES], /* */
  734.     Bslash_continued_strings, /* Do the continuations of
  735. strings require a starting backslash? */
  736.     Chk_ifelse, /* Protect parenthesized strings? */
  737.     Chk_stmts, /* Check statement syntax in \Ratfor? */
  738.     Compare_outfiles, /* Check new (temporary) vs.\ old output? */
  739.     Compound_assignments, /* Do we allow things like \.{+=}? */
  740.     CPP, /* Do we recognize \.{C++}? */
  741.     CPP_comments[NUM_LANGUAGES], /* Allow short comments? */
  742.     Dbg_output, /* Print each character fired at output? */
  743.     Deferred_macros, /* Allow deferred macros? */
  744.     Dot_constants, /* Recognize dot constants like `\.{.eq.}'? */
  745.     ForTran88, /* Turn on stuff for Fortran-88? */
  746.     Fortran_Label, /* Label on same line? */
  747.     Free_form_input[NUM_LANGUAGES], /* Free-form syntax. */
  748.     In_escape[NUM_LANGUAGES], /* (|outer_char|) continuation character
  749. for end-of-lines. */
  750.     Index_hidden, /* Index skipped include files. */
  751.     Input_macros, /* Generate the default ``\.{\\input fwebmac}'' line? */
  752.     Keep_trailing_comments, /* For \TeX, retain comments that don't
  753. start a line. */
  754.     Lc_keywords, /* Lower-case \Fortran\ and \Ratfor\ I/O keywords? */
  755.     Line_info, /* Should \FTANGLE\ print out line information? */
  756.     Lowercase_tokens, /* Output lower-case tokens (\Ratfor). */
  757.     M4, /* Recognize \.{M4} preprocessor commands? */
  758.     No_xref, /* Should \.{WEAVE} print an index? */
  759.     Number_dos, /* */
  760.     Nuweb_mode, /* Emulate \.{nuweb}? */
  761.     Overload_ops, /* Is operator overloading allowed? */
  762.     Point_comments[NUM_LANGUAGES], /* Does \.! signify a \Fortran\ or
  763. \Ratfor\ comment? */
  764.     Prn_contents, /* Print table of contents? */
  765.     Prn_index, /* Print index? */
  766.     Prn_input_lines, /* Used in |input_ln| to print out the lines sent
  767. back. */
  768.     Prn_input_addresses, /* Print out the buffer addresses. */
  769.     Prn_modules, /* Print module list? */
  770.     Prn_semis, /* Print semicolons in \Fortran\ output. */
  771.     Quoted_includes, /* Cross-reference quoted include files? */
  772.     RatFor77, /* Expand \Ratfor\ code directly to \Fortran-77? */
  773.     Read_iformats, /* Read include files for formats. */
  774.     Reverse_indices[NUM_LANGUAGES], /* C-style indexing in \Fortran? */
  775.     Rmv_files, /* Remove temporary files related to \.{-H}? */
  776.     Skip_ifiles, /* \.{-j} --- skip files already included. */
  777.     Skip_includes, /* For \.{WEAVE}, don't read in \.{@I} commands.
  778. (Uppercase '\.{I}' only.) */
  779.     Statistics, /* Print statistics about memory usage? */
  780.     Subscript_fcns, /* Put module references on functions? */
  781.     Suppress_cmds, /* ??? */
  782.     Toggle_includes, /* For \.{WEAVE}, read in \.{@I} commands, but
  783. don't print them out. */
  784.     Top_version, /* Header info at top of output? */
  785.     Translate_ASCII, /* Do we bother with the |xchr|--|xord|
  786. conversions? */
  787.     Translate_brackets, /* Brackets to parentheses in \Fortran? */
  788.     Truncate_ids, /* Shorten identifiers? */
  789.     Try_extensions, /* Search through list of possible file names? */
  790.     Xref_unnamed; /* Cross-reference unnamed references? */
  791.  
  792. DEFN_MASK Defn_mask; /* What defn's to print by \FWEAVE. */
  793. TeX_PROCESSOR TeX_Processor; /* Processor to be used with \FWEAVE. */
  794.  
  795. outer_char HUGE*outp_nm[NUM_LANGUAGES]; /* Current output file names. */
  796. FILE *outp_file[NUM_LANGUAGES]; /* File ptrs associated with above. */
  797.     } PARAMS;
  798.  
  799. IN_COMMON PARAMS params,global_params;
  800. IN_COMMON boolean stop_the_scan;
  801.  
  802.  
  803.  
  804. typedef enum {OUTER,INNER} PARSING_MODE;
  805.  
  806. IN_COMMON PARSING_MODE parsing_mode CSET(OUTER);
  807.  
  808.  
  809.  
  810. typedef struct
  811.     {
  812.     boolean Preprocessing; /* Are we scanning a preprocessor command? */
  813.     boolean At_beginning;  /* Are we at logical beginning of line? */
  814.     boolean Sharp_include_line; /* Does line start with ``|#include|''? */
  815.     boolean Sharp_pragma_line; /* Starts with ``|#pragma|''? */
  816.     } PARSE_PARAMS;
  817.  
  818. IN_COMMON PARSE_PARAMS parse_params
  819. #ifdef _COMMON_h
  820. #if(part == 0 || part == 1)
  821.     = {NO,YES}
  822. #endif
  823. #endif
  824. ;
  825.  
  826.  
  827.  
  828. EXTERN boolean upper_case_code SET(NO);
  829.  
  830. /* For debugging of target machines with a different character set than
  831. that of the present machine, use the |DEBUG_XCHR| flag to force the
  832. internal representation to be ``scrambled |ASCII|'', which replaces the
  833. array~|xchr| with |wt_style.xchr|. */
  834. #if(DEBUG_XCHR)
  835.     #define XCHR_ wt_style.xchr /* Scrambled mapping. */
  836. #else
  837.     #define XCHR_ xchr /* The mapping for this machine. */
  838. #endif /* |DEBUG_XCHR| */
  839.  
  840. #if(TRANSLATE_ASCII)
  841.     #define XORD(outer) xord[outer]
  842.     #define XCHR(inner) XCHR_[inner]
  843. #else /* Don't bother with the translations. */
  844.     #define XORD(outr) (outr) /* Funny spelling from Dethier's changes. */
  845.     #define XCHR(innr) (innr)
  846. #endif /* |TRANSLATE_ASCII| */
  847.  
  848. typedef unsigned char ASCII; /* Type of characters inside \.{WEB}. */
  849.  
  850.  
  851.  
  852. typedef struct
  853.     {
  854.     CONST char HUGE *reserved_word;
  855.     eight_bits type;
  856.     } RESERVED_WORD;
  857.  
  858.  
  859.  
  860. typedef enum
  861.     {
  862.     spotless, /*  Normal jobs */
  863.     harmless_message, /*  Non-serious info was printed */
  864.     error_message, /*  An error was noted */
  865.     fatal_message /*  We had to stop prematurely */
  866.     } HISTORY;
  867.  
  868. IN_COMMON HISTORY history CSET(spotless); /* indicates how bad this run was */
  869.  
  870.  
  871.  
  872. typedef enum {ERR_NULL,ERR_C,ERR_T,ERR_W,ERR_R,ERR_M,ERR_S} ERR_ORIGIN;
  873. IN_COMMON boolean err_happened CSET(NO);
  874.  
  875.  
  876.  
  877.  
  878. IN_COMMON LANGUAGE out_language; /* Current language for output file. */
  879. IN_COMMON FILE *out_file; /* Current output file pointer. */
  880. IN_COMMON int incl_depth; /* Current level of file nesting. */
  881.  
  882. typedef struct
  883.     {
  884.     FILE *File;    /* Pointer to file. */
  885.     LINE_NUMBER Line;     /* Line number. */
  886.     ASCII HUGE *Buffer; /* Input buffer. */
  887.     ASCII HUGE *Buffer_end;
  888.     ASCII HUGE *K0;
  889.     ASCII HUGE *Limit; /* Next unfilled position. */
  890.     int Num_in_buffer; /* Number remaining to be read. */
  891.     boolean Comment_in_buffer;
  892.     boolean Found_at,At_line;
  893.     boolean Scanning_C_cmnt,Start_C,Last_was_empty;
  894.     boolean Continuing_line,Last_was_continued;
  895.     outer_char File_name[MAX_FILE_NAME_LENGTH];
  896.     } INPUT_PRMS0;
  897.  
  898. IN_COMMON INPUT_PRMS0 HUGE *cur0_prms; /* Pointer to current parameters. */
  899.  
  900. typedef struct
  901.     {
  902.     INPUT_PRMS0 HUGE *web,HUGE *change;
  903.     } CUR_PRMS;
  904.  
  905. IN_COMMON CUR_PRMS cur_prms; /* Address of current input parameters. */
  906.  
  907. typedef struct
  908.  
  909.     {
  910.     LANGUAGE Language;
  911.     PARSING_MODE Parsing_mode;
  912.     boolean Column_mode;
  913.     } INPUT_PARAMS;
  914.  
  915. typedef struct
  916.     {
  917.     INPUT_PRMS0 web,change;
  918.     INPUT_PARAMS input_params;
  919.     } INPUT_PRMS;
  920.  
  921. IN_COMMON BUF_SIZE max_include_depth;
  922. IN_COMMON INPUT_PRMS *prms; /* Stack of |max_include_depth+1| open files. */
  923.  
  924. IN_COMMON outer_char HUGE *tex_fname; /* Name of |tex_file|. */
  925. #define tex_file out_file /* Where output of \.{WEAVE} goes. */
  926.  
  927. IN_COMMON outer_char HUGE *fwebmac; /* The default macro package. */
  928.  
  929. IN_COMMON boolean input_has_ended; /* If there is no more input. */
  930. IN_COMMON boolean changing; /* If the current line is from |change_file|. */
  931.  
  932. typedef struct
  933.     {
  934.     outer_char HUGE *name; /* The ultimate output file name. */
  935.     outer_char HUGE *tmp_name; /* Temporary file name, so new results
  936.                     can be compared with old ones. */
  937.     FILE *ptr; /* A pointer to |tmp_name|. */
  938.     eight_bits previously_opened; /* Possibly opened, but now closed. */
  939.     eight_bits global_scope; /* To control closing at end of each sectn. */
  940.     } OPEN_FILE; /* Info about previously opened files. */
  941.  
  942.  
  943. typedef eight_bits HUGE *PARGS[];
  944.  
  945.  
  946.  
  947. IN_COMMON ASCII HUGE *id_first; /* Where the current identifier begins in
  948.                     the buffer */
  949. IN_COMMON ASCII HUGE *id_loc; /* Just after the current identifier in the
  950.                     buffer */
  951.  
  952. typedef struct
  953.     {
  954.     ASCII *name;
  955.     int n;
  956.     } BUILT_IN;
  957.  
  958. IN_COMMON BUILT_IN incl_likes[]
  959. #ifdef _COMMON_h
  960. #if(part == 0 || part == 1)
  961.     = {
  962.     {(ASCII *)"changequote",11},
  963.     {(ASCII *)"ifelse",6},
  964.     {(ASCII *)"include",7},
  965.     {(ASCII *)"index",5},
  966.     {(ASCII *)"len",3},
  967.     {(ASCII *)"maketemp",8},
  968.     {(ASCII *)"sinclude",8},
  969.     {(ASCII *)"substr",6},
  970.     {(ASCII *)"syscmd",6},
  971.     {(ASCII *)"translit",8},
  972.     {(ASCII *)"",0}
  973.     }
  974. #endif
  975. #endif
  976. ;
  977.  
  978. IN_COMMON BUILT_IN WEB_incl_likes[]
  979. #ifdef _COMMON_h
  980. #if(part == 0 || part == 1)
  981.     = {
  982.     {(ASCII *)"$COMMENT",8},
  983.     {(ASCII *)"$DEFINE",7},
  984.     {(ASCII *)"$ERROR",6},
  985.     {(ASCII *)"$IF",3},
  986.     {(ASCII *)"$IFCASE",7},
  987.     {(ASCII *)"$IFELSE",7},
  988.     {(ASCII *)"$LEN",4},
  989.     {(ASCII *)"$M",2},
  990.     {(ASCII *)"_COMMENT",8},
  991.     {(ASCII *)"_DEFINE",7},
  992.     {(ASCII *)"_ERROR",6},
  993.     {(ASCII *)"_IF",3},
  994.     {(ASCII *)"_IFCASE",7},
  995.     {(ASCII *)"_IFELSE",7},
  996.     {(ASCII *)"_LEN",4},
  997.     {(ASCII *)"_M",2},
  998.     {(ASCII *)"",0}
  999.     }
  1000. #endif
  1001. #endif
  1002. ;
  1003.  
  1004.  
  1005.  
  1006. IN_COMMON BUILT_IN non_labels[]
  1007. #ifdef _COMMON_h
  1008. #if(part == 0 || part == 1)
  1009.     = {
  1010.     {(ASCII *)"contains",8},
  1011.     {(ASCII *)"default",7},
  1012.     {(ASCII *)"private",7},
  1013.     {(ASCII *)"protected",9},
  1014.     {(ASCII *)"public",6},
  1015.     {(ASCII *)"sequence",8},
  1016.     {(ASCII *)"",0}
  1017.     }
  1018. #endif
  1019. #endif
  1020. ;
  1021.  
  1022.  
  1023.  
  1024. typedef struct
  1025.     {
  1026.     ASCII *symbol;
  1027.     short len;
  1028.     eight_bits code; /* Something like |dot_const|. */
  1029.     eight_bits cat; /* Category code for special constants and
  1030. operators. */
  1031.     eight_bits token; /* The tokenized meaning of this operator. */
  1032.     } DOTS;
  1033.  
  1034. typedef struct
  1035.     {
  1036.     ASCII name[MAX_DOT_LENGTH+3]; /* Holds the macro name to be
  1037. appended. */
  1038.     eight_bits cat; /* Category of the operator. */
  1039.     eight_bits num; /* Position in the table. */
  1040.     } DOT_OP;
  1041.  
  1042. IN_COMMON DOT_OP dot_op
  1043. #ifdef _COMMON_h
  1044. #if(part == 0 || part == 1)
  1045.     = {"\\",0,0}
  1046. #endif
  1047. #endif
  1048. ;
  1049.  
  1050.  
  1051.  
  1052. IN_COMMON boolean in_macro CSET(NO);
  1053.     
  1054. IN_COMMON BUF_SIZE mbuf_size; /* Set dynamically. */
  1055. IN_COMMON eight_bits HUGE *mp; /* Next available position in |macrobuf|. */
  1056.  
  1057. IN_COMMON boolean from_buffer CSET(NO); /* Are we reading from a buffer? */
  1058.  
  1059.  
  1060.  
  1061. IN_COMMON int argc; /* copy of |ac| parameter to |main| */
  1062. IN_COMMON outer_char **argv; /* copy of |av| parameter to |main| */
  1063. IN_COMMON outer_char HUGE *pa; /* Current value of |*argv|. */
  1064.  
  1065.  
  1066.  
  1067. typedef struct
  1068.     {
  1069.     outer_char HUGE *args;
  1070.     boolean intrinsics, keywords, reserveds;
  1071.     } RSRVD;
  1072.  
  1073.  
  1074.  
  1075. IN_COMMON outer_char cchar CSET(CCHAR); /* Fortran's continuation
  1076. character. */
  1077.  
  1078. IN_COMMON ASCII cont_char CSET(92); /* Current continuation char for eol. */
  1079. IN_COMMON boolean free_Fortran CSET(NO); /* Free-form syntax in \Fortran.  */
  1080. IN_COMMON boolean free_90 CSET(NO); /* \Fortran/Ratfor-90 and free-form
  1081. syntax. */
  1082.  
  1083. IN_COMMON unsigned short tr_max[NUM_LANGUAGES]
  1084. #ifdef _COMMON_h
  1085. #if(part == 0 || part == 1)
  1086.     = {0,0,0,0,0,0,0,0}
  1087. #endif
  1088. #endif
  1089. ;
  1090.  
  1091. IN_COMMON CONST char HUGE *filter_char[NUM_LANGUAGES]
  1092. #ifdef _COMMON_h
  1093. #if(part == 0 || part == 1)
  1094.     = {"","_","_","","", "","_","_"}
  1095. #endif
  1096. #endif
  1097. ;
  1098.  
  1099. IN_COMMON outer_char abbrev_cmds[NUM_RATFOR_CMDS+1] CSET(""); /* Nothing
  1100.     suppressed by default. */
  1101.  
  1102.  
  1103.  
  1104. IN_COMMON outer_char HUGE *cmd_ln_buf;
  1105.  
  1106.  
  1107.  
  1108. typedef enum {ORDINARY_ID,RESERVED_WD,INTRINSIC_FCN,KEYWD} WORD_TYPE;
  1109.  
  1110. IN_COMMON WORD_TYPE word_type CSET(ORDINARY_ID);
  1111.  
  1112. #define X_FCN SRTN    /* |typedef| didn't work on the VAX. */
  1113.  
  1114. typedef struct RX_link
  1115.     {
  1116.     struct name_info HUGE *Rlink; /* right link in binary search tree for
  1117.                     module names */
  1118.     X_FCN (HUGE_FCN_PTR * HUGE *Expand)(VOID); /* Array of functions
  1119. for keyword expansion (one for each language). */
  1120.     boolean Expandable; /* For which language is this expandable? */
  1121.     } RX_LINK;
  1122.  
  1123. typedef struct
  1124.     {
  1125.     char Ilk;
  1126.     PARAMS params;    
  1127.     } MOD_INFO;
  1128.  
  1129. IN_COMMON boolean index_flag; /* Print identifier in index? */
  1130.  
  1131. typedef boolean NAME_TYPE; /* Type of identifier, enumerated below. */
  1132.  
  1133. enum {NEVER_DEFINED=0,
  1134.     GENERIC_NAME,FUNCTION_NAME,M_MACRO,D_MACRO,IMPLICIT_RESERVED,
  1135.     TYPEDEF_NAME,
  1136.     NEVER_DEFINED0=0x80,
  1137.     GENERIC_NAME0,FUNCTION_NAME0,M_MACRO0,D_MACRO0,IMPLICIT_RESERVED0,
  1138.     TYPEDEF_NAME0};
  1139.  
  1140. /* Maybe the |defined_type| is already marked to not appear in the index.
  1141. (It's $> 128$.)  To properly set a new type, we use a macro to keep the
  1142. flag and attach it to the new type. */
  1143. #define SET_TYPE(p,type) p->defined_type(language) =\
  1144.      ((boolean)(type) | (boolean)((p->defined_type(language) & 0x80)))
  1145.  
  1146. /* To recover the base type, use the following, which strips off the flag: */
  1147. #define DEFINED_TYPE(p) (p->defined_type(language) & 0x7F)
  1148.  
  1149. typedef struct
  1150.     {
  1151.     sixteen_bits section; /* Section number where identifier defined. */
  1152.     NAME_TYPE type; /* Kind of identifier, such as function name. */
  1153.     } DEFINED_INFO;
  1154.  
  1155. typedef struct
  1156.     {
  1157.     ASCII HUGE *text; /* The replacement text for the macro. */
  1158.     unsigned int len; /* Length of replacement text. */
  1159.     eight_bits cat; /* Category code. */
  1160.     } WV_MACRO;
  1161.  
  1162. typedef struct name_info
  1163.     {
  1164.     ASCII HUGE *byte_start; /* Beginning of the name in |byte_mem|. */
  1165.     struct name_info HUGE *link; /* Used for hashing. */
  1166.     union
  1167.         {
  1168.         struct RX_link RX; /* For \FTANGLE. */
  1169.         DEFINED_INFO defined_info[NUM_LANGUAGES]; /* For \FWEAVE. */
  1170.         } dummy;
  1171.     boolean reserved_word,intrinsic_word,keyword;
  1172.     boolean Language;
  1173.     union
  1174.         {
  1175.         char Macro_type; /* For \FTANGLE. */
  1176.         boolean upper_case; /* For \FWEAVE\ identifiers. */
  1177.         MOD_INFO HUGE *mod; /* For \FWEAVE\ module names */
  1178.         } info;
  1179.     eight_bits Ilk[NUM_LANGUAGES];/* Used by ident.'s in \WEAVE\ only. */
  1180.     ASCII HUGE *equiv_or_xref; /* Info corresponding to names. */
  1181.     WV_MACRO HUGE *wv_macro; /* For fancy identifiers. */
  1182.     } NAME_INFO; /* Contains information about an identifier or mod
  1183. name. */
  1184.  
  1185. typedef NAME_INFO HUGE *name_pointer; /* pointer into array of |name_info|s. */
  1186.  
  1187.  
  1188.  
  1189. /* Information for each language. */
  1190. typedef struct
  1191.     {
  1192.     CONST outer_char *op_macro; /* The default \FWEB\ macro. */
  1193.     boolean overloaded; /* Has it been overloaded? */
  1194.     eight_bits cat;    /* Category code for this operator. */
  1195.     outer_char HUGE *defn; /* Replacement text for the \Fortran\ macro. */
  1196.     } OP_INFO;
  1197.  
  1198. /* The description of an operator. */
  1199. typedef struct
  1200.     {
  1201.     ASCII HUGE *op_name; /* \Fortran-like name of operator. Not |const|
  1202. because it's converted to |ASCII|. */
  1203.     OP_INFO info[NUM_LANGUAGES];
  1204.     } OPERATOR;
  1205.  
  1206.  
  1207.  
  1208. typedef enum
  1209.     {
  1210.     NORMAL,RED,GREEN,BLUE,YELLOW,ORANGE,HIGHEST_COLOR
  1211.     } COLOR;
  1212.  
  1213. IN_STYLE CONST char *clr_name[]
  1214. #ifdef _STYLE_h
  1215.     = {"NORMAL","RED","GREEN","BLUE","YELLOW","ORANGE"}
  1216. #endif
  1217. ;
  1218.  
  1219. typedef struct
  1220.     {
  1221.     COLOR last,present;
  1222.     } COLOR0;
  1223.  
  1224. IN_COMMON COLOR0 color0
  1225. #ifdef _COMMON_h
  1226. #if(part == 0 || part == 1)
  1227.     = {NORMAL,NORMAL}
  1228. #endif
  1229. #endif
  1230. ;
  1231.  
  1232. typedef struct
  1233.     {
  1234.     short n;    /* Number of escape sequences attached to this color. */
  1235.     outer_char **string;    /* Array of pointers to those sequences. */
  1236.     } SEQUENCES;
  1237.  
  1238.  
  1239.  
  1240. typedef enum
  1241.     {
  1242.     TeX_escape,TeX_bgroup,TeX_egroup,TeX_math_shift,TeX_alignment_tab,
  1243.     TeX_eol,TeX_parameter,TeX_superscript,TeX_subscript,TeX_ignored,
  1244.     TeX_space,TeX_letter,TeX_other,TeX_active,TeX_comment,TeX_invalid
  1245.     } TeX_CATEGORY;
  1246.  
  1247. IN_COMMON TeX_CATEGORY TeX[128];
  1248.  
  1249.  
  1250.  
  1251. EXTERN sixteen_bits id_defined;
  1252.  
  1253. typedef struct
  1254.     {
  1255.     CONST char HUGE *name; /* Identifier. */
  1256.     int len;    /* Length of identifier. */
  1257.     X_FCN (HUGE_FCN_PTR *expand)(VOID); /* Function that expands this
  1258. token. */
  1259.     sixteen_bits HUGE *pid; /* Address of the |sixteen_bits| that is to be
  1260. initialized. */
  1261.     } SPEC;
  1262.  
  1263.  
  1264.  
  1265. typedef struct
  1266.     {
  1267.     eight_bits *start; /* Macro to be inserted. */
  1268.     eight_bits *end; /* End of |start|. */
  1269.     } INSERT_TEXT;
  1270.  
  1271. typedef struct
  1272.     {
  1273.     INSERT_TEXT program,module,subroutine,function,blockdata,interface;
  1274.     } INSERT_MATERIAL;
  1275.  
  1276.  
  1277.  
  1278. boolean Rat_OK PROTO((outer_char *msg));
  1279. IN_COMMON boolean Rat_is_loaded; /* Set by call to |is_Rat_present|. */
  1280. IN_COMMON boolean xpn_Ratfor CSET(YES);
  1281.  
  1282. IN_TANGLE int spcs_after_cmnt TSET(0);/* Turned on for Ratfor error
  1283. messages. */
  1284. IN_TANGLE int brace_level TSET(0);
  1285. IN_TANGLE boolean checking_label TSET(NO);
  1286. IN_TANGLE INSERT_MATERIAL insert; /* For automatic insertions. */
  1287.  
  1288.  
  1289. EXTERN boolean long_comment;
  1290.  
  1291.  
  1292.  
  1293. IN_COMMON ASCII xord[]; /* specifies conversion of input characters. */
  1294. #ifdef scramble_ASCII
  1295.     IN_COMMON ASCII xxord[];
  1296. #endif
  1297. IN_COMMON outer_char xchr[]; /* specifies conversion of output characters. */
  1298.  
  1299.  
  1300.  
  1301. IN_COMMON BUF_SIZE buf_size; /* Used for \FWEAVE; see \.{common.web}. */
  1302. IN_COMMON ASCII HUGE *loc; /* points to the next character to be read from the
  1303.                 buffer*/
  1304.  
  1305. typedef struct
  1306.     {
  1307.     unsigned size; /* Length of |list|. */
  1308.     outer_char HUGE *list; /* List of include files. */
  1309.     } INCL_PATHS;
  1310.  
  1311.  
  1312.  
  1313. IN_COMMON name_pointer name_ptr; /* first unused position in |byte_start|. */
  1314. IN_COMMON ASCII HUGE *byte_ptr; /* first unused position in |byte_mem|. */
  1315.  
  1316. typedef name_pointer HUGE *hash_pointer;
  1317. IN_COMMON hash_pointer hash, /* heads of hash lists */
  1318.     hash_end, /* end of |hash| */
  1319.     h; /* index into hash-head array */
  1320.  
  1321.  
  1322.  
  1323.  
  1324. EXTERN boolean mac_mod_name;
  1325.  
  1326.  
  1327.  
  1328. IN_COMMON sixteen_bits module_count; /* The current module number. */
  1329. IN_COMMON boolean HUGE *chngd_module; /* Dynamic array: Is the module/
  1330.                     changed? */
  1331. IN_COMMON boolean prn_where; /* Tells \.{TANGLE} to print line and file
  1332.                     info. */
  1333.  
  1334.  
  1335.  
  1336. #undef expr
  1337. #define expr 1
  1338.  
  1339. #undef unop
  1340. #define unop 2
  1341.  
  1342. #undef binop
  1343. #define binop 3
  1344.  
  1345. extern DOTS HUGE *dots; /* The dynamic table; see \.{common.web}. */
  1346.  
  1347. #ifdef _FWEB_h
  1348.  
  1349.     EXTERN DOTS dots0[]
  1350.    #if(part == 0 || part == 1)
  1351.         = {
  1352.         {(ASCII *)"@@@",3,dot_const,expr,0}, /* Dummy */
  1353.         {(ASCII *)"AND",3,dot_const,binop,and_and}, /* |and_and| */
  1354.         {(ASCII *)"EQ",2,dot_const,binop,eq_eq}, /* |eq_eq| */
  1355.         {(ASCII *)"EQV",3,dot_const,binop,eqv}, /* |eqv| */
  1356.         {(ASCII *)"FALSE",5,dot_const,expr,0},
  1357.         {(ASCII *)"GE",2,dot_const,binop,gt_eq}, /* |gt_eq| */
  1358.         {(ASCII *)"GT",2,dot_const,binop,62}, /* |62| */
  1359.         {(ASCII *)"LE",2,dot_const,binop,lt_eq}, /* |lt_eq| */
  1360.         {(ASCII *)"LT",2,dot_const,binop,60}, /* |60| */
  1361.         {(ASCII *)"NE",2,dot_const,binop,not_eq}, /* |not_eq| */
  1362.         {(ASCII *)"NEQV",4,dot_const,binop,neqv}, /* |neqv| */
  1363.         {(ASCII *)"NOT",3,dot_const,unop,33}, /* |33| */
  1364.         {(ASCII *)"OR",2,dot_const,binop,or_or}, /* |or_or| */
  1365.         {(ASCII *)"TRUE",4,dot_const,expr,1},
  1366.         {(ASCII *)"XOR",3,dot_const,binop,neqv}, /* |neqv| */
  1367.         {(ASCII *)"",0,0,0,0}
  1368.         }
  1369.     #endif /* |part == 1| */
  1370.         ;
  1371. #endif /* |_FWEB_h| */
  1372.  
  1373.  
  1374.  
  1375. #ifdef _FWEB_h
  1376.  
  1377.     EXTERN DOTS mcmds[]
  1378.    #if(part ==0 || part == 1)
  1379.      = {
  1380.         {(ASCII *)"define",6,WEB_definition},
  1381.         {(ASCII *)"elif",4,m_elif},
  1382.         {(ASCII *)"elseif",6,m_elif},
  1383.         {(ASCII *)"else",4,m_else},
  1384.         {(ASCII *)"endfor",6,m_endfor},
  1385.         {(ASCII *)"endif",5,m_endif},
  1386.         {(ASCII *)"for",3,m_for},
  1387.         {(ASCII *)"if",2,m_if},
  1388.         {(ASCII *)"ifdef",5,m_ifdef},
  1389.         {(ASCII *)"ifndef",6,m_ifndef},
  1390.         {(ASCII *)"line",4,m_line},
  1391.         {(ASCII *)"undef",5,m_undef},
  1392.         {(ASCII *)"",0,0}
  1393.         }
  1394.     #endif /* |part == 1| */
  1395.         ;
  1396. #endif /* |_FWEB_h| */
  1397.  
  1398.  
  1399.  
  1400. IN_COMMON sixteen_bits HUGE *args; /* For macro processing. */
  1401. IN_COMMON BUF_SIZE max_margs;
  1402.  
  1403.  
  1404. #ifdef _FWEB_h
  1405. #if(part == 0 || part == 1)
  1406.  
  1407. outer_char *ccode_name FCN((code))
  1408.     eight_bits code C1("")
  1409. {
  1410. switch(code)
  1411.     {
  1412.    case begin_FORTRAN: return (outer_char *)"begin_FORTRAN";
  1413.    case begin_RATFOR: return (outer_char *)"begin_RATFOR";
  1414.    case begin_C: return (outer_char *)"begin_C";
  1415.    case ascii_constant: return (outer_char *)"ascii_constant";
  1416.    case big_line_break: return (outer_char *)"big_line_break";
  1417.    case begin_meta: return (outer_char *)"begin_meta";
  1418.    case end_meta: return (outer_char *)"end_meta";
  1419.    case TeX_string: return (outer_char *)"TeX_string";
  1420.    case xref_roman: return (outer_char *)"xref_roman";
  1421.    case xref_typewriter: return (outer_char *)"xref_typewriter";
  1422.    case xref_wildcard: return (outer_char *)"xref_wildcard";
  1423.    case formatt: return (outer_char *)"formatt";
  1424.    case definition: return (outer_char *)"definition";
  1425.    case WEB_definition: return (outer_char *)"WEB_definition";
  1426.    case begin_code: return (outer_char *)"begin_code";
  1427.    case module_name: return (outer_char *)"module_name";
  1428.    case new_module: return (outer_char *)"new_module";
  1429.    case m_ifdef: return (outer_char *)"m_ifdef";
  1430.    case m_ifndef: return (outer_char *)"m_ifndef";
  1431.    case m_if: return (outer_char *)"m_if";
  1432.    case m_else: return (outer_char *)"m_else";
  1433.    case m_elif: return (outer_char *)"m_elif";
  1434.    case m_endif: return (outer_char *)"m_endif";
  1435.    case m_undef: return (outer_char *)"m_undef";
  1436.    case m_line: return (outer_char *)"m_line";
  1437.  
  1438. #ifdef _FTANGLE_h
  1439.    case begin_vcmnt: return (outer_char *)"begin_vcmnt";
  1440.    case begin_bp: return (outer_char *)"begin_bp";
  1441.    case insert_bp: return (outer_char *)"insert_bp";
  1442.    case control_text: return (outer_char *)"control_text";
  1443. #endif /* |_FTANGLE_h| */
  1444.  
  1445. #ifdef _FWEAVE_h
  1446.    case dont_expand: return (outer_char *)"dont_expand";
  1447.    case auto_label: return (outer_char *)"auto_label";
  1448.    case macro_module_name: return (outer_char *)"macro_module_name";
  1449.    case switch_math_flag: return (outer_char *)"switch_math_flag";
  1450.    case underline: return (outer_char *)"underline";
  1451.    case thin_space: return (outer_char *)"thin_space";
  1452.    case math_break: return (outer_char *)"math_break";
  1453.    case line_break: return (outer_char *)"line_break";
  1454.    case no_line_break: return (outer_char *)"no_line_break";
  1455.    case pseudo_semi: return (outer_char *)"pseudo_semi";
  1456.    case macro_space: return (outer_char *)"macro_space";
  1457.    case copy_mode: return (outer_char *)"copy_mode";
  1458.    case toggle_output: return (outer_char *)"toggle_output";
  1459.    case pseudo_expr: return (outer_char *)"pseudo_expr";
  1460.    case pseudo_colon: return (outer_char *)"pseudo_colon";
  1461.    case trace: return (outer_char *)"trace";
  1462. #endif /* |_FWEAVE_h| */
  1463.    default: return OC("UNKNOWN");
  1464.     }    
  1465. }
  1466. #endif /* |part == 1| */
  1467. #endif /* |_FWEB_h| */
  1468.  
  1469.  
  1470.  
  1471.  
  1472. IN_COMMON BUF_SIZE max_bytes;
  1473. IN_COMMON ASCII HUGE *byte_mem; /* Dynamic array: characters of names. */
  1474. IN_COMMON ASCII HUGE *byte_end; /* End of |byte_mem|. */
  1475.  
  1476. IN_COMMON BUF_SIZE max_names;
  1477. IN_COMMON NAME_INFO HUGE *name_dir; /* Dynamic array: information about
  1478. names. */
  1479. IN_COMMON name_pointer name_end; /* End of |name_dir|. */
  1480. IN_COMMON name_pointer npmax; /* |name_ptr - 1|. */
  1481.  
  1482. IN_COMMON BUF_SIZE longest_name;
  1483. IN_COMMON ASCII HUGE *mod_text; /* Dynamic array: name being sought for. */
  1484. IN_COMMON ASCII HUGE *mod_end; /* End of |mod_text|. */
  1485.  
  1486.  
  1487.  
  1488.  
  1489. IN_STYLE outer_char HUGE *sbuf, HUGE *sbuf_end;/* One line of style file. */
  1490. IN_STYLE CONST outer_char HUGE *sloc; /* Position in |sbuffer|. */
  1491. IN_STYLE outer_char HUGE *slimit; /* Next available position in buffer. */
  1492. IN_STYLE LINE_NUMBER s_line SSET(0); /* Input line number. */
  1493.  
  1494.  
  1495.  
  1496.  
  1497. typedef enum
  1498.     {
  1499.     _DO_CMD,
  1500.     block_CMD,blockdata_CMD,
  1501.     break_CMD,case_CMD,contains_CMD,
  1502.     default_CMD,do_CMD,for_CMD,function_CMD,
  1503.     if_CMD,interface_CMD,module_CMD,next_CMD,program_CMD,
  1504.     repeat_CMD,return_CMD,type_CMD,subroutine_CMD,switch_CMD,until_CMD,
  1505.     where_CMD,while_CMD
  1506.     } CMD;
  1507.  
  1508. typedef struct
  1509.     {
  1510.     CMD cmd; /* Type of keyword being expanded. */
  1511.     sixteen_bits name; /* Identifier for this program unit. */
  1512.     sixteen_bits symbolic; /* Symbolic loop label. */
  1513.     boolean function; /* Is this a function? */
  1514.     LINE_NUMBER line; /* Line number at which expansion started. */
  1515.     int level; /* Expansion level. */
  1516.     } BEGUN;
  1517.  
  1518. IN_TANGLE BEGUN HUGE *begun; /* Dynamic array. */
  1519. IN_TANGLE int rlevel TSET(0); /* Current level of \Ratfor\ expansion.  This is
  1520.         incremented for each expandable \Ratfor\ keyword. */
  1521.  
  1522.  
  1523.  
  1524. typedef enum
  1525.      {MORE_PARSE=-1,GOTO_MISTAKE=-2,GOTO_GET_IDENTIFIER=-3,
  1526.      GOTO_GET_A_STRING=-4,GOTO_SKIP_A_COMMENT=-5} GOTO_CODE;
  1527.  
  1528.  
  1529.  
  1530.  
  1531. typedef enum {LIMBO,TEX_,DEFINITION,CODE} PART;
  1532.  
  1533. IN_COMMON PART the_part CSET(LIMBO);
  1534.  
  1535. typedef struct
  1536.     {
  1537.     int generic_name,fcn_name,WEB_macro,outer_macro,imp_reserved_name,
  1538.         typedef_name;
  1539.     } MARK_DEFINED;
  1540.  
  1541.  
  1542.  
  1543. typedef struct
  1544.     {
  1545.     outer_char *reserved, *RESERVED;
  1546.     outer_char *short_id;
  1547.     outer_char *id, *ID;
  1548.     outer_char *id_outer, *ID_OUTER;
  1549.     outer_char *id_inner, *ID_INNER;
  1550.     outer_char *intrinsic;
  1551.     outer_char *keyword, *KEYWORD;
  1552.     outer_char *typewritr;
  1553.     outer_char *wildcrd;
  1554.     } FORMAT;
  1555.  
  1556.  
  1557.  
  1558. typedef struct
  1559. {
  1560. outer_char *options;
  1561. outer_char *file;
  1562. } OPTIONS_FILE;
  1563.  
  1564. typedef struct
  1565.     {
  1566.     OPTIONS_FILE class, package;
  1567.     } LATEX;
  1568.  
  1569.  
  1570.  
  1571. typedef char CC_BUF[2][40]; /*  One line of output for the control codes. */
  1572.  
  1573.  
  1574.  
  1575. typedef enum
  1576.     {
  1577.     MISCELLANEOUS, /* ``normal'' state */
  1578.     NUM_OR_ID, /* state associated with numbers and identifiers */
  1579.     UNBREAKABLE, /* state associated with \.{@\&} */
  1580.     VERBATIM /* state in the middle of a string */
  1581.     } OUTPUT_STATE;
  1582.  
  1583.  
  1584.  
  1585.  
  1586.