@@ -60,7 +60,7 @@ private static String getTokeLineText(Parser recognizer, Token token) {
60
60
TokenStream tokenStream = recognizer .getTokenStream ();
61
61
int index = token .getTokenIndex ();
62
62
// search for line start
63
- int tokenIndex = index - 1 ;
63
+ int tokenIndex = index ;
64
64
int start = -1 ;
65
65
while (tokenIndex >= 0 ) {
66
66
Token t = tokenStream .get (tokenIndex );
@@ -72,7 +72,7 @@ private static String getTokeLineText(Parser recognizer, Token token) {
72
72
}
73
73
74
74
// search for line stop
75
- tokenIndex = index + 1 ;
75
+ tokenIndex = index ;
76
76
int stop = -1 ;
77
77
while (tokenIndex < tokenStream .size ()) {
78
78
Token t = tokenStream .get (tokenIndex );
@@ -82,14 +82,13 @@ private static String getTokeLineText(Parser recognizer, Token token) {
82
82
}
83
83
tokenIndex ++;
84
84
}
85
-
86
85
return token .getInputStream ().getText (Interval .of (start , stop ));
87
86
}
88
87
89
88
private static void handlePythonSyntaxError (Parser recognizer , RecognitionException e ) {
90
89
Token offendingToken = e .getOffendingToken ();
91
90
String lineText = getTokeLineText (recognizer , offendingToken );
92
- String errorMarker = new String (new char [offendingToken .getCharPositionInLine () + 1 ]).replace ('\0' , ' ' ) + "^" ;
91
+ String errorMarker = new String (new char [offendingToken .getCharPositionInLine ()]).replace ('\0' , ' ' ) + "^" ;
93
92
String pythonSyntaxErrorMessage = "\n " + LINE_PADDING + lineText + "\n " + LINE_PADDING + errorMarker ;
94
93
95
94
RecognitionException re = e ;
0 commit comments