Camen Design Forum

Kroc's Work Log

Kroc

:: OZ80MANDIAS / blu

Thus far I have managed to get my Z80 assembler to successfully build Sonic 1 SMS, therefore I am now working on making it 'user-ready' in preparation for a '1.0' release.

This week I've been reworking the tokeniser (the routine that turns the source code text into a machine representation) into a more complete lexer; rather than a linear stream of tokens it'll use an Abstract Syntax Tree and also verifies the scope (that is, words follow in allowed order and the hierarchy of nested statements is validated).

Previously, the validation of scope was occurring during assembly (when the tree-like order is processed anyway), but this slows down the assembling and duplicates a great deal of validation when we introduce loops.

_Today's work:_

* Removed several lookup tables to check Token category (e.g. Expression, List, Keyword) and replaced it instead with a bit-mask included in each Token / syntax tree node). This reduces Class initialisation time (quite slow ATM), and makes checking the Token type much quicker throughout the code base. This also helps ease our progressive move from Token Stream to Syntax Tree (both systems are in use side-by-side ATM)

_Things to Consider:_

* The Repeat Operator `x` is not an operator! It creates Lists out of Expressions, so shouldn't be detected as part of any normal Expression (only one Value allowed). I will need to re-classify it as something else

* I need to solve the problem of Properties (`.property`) differentiating definition and use only by a new line; that is, a line that begins with a property defines that property, otherwise it's considered a read of an existing property. This is problematic for OZ80 because new-lines are entirely optional everywhere except for this instance, and it breaks the notion that line-breaks can be added for readability, e.g.:

% OZ80
TABLE :someData {
    BYTE .a .b .c
.d  .e .f ;this is an error as `.d` is considered a sub-routine definition and not a `BYTE`
}
%

For now the thought has been to require some kind of prefix for using Property names, e.g. `this.property` but I haven't considered what exactly

Append

(Leave this as-is, it’s a trap!)

Only the original author or a moderator can append to this post.

Pro tip: Use markup to add links, quotes and more.

Your friendly neighbourhood moderators: Kroc, Impressed, Martijn