-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtoken.h
More file actions
68 lines (59 loc) · 1.34 KB
/
Copy pathtoken.h
File metadata and controls
68 lines (59 loc) · 1.34 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
60
61
62
63
64
65
66
67
68
#ifndef TOKEN_H
#define TOKEN_H
#include "common.h"
typedef enum {
// Special
TOKEN_EOF,
TOKEN_ERROR,
TOKEN_NEWLINE,
// Literals
TOKEN_IDENT,
TOKEN_NUMBER, // Binary integer (signed or unsigned)
TOKEN_FLOAT, // Binary float
TOKEN_STRING,
// Symbols
TOKEN_LPAREN, // (
TOKEN_RPAREN, // )
TOKEN_LBRACE, // {
TOKEN_RBRACE, // }
TOKEN_LBRACKET, // [
TOKEN_RBRACKET, // ]
TOKEN_LANGLE, // <
TOKEN_RANGLE, // >
TOKEN_COMMA, // ,
TOKEN_EQUALS, // =
TOKEN_COLON, // :
TOKEN_AT, // @
TOKEN_TILDE, // ~
TOKEN_STAR, // *
TOKEN_DOT, // .
TOKEN_DASH, // - (reserved; negative numeric literals are part of NUMBER/FLOAT; standalone '-' is a syntax error)
// Keywords
TOKEN_TRY,
TOKEN_CATCH,
TOKEN_IF,
TOKEN_ELSEIF,
TOKEN_ELSE,
TOKEN_WHILE,
TOKEN_FOR,
TOKEN_PARFOR,
TOKEN_THR,
TOKEN_FUNC,
TOKEN_LAMBDA,
TOKEN_ASYNC,
TOKEN_RETURN,
TOKEN_POP,
TOKEN_BREAK,
TOKEN_CONTINUE,
TOKEN_GOTO,
TOKEN_GOTOPOINT
} PTokenType;
typedef struct {
PTokenType type;
char* literal; // For IDENT, NUMBER, FLOAT, STRING, etc.
int line;
int column;
} Token;
const char* token_type_to_string(PTokenType type);
void free_token(Token* token);
#endif // TOKEN_H