     return false unless m: @chunk.match(regex)
     if m then m[index] else false
 
+  # Are we in the midst of an unfinished expression?
+  unfinished: ->
+    prev: @prev(2)
+    @value() and @value().match and @value().match(NO_NEWLINE) and
+      prev and (prev[0] isnt '.') and not @value().match(CODE)
+
 # There are no exensions to the core lexer by default.
 Lexer.extensions: []
 

# Tokens that, when immediately preceding a `WHEN`, indicate that the `WHEN`
# occurs at the start of a line. We disambiguate these from trailing whens to
# avoid an ambiguity in the grammar.
BEFORE_WHEN: ['INDENT', 'OUTDENT', 'TERMINATOR']

    tag: id.toUpperCase() if include(KEYWORDS, id) and
      not (include(ACCESSORS, @tag(0)) and not @prev().spaced)
    @identifier_error id  if include RESERVED, id
    tag: 'LEADING_WHEN'   if tag is 'WHEN' and include LINE_BREAK, @tag()
    @token(tag, id)
    @i += id.length
    true
