
typedef int token;

// three address code operands

typedef struct operand_block * operand;

struct operand_block {
};

struct constant_operand : public operand_block {
    int value;
    constant_operand(int v) :
        value(v)
    {
    }
};

struct identifier_operand : public operand_block {
    char * name;
    identifier_operand(char * n) :
        name(n)
    {
    }
};



// three address instruction codes

typedef struct code_block * code;

struct code_block {
    operand op;
    virtual void generate() = 0;
    code_block(operand o) :
        op(o)
    {
    }
};

struct three_address_code : public code_block {
    operand left;
    char op;
    operand right;
    three_address_code(operand d, operand l, char o, operand r) :
        code_block(d), left(l), op(o), right(r)
    {
    }
    virtual void generate()
	{
		// must write this
	}
};

struct two_address_code : public code_block {
    operand source;
    two_address_code(operand d, operand s) :
        code_block(d), source(s)
    {
    }
    virtual void generate()
	{
		// must write this
	}
};

struct input_output_code : public code_block {
    char * function;
    input_output_code(operand d, char *f) :
        code_block(d), function(f)
    {
    }
    virtual void generate()
	{
		// must write this
	}
};

typedef struct code_pair * code_list;

struct code_pair {
    code info;
    code_list next;
    code_pair(code h, code_list t) :
        info(h), next(t)
    {
    }
    void generate() {
        info->generate();
        if (next) next->generate();
    }
};
