Skip to content

Commit 028369a

Browse files
committed
parse \ before ... in for loop
1 parent 5c5304c commit 028369a

File tree

1 file changed

+26
-2
lines changed

1 file changed

+26
-2
lines changed

src/com/millennialmedia/intellibot/psi/RobotLexer.java

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -415,18 +415,38 @@ private boolean isEllipsis(int position) {
415415
while (position < this.endOffset && (isWhitespace(position) || isNewLine(position))) {
416416
position++;
417417
}
418+
// support "..." in FOR loop body that begin with "\"
419+
//TODO: should there be superspace before "\"?
420+
if (isBackslash(position)) {
421+
position++;
422+
// between "\" and "...", at least one superspace
423+
if (!isSuperSpace(position)) {
424+
return false;
425+
}
426+
while (position < this.endOffset && (isWhitespace(position) || isNewLine(position))) {
427+
position++;
428+
}
429+
}
418430
return charAtEquals(position, '.') &&
419431
charAtEquals(position + 1, '.') &&
420432
charAtEquals(position + 2, '.') &&
421433
isSuperSpaceOrNewline(position + 3);
422434
}
423435

424436
private boolean isOnlyWhitespaceToPreviousLine(int position) {
425-
// TODO: "..." in FOR loop body that begin with "\"
437+
// support "..." in FOR loop body that begin with "\"
438+
boolean have_backslash = false;
426439
while (position >= 0 && !isNewLine(position)) {
427-
if (!isWhitespace(position)) {
440+
if (!isWhitespace(position) && !isBackslash((position))) {
428441
return false;
429442
}
443+
if (isBackslash(position)) {
444+
if (have_backslash || !isSuperSpace(position+1)) {
445+
return false;
446+
}
447+
have_backslash = true;
448+
}
449+
//TODO: should there be superspace before "\"?
430450
position--;
431451
}
432452
return true;
@@ -565,4 +585,8 @@ private boolean lookAheadForLoop() {
565585
return false;
566586
}
567587
}
588+
589+
private boolean isBackslash(int position) {
590+
return position < this.endOffset && this.buffer.charAt(position) == '\\';
591+
}
568592
}

0 commit comments

Comments
 (0)