7 type_get_from_lexeme(const char *lexeme
)
9 if (!strcasecmp (lexeme
, "Integer"))
11 else if (!strcasecmp (lexeme
, "Boolean"))
13 else if (!strcasecmp (lexeme
, "Char"))
20 type_get_lexeme(Type type
)
35 value_print(Value
*value
, Type type
)
37 if (type
== INTEGER
) {
38 printf("%d", value
->integer
);
39 } else if (type
== BOOLEAN
) {
40 printf("%s", value
->boolean
? "true" : "false");
41 } else if (type
== CHAR
) {
42 printf("'%c'", value
->character
);
47 value_get(Value
*value
, Type type
, void *val
)
50 fprintf(stderr
, "base.c: value_get: value == NULL\n");
54 if (type
== INTEGER
) {
55 *((int *) val
) = value
->integer
;
56 } else if (type
== BOOLEAN
) {
57 *((bool *) val
) = value
->boolean
;
58 } else if (type
== CHAR
) {
59 *((char *) val
) = value
->character
;
61 fprintf(stderr
, "base.c: value_get: unknow type\n");
67 value_set(Value
*value
, Type type
, void *val
)
70 fprintf(stderr
, "base.c: value_set: value == NULL\n");
74 if (type
== VOID
|| val
== NULL
) {
76 } else if (type
== INTEGER
) {
77 value
->integer
= *((int *) val
);
78 } else if (type
== BOOLEAN
) {
79 value
->boolean
= *((bool *) val
);
80 } else if (type
== CHAR
) {
81 value
->character
= *((char *) val
);
83 fprintf(stderr
, "base.c: value_set: unknow type\n");
89 value_set_from_int(Value
*value
, int val
)
91 value_set(value
, INTEGER
, VOID(val
));
95 value_set_from_bool(Value
*value
, bool val
)
97 value_set(value
, BOOLEAN
, VOID(val
));
101 value_set_from_char(Value
*value
, char val
)
103 value_set(value
, CHAR
, VOID(val
));