larpcc/lex.h
2026-09-16 00:20:55 +02:00

43 lines
537 B
C

#ifndef LEX_H
#define LEX_H
#include <stddef.h>
typedef struct {
size_t idx;
int line;
int col;
} Loc;
typedef enum {
Tok_Eof,
Tok_Ident,
Tok_Int,
Tok_Str,
Tok_Char,
Tok_If,
Tok_Nl = '\n',
Tok_LParen = '(',
Tok_RParen = ')',
Tok_LBrace = '{',
Tok_RBrace = '}',
} TokTy;
typedef struct {
TokTy ty;
Loc loc;
size_t len;
} Tok;
typedef struct {
const char* text;
size_t idx;
int line;
int col;
char ch;
} Lexer;
Tok lexer_next(Lexer* l);
#endif