'OF' expected
Velox reports 'OF' expected when a supported construct has reached the point where of must connect its selector or container declaration to the following type or branch list.
Example
procedure ScriptEvent(var Value: Variant);
begin
case Value
1: Value := 'one'; // Error: 'OF' expected
end;
end;
Add of after the completed selector expression:
case Value of
1: Value := 'one';
else
Value := 'other';
end;
Compiler contexts
The current modified PascalScript compiler emits the same diagnostic in four syntax families:
case Expression ofbefore the first case label;set of ElementType;array[IndexRange] of ElementTypeand dynamicarray of ElementType; andarray of ElementTypein an open-array parameter declaration parsed by the routine-declaration helper.
The token following array, set or the case selector is not interchangeable across these forms. For example, a static array must close its ] before of.
Correction procedure
- Identify whether the parser is in a
case,set, array or parameter declaration. - Complete the expression, range or closing bracket immediately before
of. - Insert the keyword at that grammar boundary.
- Check the following type or case label; a malformed preceding construct can make the reported token misleading.
Edge cases and quirks
- The message does not identify which of the four parser contexts emitted it.
- In
case, an error inside the selector expression can consume tokens up to the expectedof; correct the earliest expression error first. - In an array declaration, a missing
]normally reportsClosing square bracket expectedbefore this message. ofin exception-handler syntax is handled by a different parser path and does not use this emission family.
Related reference
case- selector types, labels andelsebehaviour.Closing square bracket (']') expected- an unfinished array range.Unknown type-ofis present but the element type is unavailable.