34 lines
464 B
C
34 lines
464 B
C
#pragma once
|
|
|
|
#include <stdint.h>
|
|
|
|
enum token_type {
|
|
TOKEN_INVALID,
|
|
TOKEN_EOF,
|
|
TOKEN_IDENTIFIER,
|
|
TOKEN_CONSTANT,
|
|
TOKEN_INT,
|
|
TOKEN_VOID,
|
|
TOKEN_RETURN,
|
|
TOKEN_LPAREN,
|
|
TOKEN_RPAREN,
|
|
TOKEN_LBRACE,
|
|
TOKEN_RBRACE,
|
|
TOKEN_SEMICOLON,
|
|
};
|
|
|
|
struct token {
|
|
enum token_type type;
|
|
int start;
|
|
int end;
|
|
int value;
|
|
};
|
|
|
|
struct lexer_state {
|
|
const uint8_t * buf;
|
|
int offset;
|
|
int size;
|
|
};
|
|
|
|
struct token lexer_next_token(struct lexer_state * state);
|