aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBad Diode <bd@badd10de.dev>2021-10-09 12:16:41 +0200
committerBad Diode <bd@badd10de.dev>2021-10-09 12:16:41 +0200
commit2c601e7a00d54181bb67b403e79ca351eae200e2 (patch)
tree323ac85068db788532f0d67a4d88b69b0c91a8c3
parentaa5db9c6d13f353cfb839f732eb81d02d74fc1b7 (diff)
downloadbdl-2c601e7a00d54181bb67b403e79ca351eae200e2.tar.gz
bdl-2c601e7a00d54181bb67b403e79ca351eae200e2.zip
Add support for comments
-rwxr-xr-xsrc/bootstrap/main.c21
1 files changed, 20 insertions, 1 deletions
diff --git a/src/bootstrap/main.c b/src/bootstrap/main.c
index 65a61f4..1494378 100755
--- a/src/bootstrap/main.c
+++ b/src/bootstrap/main.c
@@ -8,6 +8,7 @@
8 8
9// FIXME: We are not worried right now about freeing memory, but we should in 9// FIXME: We are not worried right now about freeing memory, but we should in
10// the future. 10// the future.
11// TODO: Better error messages.
11 12
12typedef struct StringView { 13typedef struct StringView {
13 char *start; 14 char *start;
@@ -143,7 +144,25 @@ tokenize(StringView sv) {
143 tokens_buf[n++] = token; 144 tokens_buf[n++] = token;
144 token_n = 0; 145 token_n = 0;
145 } 146 }
146 continue; 147 } break;
148 case ';': {
149 if (token_n != 0) {
150 Token token = (Token){
151 .type = TOKEN_UNKNOWN,
152 .value = (StringView){
153 .start = &sv.start[i - token_n],
154 .n = token_n,
155 }
156 };
157 token.type = find_token_type(token.value);
158 tokens_buf[n++] = token;
159 token_n = 0;
160 }
161
162 // Advance until the next newline.
163 do {
164 i++;
165 } while (i < sv.n && sv.start[(i + 1)] != '\n');
147 } break; 166 } break;
148 case '"': { 167 case '"': {
149 if (token_n != 0) { 168 if (token_n != 0) {