Allow only one return

This commit is contained in:
2025-03-01 00:00:36 +01:00
parent f091344cce
commit 18602d00a1
10 changed files with 39 additions and 198 deletions

View File

@ -140,7 +140,6 @@ proc exit(code: Int) -> !; extern
Standard procedures.
*)
proc reallocarray(ptr: ^Byte, n: Word, size: Word) -> ^Byte;
begin
return realloc(ptr, n * size)
end
@ -198,32 +197,26 @@ begin
end
proc is_digit(c: Char) -> Bool;
begin
return cast(c: Int) >= cast('0': Int) and cast(c: Int) <= cast('9': Int)
end
proc is_alpha(c: Char) -> Bool;
begin
return cast(c: Int) >= cast('A': Int) and cast(c: Int) <= cast('z': Int)
end
proc is_alnum(c: Char) -> Bool;
begin
return is_digit(c) or is_alpha(c)
end
proc is_space(c: Char) -> Bool;
begin
return c = ' ' or c = '\n' or c = '\t'
end
proc substring(string: String, start: Word, count: Word) -> String;
begin
return String(string.ptr + start, count)
end
proc open_substring(string: String, start: Word) -> String;
begin
return substring(string, start, string.length - start)
end
@ -277,7 +270,6 @@ end
*)
proc make_position() -> Position;
begin
return Position(1u, 1u)
end
@ -376,12 +368,10 @@ begin
end
proc source_code_empty(source_code: ^SourceCode) -> Bool;
begin
return source_code^.empty(source_code^.input)
end
proc source_code_head(source_code: SourceCode) -> Char;
begin
return source_code.head(source_code.input)
end
@ -398,7 +388,6 @@ begin
end
proc source_code_expect(source_code: ^SourceCode, expected: Char) -> Bool;
begin
return not source_code_empty(source_code) and source_code_head(source_code^) = expected
end
@ -413,7 +402,6 @@ begin
end
proc is_ident(char: Char) -> Bool;
begin
return is_alnum(char) or char = '_'
end
@ -916,7 +904,7 @@ begin
result^.syntax_tree := false
result^.input := nil
while i < argc do
while i < argc and result <> nil do
parameter := argv + i
if strcmp(parameter^, "--tokenize\0".ptr) = 0 then
@ -932,14 +920,14 @@ begin
write_z(parameter^)
write_s(".\n")
return nil
result := nil
end
i := i + 1
end
if result^.input = nil then
if result <> nil and result^.input = nil then
write_s("Fatal error: no input files.\n")
return nil
result := nil
end
return result