home *** CD-ROM | disk | FTP | other *** search
/ The World of Computer Software / World_Of_Computer_Software-02-387-Vol-3of3.iso / p / perl4036.zip / x2p / a2p.h < prev    next >
C/C++ Source or Header  |  1993-02-08  |  6KB  |  339 lines

  1. /* $RCSfile: a2p.h,v $$Revision: 4.0.1.2 $$Date: 92/06/08 16:12:23 $
  2.  *
  3.  *    Copyright (c) 1991, Larry Wall
  4.  *
  5.  *    You may distribute under the terms of either the GNU General Public
  6.  *    License or the Artistic License, as specified in the README file.
  7.  *
  8.  * $Log:    a2p.h,v $
  9.  * Revision 4.0.1.2  92/06/08  16:12:23  lwall
  10.  * patch20: hash tables now split only if the memory is available to do so
  11.  * 
  12.  * Revision 4.0.1.1  91/06/07  12:12:27  lwall
  13.  * patch4: new copyright notice
  14.  * 
  15.  * Revision 4.0  91/03/20  01:57:07  lwall
  16.  * 4.0 baseline.
  17.  * 
  18.  */
  19.  
  20. #define VOIDUSED 1
  21. #include "../config.h"
  22.  
  23. #ifndef HAS_BCOPY
  24. #   define bcopy(s1,s2,l) memcpy(s2,s1,l)
  25. #endif
  26. #ifndef HAS_BZERO
  27. #   define bzero(s,l) memset(s,0,l)
  28. #endif
  29.  
  30. #include "handy.h"
  31. #define Nullop 0
  32.  
  33. #define OPROG        1
  34. #define OJUNK        2
  35. #define OHUNKS        3
  36. #define ORANGE        4
  37. #define OPAT        5
  38. #define OHUNK        6
  39. #define OPPAREN        7
  40. #define OPANDAND    8
  41. #define OPOROR        9
  42. #define OPNOT        10
  43. #define OCPAREN        11
  44. #define OCANDAND    12
  45. #define OCOROR        13
  46. #define OCNOT        14
  47. #define ORELOP        15
  48. #define ORPAREN        16
  49. #define OMATCHOP    17
  50. #define OMPAREN        18
  51. #define OCONCAT        19
  52. #define OASSIGN        20
  53. #define OADD        21
  54. #define OSUBTRACT    22
  55. #define OMULT        23
  56. #define ODIV        24
  57. #define OMOD        25
  58. #define OPOSTINCR    26
  59. #define OPOSTDECR    27
  60. #define OPREINCR    28
  61. #define OPREDECR    29
  62. #define OUMINUS        30
  63. #define OUPLUS        31
  64. #define OPAREN        32
  65. #define OGETLINE    33
  66. #define OSPRINTF    34
  67. #define OSUBSTR        35
  68. #define OSTRING        36
  69. #define OSPLIT        37
  70. #define OSNEWLINE    38
  71. #define OINDEX        39
  72. #define ONUM        40
  73. #define OSTR        41
  74. #define OVAR        42
  75. #define OFLD        43
  76. #define ONEWLINE    44
  77. #define OCOMMENT    45
  78. #define OCOMMA        46
  79. #define OSEMICOLON    47
  80. #define OSCOMMENT    48
  81. #define OSTATES        49
  82. #define OSTATE        50
  83. #define OPRINT        51
  84. #define OPRINTF        52
  85. #define OBREAK        53
  86. #define ONEXT        54
  87. #define OEXIT        55
  88. #define OCONTINUE    56
  89. #define OREDIR        57
  90. #define OIF        58
  91. #define OWHILE        59
  92. #define OFOR        60
  93. #define OFORIN        61
  94. #define OVFLD        62
  95. #define OBLOCK        63
  96. #define OREGEX        64
  97. #define OLENGTH        65
  98. #define OLOG        66
  99. #define OEXP        67
  100. #define OSQRT        68
  101. #define OINT        69
  102. #define ODO        70
  103. #define OPOW        71
  104. #define OSUB        72
  105. #define OGSUB        73
  106. #define OMATCH        74
  107. #define OUSERFUN    75
  108. #define OUSERDEF    76
  109. #define OCLOSE        77
  110. #define OATAN2        78
  111. #define OSIN        79
  112. #define OCOS        80
  113. #define ORAND        81
  114. #define OSRAND        82
  115. #define ODELETE        83
  116. #define OSYSTEM        84
  117. #define OCOND        85
  118. #define ORETURN        86
  119. #define ODEFINED    87
  120. #define OSTAR        88
  121.  
  122. #ifdef DOINIT
  123. char *opname[] = {
  124.     "0",
  125.     "PROG",
  126.     "JUNK",
  127.     "HUNKS",
  128.     "RANGE",
  129.     "PAT",
  130.     "HUNK",
  131.     "PPAREN",
  132.     "PANDAND",
  133.     "POROR",
  134.     "PNOT",
  135.     "CPAREN",
  136.     "CANDAND",
  137.     "COROR",
  138.     "CNOT",
  139.     "RELOP",
  140.     "RPAREN",
  141.     "MATCHOP",
  142.     "MPAREN",
  143.     "CONCAT",
  144.     "ASSIGN",
  145.     "ADD",
  146.     "SUBTRACT",
  147.     "MULT",
  148.     "DIV",
  149.     "MOD",
  150.     "POSTINCR",
  151.     "POSTDECR",
  152.     "PREINCR",
  153.     "PREDECR",
  154.     "UMINUS",
  155.     "UPLUS",
  156.     "PAREN",
  157.     "GETLINE",
  158.     "SPRINTF",
  159.     "SUBSTR",
  160.     "STRING",
  161.     "SPLIT",
  162.     "SNEWLINE",
  163.     "INDEX",
  164.     "NUM",
  165.     "STR",
  166.     "VAR",
  167.     "FLD",
  168.     "NEWLINE",
  169.     "COMMENT",
  170.     "COMMA",
  171.     "SEMICOLON",
  172.     "SCOMMENT",
  173.     "STATES",
  174.     "STATE",
  175.     "PRINT",
  176.     "PRINTF",
  177.     "BREAK",
  178.     "NEXT",
  179.     "EXIT",
  180.     "CONTINUE",
  181.     "REDIR",
  182.     "IF",
  183.     "WHILE",
  184.     "FOR",
  185.     "FORIN",
  186.     "VFLD",
  187.     "BLOCK",
  188.     "REGEX",
  189.     "LENGTH",
  190.     "LOG",
  191.     "EXP",
  192.     "SQRT",
  193.     "INT",
  194.     "DO",
  195.     "POW",
  196.     "SUB",
  197.     "GSUB",
  198.     "MATCH",
  199.     "USERFUN",
  200.     "USERDEF",
  201.     "CLOSE",
  202.     "ATAN2",
  203.     "SIN",
  204.     "COS",
  205.     "RAND",
  206.     "SRAND",
  207.     "DELETE",
  208.     "SYSTEM",
  209.     "COND",
  210.     "RETURN",
  211.     "DEFINED",
  212.     "STAR",
  213.     "89"
  214. };
  215. #else
  216. extern char *opname[];
  217. #endif
  218.  
  219. EXT int mop INIT(1);
  220.  
  221. union u_ops {
  222.     int ival;
  223.     char *cval;
  224. };
  225. #if defined(iAPX286) || defined(M_I286) || defined(I80286)     /* 80286 hack */
  226. #define OPSMAX (64000/sizeof(union u_ops))    /* approx. max segment size */
  227. #else
  228. #define OPSMAX 50000
  229. #endif                             /* 80286 hack */
  230. union u_ops ops[OPSMAX];
  231.  
  232. #include <stdio.h>
  233. #include <ctype.h>
  234.  
  235. typedef struct string STR;
  236. typedef struct htbl HASH;
  237.  
  238. #include "str.h"
  239. #include "hash.h"
  240.  
  241. /* A string is TRUE if not "" or "0". */
  242. #define True(val) (tmps = (val), (*tmps && !(*tmps == '0' && !tmps[1])))
  243. EXT char *Yes INIT("1");
  244. EXT char *No INIT("");
  245.  
  246. #define str_true(str) (Str = (str), (Str->str_pok ? True(Str->str_ptr) : (Str->str_nok ? (Str->str_nval != 0.0) : 0 )))
  247.  
  248. #define str_peek(str) (Str = (str), (Str->str_pok ? Str->str_ptr : (Str->str_nok ? (sprintf(buf,"num(%g)",Str->str_nval),buf) : "" )))
  249. #define str_get(str) (Str = (str), (Str->str_pok ? Str->str_ptr : str_2ptr(Str)))
  250. #define str_gnum(str) (Str = (str), (Str->str_nok ? Str->str_nval : str_2num(Str)))
  251. EXT STR *Str;
  252.  
  253. #define GROWSTR(pp,lp,len) if (*(lp) < (len)) growstr(pp,lp,len)
  254.  
  255. STR *str_new();
  256.  
  257. char *scanpat();
  258. char *scannum();
  259.  
  260. void str_free();
  261.  
  262. EXT int line INIT(0);
  263.  
  264. EXT FILE *rsfp;
  265. EXT char buf[2048];
  266. EXT char *bufptr INIT(buf);
  267.  
  268. EXT STR *linestr INIT(Nullstr);
  269.  
  270. EXT char tokenbuf[2048];
  271. EXT int expectterm INIT(TRUE);
  272.  
  273. #ifdef DEBUGGING
  274. EXT int debug INIT(0);
  275. EXT int dlevel INIT(0);
  276. #define YYDEBUG 1
  277. extern int yydebug;
  278. #endif
  279.  
  280. EXT STR *freestrroot INIT(Nullstr);
  281.  
  282. EXT STR str_no;
  283. EXT STR str_yes;
  284.  
  285. EXT bool do_split INIT(FALSE);
  286. EXT bool split_to_array INIT(FALSE);
  287. EXT bool set_array_base INIT(FALSE);
  288. EXT bool saw_RS INIT(FALSE);
  289. EXT bool saw_OFS INIT(FALSE);
  290. EXT bool saw_ORS INIT(FALSE);
  291. EXT bool saw_line_op INIT(FALSE);
  292. EXT bool in_begin INIT(TRUE);
  293. EXT bool do_opens INIT(FALSE);
  294. EXT bool do_fancy_opens INIT(FALSE);
  295. EXT bool lval_field INIT(FALSE);
  296. EXT bool do_chop INIT(FALSE);
  297. EXT bool need_entire INIT(FALSE);
  298. EXT bool absmaxfld INIT(FALSE);
  299. EXT bool saw_altinput INIT(FALSE);
  300.  
  301. EXT bool nomemok INIT(FALSE);
  302.  
  303. EXT char const_FS INIT(0);
  304. EXT char *namelist INIT(Nullch);
  305. EXT char fswitch INIT(0);
  306.  
  307. EXT int saw_FS INIT(0);
  308. EXT int maxfld INIT(0);
  309. EXT int arymax INIT(0);
  310. char *nameary[100];
  311.  
  312. EXT STR *opens;
  313.  
  314. EXT HASH *symtab;
  315. EXT HASH *curarghash;
  316.  
  317. #define P_MIN        0
  318. #define P_LISTOP    5
  319. #define P_COMMA        10
  320. #define P_ASSIGN    15
  321. #define P_COND        20
  322. #define P_DOTDOT    25
  323. #define P_OROR        30
  324. #define P_ANDAND    35
  325. #define P_OR        40
  326. #define P_AND        45
  327. #define P_EQ        50
  328. #define P_REL        55
  329. #define P_UNI        60
  330. #define P_FILETEST    65
  331. #define P_SHIFT        70
  332. #define P_ADD        75
  333. #define P_MUL        80
  334. #define P_MATCH        85
  335. #define P_UNARY        90
  336. #define P_POW        95
  337. #define P_AUTO        100
  338. #define P_MAX        999
  339.