Going through the list of proposals in the spec, here are some
possible implementation strategies (each of which represent a mini-
project):
1. Memory: it might be nice to add a static variable liveness check
module to the pipeline. Special GC nodes could be added to the parse
tree that free variables which are never used again after that point.
2. Declaration: implementing "ITZ A <type>" is fairly simple and
involves adding some type information to the declaration statement
node. (I.e., in this version of the code, adding a TypeNode field to
DeclarationStmtNode.)
3. Deallocation: since NOOB is not an expression, it will not parse
with the current grammar. It makes sense to just parse "R NOOB" as a
completely new token (TT_RNOOB) and add it into the parse tree as a
new stmt node type (DeallocationStmtNode).
4. Primitive types: I *think* this is already handled because of the
way the interpreter is written.
5. SRS cast: this is interesting and will be fun to implement. I
think the easiest way would be to add a flag to the IdentifierNode
structure called "indirect" which is zero if a normal variable access
and non-zero if an indirect (SRS) variable access. Then, I would
change interpretIdentifierExprNode in interpreter.c to check this flag
and, if non-zero, cast the identifier to a YARN and then look it up in
the symbol table.
6. FUNKSHUNS: we need to change the function call syntax slightly and
tokenize the question mark (TT_QUESTION) and check for it when parsing
functions. Also, MKAY must be used to remove ambiguity from the
grammar (we can then remove the current function table builder step
from the pipeline).
7. BUKKITs
There is a lot to be done here but here is one idea: modify the
ValueData union to have another field for BUKKITs, a ScopeObject *
pointer to the contents of the BUKKIT.
Because BUKKITs can hold functions, an additional ValueData field must
be a FuncDefStmtNode * pointer. The grammar is currently parsed to
retain scope data (e.g., in "<scope> HAS A ..." the
DeclarationScopeNode stores "<scope>" in the "scope" field) but this
needs to be incorporated into the interpreter to reference the correct
scope at runtime.
The inline BUKKIT declaration can be accomplished with some new tokens
(TT_OHAIIM, TT_IMLIEK, KTHX) and a new parse tree node like:
typedef struct {
IdentifierNode *name;
IdentifierNode *parent;
BlockNode *body;
} StructDeclStmtNode;
To access BUKKIT slots, we need a new token (TT_HYPHENZ) and a new
expression node:
typedef struct {
IdentifierNode *parent;
IdentifierNode *target;
} MemberAccessExprNode;
I think the sections starting with "Special Slots" need to be
revisited and potentially revised. Completing the above would add a
lot of functionality to the interpreter.
(Note that if changes are made to the grammar, please update the EBNF
in parser.h accordingly.)
I think that making a single binary compatible with both 1.2 and 1.3
could get really messy because 1.3 modifies some of the functionality/
grammar of 1.2. I think it would be a good idea to have a new
"unstable" branch for 1.3 and maintain 1.2 and 1.3 separately. Any
thoughts on this?