-
Notifications
You must be signed in to change notification settings - Fork 0
/
\
59 lines (53 loc) · 1.29 KB
/
\
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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
#include <stdlib.h>
#include <sys/types.h>
#ifndef TOKENS
#define TOKENS
typedef enum TokenType {
TokenType_Ident,
TokenType_LeftParenthesis,
TokenType_RightParenthesis,
TokenType_LeftBracket,
TokenType_RightBracket,
TokenType_DoubleQuote,
TokenType_SingleQuote,
TokenType_DollarSign,
TokenType_AtSign,
TokenType_EqualSign,
TokenType_Space,
// double char tokens
TokenType_RightArrow,
TokenType_LeftArrow,
} TokenType;
typedef enum IdentType {
IdentType_println,
IdentType_printfln,
IdentType_print,
IdentType_printf,
IdentType_var_init,
IdentType_var_name,
IdentType_if_statement,
IdentType_break_bracket,
IdentType_for_loop,
} IdentType;
typedef struct Token {
char* value;
TokenType token_type;
char character;
} Token;
typedef struct Expression {
Token* tokens;
uint size;
uint max;
} Expression;
Expression EXPRESSION_new();
void EXPRESSIONappend(Expression *P_expr, Token token);
int EXPRESSION_token_exist(Expression *P_expr,int start,TokenType token);
typedef struct Expressions {
Expression* exprs;
uint size;
uint max;
} Expressions;
Expressions EXPRESSIONS_new();
void EXPRESSIONS_append(Expressions* P_exprs,Expression expr);
void EXPRESSIONS_drop(Expressions exprs);
#endif