-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathstmt.h
40 lines (32 loc) · 896 Bytes
/
stmt.h
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 STMT_H
#define STMT_H
#include "decl.h"
#include <stdbool.h>
typedef enum {
STMT_DECL,
STMT_EXPR,
STMT_IF_ELSE,
STMT_FOR,
STMT_PRINT,
STMT_RETURN,
STMT_BLOCK
} stmt_t;
struct stmt {
stmt_t kind;
struct decl *decl;
// used by for (3) [take care no middle is null], print (?), if (1)
struct expr *expr_list;
//struct expr *init_expr;
//struct expr *expr;
//struct expr *next_expr;
// used by block (duh), and IF (if body; next ptr is the else body, if exists)
struct stmt *body;
//struct stmt *else_body;
struct stmt *next;
};
struct stmt * stmt_create( stmt_t kind, struct decl *decl, struct expr *expr_list, struct stmt *body);
void stmt_print( struct stmt *s, int indents, bool indent_first );
void stmt_print_list( struct stmt *s, int indents, char *delim );
struct scope;
int stmt_resolve( struct stmt *s, struct scope *sc, bool verbose);
#endif