antlr / grammars-v4

Grammars written for ANTLR v4; expectation that the grammars are free of actions.
MIT License
10.24k stars 3.71k forks source link

RightShift lexer rule eclipsing double template end character '>' #1753

Open romeo-cmd opened 4 years ago

romeo-cmd commented 4 years ago

I think lexer rule RightShift : '>>' unables matching rule simpletemplateid in the case where there are more than two levels of imbrication of simpletemplateid rule.

For instance, the explicit template instanciation template class MyTemplate1<MyTemplate2<MyClass>>; will not be recognized because symbol >> is matched with lexeme RightShift.

To correct it, I propose to change lexer rule RightShift : >> into parser rule rightshift : '>' '>' and change every reference to rule RightShift into a reference to rule rightshift.

Note: This problem might also happen with lexemes RightShiftAssign, LeftShift, and LeftShiftAssign but I think in practice it is impossible.

KvanTTT commented 4 years ago

Do you mean C++ grammar?

romeo-cmd commented 4 years ago

Yes, sorry.

KvanTTT commented 4 years ago

Yes, it makes sense. We have the same tokens for java, Objective-C grammars.

KvanTTT commented 4 years ago

Would you like to suggest a pull request with the fix?

romeo-cmd commented 4 years ago

Yes why not! How can I do it?

KvanTTT commented 4 years ago

See instructions here: https://help.github.com/en/github/collaborating-with-issues-and-pull-requests/about-pull-requests