Avaliacao de expressoes e Atribuicao quase prontas.
[toypasc.git] / base.h
blobcfb80e0c2f33a191683fcb6c68ef4473a9bd916a
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 //IDENTIFIER defined as token
50 //INT_LITERAL, BOOL_LITERAL, CHAR_LITERAL defined as tokens
51 } Kind;
53 typedef union {
54 int integer;
55 bool boolean;
56 char character;
57 } Value;
59 char *type_get_lexeme(Type type);
60 Type type_get_from_lexeme(const char *lexeme);
62 void value_get(Value *value, Type type, void *val);
63 void value_set(Value *value, Type type, void *val);
65 void value_set_from_int(Value *value, int val);
66 void value_set_from_bool(Value *value, bool val);
67 void value_set_from_char(Value *value, char val);
69 void value_print(FILE *file, Value *value, Type type);
71 #endif // BASE_H