Iniciado trabalho com llvm_codegen_visitor.
[toypasc.git] / base.h
blob49685b40a85dd6867b42a72090db0076020e7b41
1 #ifndef BASE_H
2 #define BASE_H
4 #define VOID(var) ((void *) &var)
6 typedef enum {
7 FALSE = 0,
8 TRUE
9 } bool;
11 typedef enum TypeEnum {
12 ERROR = -1,
13 VOID,
14 INTEGER,
15 BOOLEAN,
16 CHAR
17 } Type;
19 typedef enum KindEnum {
20 NONE_KIND = -1,
21 PROGRAM,
22 PROGRAM_DECL,
23 VARDECL_LIST,
24 VARDECL,
25 IDENT_LIST,
26 PROCFUNC_LIST,
27 PROCEDURE,
28 FUNCTION,
29 PARAM_LIST,
30 PARAMETER,
31 STATEMENT_LIST,
32 PRINTINT_STMT,
33 PRINTCHAR_STMT,
34 PRINTBOOL_STMT,
35 PRINTLINE_STMT,
36 ASSIGNMENT_STMT,
37 IF_STMT,
38 WHILE_STMT,
39 FOR_STMT,
40 REL_EXPR,
41 ADD_EXPR,
42 MUL_EXPR,
43 NOTFACTOR,
44 CALL,
45 CALLPARAM_LIST,
46 //IDENTIFIER defined as token
47 //INT_LITERAL, BOOL_LITERAL, CHAR_LITERAL defined as tokens
48 } Kind;
50 typedef union {
51 int integer;
52 bool boolean;
53 char character;
54 } Value;
56 char *type_get_lexeme(Type type);
57 Type type_get_from_lexeme(const char *lexeme);
59 void value_get(Value *value, Type type, void *val);
60 void value_set(Value *value, Type type, void *val);
62 void value_set_from_int(Value *value, int val);
63 void value_set_from_bool(Value *value, bool val);
64 void value_set_from_char(Value *value, char val);
66 void value_print(FILE *file, Value *value, Type type);
68 #endif // BASE_H