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

Kotlin: Simplify regexes and name fixes #1326

Merged
merged 3 commits into from
Sep 9, 2019
Merged

Kotlin: Simplify regexes and name fixes #1326

merged 3 commits into from
Sep 9, 2019

Conversation

lordcodes
Copy link
Contributor

@lordcodes lordcodes commented Sep 9, 2019

Simplify the regex for matching names/identifiers in the Kotlin lexer.

Rather than having a regex for name with or without wrapped back-ticks, just have optional match for back-tick at start and end of the identifier.

Remove unnecessary id regex, when it just wrapped name into capture group.

Fix annotation matching, as it was surrounding the full name rule with @ and uppercase start. However, this meant it looked for back-ticks after the uppercase first character.

Locations that are matching for Name::Class token now look for class_name so expect capital first letter.

Remove @ from the name matcher, as there was already a separate rule to match annotations and marking them as Name::Decorator instead.

Fixes #1324

@pyrmont

Fix - Annotations, e.g. @deprecated or @`BacktickedAnnotation`
For Name::Class locations, specifically match the class name regex,
with a capital letter.
Copy link
Contributor

@pyrmont pyrmont left a comment

Choose a reason for hiding this comment

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

Thanks for this—looks pretty good!

lib/rouge/lexers/kotlin.rb Outdated Show resolved Hide resolved
@pyrmont pyrmont added the author-action The PR has been reviewed but action by the author is needed label Sep 9, 2019
@pyrmont pyrmont self-assigned this Sep 9, 2019
@pyrmont pyrmont merged commit 8031e83 into rouge-ruby:master Sep 9, 2019
@pyrmont
Copy link
Contributor

pyrmont commented Sep 9, 2019

@lordcodes Thanks for all your help on the Kotlin lexer recently! I think this is a great improvement on the clarity of the code :)

@pyrmont pyrmont removed the author-action The PR has been reviewed but action by the author is needed label Sep 9, 2019
@lordcodes lordcodes deleted the kotlin-simplify-regexes branch September 10, 2019 05:32
@lordcodes
Copy link
Contributor Author

@pyrmont Thank you. Happy to help! Great to see it cleaned up and so much more being highlighted!

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.

Rationalise regular expressions in Kotlin lexer
2 participants