-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathexpression.h
More file actions
40 lines (32 loc) · 918 Bytes
/
expression.h
File metadata and controls
40 lines (32 loc) · 918 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#ifndef EXPRESSION_H_INCLUDED
#define EXPRESSION_H_INCLUDED
#include <stdlib.h>
#include <stdio.h>
#include "error.h"
#include "bool.h"
typedef union{
int _int;
char _char;
double _double;
Bool _bool;
} Value;
typedef enum{
INT, CHAR, DOUBLE, BOOL, UNKNOWN
} Type;
static const char * strType[] = {"Entero","Caracter","Decimal", "Proposicion", "Desconocido(?)"};
typedef struct {
Type type;
Value value;
} Expression;
Expression * create(Type type);
Expression * createInt(int value);
Expression * createDouble(double value);
Expression * createChar(char value);
Expression * createBool(Bool value);
EXIT_CODE getInt(Expression * expression, int* value);
EXIT_CODE getDouble(Expression * expression, double *value);
EXIT_CODE getChar(Expression * expression, char *value);
EXIT_CODE getBool(Expression * expression, Bool *value);
Type getType(Expression* e);
void printExpression(Expression *e);
#endif