aboutsummaryrefslogtreecommitdiff
path: root/src/parser.cpp
diff options
context:
space:
mode:
authorgingerBill <gingerBill@users.noreply.github.com>2026-01-26 10:49:24 +0000
committergingerBill <gingerBill@users.noreply.github.com>2026-01-26 10:49:24 +0000
commit83a10e929f634dad2f7e2542ec18d90f73a8925c (patch)
treeb30f577ef2f0f890c42d7698ad14529cd1255ff3 /src/parser.cpp
parent628b4b03be69379f687011c9374d3a32f5205bf1 (diff)
Require space after the prefix of `#+build` style tags
Diffstat (limited to 'src/parser.cpp')
-rw-r--r--src/parser.cpp27
1 files changed, 27 insertions, 0 deletions
diff --git a/src/parser.cpp b/src/parser.cpp
index c1a7fe0ff..af533d9a3 100644
--- a/src/parser.cpp
+++ b/src/parser.cpp
@@ -6238,9 +6238,28 @@ gb_internal String build_tag_get_token(String s, String *out) {
return s;
}
+// returns true on failure
+gb_internal bool build_require_space_after(String s, String prefix) {
+ GB_ASSERT(string_starts_with(s, prefix));
+
+ if (s.len == prefix.len) {
+ return false;
+ }
+ String stripped = string_trim_whitespace(substring(s, prefix.len, s.len));
+
+ if (s[prefix.len] != ' ' && stripped.len != 0) {
+ return true;
+ }
+ return false;
+}
+
gb_internal bool parse_build_tag(Token token_for_pos, String s) {
String const prefix = str_lit("build");
GB_ASSERT(string_starts_with(s, prefix));
+ if (build_require_space_after(s, prefix)) {
+ syntax_error(token_for_pos, "Expected a space after #+%.*s", LIT(prefix));
+ return true;
+ }
s = string_trim_whitespace(substring(s, prefix.len, s.len));
if (s.len == 0) {
@@ -6367,6 +6386,10 @@ gb_internal String vet_tag_get_token(String s, String *out, bool allow_colon) {
gb_internal u64 parse_vet_tag(Token token_for_pos, String s) {
String const prefix = str_lit("vet");
GB_ASSERT(string_starts_with(s, prefix));
+ if (build_require_space_after(s, prefix)) {
+ syntax_error(token_for_pos, "Expected a space after #+%.*s", LIT(prefix));
+ return true;
+ }
s = string_trim_whitespace(substring(s, prefix.len, s.len));
u64 vet_flags = build_context.vet_flags;
@@ -6424,6 +6447,10 @@ gb_internal u64 parse_vet_tag(Token token_for_pos, String s) {
gb_internal u64 parse_feature_tag(Token token_for_pos, String s) {
String const prefix = str_lit("feature");
GB_ASSERT(string_starts_with(s, prefix));
+ if (build_require_space_after(s, prefix)) {
+ syntax_error(token_for_pos, "Expected a space after #+%.*s", LIT(prefix));
+ return true;
+ }
s = string_trim_whitespace(substring(s, prefix.len, s.len));
if (s.len == 0) {