perl 2.0 (no announcement message available)
[p5sagit/p5-mst-13.2.git] / cmd.h
1 /* $Header: cmd.h,v 2.0 88/06/05 00:08:28 root Exp $
2  *
3  * $Log:        cmd.h,v $
4  * Revision 2.0  88/06/05  00:08:28  root
5  * Baseline version 2.0.
6  * 
7  */
8
9 #define C_NULL 0
10 #define C_IF 1
11 #define C_WHILE 2
12 #define C_EXPR 3
13 #define C_BLOCK 4
14
15 #ifdef DEBUGGING
16 #ifndef DOINIT
17 extern char *cmdname[];
18 #else
19 char *cmdname[] = {
20     "NULL",
21     "IF",
22     "WHILE",
23     "EXPR",
24     "BLOCK",
25     "5",
26     "6",
27     "7",
28     "8",
29     "9",
30     "10",
31     "11",
32     "12",
33     "13",
34     "14",
35     "15",
36     "16"
37 };
38 #endif
39 #endif /* DEBUGGING */
40
41 #define CF_OPTIMIZE 077 /* type of optimization */
42 #define CF_FIRSTNEG 0100/* conditional is ($register NE 'string') */
43 #define CF_NESURE 0200  /* if short doesn't match we're sure */
44 #define CF_EQSURE 0400  /* if short does match we're sure */
45 #define CF_COND 01000   /* test c_expr as conditional first, if not null. */
46                         /* Set for everything except do {} while currently */
47 #define CF_LOOP 02000   /* loop on the c_expr conditional (loop modifiers) */
48 #define CF_INVERT 04000 /* it's an "unless" or an "until" */
49 #define CF_ONCE 010000  /* we've already pushed the label on the stack */
50 #define CF_FLIP 020000  /* on a match do flipflop */
51
52 #define CFT_FALSE 0     /* c_expr is always false */
53 #define CFT_TRUE 1      /* c_expr is always true */
54 #define CFT_REG 2       /* c_expr is a simple register */
55 #define CFT_ANCHOR 3    /* c_expr is an anchored search /^.../ */
56 #define CFT_STROP 4     /* c_expr is a string comparison */
57 #define CFT_SCAN 5      /* c_expr is an unanchored search /.../ */
58 #define CFT_GETS 6      /* c_expr is <filehandle> */
59 #define CFT_EVAL 7      /* c_expr is not optimized, so call eval() */
60 #define CFT_UNFLIP 8    /* 2nd half of range not optimized */
61 #define CFT_CHOP 9      /* c_expr is a chop on a register */
62 #define CFT_ARRAY 10    /* this is a foreach loop */
63 #define CFT_INDGETS 11  /* c_expr is <$variable> */
64 #define CFT_NUMOP 12    /* c_expr is a numeric comparison */
65
66 #ifdef DEBUGGING
67 #ifndef DOINIT
68 extern char *cmdopt[];
69 #else
70 char *cmdopt[] = {
71     "FALSE",
72     "TRUE",
73     "REG",
74     "ANCHOR",
75     "STROP",
76     "SCAN",
77     "GETS",
78     "EVAL",
79     "UNFLIP",
80     "CHOP",
81     "ARRAY",
82     "INDGETS",
83     "NUMOP",
84     "13"
85 };
86 #endif
87 #endif /* DEBUGGING */
88
89 struct acmd {
90     STAB        *ac_stab;       /* a symbol table entry */
91     ARG         *ac_expr;       /* any associated expression */
92 };
93
94 struct ccmd {
95     CMD         *cc_true;       /* normal code to do on if and while */
96     CMD         *cc_alt;        /* else code or continue code */
97 };
98
99 struct cmd {
100     CMD         *c_next;        /* the next command at this level */
101     ARG         *c_expr;        /* conditional expression */
102     CMD         *c_head;        /* head of this command list */
103     STR         *c_short;       /* string to match as shortcut */
104     STAB        *c_stab;        /* a symbol table entry, mostly for fp */
105     SPAT        *c_spat;        /* pattern used by optimization */
106     char        *c_label;       /* label for this construct */
107     union ucmd {
108         struct acmd acmd;       /* normal command */
109         struct ccmd ccmd;       /* compound command */
110     } ucmd;
111     short       c_slen;         /* len of c_short, if not null */
112     short       c_flags;        /* optimization flags--see above */
113     char        *c_file;        /* file the following line # is from */
114     line_t      c_line;         /* line # of this command */
115     char        c_type;         /* what this command does */
116 };
117
118 #define Nullcmd Null(CMD*)
119
120 EXT CMD *main_root INIT(Nullcmd);
121 EXT CMD *eval_root INIT(Nullcmd);
122
123 EXT struct compcmd {
124     CMD *comp_true;
125     CMD *comp_alt;
126 };
127
128 void opt_arg();
129 void evalstatic();
130 STR *cmd_exec();