Unexpected end of file
Velox reports Unexpected end of file when it reaches the end of the compiled source while a statement block or required outer source structure is still open. The reported end position is where the compiler proved that more source was required; the missing token is usually earlier.
Example
procedure ScriptEvent(var Value: Variant);
begin
if Value = '' then
begin
Value := 'missing end';
end; // Error: the procedure block is still open at end of source
Close every nested block before closing the routine:
procedure ScriptEvent(var Value: Variant);
begin
if Value = '' then
begin
Value := 'complete';
end;
end;
How Velox detects it
There are two current emission paths:
- While compiling a routine or nested structured block, the statement compiler encounters the end-of-source token before the block's terminating keyword.
- At the outer compile loop, the parser reaches end of source while the required top-level structure remains incomplete.
Velox enables an embedded-compiler option that can relax the final outer end requirement for supported wrapper forms. That option does not close an unfinished procedure, begin..end, case, try, loop or other nested structure. Nested EOF still produces this error.
Correction procedure
- Repair the first diagnostic in the compiler output before this one.
- Starting at the reported routine, pair every
beginwithend. - Check structured terminators such as
until,exceptandfinally, and theendbelonging tocase,try, class or record declarations. - Check included source as part of the same compilation; the opening construct and EOF can be in different physical inputs.
- Recompile after the structural correction. Do not append
endrepeatedly without identifying which construct owns it.
Edge cases and quirks
- An unterminated string or block comment is normally detected by the lexer as
String errororComment error, not this parser diagnostic. - Missing closing parentheses, brackets or required punctuation can produce their specific diagnostic before EOF. Fix that earlier message first.
- A missing
endcan make the parser treat later valid statements as part of the wrong block; the last line is not necessarily defective. ifand loop bodies consisting of one statement do not require an extrabegin..end, but anybeginthat is present must be closed.- Compiler options that accept a shortened outer wrapper do not make nested blocks optional.
- This is a compile-time error. No part of the event executes.
Related reference
END expected- the parser reached a token where a specificendwas required.BEGIN expected- a required block body did not start.Comment error- a block comment reached end of source without closing.String error- a quoted string reached a line or source boundary without closing.