Repeated string pattern: difference between the FrontEnd and WolframScript?
The notebook interface and the kernel have different parsers, because the notebook needs to manipulate the input before the kernel sees it for a variety of reasons. There are many differences between the two parsers. It has not been a priority to Wolfram to fix the differences.
I have been trying to catalog the differences here (rendered as a webpage here). Most differences are semantically equivalent, but some are meaningful, as you have discovered.
I suspect, much to my chagrin, that the FE is right and the InputForm parser is wrong. For one thing, the kernel itself thinks that parens are needed for Repeated
:
Repeated[Pattern[x,Blank[]]]//InputForm
(*(x_)..*)
The reason it breaks in the FE is that the FE treats the x_. as a single token: RowBox[{"x_.", "."}]
. And that's absolutely correct: see tutorial/OperatorInputForms and the section "Spaces to Avoid", because "x_." is a "special input form". On the other hand, .. is a normal operator, so it is another token. For example a.. is RowBox[{"a", ".."}]
. So the question is whether "x_.." should be RowBox[{"x_.","."}]
or RowBox[{"x_",".."}]
. And what happens if something is added after the second dot? Now, according the precednece tables, forms involving _
have higher precedence than pretty much any operator (MessageName seems to be the lone exception). In which case the FE is doing the right thing. I'll ruminate and discuss some more whether that's the resolution, but this is clearly a bug one way or the other.
P.S. We do take these differences seriously, especially when easily typable input parses differently in the two contexts.