1.4 struct expression

An expression has the following structure:
 
struct expression {
        int exp_type;
        union {
                char *sym;
                int val;
                struct operation *op;
        } u;
};

exp_type

This member specifies the type of the expression. Table 1.4 shows its values.
u
This member represents for one specific type of expression. It can be a symbol, or an integer, or an operation. Therefore, it is a union of three members, one is a pointer to a string of symbol name, one is an integer, and the other is a pointer to an operation structure (see section 1.5). Which member is active depends on the value of exp_type. Table 1.4 shows the rule.

Table 1.4 Expression Types

Name
Value
Active Member in Union
Expression Data Structure
SYM
0
u.sym
a string of symbol name
VAL
1
u.val
an integer 
OP
2
u.op
an operation structure

table of content