antlr / grammars-v4

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

[pcre] parse of octal is wrong #3687

Closed kaby76 closed 1 year ago

kaby76 commented 1 year ago

According to this, the priority of backreference should be moved to the top in order to parse octal literals correctly.

Note, in my opinion, I don't think the suggested fix is correct. The problem is that the grammar is ambiguous. Just because Antlr4 allows you to fix ambiguity by alt reordering does not mean you should.

_There's an extra level of complexity with the rule atom with the addition of "shared_literal", "sharedatom", "literal", etc. The result is that ambiguity.

I would have kept atom flat with respect to the "shared" rules, i.e., unfold these rules into "atom" then remove the ambiguity--and not by reordering the alts.

bkiers commented 1 year ago

This can be closed since the grammar has been updated (and the issue was also resolved along the way): https://github.com/antlr/grammars-v4/pull/3690

kaby76 commented 1 year ago

This will be fixed with merge of https://github.com/antlr/grammars-v4/pull/3690.