@@ -645,7 +645,8 @@ exports.Rewriter = class Rewriter
645
645
condition = (token , i ) ->
646
646
[tag ] = token
647
647
[prevTag ] = @tokens [i - 1 ]
648
- tag is ' TERMINATOR' or (tag is ' INDENT' and prevTag not in SINGLE_LINERS)
648
+ [nextTag ] = @tokens [i + 1 ] unless i is @tokens .length - 1
649
+ tag is ' TERMINATOR' and nextTag not in LEADING_LOGICAL or (tag is ' INDENT' and prevTag not in SINGLE_LINERS)
649
650
650
651
action = (token , i ) ->
651
652
if token[0 ] isnt ' INDENT' or (token .generated and not token .fromThen )
@@ -674,8 +675,8 @@ exports.Rewriter = class Rewriter
674
675
# LEADING_OR token to disambiguate grammar.
675
676
tagLeadingLogical : ->
676
677
@scanTokens (token , i , tokens ) ->
677
- return 1 unless token[0 ] is ' TERMINATOR' and tokens .length >= i + 2 and (operatorToken = tokens[i + 1 ])[0 ] in [ ' && ' , ' || ' ]
678
- token[0 ] = " LEADING_#{ if operatorToken[0 ] is ' && ' then ' AND ' else ' OR ' } "
678
+ return 1 unless token[0 ] is ' TERMINATOR' and tokens .length >= i + 2 and (operatorToken = tokens[i + 1 ])[0 ] in LEADING_LOGICAL
679
+ token[0 ] = " LEADING_#{ LEADING_LOGICAL_NAMES[ operatorToken[0 ]] } "
679
680
token[1 ] = operatorToken[1 ]
680
681
token[2 ].last_line = operatorToken[2 ].last_line
681
682
token[2 ].last_column = operatorToken[2 ].last_column
@@ -775,3 +776,8 @@ DISCARDED = ['(', ')', '[', ']', '{', '}', '.', '..', '...', ',', '=', '++', '--
775
776
' INTERPOLATION_START' , ' INTERPOLATION_END' , ' LEADING_WHEN' , ' OUTDENT' , ' PARAM_END' ,
776
777
' REGEX_START' , ' REGEX_END' , ' RETURN' , ' STRING_END' , ' THROW' , ' UNARY' , ' YIELD'
777
778
].concat IMPLICIT_UNSPACED_CALL .concat IMPLICIT_END .concat CALL_CLOSERS .concat CONTROL_IN_IMPLICIT
779
+
780
+ LEADING_LOGICAL_NAMES =
781
+ ' &&' : ' AND'
782
+ ' ||' : ' OR'
783
+ LEADING_LOGICAL = Object .keys LEADING_LOGICAL_NAMES
0 commit comments