major overhaul of parser: now implements a real AST. See documentation.md