function TemplateVisitor() {
  this.frameStack = [];
  this.actions = [];
  this.programDepth = -1;
}
Takes in an AST and outputs a list of actions to be consumed
by a compiler. For example, the template

    foo{{bar}}<div>baz</div>

produces the actions

    [['startProgram', [programNode, 0]],
     ['text', [textNode, 0, 3]],
     ['mustache', [mustacheNode, 1, 3]],
     ['openElement', [elementNode, 2, 3, 0]],
     ['text', [textNode, 0, 1]],
     ['closeElement', [elementNode, 2, 3],
     ['endProgram', [programNode]]]

This visitor walks the AST depth first and backwards. As
a result the bottom-most child template will appear at the
top of the actions list whereas the root template will appear
at the bottom of the list. For example,

    <div>{{#if}}foo{{else}}bar<b></b>{{/if}}</div>

produces the actions

    [['startProgram', [programNode, 0]],
     ['text', [textNode, 0, 2, 0]],
     ['openElement', [elementNode, 1, 2, 0]],
     ['closeElement', [elementNode, 1, 2]],
     ['endProgram', [programNode]],
     ['startProgram', [programNode, 0]],
     ['text', [textNode, 0, 1]],
     ['endProgram', [programNode]],
     ['startProgram', [programNode, 2]],
     ['openElement', [elementNode, 0, 1, 1]],
     ['block', [blockNode, 0, 1]],
     ['closeElement', [elementNode, 0, 1]],
     ['endProgram', [programNode]]]

The state of the traversal is maintained by a stack of frames.
Whenever a node with children is entered (either a ProgramNode
or an ElementNode) a frame is pushed onto the stack. The frame
contains information about the state of the traversal of that
node. For example,

  - index of the current child node being visited
  - the number of mustaches contained within its child nodes
  - the list of actions generated by its child nodes