-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathexpr.h
More file actions
executable file
·37 lines (29 loc) · 790 Bytes
/
expr.h
File metadata and controls
executable file
·37 lines (29 loc) · 790 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
#ifndef EXPR_H
#define EXPR_H
#include "symbol.h"
typedef enum {
EXPR_ADD,
EXPR_SUB,
EXPR_MUL,
EXPR_DIV
/* many more kinds of exprs to add here */
} expr_t;
struct expr {
/* used by all kinds of exprs */
expr_t kind;
struct expr *left;
struct expr *right;
/* used by various leaf exprs */
const char *name;
int literal_value;
const char * string_literal;
struct symbol *symbol;
};
struct expr * expr_create( expr_t kind, struct expr *left, struct expr *right );
struct expr * expr_create_name( const char *n );
struct expr * expr_create_integer_literal( int c );
struct expr * expr_create_boolean_literal( int c );
struct expr * expr_create_char_literal( char c );
struct expr * expr_create_string_literal( const char *str );
void expr_print( struct expr *e );
#endif