@@ -60,7 +60,7 @@ private static String getTokeLineText(Parser recognizer, Token token) {
6060 TokenStream tokenStream = recognizer .getTokenStream ();
6161 int index = token .getTokenIndex ();
6262 // search for line start
63- int tokenIndex = index - 1 ;
63+ int tokenIndex = index ;
6464 int start = -1 ;
6565 while (tokenIndex >= 0 ) {
6666 Token t = tokenStream .get (tokenIndex );
@@ -72,7 +72,7 @@ private static String getTokeLineText(Parser recognizer, Token token) {
7272 }
7373
7474 // search for line stop
75- tokenIndex = index + 1 ;
75+ tokenIndex = index ;
7676 int stop = -1 ;
7777 while (tokenIndex < tokenStream .size ()) {
7878 Token t = tokenStream .get (tokenIndex );
@@ -82,14 +82,13 @@ private static String getTokeLineText(Parser recognizer, Token token) {
8282 }
8383 tokenIndex ++;
8484 }
85-
8685 return token .getInputStream ().getText (Interval .of (start , stop ));
8786 }
8887
8988 private static void handlePythonSyntaxError (Parser recognizer , RecognitionException e ) {
9089 Token offendingToken = e .getOffendingToken ();
9190 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' , ' ' ) + "^" ;
9392 String pythonSyntaxErrorMessage = "\n " + LINE_PADDING + lineText + "\n " + LINE_PADDING + errorMarker ;
9493
9594 RecognitionException re = e ;
0 commit comments