aboutsummaryrefslogtreecommitdiff
path: root/src/compiler
diff options
context:
space:
mode:
authorGravatar zinc <zinc@downsta.ir> 2026-10-14 16:50:41 +0330
committerGravatar zinc <zinc@downsta.ir> 2026-10-14 16:50:41 +0330
commitccbc77c2d3fa348d0de6f32fc540468401e6880b (patch)
tree32137a48a9a66e5ca486fee5597aaed3f0c12a8b /src/compiler
parentbool: a value stored into a bool is normalised to 0 or 1 (appendix b.2.6) (diff)
lexer: a block comment that is never closed is 'unterminated comment' (appendix b.2.11)
Diffstat (limited to 'src/compiler')
-rw-r--r--src/compiler/lex.zc2
1 files changed, 2 insertions, 0 deletions
diff --git a/src/compiler/lex.zc b/src/compiler/lex.zc
index d06b81b..2763333 100644
--- a/src/compiler/lex.zc
+++ b/src/compiler/lex.zc
@@ -428,6 +428,7 @@ int docblock(int nl) {
doc_char(c);
if (c == 10) bol = 1;
}
+ if (ch < 0) { tline = line; serr("unterminated comment"); }
while (dn && (dbuf[dn - 1] == 32 || dbuf[dn - 1] == 9 || dbuf[dn - 1] == 10 || dbuf[dn - 1] == 13)) dn--;
doc_char(10); dlast = cl; docpending = 1;
if (adj) dn = 0;
@@ -489,6 +490,7 @@ int lex1() {
if (docs_on) { docblock(nl); tglue = 0; continue; }
nextch();
while (ch >= 0) { if (ch == '*') { nextch(); if (ch == '/') break; } else nextch(); }
+ if (ch < 0) { tline = line; serr("unterminated comment"); } // a /* with no */ (spec 1.2.2)
nextch(); tglue = 0; continue;
}
tline = line; toff = cpos() - 1; tbuf[0] = '/'; oplex(1); return 0;