/* * toy.g: global types for the compiler. */ type /* type which enumerates all of the tokens the lexical scanner produces */ TokenKind_t = enum { tk_eof, /* end of the source input reached */ tk_illegal, /* unknown characters in input */ tk_number, /* a numeric constant, e.g. 128 */ tk_string, /* a string constant */ tk_id, /* an identifier */ tk_proc, /* the reserved word 'proc' */ tk_corp, tk_void, tk_int, tk_bool, tk_true, tk_false, tk_if, tk_then, tk_elif, tk_else, tk_fi, tk_while, tk_do, tk_od, tk_readln, tk_write, tk_assign, /* the assignment operator, ':=' */ tk_leftParen, tk_rightParen, tk_semicolon, tk_colon, tk_comma, tk_plus, tk_minus, tk_slash, tk_star, tk_equal, tk_notEqual, tk_less, tk_lessEqual, tk_greater, tk_greaterEqual }, /* type which describes the toy-type of an expression or call */ ResultType_t = enum { rt_void, rt_bool, rt_int, rt_error /* unknown type */ }, /* type which enumerates the various kinds of symbol-table entries */ SymbolKind_t = enum { sk_empty, /* slot is empty in table */ sk_reservedWord, /* slot used for a reserved word */ sk_undefined, /* an undefined symbol */ sk_globalVariable, sk_procedure, sk_parameter, sk_localVariable }, /* type which describes each symbol-table entry */ SymbolEntry_t = struct { *char se_name; /* points to text of name of symbol */ ulong se_length; /* length of name, including '\e' */ SymbolKind_t se_kind; /* what kind of symbol it is */ ResultType_t se_type; /* what it's type is */ uint se_parCount; /* count of parameters (for procs) */ int se_value; /* value - used by code generation */ }, /* type which enumerates the various relocation targets */ RelocCode_t = enum { rc_none, /* a marker only */ rc_globalVariable, /* reference to a global variable */ rc_main, /* reference to 'main' by run-time system */ rc_printString, /* ref to run-time routine 'printString' */ rc_printInt, rc_readLine, rc_readInt };