#ifndef PARSE_H #define PARSE_H #include typedef struct { char ch; int line; int col; } SourceChar; typedef struct { const char* text; size_t i; int line; int col; } SourceCharIter; void source_char_iter_init(SourceCharIter* r, const char* text); SourceChar source_iter_next(SourceCharIter* r); typedef struct { char ch; int line; int col; } LslChar; typedef struct { SourceCharIter* source_char_iter; SourceChar curr; } LslCharIter; void lsl_iter_init(LslCharIter* r, SourceCharIter* source_char_iter); LslChar lsl_iter_next(LslCharIter* r); typedef enum { Tok_Eof, Tok_Eol, Tok_Ident, Tok_Int, Tok_Str, Tok_Char, Tok_HeaderName, Tok_Newline = '\n', // NOTE: has value 10 Tok_Semicolon = ';', Tok_LParen = '(', Tok_RParen = ')', Tok_LBrace = '{', Tok_RBrace = '}', } TokTy; typedef struct { TokTy ty; char* text; int line; int col; } Tok; typedef struct { LslCharIter* lsl_char_iter; LslChar curr; } Lexer; void lexer_init(Lexer* r, LslCharIter* lsl_char_iter); Tok lexer_next(Lexer* l); #endif