Apex parser doesn't properly recognize "/**/"

Issue #1991 resolved
Dr. Alexander Hug created an issue

Hello,

I often find the characters /**/ somewhere in existing code. This line just means nothing, just an “optical” divider.
IC interprets this string as a starting and/or ending point for a comment block, hence the following code is grayed out, and will cause “not found” issues along the project.

Quick fix is to either remove or extend the string to /***/, and everything is fine.

Thank you, Alexander

Comments (5)

  1. Scott Wells repo owner

    Interesting. Yes, the issue is that IC2's lexer is tokenizing that as an unterminated documentation comment, i.e., /** not followed by */. I tried a few very simple changes to the lexer to accommodate this pattern, but (probably getting into "more than you wanted to know" territory here), because of the specific way the lexer rules for block comments are structured to allow for both block comments and documentation comments, and both of those being temporarily unterminated, it's not quite as easy as just adding a special case for /**/ or even updating the rule for doc comment to be /**[^/].

    As a result, while this is definitely a lexer bug, given that it's not affecting many users (surprisingly this is the first time I've seen it reported), and given that it's not a trivial fix, and finally given that it has a reasonable workaround of changing /**/ to /***/, this one probably won't be fixed in the near future. I will keep it open, though, as I hate having lexer/parser bugs. This one will sit in the back of my head for a while, and then one day I'll have had enough and will come back to it and figure it out.

  2. Log in to comment