Improve type.Table. Validate types.

Depends on #24.

### Type:
* Rewrite of `Table`:
  * Don't create new `Type` objects; reuse AST nodes.
  * Store type info using only dictionaries; leverage `__eq__` and `__hash__` of the respective AST nodes.
  * Simplify code: use `try` blocks instead of double checking.
  * Allow cross-referencing of user-defined types and constructors to ease type inference.
* Add type validation.
* Fix bad line info in error message.

### Tests:
* Add complete suite of unit tests for `type` module.
If a position is required here, it must be set when the `ast.Ref` references the `ast.Array`.