@@ -129,16 +129,6 @@ exports.Rewriter = class Rewriter
129129 @ detectEnd i + 1 , condition, action if token[0 ] is ' INDEX_START'
130130 1
131131
132- tagLeadingLogical : ->
133- @scanTokens (token , i , tokens ) ->
134- return 1 unless token[0 ] is ' TERMINATOR' and tokens .length >= i + 2 and (operatorToken = tokens[i + 1 ])[0 ] in [' &&' , ' ||' ]
135- token[0 ] = " LEADING_#{ operatorToken[0 ]} "
136- token[1 ] = operatorToken[1 ]
137- token[2 ].last_line = operatorToken[2 ].last_line
138- token[2 ].last_column = operatorToken[2 ].last_column
139- tokens .splice i + 1 , 1
140- 1
141-
142132 # Match tags in token stream starting at `i` with `pattern`.
143133 # `pattern` may consist of strings (equality), an array of strings (one of)
144134 # or null (wildcard). Returns the index of the match or -1 if no match.
@@ -672,6 +662,18 @@ exports.Rewriter = class Rewriter
672662 @ detectEnd i + 1 , condition, action
673663 return 1
674664
665+ # Convert TERMINATOR followed by && or || into a single LEADING_&& or
666+ # LEADING_|| token to disambiguate grammar.
667+ tagLeadingLogical : ->
668+ @scanTokens (token , i , tokens ) ->
669+ 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 ]} "
671+ token[1 ] = operatorToken[1 ]
672+ token[2 ].last_line = operatorToken[2 ].last_line
673+ token[2 ].last_column = operatorToken[2 ].last_column
674+ tokens .splice i + 1 , 1
675+ 1
676+
675677 # Generate the indentation tokens, based on another token on the same line.
676678 indentation : (origin ) ->
677679 indent = [' INDENT' , 2 ]
0 commit comments