-
Notifications
You must be signed in to change notification settings - Fork 0
/
scanner.h
42 lines (33 loc) · 996 Bytes
/
scanner.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
#ifndef peach_scanner_h
#define peach_scanner_h
#include <stddef.h>
typedef enum {
TOKEN_LEFT_PAREN, TOKEN_RIGHT_PAREN,
TOKEN_LEFT_BRACE, TOKEN_RIGHT_BRACE,
TOKEN_COMMA, TOKEN_DOT, TOKEN_MINUS, TOKEN_PLUS,
TOKEN_SEMICOLON, TOKEN_SLASH, TOKEN_STAR,
TOKEN_BANG, TOKEN_BANG_EQUAL,
TOKEN_EQUAL, TOKEN_EQUAL_EQUAL,
TOKEN_GREATER, TOKEN_GREATER_EQUAL,
TOKEN_LESS, TOKEN_LESS_EQUAL,
TOKEN_IDENTIFIER, TOKEN_STRING, TOKEN_NUMBER,
TOKEN_AND, TOKEN_CLASS, TOKEN_ELSE, TOKEN_FALSE,
TOKEN_FOR, TOKEN_FN, TOKEN_IF, TOKEN_NIL, TOKEN_OR,
TOKEN_PRINT, TOKEN_RETURN, TOKEN_SUPER, TOKEN_THIS,
TOKEN_TRUE, TOKEN_LET, TOKEN_WHILE,
TOKEN_ERROR, TOKEN_EOF
} TokenType;
typedef struct {
TokenType type;
const char* start;
size_t length;
size_t line;
} Token;
typedef struct {
const char* start;
const char* current;
size_t line;
} Scanner;
void Scanner_init(Scanner* scanner, const char* source);
Token Scanner_scan_token(Scanner* scanner);
#endif // !peach_scanner_h