   # Insert the missing braces here, so that the parser doesn't have to.
   addImplicitBraces: ->
     stack = []
-    @scanTokens (prev, token, post, i) =>
+    @scanTokens (token, i) =>
       if include EXPRESSION_START, token[0]
-        stack.push(if (token[0] is 'INDENT' and (prev and prev[0] is '{')) then '{' else token[0])
+        stack.push(if (token[0] is 'INDENT' and (@tag(i - 1) is '{')) then '{' else token[0])
       if include EXPRESSION_END, token[0]
         stack.pop()
       last = stack[stack.length - 1]
-      before = @tokens[i - 2]
       if token[0] is ':' and (not last or last[0] isnt '{')
         stack.push '{'
-        idx = if before and before[0] is '@' then i - 2 else i - 1
+        idx = if @tag(i - 2) is '@' then i - 2 else i - 1
         @tokens.splice idx, 0, ['{', '{', token[2]]
         condition = (token, i) ->
           [one, two, three] = @tokens.slice(i + 1, i + 4)

  # Massage newlines and indentations so that comments don't have to be
  # correctly indented, or appear on a line of their own.
  adjustComments: ->
    @scanTokens (prev, token, post, i) =>
      return 1 unless token[0] is 'HERECOMMENT'
      [before, after] = [@tokens[i - 2], @tokens[i + 2]]
      if after and after[0] is 'INDENT'
        @tokens.splice i + 2, 1
        if before and before[0] is 'OUTDENT' and post and prev[0] is post[0] is 'TERMINATOR'

    i = 0
    loop
      break unless @tokens[i]
      move = block @tokens[i], i
      i += move
    true

