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
)
39 value_print(FILE *file
, Value
*value
, Type type
)
41 if (type
== INTEGER
) {
42 fprintf(file
, "%d", value
->integer
);
43 } else if (type
== BOOLEAN
) {
44 fprintf(file
, "%s", value
->boolean
? "true" : "false");
45 } else if (type
== CHAR
) {
46 fprintf(file
, "'%c'", value
->character
);
51 value_get(Value
*value
, Type type
, void *val
)
54 fprintf(stderr
, "base.c: value_get: value == NULL\n");
58 if (type
== INTEGER
) {
59 *((int *) val
) = value
->integer
;
60 } else if (type
== BOOLEAN
) {
61 *((bool *) val
) = value
->boolean
;
62 } else if (type
== CHAR
) {
63 *((char *) val
) = value
->character
;
65 fprintf(stderr
, "base.c: value_get: unknow type\n");
71 value_set(Value
*value
, Type type
, void *val
)
74 fprintf(stderr
, "base.c: value_set: value == NULL\n");
78 if (type
== VOID
|| val
== NULL
) {
80 } else if (type
== INTEGER
) {
81 value
->integer
= *((int *) val
);
82 } else if (type
== BOOLEAN
) {
83 value
->boolean
= *((bool *) val
);
84 } else if (type
== CHAR
) {
85 value
->character
= *((char *) val
);
87 fprintf(stderr
, "base.c: value_set: unknow type\n");
93 value_set_from_int(Value
*value
, int val
)
95 value_set(value
, INTEGER
, VOID(val
));
99 value_set_from_bool(Value
*value
, bool val
)
101 value_set(value
, BOOLEAN
, VOID(val
));
105 value_set_from_char(Value
*value
, char val
)
107 value_set(value
, CHAR
, VOID(val
));