changelog for 0.9.1
[posh.git] / c_test.h
blob0e487e9003ce62fb6cdcbfec2d3bd72f5e89a117
1 /* Various types of operations. Keeping things grouped nicely
2 * (unary,binary) makes switch() statements more efficeint.
3 */
4 enum Test_op {
5 TO_NONOP = 0, /* non-operator */
6 /* unary operators */
7 TO_STNZE, TO_STZER, TO_OPTION,
8 TO_FILAXST,
9 TO_FILEXST,
10 TO_FILREG, TO_FILBDEV, TO_FILCDEV, TO_FILSYM, TO_FILFIFO, TO_FILSOCK,
11 TO_FILCDF, TO_FILID, TO_FILGID, TO_FILSETG, TO_FILSTCK, TO_FILUID,
12 TO_FILRD, TO_FILGZ, TO_FILTT, TO_FILSETU, TO_FILWR, TO_FILEX,
13 /* binary operators */
14 TO_STEQL, TO_STNEQ, TO_STLT, TO_STGT, TO_INTEQ, TO_INTNE, TO_INTGT,
15 TO_INTGE, TO_INTLT, TO_INTLE, TO_FILEQ, TO_FILNT, TO_FILOT
17 typedef enum Test_op Test_op;
19 /* Used by Test_env.isa() (order important - used to index *_tokens[] arrays) */
20 enum Test_meta {
21 TM_OR, /* -o or || */
22 TM_AND, /* -a or && */
23 TM_NOT, /* ! */
24 TM_UNOP, /* unary operator */
25 TM_BINOP, /* binary operator */
26 TM_END /* end of input */
28 typedef enum Test_meta Test_meta;
30 #define TEF_ERROR BIT(0) /* set if we've hit an error */
31 #define TEF_DBRACKET BIT(1) /* set if [[ .. ]] test */
33 typedef struct test_env Test_env;
34 struct test_env {
35 int flags; /* TEF_* */
36 union {
37 char **wp; /* used by ptest_* */
38 XPtrV *av; /* used by dbtestp_* */
39 } pos;
40 char **wp_end; /* used by ptest_* */
41 int (*isa) ARGS((Test_env *te, Test_meta meta));
42 const char *(*getopnd) ARGS((Test_env *te, Test_op op, int do_eval));
43 int (*eval) ARGS((Test_env *te, Test_op op, const char *opnd1,
44 const char *opnd2, int do_eval));
45 void (*error) ARGS((Test_env *te, int offset, const char *msg));
48 Test_op test_isop ARGS((Test_env *te, Test_meta meta, const char *s));
49 int test_eval ARGS((Test_env *te, Test_op op, const char *opnd1,
50 const char *opnd2, int do_eval));
51 int test_parse ARGS((Test_env *te));