uros-b commented on PR #58826:
URL: https://github.com/apache/spark/pull/58826#issuecomment-5683164642
Implementation: prefer a nested fragment over token-index arithmetic
```
return _input.LA(1) == '+' && _input.index() == _tokenStartCharIndex + 2;
```
This works in ANTLR 4.13.1: recursive BRACKETED_COMMENT stays in one
nextToken(), so _tokenStartCharIndex stays the outer /, and predicate edges are
not frozen into the DFA. The + 2 also survives speculative predicate eval,
which consumes the * of /* before calling isHint().
It still depends on lexer internals (_tokenStartCharIndex, the length of
'/*'). A grammar split makes the same rule obvious and leaves isHint() as
lookahead-only, like isValidDecimal():
```
BRACKETED_COMMENT
: '/*' {!isHint()}? COMMENT_BODY -> channel(HIDDEN)
;
fragment COMMENT_BODY
: (NESTED_BRACKETED_COMMENT | .)*? ('*/' | {markUnclosedComment();} EOF)
;
fragment NESTED_BRACKETED_COMMENT
: '/*' COMMENT_BODY
;
```
Nested /*+ never calls isHint(). Top-level /*+ still fails {!isHint()}? and
matches HENT_START. If you keep the index check, spell out that 2 is the length
of '/*'.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]