From 4f892455707311c03eaad69fca119eefb6908313 Mon Sep 17 00:00:00 2001 From: Jeremy Ashkenas Date: Mon, 11 Oct 2010 16:34:16 -0400 Subject: [PATCH] NEXT_ELLPSIS.test --- lib/lexer.js | 7 +++---- src/lexer.coffee | 5 ++--- 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/lib/lexer.js b/lib/lexer.js index 7db86d46..487a423d 100644 --- a/lib/lexer.js +++ b/lib/lexer.js @@ -235,7 +235,7 @@ return true; }; Lexer.prototype.lineToken = function() { - var _ref2, diff, indent, match, nextCharacter, nextEllipsis, noNewlines, prev, size; + var diff, indent, match, nextCharacter, noNewlines, prev, size; if (!(match = MULTI_DENT.exec(this.chunk))) { return false; } @@ -245,8 +245,7 @@ prev = last(this.tokens, 1); size = indent.length - 1 - indent.lastIndexOf('\n'); nextCharacter = NEXT_CHARACTER.exec(this.chunk)[1]; - nextEllipsis = (((_ref2 = NEXT_ELLIPSIS.exec(this.chunk)) != null) ? _ref2[1] : undefined); - noNewlines = (('.' === nextCharacter || ',' === nextCharacter) && !nextEllipsis) || this.unfinished(); + noNewlines = (('.' === nextCharacter || ',' === nextCharacter) && !NEXT_ELLIPSIS.test(this.chunk)) || this.unfinished(); if (size - this.indebt === this.indent) { if (noNewlines) { return this.suppressNewlines(); @@ -616,7 +615,7 @@ HEREDOC_INDENT = /\n+([ \t]*)/g; ASSIGNED = /^\s*@?[$A-Za-z_][$\w]*[ \t]*?[:=][^:=>]/; NEXT_CHARACTER = /^\s*(\S?)/; - NEXT_ELLIPSIS = /^\s*(\.\.\.?)/; + NEXT_ELLIPSIS = /^\s*\.\.\.?/; LEADING_SPACES = /^\s+/; TRAILING_SPACES = /\s+$/; NO_NEWLINE = /^(?:[-+*&|\/%=<>!.\\][<>=&|]*|and|or|is(?:nt)?|n(?:ot|ew)|delete|typeof|instanceof)$/; diff --git a/src/lexer.coffee b/src/lexer.coffee index b9c22362..a9adbce5 100644 --- a/src/lexer.coffee +++ b/src/lexer.coffee @@ -237,8 +237,7 @@ exports.Lexer = class Lexer prev = last @tokens, 1 size = indent.length - 1 - indent.lastIndexOf '\n' nextCharacter = NEXT_CHARACTER.exec(@chunk)[1] - nextEllipsis = NEXT_ELLIPSIS.exec(@chunk)?[1] - noNewlines = (nextCharacter in ['.', ','] and not nextEllipsis) or @unfinished() + noNewlines = (nextCharacter in ['.', ','] and not NEXT_ELLIPSIS.test(@chunk)) or @unfinished() if size - @indebt is @indent return @suppressNewlines() if noNewlines return @newlineToken indent @@ -579,7 +578,7 @@ MULTILINER = /\n/g HEREDOC_INDENT = /\n+([ \t]*)/g ASSIGNED = /^\s*@?[$A-Za-z_][$\w]*[ \t]*?[:=][^:=>]/ NEXT_CHARACTER = /^\s*(\S?)/ -NEXT_ELLIPSIS = /^\s*(\.\.\.?)/ +NEXT_ELLIPSIS = /^\s*\.\.\.?/ LEADING_SPACES = /^\s+/ TRAILING_SPACES = /\s+$/ NO_NEWLINE = /// ^