Support Ruby method names and operator overrides, including Unicode#1531
Merged
Anteru merged 3 commits intopygments:masterfrom Feb 14, 2021
Merged
Support Ruby method names and operator overrides, including Unicode#1531Anteru merged 3 commits intopygments:masterfrom
Anteru merged 3 commits intopygments:masterfrom
Conversation
Fixes pygments#253 This patch contains these changes: * Add 50+ new Ruby tests for method name/operator override matching. * Unicode method names are now supported (pygments#253). * `=` method name postfixes are now supported. * These operator overrides are now supported: `<`, `<=`, `!` `!@`, `~@`, `!`, `!=`, `!~`, `=~` * The `<>` "operator" override is removed. It appears that this was a typo in the regular expression (`<=?>` should have been `<=>?`). Syntax verified with https://docs.ruby-lang.org/en/2.7.0/syntax/methods_rdoc.html
Anteru
requested changes
Sep 4, 2020
Contributor
Author
|
I needed to use the \u Unicode escapes, so the r prefix wasn't desirable on that line...and then I overlooked standardizing the rest of the lines.
Is it acceptable to remove the r prefix from all of the lines in the multi-line string literal block?
…On September 4, 2020 7:29:01 PM UTC, "Matthäus G. Chajdas" ***@***.***> wrote:
@Anteru requested changes on this pull request.
> @@ -328,9 +328,13 @@ def intp_string_callback(self, match, ctx):
],
'funcname': [
(r'\(', Punctuation, 'defexpr'),
- (r'(?:([a-zA-Z_]\w*)(\.))?'
- r'([a-zA-Z_]\w*[!?]?|\*\*?|[-+]@?|'
- r'[/%&|^`~]|\[\]=?|<<|>>|<=?>|>=?|===?)',
+ (r'(?:([a-zA-Z_]\w*)(\.))?' # optional scope name, like "self."
+ '('
+ '[a-zA-Z\u0080-\uffff][a-zA-Z0-9_\u0080-\uffff]*[!?=]?' # method name
+ '|!=|!~|=~|\\*\\*?|[-+!~]@?|[/%&|^]|<=>|<[<=]?|>[>=]?|===?' # or operator override
+ r'|\[\]=?' # or element reference/assignment override
+ '|`' # or the undocumented backtick override
Any particular reason for mixing raw and non-raw strings here? I'd prefer to have everything consistent (i.e. `r'...'`) because it makes editing less error prone.
--
You are receiving this because you authored the thread.
Reply to this email directly or view it on GitHub:
#1531 (review)
|
Collaborator
|
Thanks a lot, merged! |
This was referenced Mar 8, 2021
This was referenced Mar 12, 2021
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.
Fixes #253
This patch contains these changes:
=method name postfixes are now supported.<,<=,!!@,~@,!,!=,!~,=~<>"operator" override is removed. It appears that this wasa typo in the regular expression (
<=?>should have been<=>?).Syntax verified with https://docs.ruby-lang.org/en/2.7.0/syntax/methods_rdoc.html