Skip to content

Commit 1d671d2

Browse files
committed
fixes from code review
1 parent 2a7d1fe commit 1d671d2

File tree

7 files changed

+26
-15
lines changed

7 files changed

+26
-15
lines changed

lib/coffeescript/grammar.js

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/coffeescript/lexer.js

Lines changed: 5 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/coffeescript/parser.js

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/coffeescript/rewriter.js

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/grammar.coffee

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -838,9 +838,9 @@ grammar =
838838
o 'Expression ^ Expression', -> new Op $2, $1, $3
839839
o 'Expression | Expression', -> new Op $2, $1, $3
840840
o 'Expression && Expression', -> new Op $2, $1, $3
841-
o 'Expression LEADING_&& Expression', -> new Op $2, $1, $3
841+
o 'Expression LEADING_AND Expression', -> new Op $2, $1, $3
842842
o 'Expression || Expression', -> new Op $2, $1, $3
843-
o 'Expression LEADING_|| Expression', -> new Op $2, $1, $3
843+
o 'Expression LEADING_OR Expression', -> new Op $2, $1, $3
844844
o 'Expression BIN? Expression', -> new Op $2, $1, $3
845845
o 'Expression RELATION Expression', ->
846846
if $2.charAt(0) is '!'
@@ -884,8 +884,8 @@ operators = [
884884
['left', '&']
885885
['left', '^']
886886
['left', '|']
887-
['left', '&&', 'LEADING_&&']
888-
['left', '||', 'LEADING_||']
887+
['left', '&&', 'LEADING_AND']
888+
['left', '||', 'LEADING_OR']
889889
['left', 'BIN?']
890890
['nonassoc', 'INDENT', 'OUTDENT']
891891
['right', 'YIELD']

src/lexer.coffee

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1301,7 +1301,13 @@ POSSIBLY_DIVISION = /// ^ /=?\s ///
13011301
# Other regexes.
13021302
HERECOMMENT_ILLEGAL = /\*\//
13031303
1304+
# When appearing at the beginning of a line, suppresses TERMINATOR and INDENT
1305+
# tokens. So unless the line is outdented, the line's tokens will appear (in the
1306+
# unrewritten token stream) to be a continuation of the previous line
13041307
LINE_CONTINUER = /// ^ \s* (?: , | \??\.(?![.\d]) | \??:: ) ///
1308+
1309+
# When appearing at the beginning of an indented line, causes a TERMINATOR token
1310+
# to be generated rather than an INDENT
13051311
INDENT_SUPPRESSOR = /// ^ \s* (?: and\s+(?!:)\S | or\s+(?!:)\S | && | \|\| ) ///
13061312
13071313
STRING_INVALID_ESCAPE = ///

src/rewriter.coffee

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -662,12 +662,12 @@ exports.Rewriter = class Rewriter
662662
@detectEnd i + 1, condition, action
663663
return 1
664664

665-
# Convert TERMINATOR followed by && or || into a single LEADING_&& or
666-
# LEADING_|| token to disambiguate grammar.
665+
# Convert TERMINATOR followed by && or || into a single LEADING_AND or
666+
# LEADING_OR token to disambiguate grammar.
667667
tagLeadingLogical: ->
668668
@scanTokens (token, i, tokens) ->
669669
return 1 unless token[0] is 'TERMINATOR' and tokens.length >= i + 2 and (operatorToken = tokens[i + 1])[0] in ['&&', '||']
670-
token[0] = "LEADING_#{operatorToken[0]}"
670+
token[0] = "LEADING_#{if operatorToken[0] is '&&' then 'AND' else 'OR'}"
671671
token[1] = operatorToken[1]
672672
token[2].last_line = operatorToken[2].last_line
673673
token[2].last_column = operatorToken[2].last_column

0 commit comments

Comments
 (0)