| Commit message (Collapse) | Author | Age |
| |
|
|
|
|
|
|
|
|
|
| |
This commit includes the arity of a parent macro in the namespace
of a macro argument, so that the assembler library can recognise that
two macro implementations with different arities are not the same.
This fixes an error where two implementations of a macro with the same
name but different arity could not share argument names, because the
arity of the parent macro wasn't being taken into account when checking
for redefinitions.
|
| |
|
|
|
|
| |
This allows an integer invocation with arguments to be wrapped in `[]`
square brackets so that it can be passed to another invocation as an
argument.
|
| | |
|
| |
|
|
|
|
| |
This variant was never needed or constructed, I would have added it to
match the invocation variants of the block and integer tokens (which do
have a use).
|
| |
|
|
|
|
| |
The single-quote character is used in register names on some processor
architectures. The double-quote character is also allowed to be used in
identifiers for consistency, it could be confusing otherwise.
|
| |
|
|
|
|
| |
This is preferable to having the assembler crash with a stack overflow
error, because the user can now see which invocation caused the
overflow.
|
| |
|
|
|
|
| |
Previously, if the first intermediate token in a program was a pinned
address, the address was being discarded and address zero was being
pinned instead.
|
| |
|
|
|
|
| |
The string-style argument syntax is no longer supported, it has been
replaced with a list-style syntax (using square brackets instead of
double-quotes).
|
| |
|
|
|
| |
This completes the Torque version 3 rewrite, other than some extensive
testing that is yet to be done.
|
| |
|
|
|
|
|
|
| |
Massive improvement. Label references can be used anywhere in the
program, with the program being assembled repeatedly until all labels
have stabilised. The bytecode stage will just be a tiny stage tacked
onto the end, rather than the old bytecode stage that would resolve
labels and expressions.
|
| |
|
|
|
|
|
|
|
| |
To be able to re-use the symbol parser code in the intermediate stage
in order to quickly find all symbol definitions and invocations in the
program (in particular now that macro definitions are indistinguishable
from label definitions, since they can both follow references), the
symbol parser now tracks additional information about each symbol
(argument count, torque-specific role, and parent macro definition).
|
| |
|
|
|
|
|
|
|
|
| |
Previously, strings were implemented as lists of integers, but there
was no way to create an arbitrary list of integers to pass to a macro
invocation.
This commit extends the []-delimited expression syntax, treating
expressions that contain only integers and invocations as lists of
integers. Strings are implemented as a sub-type of list.
|
| |
|
|
|
| |
Changes string arguments from "name" to [name], to prepare for generic
lists in the language. Doesn't compile.
|
| |
|
|
|
| |
There is no longer any reason to enforce this restriction. This will
allow the use of more complex macro recursion by programs.
|
| |
|
|
|
| |
This is done by suffixing the argument count to the symbol name using
the ':' separator character, which can't normally be used in a symbol.
|
| | |
|
| |
|
|
| |
This terminology has been used in the manual for a long time now.
|
| |
|
|
|
|
| |
Al non-macro-definition semantic tokens were being printed starting
from indentation level zero, instead of from the provided indentation
value.
|
| |
|
|
|
|
| |
This case was previously being reported with the message "The macro
definition was not terminated, add a ';' character to terminate", which
was not very helpful.
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
This is a relaxation of the rule where a label reference could not
be used in any context that could change the length of an assembled
program.
We implement this in the bytecode stage by naively calculating an
initial address for each label as before. If a pinned address is
calculated from a label reference, some of the calculated addresses
could be incorrect. We then attempt to run the bytecode stage, which
will calculate a more accurate address for each label based on how
pinned addresses are calculated. If the address of any label was
changed by running this stage, we re-run the stage up to three more
times until all labels stabilise. If the labels fail to stabilise, we
return an error.
|
| |
|
|
|
|
|
|
|
|
|
| |
This feature promotes strings to a first-class type in the language.
If a string is passed to an invocation via the new string-type argument,
the string will be passed as a whole value. String arguments can still
be passed to an invocation via an integer-type argument, in which case
they'll be broken apart into individual characters with the macro being
invoked once per character.
String-type macro arguments are declared like "name".
|
| |
|
|
|
|
| |
The code here is really expecting a block value, but has received an
integer value. This catches the case where an integer value is
incorrectly included in a macro definition body alongside block tokens.
|
| |
|
|
|
|
|
| |
A macro can now invoke itself if the invocation is inside a conditional
block that will eventually return false. The assembler stack can still
overflow if the macro recurses too deeply, or if a macro calls itself
without a conditional block.
|
| |
|
|
|
| |
This will currently cause the assembler to hang in all situations where
it is used.
|
| |
|
|
|
| |
The <len> operator returns the width of an integer in bits, using the
same calculation as for packing an integer into a bit field.
|
| |
|
|
| |
Octal literals use the prefix '0o'.
|
| |
|
|
|
|
|
|
|
|
|
|
| |
The width of a negative integer was previously being counted in the
same way as for a positive integer, by inverting the bits to make it a
positive integer and then finding the placement of the highest-order 1
bit.
The actual width of a negative integer will always be one greater than
this value however, because the highest-order 1 bit of an inverted
negative integer will always have directly above it a significant 0 bit
used as the sign bit.
|
| |
|
|
|
| |
Negative literals take the forms -29, -0x1D, and -0b11101 for decimal,
hexadecimal, and binary.
|
| |
|
|
|
|
|
| |
Previously, the token quoted in the error message for an invalid
literal error included the radix prefix. This is already visible in
the highlighted source report, and implied by the named radix in the
error message.
|
| |
|
|
| |
torque-asm now uses the Compiler type provided by the assembler library.
|
| |
|
|
|
|
|
| |
- Rename tokens field on SyntacticMacroDefinition to body
- Rename push_err! macro to err!
- Create macros for character-matching logic in syntactic parsing
- Replace .as_bytes().to_vec() pattern with .into_bytes()
|
|
|
The language is now more general, the code is better structured, error
reporting is more detailed, and many new language features have
been implemented:
- conditional blocks
- first-class strings
- more expression operators
- binary literals
- negative values
- invocations in constant expressions
|