From df4a225ccf79dd9f5fa3faef4fd68ae87471f0ca Mon Sep 17 00:00:00 2001 From: Freya Murphy Date: Fri, 13 Sep 2024 11:11:18 -0400 Subject: better --- masm/lex.h | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'masm/lex.h') diff --git a/masm/lex.h b/masm/lex.h index f1c482a..e08d0a3 100644 --- a/masm/lex.h +++ b/masm/lex.h @@ -14,6 +14,13 @@ struct lexer { int y; }; +struct lexer_state { + long offset; + int peek; + int x; + int y; +}; + enum token_type { TOK_IDENT, TOK_REG, @@ -52,4 +59,10 @@ int lexer_next(struct lexer *lexer, struct token *token); /* token type to string */ char *token_str(enum token_type); +/* save the state of a lexer */ +void lexer_save(struct lexer *lexer, struct lexer_state *state); + +/* load a different state into a lexer */ +void lexer_load(struct lexer *lexer, const struct lexer_state *state); + #endif /* __LEX_H__ */ -- cgit v1.2.3-freya