You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
193 lines
5.5 KiB
Plaintext
193 lines
5.5 KiB
Plaintext
[appendix]
|
|
[[miss2]]
|
|
== How to MISS2
|
|
The leaked script compiler is full of bugs. It was written for in-house use, so it's meant to work and recognize at least the intended language. The problem is, the language is too inconsistent in this buggy superset. After constantly trying to make those bugs part of this specification, I strongly believe we shouldn't. For the conservative, the following is a list of known things miss2 accepts that this specification does not.
|
|
|
|
Do note a regular lexical grammar (like above) cannot be built for the language recognized by miss2.
|
|
|
|
*Unrestricted character set*
|
|
|
|
More control codes than the specified are _accepted_ by miss2 (such as `\r` anywhere or `\v`). The compiler behaves in weird ways when those are used.
|
|
|
|
You may use custom characters (c > 127), but you may clash with the characters DMA used to tokenize string literals.
|
|
|
|
BLA BLA The in-house compiler recognizes all of the octets in the range 01 through FF almost indiscriminately. Some of these codes produce unexpected results, while others are used internally during translation (for e.g. escaping string literals). In practice, only the printable characters were used by designers. For simplicity we restrict source code to these characters. BLA BLA
|
|
|
|
*A string literal is the same as four tokens*
|
|
|
|
----
|
|
SAVE_STRING_TO_DEBUG_FILE "OO AR AZ WERTY"
|
|
SAVE_STRING_TO_DEBUG_FILE FOO BAR BAZ QWERTY
|
|
// both are recognized by miss2 and produce the same bytecode
|
|
// this specification only accepts the string literal one
|
|
----
|
|
|
|
*A string literal ends a line*
|
|
|
|
As part of transforming a string literal into tokens, miss2 puts a null terminator in the line. Thus, any argument following it is kinda of ignored.
|
|
|
|
----
|
|
SAVE_STRING_TO_DEBUG_FILE "this is a string" and this is ignored
|
|
// this specification does not accept this
|
|
----
|
|
|
|
*Accepts internal compiler commands*
|
|
|
|
Remove the constraint that commands that conflict with grammar definitions cannot be used in a `command_statement` and you get atrocities like:
|
|
|
|
----
|
|
IF { // does not begin a lexical scope
|
|
ENDIF
|
|
|
|
IF WHILE 0 // it's like an ANDOR within an ANDOR
|
|
ENDIF
|
|
|
|
// there is probably a lot more of these
|
|
----
|
|
|
|
*WHILENOT is incomplete*
|
|
|
|
WHILENOT only accepts equality comparison
|
|
|
|
----
|
|
WHILENOT x = 1
|
|
ENDWHILE
|
|
|
|
WHILENOT x < 1 // not recognized
|
|
ENDWHILE
|
|
|
|
// since we accept the above, we are not a subset anymore.
|
|
// to fix this (and become a subset again) only allow equality
|
|
// on WHILENOT.
|
|
----
|
|
|
|
*AND/OR behaves differently than IF/WHILE/expressions*
|
|
|
|
----
|
|
WHILENOT x < 1 // not recognized
|
|
AND x < 1 // recognized
|
|
ENDWHILE
|
|
// this specification accepts both
|
|
|
|
WHILE WAIT 1-1 // not recognized
|
|
AND WAIT 1-1 // recognized
|
|
// this specification accepts neither
|
|
|
|
WHILE WAIT-1 // the command WAIT with a -1 argument
|
|
AND WAIT-1 // a command named WAIT-1
|
|
// this specification accepts neither
|
|
----
|
|
|
|
*INT tokens allow minus in the middle*
|
|
|
|
----
|
|
WAIT 1-1
|
|
WAIT 1-
|
|
// this specification does not accept this
|
|
----
|
|
|
|
*Commands may have operator characters*
|
|
|
|
----
|
|
--b // recognized as '--' identifier(b)
|
|
--b b // recognized as command(--b) identifier(b)
|
|
// this makes the lexer context sensitive
|
|
// but this spec disallow the later form based
|
|
// on the belief the IF/WHILE/expressions parser
|
|
// is the correct one (details above).
|
|
----
|
|
|
|
*anything may follow MISSION_START*
|
|
|
|
----
|
|
MISSION_START anythin"may follow" this thing
|
|
MISSION_END the same "happens"with mission_end
|
|
// this specification does not accept this
|
|
----
|
|
|
|
*labels may contain any printable character (except quotation marks)*
|
|
|
|
----
|
|
e-=1: // recognized (we don't accept this)
|
|
GOTO e-=1 // not recognized
|
|
LAUNCH_MISSION e/=.sc // recognized (we don't accept this)
|
|
----
|
|
|
|
*label may be empty or not match identifier*
|
|
|
|
The name of a label may be empty. The name of a label may contain characters that do not match the `identifier` production.
|
|
|
|
----
|
|
: // recognized
|
|
:::: // recognized
|
|
@abc: // recognized
|
|
// this specification does not accept this
|
|
----
|
|
|
|
*non-identifiers on the lhs of assignment expressions*
|
|
|
|
Some expressions implement this correctly in miss2, some don't.
|
|
|
|
----
|
|
1 = ABS 2 // recognized
|
|
--1 // recognized for every unary expression
|
|
1 = 2 * 3 // recognized for every ternary expression
|
|
1 = 2 // recognized
|
|
1 =# 2 // recognized
|
|
1 *= 2 // not recognized for every other binary expression
|
|
// this specification does not accept any of this
|
|
----
|
|
|
|
*labels in AND/OR*
|
|
|
|
miss2 allows labels to prefix AND/OR conditions. However, it produces weird code. As such, this specification does not accept it.
|
|
|
|
----
|
|
IF x = 0
|
|
lab_or: OR x = 1 // goes to the WAIT 0 after the last condition
|
|
OR x = 2 // this specification does not accept this
|
|
WAIT 1
|
|
ELSE
|
|
WAIT 2
|
|
ENDIF
|
|
----
|
|
|
|
*weird closing blocks*
|
|
|
|
stuff like the following is recognized by miss2
|
|
|
|
----
|
|
WHILE x = 0
|
|
IF y = 1
|
|
WAIT 0
|
|
ENDWHILE
|
|
ENDIF
|
|
// this specification does not accept this (nor variations of this)
|
|
----
|
|
|
|
this happens with scopes, IFs, REPEATs, WHILEs, `MISSION_END`, and what not.
|
|
|
|
it is very interesting actually, but clearly a language bug (would not say a implementation bug though).
|
|
|
|
*exclusive scripts*
|
|
|
|
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?)
|
|
// [...] we are not a subset anymore because of this.
|
|
----
|
|
|
|
*arrays*
|
|
|
|
----
|
|
WAIT array[1]anything // recognized
|
|
WAIT non_array[1] // recognized
|
|
WAIT non_array[2] // not recognized
|
|
// this specification does not accept this
|
|
----
|