New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix llvm highlighting of variables with :
in name
#54405
base: master
Are you sure you want to change the base?
Conversation
:
in name
@@ -353,7 +353,7 @@ const llvm_types = | |||
const llvm_cond = r"^(?:[ou]?eq|[ou]?ne|[uso][gl][te]|ord|uno)$" # true|false | |||
|
|||
function print_llvm_tokens(io, tokens) | |||
m = match(r"^((?:[^\s:]+:)?)(\s*)(.*)", tokens) | |||
m = match(r"^((?:[^(%\")\s:]+:)?)(\s*)(.*)", tokens) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
m = match(r"^((?:[^(%\")\s:]+:)?)(\s*)(.*)", tokens) | |
m = match(r"^((?:[^%@][^\s:]*:)?)(\s*)(.*)", tokens) |
⚠MY SUGGESTION IS NOT TESTED
I have my doubts if your regex is what you intended.
I think it is clearer in intent that it is not a variable, i.e., it does not start with %
and @
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Indeed, this didn't match the sequence %"
but rather either one of (%")
. I updated with matching the %
at the beginning and added a case of string labels which is valid.
This comment was marked as outdated.
This comment was marked as outdated.
Sorry, something went wrong.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, what I am referring to is either one of:
bla-bla: ; pred = %"another%block"
br label %"another%block"
"another%block": ; pred = %bla-bla
br label %bla-bla
Sorry, I meant matching %
as actually not matching it (using [^%]
), in the end I just removed %
from the set of allowed character for the first case (bla-bla
style).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of using an banlist, we could also use the following pattern:
what do you think?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We do not need a formal parser or lexer, since we can assume that the output of code_llvm
is syntactically correct.
There are no formal assurances, but we can easily fix the problem, as we can do with this PR.
7043136
to
837a63c
Compare
This prevents values with `:` in their name to be printed as labels.
837a63c
to
75b6237
Compare
Co-authored-by: kimikage <kimikage.ceo@gmail.com>
@kimikage does this look OK to you now? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Note that this approval does not mean that it has been cross-checked, since it is in effect my suggestion.
This prevents values with
:
in their name to be printed as labels.Before
After