aboutsummaryrefslogtreecommitdiff
path: root/bootstrap/parse.c
diff options
context:
space:
mode:
authorlemon <lsof@mailbox.org>2022-08-14 07:30:39 +0200
committerlemon <lsof@mailbox.org>2022-08-14 07:30:39 +0200
commit66ed623e65ab9350f08061fe7cf12b989c84f65c (patch)
tree7c8fef7fc27dd331662faca230c460486020783f /bootstrap/parse.c
parentd1aaf316dc7ca6ea208eec8ab43eb64936829675 (diff)
better comment syntax
Diffstat (limited to 'bootstrap/parse.c')
-rw-r--r--bootstrap/parse.c27
1 files changed, 13 insertions, 14 deletions
diff --git a/bootstrap/parse.c b/bootstrap/parse.c
index 8707709..75a3279 100644
--- a/bootstrap/parse.c
+++ b/bootstrap/parse.c
@@ -370,9 +370,20 @@ lex(struct parser *P) {
} else if (c == '#') {
char s[100];
- if (readtilhsep(P, s, sizeof s, 0) < 0)
+ if (readtilhsep(P, s, sizeof s, 0) < 0) {
fatal(P, P->tokspan, "invalid #keyword");
- else if (!strcmp(s, "#")) {
+ } else if (!strcmp(s, "#") && chrpeek(P) == '{') {
+ chr(P);
+ int bal = 1;
+ while (bal != 0) {
+ switch (lex(P).t) {
+ case '{': ++bal; break;
+ case '}': --bal; break;
+ case TKeof: fatal(P, tok.span, "unterminated comment");
+ }
+ }
+ return lex(P);
+ } else if (!strcmp(s, "#")) {
tok.t = '#';
} else if (!strcmp(s, "#t") || !strcmp(s, "#f")) {
tok.t = TKboolit;
@@ -394,18 +405,6 @@ lex(struct parser *P) {
tok.t = '#FIL';
} else if (!strcmp(s, "#LINE")) {
tok.t = '#LIN';
- } else if (!strcmp(s, "#!")) {
- if (chr(P) != '{') fatal(P, P->tokspan, "expected '{' after '#!'");
- int bal = 1;
- while (bal != 0) {
- switch (lex(P).t) {
- case '{': ++bal; break;
- case '}': --bal; break;
- case TKeof: fatal(P, tok.span, "unterminated comment");
- }
- }
- return lex(P);
-
} else {
fatal(P, P->tokspan, "invalid #keyword");
}