Closed spotlessmind1975 closed 1 month ago
Is there any way to deal with the fact that you can omit the EXEC keyword (so that just label
works just like EXEC label
)?
Arndt
Hi @godot64 , and thank you for your comment!
The current ugBASIC syntax allows you to call methods without using the EXEC
keyword (TSB semantics) by using a pair of square brackets ([]
).
Example:
PROCEDURE this : END PROC
this[]
I need to check whether the lexer/parser would run into trouble if the BASIC programmer omits the square brackets. It may be necessary to consider other constraints in the neighborhood, to locate the end of the statement.
First published on BETA UPDATE [rev. 20240730].
Syntax:
In TSB, just like in Simons' Basic, subroutines can be given a name (see
PROC
). This makes them independent of their position in the program and makes it easier for the programmer to keep track of things (names are easier to assign to a purpose than line numbers). TheEXEC
command calls such a subroutine, processes it and returns to its starting point. It is therefore largely equivalent to the BASIC V2 commandGOSUB
. This is not the ugBASIC semantic.So ugBASIC should support a pragma to define the semantic for
EXEC
keyword.Unlike in Simons' Basic and TSB, the EXEC keyword canno be omitted. In addition, any other BASIC commands can follow a colon after the label in the line in which a procedure call is used. TSB-EXEC also ignores a space at the beginning of a label (the possible gap between
PROC
and the label name as in the example below). Procedure calls can therefore be handled much more flexibly than under Simons' Basic.The processing speed of
EXEC
andCALL
is much slower under Simons' Basic than with the comparable commandsGOSUB
andGOTO
in Basic V2, because all characters of the label must be compared when searching for the jump destination. To compensate for this disadvantage, TSB creates a table of allPROC
addresses (starting at address$C400
) during program execution and first looks forPROCs
in this table (seeCHECK
). The processing speed of a program with many procedures is thus significantly increased during operation and is faster than Basic V2.If the label behind
EXEC
is not found in the program, the error messageNO PROC ERROR
appears. If a TSB program encounters an end of procedure (END PROC
) without having called a procedure, the messageEND PROC W/O EXEC ERROR
appears. If there are too many nestings (more than ten), TSB reports anOVERFLOW ERROR
.