Fix LPeg precedence for Lua dot operators#1
Open
xolox wants to merge 1 commit intostevedonovan:masterfrom
xolox:lpeg-precedence
Open
Fix LPeg precedence for Lua dot operators#1xolox wants to merge 1 commit intostevedonovan:masterfrom xolox:lpeg-precedence
xolox wants to merge 1 commit intostevedonovan:masterfrom
xolox:lpeg-precedence
Conversation
LPeg doesn't have a "longest match is preferred" rule which means that when the LPeg pattern "operator" in the Lua lexer first tries to match the Lua dot operator and then tries to match the double dot operator, the second match can never succeed because the first sub-pattern (the single dot) has already been matched and will be returned as a successful match. Because the single dot is already included in the last sub-pattern (the set of single-character operators) I've just removed the P '.' sub-pattern. I also removed the P prefixes because they're not needed (as long as an LPeg pattern is on the left side of the long expression of valid multi-character operators).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Hi Steve,
I saw your LuaMacro 2.4 announcement on luarocks-dev:
I seem to remember taking this shortcut in my original Lua lexer and indeed, I fixed the same bug in LXSH. Sorry about that :-). Anyway, I was curious how you changed it and think I found a minor bug in the change: The matching of the
.operator prevents the..operator from ever being matched. Here's the explanation I wrote in the commit message:In the 10 minutes I spend on this I didn't figure out how to install LuaMacro + run the tests (I've not used LuaMacro before), so please run them before merging my change to make sure I didn't break them with my suggested change :-].