You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319
  1. /* $Header: arg.h,v 1.0.1.1 88/01/28 10:22:40 root Exp $
  2. *
  3. * $Log: arg.h,v $
  4. * Revision 1.0.1.1 88/01/28 10:22:40 root
  5. * patch8: added eval operator.
  6. *
  7. * Revision 1.0 87/12/18 13:04:39 root
  8. * Initial revision
  9. *
  10. */
  11. #define O_NULL 0
  12. #define O_ITEM 1
  13. #define O_ITEM2 2
  14. #define O_ITEM3 3
  15. #define O_CONCAT 4
  16. #define O_MATCH 5
  17. #define O_NMATCH 6
  18. #define O_SUBST 7
  19. #define O_NSUBST 8
  20. #define O_ASSIGN 9
  21. #define O_MULTIPLY 10
  22. #define O_DIVIDE 11
  23. #define O_MODULO 12
  24. #define O_ADD 13
  25. #define O_SUBTRACT 14
  26. #define O_LEFT_SHIFT 15
  27. #define O_RIGHT_SHIFT 16
  28. #define O_LT 17
  29. #define O_GT 18
  30. #define O_LE 19
  31. #define O_GE 20
  32. #define O_EQ 21
  33. #define O_NE 22
  34. #define O_BIT_AND 23
  35. #define O_XOR 24
  36. #define O_BIT_OR 25
  37. #define O_AND 26
  38. #define O_OR 27
  39. #define O_COND_EXPR 28
  40. #define O_COMMA 29
  41. #define O_NEGATE 30
  42. #define O_NOT 31
  43. #define O_COMPLEMENT 32
  44. #define O_WRITE 33
  45. #define O_OPEN 34
  46. #define O_TRANS 35
  47. #define O_NTRANS 36
  48. #define O_CLOSE 37
  49. #define O_ARRAY 38
  50. #define O_HASH 39
  51. #define O_LARRAY 40
  52. #define O_LHASH 41
  53. #define O_PUSH 42
  54. #define O_POP 43
  55. #define O_SHIFT 44
  56. #define O_SPLIT 45
  57. #define O_LENGTH 46
  58. #define O_SPRINTF 47
  59. #define O_SUBSTR 48
  60. #define O_JOIN 49
  61. #define O_SLT 50
  62. #define O_SGT 51
  63. #define O_SLE 52
  64. #define O_SGE 53
  65. #define O_SEQ 54
  66. #define O_SNE 55
  67. #define O_SUBR 56
  68. #define O_PRINT 57
  69. #define O_CHDIR 58
  70. #define O_DIE 59
  71. #define O_EXIT 60
  72. #define O_RESET 61
  73. #define O_LIST 62
  74. #define O_SELECT 63
  75. #define O_EOF 64
  76. #define O_TELL 65
  77. #define O_SEEK 66
  78. #define O_LAST 67
  79. #define O_NEXT 68
  80. #define O_REDO 69
  81. #define O_GOTO 70
  82. #define O_INDEX 71
  83. #define O_TIME 72
  84. #define O_TMS 73
  85. #define O_LOCALTIME 74
  86. #define O_GMTIME 75
  87. #define O_STAT 76
  88. #define O_CRYPT 77
  89. #define O_EXP 78
  90. #define O_LOG 79
  91. #define O_SQRT 80
  92. #define O_INT 81
  93. #define O_PRTF 82
  94. #define O_ORD 83
  95. #define O_SLEEP 84
  96. #define O_FLIP 85
  97. #define O_FLOP 86
  98. #define O_KEYS 87
  99. #define O_VALUES 88
  100. #define O_EACH 89
  101. #define O_CHOP 90
  102. #define O_FORK 91
  103. #define O_EXEC 92
  104. #define O_SYSTEM 93
  105. #define O_OCT 94
  106. #define O_HEX 95
  107. #define O_CHMOD 96
  108. #define O_CHOWN 97
  109. #define O_KILL 98
  110. #define O_RENAME 99
  111. #define O_UNLINK 100
  112. #define O_UMASK 101
  113. #define O_UNSHIFT 102
  114. #define O_LINK 103
  115. #define O_REPEAT 104
  116. #define O_EVAL 105
  117. #define MAXO 106
  118. #ifndef DOINIT
  119. extern char *opname[];
  120. #else
  121. char *opname[] = {
  122. "NULL",
  123. "ITEM",
  124. "ITEM2",
  125. "ITEM3",
  126. "CONCAT",
  127. "MATCH",
  128. "NMATCH",
  129. "SUBST",
  130. "NSUBST",
  131. "ASSIGN",
  132. "MULTIPLY",
  133. "DIVIDE",
  134. "MODULO",
  135. "ADD",
  136. "SUBTRACT",
  137. "LEFT_SHIFT",
  138. "RIGHT_SHIFT",
  139. "LT",
  140. "GT",
  141. "LE",
  142. "GE",
  143. "EQ",
  144. "NE",
  145. "BIT_AND",
  146. "XOR",
  147. "BIT_OR",
  148. "AND",
  149. "OR",
  150. "COND_EXPR",
  151. "COMMA",
  152. "NEGATE",
  153. "NOT",
  154. "COMPLEMENT",
  155. "WRITE",
  156. "OPEN",
  157. "TRANS",
  158. "NTRANS",
  159. "CLOSE",
  160. "ARRAY",
  161. "HASH",
  162. "LARRAY",
  163. "LHASH",
  164. "PUSH",
  165. "POP",
  166. "SHIFT",
  167. "SPLIT",
  168. "LENGTH",
  169. "SPRINTF",
  170. "SUBSTR",
  171. "JOIN",
  172. "SLT",
  173. "SGT",
  174. "SLE",
  175. "SGE",
  176. "SEQ",
  177. "SNE",
  178. "SUBR",
  179. "PRINT",
  180. "CHDIR",
  181. "DIE",
  182. "EXIT",
  183. "RESET",
  184. "LIST",
  185. "SELECT",
  186. "EOF",
  187. "TELL",
  188. "SEEK",
  189. "LAST",
  190. "NEXT",
  191. "REDO",
  192. "GOTO",/* shudder */
  193. "INDEX",
  194. "TIME",
  195. "TIMES",
  196. "LOCALTIME",
  197. "GMTIME",
  198. "STAT",
  199. "CRYPT",
  200. "EXP",
  201. "LOG",
  202. "SQRT",
  203. "INT",
  204. "PRINTF",
  205. "ORD",
  206. "SLEEP",
  207. "FLIP",
  208. "FLOP",
  209. "KEYS",
  210. "VALUES",
  211. "EACH",
  212. "CHOP",
  213. "FORK",
  214. "EXEC",
  215. "SYSTEM",
  216. "OCT",
  217. "HEX",
  218. "CHMOD",
  219. "CHOWN",
  220. "KILL",
  221. "RENAME",
  222. "UNLINK",
  223. "UMASK",
  224. "UNSHIFT",
  225. "LINK",
  226. "REPEAT",
  227. "EVAL",
  228. "106"
  229. };
  230. #endif
  231. #define A_NULL 0
  232. #define A_EXPR 1
  233. #define A_CMD 2
  234. #define A_STAB 3
  235. #define A_LVAL 4
  236. #define A_SINGLE 5
  237. #define A_DOUBLE 6
  238. #define A_BACKTICK 7
  239. #define A_READ 8
  240. #define A_SPAT 9
  241. #define A_LEXPR 10
  242. #define A_ARYLEN 11
  243. #define A_NUMBER 12
  244. #ifndef DOINIT
  245. extern char *argname[];
  246. #else
  247. char *argname[] = {
  248. "A_NULL",
  249. "EXPR",
  250. "CMD",
  251. "STAB",
  252. "LVAL",
  253. "SINGLE",
  254. "DOUBLE",
  255. "BACKTICK",
  256. "READ",
  257. "SPAT",
  258. "LEXPR",
  259. "ARYLEN",
  260. "NUMBER",
  261. "13"
  262. };
  263. #endif
  264. #ifndef DOINIT
  265. extern bool hoistable[];
  266. #else
  267. bool hoistable[] = {0, 0, 1, 1, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0};
  268. #endif
  269. struct arg {
  270. union argptr {
  271. ARG *arg_arg;
  272. char *arg_cval;
  273. STAB *arg_stab;
  274. SPAT *arg_spat;
  275. CMD *arg_cmd;
  276. STR *arg_str;
  277. double arg_nval;
  278. } arg_ptr;
  279. short arg_len;
  280. char arg_type;
  281. char arg_flags;
  282. };
  283. #define AF_SPECIAL 1 /* op wants to evaluate this arg itself */
  284. #define AF_POST 2 /* post *crement this item */
  285. #define AF_PRE 4 /* pre *crement this item */
  286. #define AF_UP 8 /* increment rather than decrement */
  287. #define AF_COMMON 16 /* left and right have symbols in common */
  288. #define AF_NUMERIC 32 /* return as numeric rather than string */
  289. #define AF_LISTISH 64 /* turn into list if important */
  290. /*
  291. * Most of the ARG pointers are used as pointers to arrays of ARG. When
  292. * so used, the 0th element is special, and represents the operator to
  293. * use on the list of arguments following. The arg_len in the 0th element
  294. * gives the maximum argument number, and the arg_str is used to store
  295. * the return value in a more-or-less static location. Sorry it's not
  296. * re-entrant, but it sure makes it efficient. The arg_type of the
  297. * 0th element is an operator (O_*) rather than an argument type (A_*).
  298. */
  299. #define Nullarg Null(ARG*)
  300. EXT char opargs[MAXO];
  301. int do_trans();
  302. int do_split();
  303. bool do_eof();
  304. long do_tell();
  305. bool do_seek();
  306. int do_tms();
  307. int do_time();
  308. int do_stat();