davidedc/livecodelab — pull request #227 by rumblesan (2014-02-16 02:22:59+00:00)
Title: New language parser - Don't merge just yet

# Holy Crap it's a new Parser!

This is a new, custom built parser and interpreter for the LCL language as discussed in the language spec google doc here,
https://docs.google.com/document/d/16UmUEUOLnS147bM1zxaNh4y8abrX10onackHo09L4O8/edit?usp=sharing

Not everything is working just yet, for a start, I think it's a bit slower than the previous LCL implementation because we're not **eval** -ing javascript but interpreting a proper AST. There's tweaking to be done there, but that's a more long term issue.

## Things that are broken
* Comments after code don't work so `a = 3 // a comment` will break things
* Strings aren't implemented so the audio is broken. Should be a quick fix though
* JS object stuff doesn't work
* Block scoping for colours
* No arrays or coffee script `for i in [1 .. 3]`
* Scoping might be funny
* Function definition might be funny
* Could still be some edge cases around blocks and newlines behaving wierdly
* Still needs plenty of testing
* No return values from functions

## Things that are working
Quite a few of the new features are now up and running.

### Times Loops
Times blocks can have a loop variable, and can also use variables instead of numbers.
```
loop = 10
loop times with count
rotate count
box
```

### Scoped Matrix and colour commands
```
fill red

rotate time / 1000
fill blue
box

box
```
This will give you a rotating blue box and a still red box.

### Inlining for Matrix and Colour commands
The scoping also works when matrix and colour functions are called inline, with optional `>>` symbols available.
```
fill red
rotate time, 3, 3 fill blue box
rotate time, 5, 5 >> fill blue >> peg
box
```

## Work still to do
There's still plenty of fixing and tweaking needed, don't think it's ready to merge to master yet, but a bit more work and it will be. For the time being, if people could have a look at it, find bugs and discuss language features and the like that would be ace.

I'll probably update this with more info as I remember, and I'll be pushing more commits up to here.