Most of the ambiguity would be solved if you wrote an ast tree directly, like in scratch (or even lisp).
I would still consider the link above editing text... but I posted it anyway for what it is worth.
The idea seems to be to confine the text to its AST in a form like fashion.