Skip to content
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 solidity lexer not picking up many of the operators (e.g. boolean and) #2292

Merged
merged 2 commits into from
Dec 3, 2022

Conversation

f0rki
Copy link
Contributor

@f0rki f0rki commented Dec 3, 2022

I noticed that the lexer for Solidity would not pick up boolean operators. Odd that nobody noticed this. To fix it I switched to the same regex for operators in the solidity lexer as in the CFamilyLexer. I updated the testcase with a function that covers all the operators I am aware of.

@@ -59,7 +59,7 @@ class SolidityLexer(RegexLexer):
(datatype, Keyword.Type),
include('constants'),
(r'[a-zA-Z_]\w*', Text),
(r'[!<=>+*/-]', Operator),
(r'[~!%^&*+=|?:<>/-]', Operator),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

: is now recognized as both Operator and Punctuation - which makes more sense?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good catch. it is somewhat ambiguous. : can be used in the shorthand if operator a ? b : c or also in structs like {x : y}. I would stick with Operator.

@birkenfeld birkenfeld added the changelog-update Items which need to get mentioned in the changelog label Dec 3, 2022
@birkenfeld
Copy link
Member

Thanks! Tests are happy too, so let's go.

@birkenfeld birkenfeld merged commit e9703b7 into pygments:master Dec 3, 2022
@Anteru Anteru added this to the 2.14.0 milestone Dec 30, 2022
@Anteru Anteru removed the changelog-update Items which need to get mentioned in the changelog label Dec 30, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants