aboutsummaryrefslogtreecommitdiff
path: root/src/tokenizer.cpp
diff options
context:
space:
mode:
authorKarl Zylinski <karl@zylinski.se>2024-09-05 21:17:40 +0200
committerKarl Zylinski <karl@zylinski.se>2024-09-08 01:50:56 +0200
commitdc767da12b0e03a6cd9ff20085565c95c06ef7bc (patch)
treea5ecc5d6a5716f19fd0a0a882de5b489ebdb0121 /src/tokenizer.cpp
parenta99e57c62c1c2d6b0e7a5fcd841eba79e9255d5b (diff)
Make tags use #+ syntax instead of //+ syntax so it no longer looks like a comment. Old style still works but is deprecated with a warning. Using unknown tags is now an error instead of a warning. There is a new token for #+ which consumes the whole line (or until it hits a comment). The tags are parsed like before. There are errors to tell you if you use something invalid in the pre-package-line block.
Diffstat (limited to 'src/tokenizer.cpp')
-rw-r--r--src/tokenizer.cpp15
1 files changed, 15 insertions, 0 deletions
diff --git a/src/tokenizer.cpp b/src/tokenizer.cpp
index 4425bee29..e9bad390e 100644
--- a/src/tokenizer.cpp
+++ b/src/tokenizer.cpp
@@ -2,6 +2,7 @@
TOKEN_KIND(Token_Invalid, "Invalid"), \
TOKEN_KIND(Token_EOF, "EOF"), \
TOKEN_KIND(Token_Comment, "Comment"), \
+ TOKEN_KIND(Token_FileTag, "FileTag"), \
\
TOKEN_KIND(Token__LiteralBegin, ""), \
TOKEN_KIND(Token_Ident, "identifier"), \
@@ -939,6 +940,20 @@ gb_internal void tokenizer_get_token(Tokenizer *t, Token *token, int repeat=0) {
if (t->curr_rune == '!') {
token->kind = Token_Comment;
tokenizer_skip_line(t);
+ } else if (t->curr_rune == '+') {
+ token->kind = Token_FileTag;
+
+ // Skip the line or until it ends or until we hit was is probably a comment.
+ // The parsing of tags happens in `parse_file`.
+ while (t->curr_rune != GB_RUNE_EOF) {
+ if (t->curr_rune == '\n') {
+ break;
+ }
+ if (t->curr_rune == '/') {
+ break;
+ }
+ advance_to_next_rune(t);
+ }
}
break;
case '/':