 # blocks, so it doesn't need to.
 # ')' can close a single-line block, but we need to make sure it's balanced.
 re::add_implicit_indentation: ->
-  this.scan_tokens (prev, token, post, i) =>
+  @scan_tokens (prev, token, post, i) =>
     return 1 unless SINGLE_LINERS.indexOf(token[0]) >= 0 and post[0] isnt 'INDENT' and
       not (token[0] is 'ELSE' and post[0] is 'IF')
     starter: token[0]
-    this.tokens.splice(i + 1, 0, ['INDENT', 2, token[2]])
+    @tokens.splice(i + 1, 0, ['INDENT', 2, token[2]])
     idx: i + 1
     parens: 0
     while true
       idx += 1
-      tok: this.tokens[idx]
+      tok: @tokens[idx]
       if (not tok or SINGLE_CLOSERS.indexOf(tok[0]) >= 0 or
           (tok[0] is ')' && parens is 0)) and
           not (starter is 'ELSE' and tok[0] is 'ELSE')
-        insertion: if this.tokens[idx - 1][0] is "," then idx - 1 else idx
-        this.tokens.splice(insertion, 0, ['OUTDENT', 2, token[2]])
+        insertion: if @tokens[idx - 1][0] is "," then idx - 1 else idx
+        @tokens.splice(insertion, 0, ['OUTDENT', 2, token[2]])
         break
       parens += 1 if tok[0] is '('
       parens -= 1 if tok[0] is ')'
     return 1 unless token[0] is 'THEN'
-    this.tokens.splice(i, 1)
+    @tokens.splice(i, 1)
     return 0
 
 # Ensure that all listed pairs of tokens are correctly balanced throughout
 # the course of the token stream.
 re::ensure_balance: (pairs) ->
   levels: {}
-  this.scan_tokens (prev, token, post, i) =>
+  @scan_tokens (prev, token, post, i) =>
     for pair in pairs
       [open, close]: pair
       levels[open] ||= 0

# Leading newlines would introduce an ambiguity in the grammar, so we
# dispatch them here.
re::remove_leading_newlines: ->
  this.tokens.shift() if this.tokens[0][0] is 'TERMINATOR'

# Some blocks occur in the middle of expressions -- when we're expecting
# this, remove their trailing newlines.
re::remove_mid_expression_newlines: ->
  this.scan_tokens (prev, token, post, i) =>
    return 1 unless post and EXPRESSION_CLOSE.indexOf(post[0]) >= 0 and token[0] is 'TERMINATOR'
    this.tokens.splice(i, 1)
    return 0

# Make sure that we don't accidentally break trailing commas, which need
# to go on the outside of expression closers.
re::move_commas_outside_outdents: ->
  this.scan_tokens (prev, token, post, i) =>
    this.tokens.splice(i, 1, token) if token[0] is 'OUTDENT' and prev[0] is ','
    return 1

# We've tagged the opening parenthesis of a method call, and the opening

# deal with them.
re::add_implicit_parentheses: ->
  stack: [0]
  @scan_tokens (prev, token, post, i) =>
    stack.push(0) if token[0] is 'INDENT'
    if token[0] is 'OUTDENT'
      last: stack.pop()
