$brackets definition in HLL::Grammar has duplicate bracket pairs
tbrowder opened this issue · comments
Variable $brackets is a string composed of bracket pairs of chars. There are some duplicated pairs.
The leading pairs are shown in their actual form inside apostrophes while the remainder are shown as a concatenated string of paired hex codepoints. When the formed chars are converted to their hex codepoints, it becomes obvious there are duplicate pairs (they match the first eight codepoints). Unless there is a reason for it, the duplicate pairs should be removed; otherwise, the reason should be documented near the definition.
The visible pairs:
'<>[](){}'
Their hex codepoints:
"\x[003C]\x[003E]\x[005B]\x[005D]\x[0028]\x[0029]\x[007B]\x[007D]"
Fixed with 30593cdc28 Thanks for the spot!
Well, if that's the case... the first 4 pairs are still the first 4 pairs, just in a slightly different order
Shall we order the pairs by the left bracket codepoint? I have already created a new table with the order as is. But it's easy to reorder if need be.
Problem with that approach is that we either would need two tables (one for openers, one for closers), or we would always need to include the length of the array in the calculation on where to find the closer for a given opener.
So if we're refactoring this, I think having two tables would make the most sense, as the index of the opener would be the index for the closer.
Of course with appropriate documentation that these two lists should be in sync :-)
I probably confused the issue. I was talking about a table for the docs, not changing the HLL::Grammar. I always meant that docs table as a user reference for finding valid bracket pairs. I know it was always kind of worthless as a table of openers only, but I wasn't smart enough to find the HLL::Grammar $brackets string at the time--my primary motivation was to generate a complex table.