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