Skip to content

Commit

Permalink
fixed jashkenas#1102; lexer: cleaned up unfinished
Browse files Browse the repository at this point in the history
  • Loading branch information
satyr committed Sep 6, 2011
1 parent 036fc56 commit 2ea51b0
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 16 deletions.
8 changes: 3 additions & 5 deletions lib/coffee-script/lexer.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 2 additions & 11 deletions src/lexer.coffee
Expand Up @@ -489,9 +489,8 @@ exports.Lexer = class Lexer
# Are we in the midst of an unfinished expression?
unfinished: ->
LINE_CONTINUER.test(@chunk) or
(prev = last @tokens, 1) and prev[0] isnt '.' and
(value = @value()) and not value.reserved and
NO_NEWLINE.test(value) and not CODE.test(value) and not ASSIGNED.test(@chunk)
@tag() in ['\\', '.', '?.', 'UNARY', 'MATH', '+', '-', 'SHIFT', 'RELATION'
'COMPARE', 'LOGIC', 'COMPOUND_ASSIGN', 'THROW', 'EXTENDS']

# Converts newlines for string literals.
escapeLines: (str, heredoc) ->
Expand Down Expand Up @@ -610,18 +609,10 @@ HEREDOC_INDENT = /\n+([^\n\S]*)/g

HEREDOC_ILLEGAL = /\*\//

ASSIGNED = /^\s*@?([$A-Za-z_][$\w\x7f-\uffff]*|['"].*['"])[^\n\S]*?[:=][^:=>]/

LINE_CONTINUER = /// ^ \s* (?: , | \??\.(?![.\d]) | :: ) ///

TRAILING_SPACES = /\s+$/

NO_NEWLINE = /// ^ (?: # non-capturing group
[-+*&|/%=<>!.\\][<>=&|]* | # symbol operators
and | or | is(?:nt)? | n(?:ot|ew) | # word operators
delete | typeof | instanceof
) $ ///

# Compound assignment tokens.
COMPOUND_ASSIGN = [
'-=', '+=', '/=', '*=', '%=', '||=', '&&=', '?=', '<<=', '>>=', '>>>=', '&=', '^=', '|='
Expand Down
4 changes: 4 additions & 0 deletions test/operators.coffee
Expand Up @@ -243,3 +243,7 @@ test "#1234: Applying a splat to :: applies the splat to the wrong object", ->

arr = []
eq nonce, C::method arr... # should be applied to `C::`

test "#1102: String literal prevents line continuation", ->
eq "': '", '' +
"': '"

0 comments on commit 2ea51b0

Please sign in to comment.