aseba-community/aseba — pull request #108 by vaussard (2012-07-26 09:30:37+00:00)
Title: Vectorial syntax tree to parse generalized expressions

The current abstract syntax tree (later AST) generated by the parser is limited to the Aseba instruction set and lead to a number of hacks to implement new features. To overcome this, this set of patches implement an intermediate AST, where all expressions are considered to apply on vectors.

Two new classes have been defined: ImmediateVectorNode extends ImmediateNode by providing a N-element vector for integers. MemoryVectorNode is a generalization of StoreNode / LoadNode / ArrayWriteNode / ArrayReadNode to access the memory as a vector.

When expanding this vectorial AST to a regular Aseba tree, vectors are first checked for size consistency. A tree operating on vectors of N-element will finally extends to N-tree of 1-element operations. When expanding the tree, several substitution can occur before reaching the final state. This greatly simply the parser for cases like "foo++", and even extend such operations to vectors for free.

A mechanism to allocate temporary variable (limited to the context of the current statement) is also implemented.

As a result, following operations are now possible:

```
var i[] = [1,2,3]
var j[3] = i
var k[5]

k[0:2] = i
k[3:4] = j[0:1] + [1,1]
k++
k[i[0]+1]++

call math.add(i, j + k[0:2], [3,2,1])

emit myevent [1,1,1]*k[1:3]
```