diff --git a/core.html b/core.html index 1e833b2..a1594b7 100644 --- a/core.html +++ b/core.html @@ -11,7 +11,7 @@ span.underline{text-decoration: underline;} div.column{display: inline-block; vertical-align: top; width: 50%;} - + @@ -34,12 +34,13 @@
A script is a unit of execution which contains its own program counter, local variables and compare flag.
A program is a collection of scripts running concurrently in a cooperative fashion.
A variable is a named storage location. This location holds a value of specific type.
-There are global and local variables. Global variables are stored in a way they are accessible from any script. Local variables are said to pertain to the particular script and only accessible from it.
+There are global and local variables. Global variables are stored in a way they are accessible from any script. Local variables pertains to its particular script and is only accessible from it.
The lifetime of a global variable is the same as of the execution of all scripts. The lifetime of a local variable is the same as its script and lexical scope.
A command is an operation to be performed by a script. Commands produces side-effects which are described by each command description.
A possible side-effect of executing a command is the updating of the compare flag. The compare flag of a command is the boolean result it produces. The compare flag of a script is the compare flag of the its last executed command. The compare flag is useful for conditionally changing the flow of control.
@@ -200,15 +201,15 @@A command is said to terminate a script if it halts and reclaims storage of such a script.
A script file is a source file containing a sequence of commands. Those commands are executed concurrently by multiple scripts.
-The multi-file is a collection of script files. Hereafter being the collection of script files being translated.
+The multi-file is a collection of script files. Hereafter being the collection of script files being translated.
The main script file is the entry script file. This is where the first script (called the main script) starts execution. Translation begins here.
-Other script files are required to become part of the multi-file by the means of require statements within the main script file. The main script file itself is required from the translation environment.
-Many kinds of script files can be required.
+Other script files are required to become part of the multi-file by the means of require statements within the main script file. The main script file itself is required from the translation environment.
+Many kinds of script files can be required.
A main extension file (or foreign gosub file) is a script file required by the means of a GOSUB_FILE statement. Other script files can be required from here as well.
A subscript file is a script file required by the means of the LAUNCH_MISSION statement. A subscript is a script started by the same statement.
-A mission script file is a script file required by the means of the LOAD_AND_LAUNCH_MISSION statement. A mission script is a script started by the same statement. Only a single mission script can be running at once.
-Commands in the main script file, main extension files and subscript files shall not refer to labels in mission script files. A mission script file shall not refer to labels in other mission script files.
-The main script file is found in a unspecified manner. The other script files are found by recursively searching a directory with the same filename (excluding extension) as the main script file. This directory is in the same path as the main script file. The search for the script files shall be case-insensitive. All script files must have a .sc extension. If multiple script files with the same name are found, behaviour is unspecified.
A mission script file is a script file required by the means of the LOAD_AND_LAUNCH_MISSION statement. A mission script is a script started by the same statement. Only a single mission script can be running at once.
+An implementation may contain special features regarding the way subscripts and mission scripts are executed.
+The main script file is found in a unspecified manner. The other script files are found by recursively searching a directory with the same filename (excluding extension) as the main script file. This directory is in the same path as the main script file. The search for the script files shall be case-insensitive. All script files must have a .sc extension. If multiple script files with the same name are found, behaviour is unspecified.
A script type is said to come before another script type under the following total order:
digit := '0'..'9' ;
integer := ['-'] digit {digit} ;
A integer literal is a sequence of digits optionally preceded by a minus sign.
If the literal begins with a minus, the number following it shall be negated.
-floating_form1 := '.' digit { digit | '.' | 'F' } ;
floating_form2 := digit { digit } ('.' | 'F') { digit | '.' | 'F' } ;
floating := ['-'] (floating_form1 | floating_form2) ;
@@ -342,26 +343,26 @@ identifier := ('$' | 'A'..'Z') {token_char} ;
An identifier is a sequence of token characters beggining with a dollar or alphabetic character.
Constraints
An identifier shall not end with a : character.
A string literal holds a string delimited by quotation marks.
string_literal := '"' { ascii_char - (newline | '"') } '"' ;
-A variable name is a sequence of token characters, except the characters [ and ] cannot happen.
variable_char := token_char - ('[' | ']') ;
variable_name := ('$' | 'A'..'Z') {variable_char} ;
-A variable reference is a variable name optionally followed by an array subscript. Any character following the subscript shall be ignored. A subscript shall not happen more than once.
+A variable reference is a variable name optionally followed by an array subscript.
subscript := '[' (variable_name | integer) ']' ;
-variable := variable_name [ subscript {variable_char} ] ;
-The type of a variable reference is the inner type of the variable name being referenced.
-The subscript uses an integer literal or another variable name of integer type for indexing.
-The indexing is zero-based.
-The integer literal in a subscript must be positive.
+variable := variable_name [ subscript ] ; +The type of a variable reference is the type of the variable name being referenced.
+The subscript uses an integer literal or another variable name of integer type for zero-based indexing.
The program is ill-formed if the array subscript uses a negative or out of bounds value for indexing.
+The program is ill-formed if a variable name is followed by a subscript but the variable is not an array.
+An array variable name which is not followed by a subscript behaves as if its zero-indexed element is referenced.
A command receives several arguments. Every argument must obey the rules of its corresponding parameter definition.
A parameter definition is a set of definitions regarding a single parameter for a specific command.
@@ -659,6 +660,7 @@The compare flag is set to true if the compare flag of all conditional elements in a AND list holds true. Otherwise it is set to false.
The compare flag is set to true if the compare flag of at least one conditional elements in a OR list holds true. Otherwise it is set to false.
A conditional list shall not be short-circuit evaluated. All conditional elements are executed in order.
+The behaviour is unspecified if the command used in a conditional element does not cause side-effects in the compare flag.
Selection statements selects which statement to execute depending on certain conditions.
Require statements request script files to become part of the multi-file being translated.
+A file can be required more than once. If it is required using the same statement as the first request, the latter request is ignored. Otherwise, behaviour is unspecified.
Constraints
Require statements shall only appear in the main script file or main extension files.
A main script file is a sequence of zero or more statements.
Semantics
The main script starts execution at the first statement of the main script file. If there is no statement to be executed, behaviour is unspecified.
+Constraints
+Commands in the main script file shall not refer to labels in mission script files.
main_extension_file := {statement} ;
A main extension file is a sequence of zero or more statements.
+Constraints
+Commands in main extension files shall not refer to labels in mission script files.
subscript_file := 'MISSION_START' eol
{statement}
@@ -755,11 +762,14 @@ 11.3 Subscri
A subscript file is a sequence of zero or more statements in a MISSION_START and MISSION_END block. More statements can follow.
Constraints
The MISSION_START command shall be the very first line of the subscript file and shall not be preceded by anything but ASCII spaces () and horizontal tabs (\t). Even comments are disallowed.
+Commands in subscript files shall not refer to labels in mission script files.
Semantics
The MISSION_END command behaves as if by executing the TERMINATE_THIS_SCRIPT command.
11.4 Mission Script Files
mission_script_file := subscript_file ;
A mission script file has the same structure of a subscript file.
+Constraints
+Commands in mission script files shall not refer to labels in mission script files other than itself.
12 Supporting Commands
In order to perform useful computation the following supporting commands may be available.
12.1 WAIT
@@ -1066,7 +1076,7 @@ 14.1
// NOTE: filename is not an identifier because, for instance,
// filename(4x4.sc) cannot be classified as an identifier.
-OR // command(AND)
+OR // command(OR)
NOT // command(NOT)
IF SOMETHING //
OR OR // 'OR' command(OR)
@@ -1205,8 +1215,13 @@ 14.3 How to MIS
we don’t really what are these, so we won’t specify them.
entities
VAR_INT vcar
-COMMAND_INPUT_CAR_OUTPUT_CAR vcar vcar // this spec gives an error, miss2 recognizes (does not look like intended behaviour?)
-TODO SAN ANDREAS ALLOWS IDENTIFIERS TO BEGIN WITH UNDERSCORES TODO scripts subscripts mission script and such (what are the execution differences) TODO translation limits TODO what about commands that do not produce compare flag changes but may appear in a conditional statement TODO timera timerb (remember, only within scope; cannot declare var with same name; global shall not be named timera/timerb) TODO better name for what we are calling require statements TODO interesting NOP is not compiled TODO rockstar does not know if it calls arg 17 a text string or a string identifier. I will go for identifier. TODO SAVE_VAR_INT TODO should we fix the floating point literals (e.g. ‘1.9.2’)? I think there are DMA scripts that need this. TODO maybe move the semantic definition that we cannot use mission script labels from outside it from concepts to the script file structure section TODO the rationale for global having unspecified initial value: Stories variable sharing (must read more though). TODO read gta3sc issues and source for quirks TODO re-read Wesser’s PM TODO fix AND OR NOT defect? TODO list of special command names (user cannot write these) TODO correctly specify that a[1] = a[1]abc + 2 is not the same as a[1] = a[1] + 2 TODO talk about repetion of filenames and using in different script types TODO define semantics for arr (no brackets) TODO creating packages and such are declarations too (not only var decls) TODO declarations, entities and variable usage TODO label semantics of start new script (GTA3 allows label: {}) TODO remember GTASA INPUT_OPT does not accept text label vars at all (not at runtime level) LIMITS TODO gxtsema gxt key length <8 TODO gxtsema filename (excluding extension must be) <16 TODO label name <=38 TODO varname <40 TODO scriptname <=7 TODO scriptnames <= 300 TODO <=9216 gvar storage words TODO <=16 lvars storage words TODO <=255 array size TODO <=35000 label refs TODO <=255 line TODO <=127 string
+COMMAND_INPUT_CAR_OUTPUT_CAR vcar vcar
+// this spec gives an error, miss2 recognizes (does not look like intended behaviour?)
+// [...] we are not a subset anymore because of this.
+arrays
+WAIT arr[0]anything // recognized
+// this specification does not accept this
+TODO should we fix the floating point literals (e.g. ‘1.9.2’)? I think there are DMA scripts that need this. TODO list of special command names (user cannot write these, include AND/OR/NOT) TODO label semantics of start new script (GTA3 allows label: {}) TODO SAN ANDREAS ALLOWS IDENTIFIERS TO BEGIN WITH UNDERSCORES TODO remember GTASA INPUT_OPT does not accept text label vars at all (not at runtime level) TODO timera timerb (remember, only within scope; cannot declare var with same name; global shall not be named timera/timerb) TODO interesting NOP is not compiled TODO creating packages and such are declarations too (not only var decls) TODO translation limits LIMITS TODO gxtsema gxt key length <8 TODO gxtsema filename (excluding extension must be) <16 TODO label name <=38 TODO varname <40 TODO scriptname <=7 TODO scriptnames <= 300 TODO <=9216 gvar storage words TODO <=16 lvars storage words TODO <=255 array size TODO <=35000 label refs TODO <=255 line TODO <=127 string