mechaniputer / libreDSSP

A GPL Licensed DSSP Interpreter

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Variables and types

mechaniputer opened this issue · comments

It looks as though variables are supposed to be declared like 'VAR foo' before being assigned a value. Currently the 'VAR' keyword is not implemented and variables can be assigned without first declaring them like: '7 ! foo'

See this document: http://brokestream.com/daf.txt

Declaring a variable with VAR should result in that variable being named, allocated and initialized to zero. Implicitly declaring a variable through the assignment operator should print a warning that this will be deprecated in a future release.

Types should also be supported like this:
WORD VAR foo
BYTE VAR foo

WORD should be the default type, corresponding to the size of the machine word.

To implement this, the types (WORD, BYTE, etc) could be defined as core words which expect the next item on the command stack to be VAR and otherwise print an error. These words would pop VAR from the command stack before declaring the variable. VAR would also be a core word to declare a variable of the default type (but if a type specifier is used, VAR would be popped and ignored in favor of the type-specific declaration)