In fact, the kernel always sends the position of the first syntax error to the input line in FrontEnd (if this input line contains an error). This can be demonstrated with the following MathLink code:
In[32]:= link = LinkLaunch[First[$CommandLine] <> " -mathlink"]; LinkRead[link]; LinkWrite[link, EnterTextPacket["2+"]] LinkRead[link] LinkRead[link] LinkRead[link] Out[35]= MessagePacket[Syntax, "sntxi"] Out[36]= TextPacket["Syntax::sntxi: Incomplete expression; more input is needed. "] Out[37]= SyntaxPacket[5]
An integer in SyntaxPacket "indicates the position at which a syntax error was detected in the input string" as described in the documentation. At first it is puzzling that this position in the case of the input string â 2+ â is obviously outside the input string. But it seems that in fact this position is calculated for the InputForm line of the input line, which in this case is equal to: " 2+\n\n ".
We can check how this works with $SyntaxHandler , defined as follows:
In[41]:= link = LinkLaunch[First[$CommandLine] <> " -mathlink"]; LinkRead[link] LinkWrite[link, EnterTextPacket[ "$SyntaxHandler= Function[{str,pos}, Print["Input string: ",ToString[str,InputForm]]; Print["Position of syntax error: ",pos]; $Failed ]; "]] LinkRead[link] LinkWrite[link, EnterTextPacket["2+"]] While[Head[packet = LinkRead[link]] =!= InputNamePacket, Print[packet]]; Print[packet] Out[42]= InputNamePacket["In[1]:= "] Out[44]= InputNamePacket["In[2]:= "] During evaluation of In[41]:= MessagePacket[Syntax,sntxi] During evaluation of In[41]:= TextPacket[Syntax::sntxi: Incomplete expression; more input is needed. ] During evaluation of In[41]:= TextPacket[Input string: "2+\n\n" ] During evaluation of In[41]:= TextPacket[Position of syntax error: 6 ] During evaluation of In[41]:= SyntaxPacket[5] During evaluation of In[41]:= InputNamePacket[In[2]:= ]
You can see inconsistency between the positions of the same syntax error reported by SyntaxPacket and $SyntaxHandler . But it seems possible to understand how they calculate the position: both use the InputForm input line and the position before the input line is number 0 for $SyntaxHandler and number 1 in the case of SyntaxPacket . Thus, we can define $SyntaxHandler to get an accurate visual representation of the position of the syntax error inside the input string ( Cell input must have the RawInputForm style ) as follows:
$SyntaxHandler = Function[{str, pos}, Print["Input string: ", ToString[str, InputForm], "\n", "Position of syntax error: ", pos, "\n", StringInsert[ToString[str, InputForm], ToString[Style["\[DownArrowBar]", Red, Background -> Yellow], StandardForm], pos + 2]]; $Failed];
Once again, I emphasize that the input cell MUST have a "RawInputForm" style! Such a cell can be created by creating a regular empty input cell and then converting it to the "RawInputForm" cell using the appropriate command in the menu Cell -> Convert To .
Let's see how it works:

The reason we should use the "RawInputForm" cell is probably applied by $SyntaxHandler ony, when the input is sent to the kernel as a String rather than Boxes , as it happens with the default StandardForm input cells.