aboutsummaryrefslogtreecommitdiff
path: root/bootstrap
diff options
context:
space:
mode:
authorSamuel Lidén Borell <samuel@kodafritt.se>2026-01-04 23:55:01 +0100
committerSamuel Lidén Borell <samuel@kodafritt.se>2026-01-04 23:55:01 +0100
commitd09e8e7d6f1856ee41c3356dc57ae4429adfe89f (patch)
tree52fa4ed9a12ab9938bf829770b1d8c30837d0c57 /bootstrap
parent6a2fda6b1b6953e38ee158d6cddbf1442394e1ba (diff)
downloadslul-try2-main.tar.gz
slul-try2-main.zip
bootstrap: Fix error on last line in interfacesHEADmain
Diffstat (limited to 'bootstrap')
-rw-r--r--bootstrap/parsedecl.c4
-rw-r--r--bootstrap/token.c11
-rw-r--r--bootstrap/token.h1
3 files changed, 11 insertions, 5 deletions
diff --git a/bootstrap/parsedecl.c b/bootstrap/parsedecl.c
index b6a7904..18d322c 100644
--- a/bootstrap/parsedecl.c
+++ b/bootstrap/parsedecl.c
@@ -602,7 +602,7 @@ static void parse_func(enum FuncKind kind)
error_ident("Unexpected symbol in function definition of",
&current_func->ident);
}
- expect_next_line();
+ expect_next_line_or_eof();
if (next_section == section) {
error_ident("Duplicate section in function declaration of",
&current_func->ident);
@@ -661,7 +661,7 @@ static enum Token parse_paramlist(struct Var **list_out, size_t *count_out)
*nextptr = var;
nextptr = &var->next;
var->is_funcparam = true;
- expect_next_line();
+ expect_next_line_or_eof();
count++;
if (count > FUNCPARAMS_MAX) {
error("Too many parameters");
diff --git a/bootstrap/token.c b/bootstrap/token.c
index 7b1785d..32ce79b 100644
--- a/bootstrap/token.c
+++ b/bootstrap/token.c
@@ -441,6 +441,13 @@ void expect(struct LexemeInfo *li_out, enum Token expected,
void expect_next_line(void)
{
+ if (!expect_next_line_or_eof()) {
+ error("Unexpected end of file");
+ }
+}
+
+bool expect_next_line_or_eof(void)
+{
struct LexemeInfo li;
enum Token t = tokenize(&li);
if (t != T_EOL) {
@@ -448,9 +455,7 @@ void expect_next_line(void)
"Assignment not possible here. Should probably be `==`" :
"Expected line break");
}
- if (!tokenizer_next_line()) {
- error("Unexpected end of file");
- }
+ return tokenizer_next_line();
}
enum IdentKind classify_ident(const struct LexemeInfo *li)
diff --git a/bootstrap/token.h b/bootstrap/token.h
index 289a455..484abab 100644
--- a/bootstrap/token.h
+++ b/bootstrap/token.h
@@ -137,6 +137,7 @@ void unread_line(void);
void expect(struct LexemeInfo *li_out, enum Token expected,
const char *errmsg);
void expect_next_line(void);
+bool expect_next_line_or_eof(void);
enum IdentKind classify_ident(const struct LexemeInfo *li);