Add DEFINE preprocessor directive

This commit is contained in:
2020-05-30 12:21:50 +02:00
parent 3bb2cc17e9
commit 0286f25e8d
5 changed files with 174 additions and 29 deletions

View File

@@ -12,7 +12,7 @@ language, or keep on reading!
## From Text To Runtime Behaviour
In order to turn the source text into executable code we use 3 passes:
- Pass 1: tokenization (syntax check)
- Pass 1: tokenization (syntax check) and preprocessing (substitution)
- Pass 2: interpretation (semantics check)
- Pass 3: execution (runtime check)
@@ -69,7 +69,6 @@ The following characters are used as identifiers:
- semicolon (`;`) for statement termination
- hash (`#`) for comments
- square brackets (`[` and `]`) for addressing memory
- double quotes (`"`) for string values
## Memory Model
@@ -87,12 +86,16 @@ second byte of location `$900`).
All symbols are reserved keywords and can therefore NOT be used as labels.
There is currently no strict checking, so be careful.
## Directives
## Preprocessor
- `DECLARE` declares the first label argument to equal the second, immediate
value, argument and is used to declare a constant for the virtual machine.
- `STRING` puts the string value declared as the second argument in the memory
memory location of the first immediate argument
All preprocessor directives are prefixed by a `#`. Ill formed preprocessor
directives do not halt compilation, they are merely reported and then ignored.
- `DEFINE` replaces any occurrence of the first argument by the second argument.
The second argument may be empty, effectively deleting occurences of argument
one. Quotes are currently not supported and arguments are separated by
whitespace. If multiple defines exist for the same substitution the first
declared is used.
### Operands