-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathToken.h
61 lines (50 loc) · 1.1 KB
/
Token.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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
#ifndef TOKEN_H_
#define TOKEN_H_
typedef enum {
DEFAULT, // not an actual token type
SPACE, // space or tab
PLINE, // physical line break
// words: fit ^[a-zA-Z_][a-zA-Z_0-9]*$
// reserved words
FOR, // for
ROF, // end of for
IN, // in
WHILE, // while
ELIHW, // end of while
DEF, // def
FED, // end of def
CLASS, // class
SSALC, // end of class
IF, // if
FI, // end of if
ELSEIF, // elseif
ELSE, // else
// any other word-- variable, constant, class/function name, etc.
WORD,
// expression grouping / flow control
COMMA, // ,
SEMI, // ;
POPEN, // (
PCLOSE, // )
BROPEN, // {
BRCLOSE, // }
SQOPEN, // [
SQCLOSE, // ]
// LITERALS
LSTRING, // string literal
LINTEGER,// integer literal
LFLOAT, // float literal
LTRUE, // true literal
LFALSE, // false literal
LNULL, // null literal
COMMENT,
// anything else is an operator (or syntax error)
OPERATOR
} TokenType;
typedef struct {
TokenType type;
char *value;
} Token;
Token *Token_new(TokenType type, const char *value);
void Token_delete(Token *token);
#endif