summaryrefslogtreecommitdiff
path: root/tokenizer.c
diff options
context:
space:
mode:
authorLeo Tenenbaum <pommicket@gmail.com>2020-01-07 21:38:46 -0500
committerLeo Tenenbaum <pommicket@gmail.com>2020-01-07 21:38:46 -0500
commit0bd0b45ae59e559d88bdc908b8bab8401eb41a30 (patch)
treefef49167817b808d277d632c50d3a95e1d0b75cf /tokenizer.c
parente874576da9ff59d2234635a1e9b3f47d47c470db (diff)
fixed bug with multiline comments
Diffstat (limited to 'tokenizer.c')
-rw-r--r--tokenizer.c11
1 files changed, 6 insertions, 5 deletions
diff --git a/tokenizer.c b/tokenizer.c
index 901c2ee..97c856f 100644
--- a/tokenizer.c
+++ b/tokenizer.c
@@ -244,7 +244,7 @@ static bool tokenize_string(Tokenizer *t, char *str) {
case '*': { /* multi line comment */
tokr_nextchar(t);
int comment_level = 1; /* allow nested multi-line comments */
- while (*t->s) {
+ while (1) {
if (t->s[0] == '*' && t->s[1] == '/') {
t->s += 2;
--comment_level;
@@ -255,13 +255,14 @@ static bool tokenize_string(Tokenizer *t, char *str) {
t->s += 2;
++comment_level;
} else {
+ if (*t->s == 0) {
+ tokenization_err(t, "End of file reached inside multi-line comment.");
+ return false;
+ }
+
tokr_nextchar(t);
}
}
- if (*t->s == 0) {
- tokenization_err(t, "End of file reached inside multi-line comment.");
- abort(); /* there won't be any further errors, of course */
- }
} break;
default:
is_comment = 0;