Jamison Creek – the latest version

I moved to a new home recently … where “recently” is actually about 6 months ago. I’m using the extra demands on my time involved in buying a house, packing up contents and unpacking at the other end, as an excuse for not making progress on this project for a while. But the excuse if over, and coding has restarted. I, at least, and happy about that.

I’ve just tagged a new version – Jamison Creek – in honour of my new home. The main advance in this release is that types are starting to take shape. I had intended to implement various flavour of numbers – integers and floats of various sizes – when I first did types, but it didn’t turn out that way: they are actually rather complex as they have subtleties that need to be worked out carefully. I needed something simpler to flesh out the infrastructure for types, so I’ve just extended to current built-in types of “number”, “string” and “Boolean” with arrays and structs.

The syntax for declaring an array is different from what I proposed earlier. Had I used `[number:12]` for an array of 12 numbers, then an array of 12 arrays of 3 numbers would have been `[[number:3]:12]` which is ugly. That could be fairly easily abbreviated as `[numer:3:12]` but the indexes are backwards: the last element would be `foo[11][2]`, which would be confusing. So instead, arrays have the base type *after* the element count, and that count is enclosed in brackets, so `[12][3]number` is an array of 12 arrays of 3 numbers, which I think works well.

Structs use the same approach to block structure as complex statements, and they declare fields much like assignment declarations declare variables, so the initial value is optional. So:
struct foo:
name:string="John Doe"
age:number=21
male:Boolean=True

can also be given as

struct foo { name:string="JohnDoe"; age:number=21;male:Boolean=True; }

These declaration are not part of code – in a `program` – but come as separate declaration. `program` is now also a declaration at the same level. To flesh out these declarations we can also have `const` at the declaration level

I’ve introduced a few new operators too: `and then` and `or else` are short-circuit Boolean operations which only evaluate the right hand side is the value is necessary to determine and answer. There is also a trinary operator: `if ... else` which effects a conditional expression.

As well as these language enhancements, I’ve added some proper regression testing. There are a collection of small sample programs
together with expected outputs, and a script that not only tests that the output is correct, but also:

  • uses valgrind to detect memory leaks
  • prints the program and ensure the printed program runs correctly too
  • ensures the printed program prints exactly the same as the original did
  • Uses the gcc coverage support to track the fraction of interesting code lines that are being tests, and reports and error if this drops below a set threshold, currently 94%.

Hopefully it will be much less than a year before my next version is tagged. Some things I have planned for the next version are:

  • Improved syntax error handling – particularly better messages and better recovery.
  • development of ‘struct’, at least anonymous fields
  • a variety of numeric types
  • more operators: >> << op= ???
  • pointers and memory allocation. This will be the big change and will probably get another blog post soon.

For now, you can read the current interpreter as Literate code.

This entry was posted in Uncategorized. Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *


five + 1 =


*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>