Note [prefix_minus in negLitPred and negHashLitPred]
We want to parse -1 as a single token, but x-1 as three tokens. So in negLitPred (and negHashLitPred) we require that we have a prefix occurrence of the minus sign. See Note [Whitespace-sensitive operator parsing] for a detailed definition of a prefix occurrence. The condition for a prefix occurrence of an operator is: not precededByClosingToken && followedByOpeningToken but we don't check followedByOpeningToken when parsing a negative literal. It holds simply because we immediately lex a literal after the minus.
References 1
- Whitespace-sensitive operator parsing GHC.Parser.Lexer
Referenced by 2
- GHC.Parser.Lexer call site ×2