compiler/lexer.h
2025-02-24 22:12:13 -06:00

36 lines
514 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_IF,
TOKEN_ELSE,
TOKEN_LPAREN,
TOKEN_RPAREN,
TOKEN_LBRACE,
TOKEN_RBRACE,
TOKEN_SEMICOLON,
};
struct token {
enum token_type type;
const uint8_t * start;
const uint8_t * end;
int value;
};
struct lexer_state {
const uint8_t * buf;
int offset;
int size;
};
struct token lexer_next_token(struct lexer_state * state);