aboutsummaryrefslogtreecommitdiff
path: root/include/lex.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/lex.h')
-rw-r--r--include/lex.h11
1 files changed, 10 insertions, 1 deletions
diff --git a/include/lex.h b/include/lex.h
index ba1596d..51485a5 100644
--- a/include/lex.h
+++ b/include/lex.h
@@ -103,8 +103,14 @@ struct number {
} value;
};
+struct location {
+ const char *file;
+ int line, column;
+};
+
struct token {
enum lexical_token token;
+ struct location loc;
union {
struct number num;
const char *str;
@@ -117,11 +123,14 @@ struct lexer {
char *buf;
size_t bufsz, buflen;
struct token un;
+ struct location loc;
};
-void lex_init(struct lexer *lexer, FILE *f);
+void lex_init(struct lexer *lexer, FILE *f, const char *filename);
void lex_finish(struct lexer *lexer);
+struct location lex_loc(struct lexer *lexer);
+
enum lexical_token lex(struct lexer *lexer, struct token *out);
void unlex(struct lexer *lexer, const struct token *in);
bool match(struct lexer *lexer, enum lexical_token token);