Feeding the Snake
string-literals

Add string literals to the interpreter's parser. In factor(), when we see ", read characters until the closing ", store them on the heap starting at address 60000, and return the packed (addr, len) value.

var string_offset: usize = 60000;

In factor():

    if (cur() == '"') {
        pos += 1; // skip opening quote
        const addr: usize = string_offset;
        while (cur() != '"' and cur() != 0) {
            heap[string_offset] = cur();
            string_offset += 1;
            pos += 1;
        }
        if (cur() == '"') { pos += 1; skip(); }
        const len: usize = string_offset - addr;
        return @as(i64, addr) * 65536 + @as(i64, len);
    }

Test:

    check("\"hello\" / 65536", 60000);          // addr = 60000
    check("\"hello\" - \"hello\" / 65536 * 65536", 5);   // len = 5

OK, that's not pretty. Let's add some helpers to make strings usable.