From 05bf718e37efdc5201ad281e85da7850af31bd59 Mon Sep 17 00:00:00 2001 From: hachem Date: Sat, 19 Sep 2026 10:49:33 +0200 Subject: feat: basic lexer with flex --- lexer.h | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 lexer.h (limited to 'lexer.h') diff --git a/lexer.h b/lexer.h new file mode 100644 index 0000000..eb7a4d3 --- /dev/null +++ b/lexer.h @@ -0,0 +1,30 @@ +#pragma once + +#include +#include + +// single characters stand for themselves +// so the named tokens start past them +enum Token +{ + TOK_END = 0, + TOK_COLONCOLON = 256, + TOK_EMIT, + TOK_COMMIT, + TOK_DECLTYPE, + TOK_DIFFERENCE, + TOK_CHAR +}; + +// provided by flex +// the input +// the current line +// and the scanner itself +extern FILE* yyin; +extern int yylineno; +int yylex(void); + +// true once the lexer has refused something +bool lexer_failed(void); +// the character inside the most recent TOK_CHAR +char lexer_character(void); -- cgit v1.3