Skip to content
This repository has been archived by the owner on Sep 8, 2023. It is now read-only.

Commit

Permalink
Fix handling of ::class in Kotlin lexer (rouge-ruby#1572)
Browse files Browse the repository at this point in the history
Due to the way the Kotlin lexer treats the 'class' keyword, the use of
the callable reference, `::class`, can result in the lexer moving into
an incorrect state where it interprets `class` as beginning a class
definition. This commit fixes that bug.

Co-authored-by: Michael Camilleri <mike@inqk.net>
  • Loading branch information
2 people authored and mattt committed May 19, 2021
1 parent 3f2a70d commit 889ccbc
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions lib/rouge/lexers/kotlin.rb
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,9 @@ class Kotlin < RegexLexer
rule %r'/[*].*[*]/', Comment::Multiline # single line block comment
rule %r'/[*].*', Comment::Multiline, :comment # multiline block comment
rule %r'\n', Text
rule %r'(::)(class)' do
groups Operator, Keyword
end
rule %r'::|!!|\?[:.]', Operator
rule %r"(\.\.)", Operator
# Number literals
Expand Down

0 comments on commit 889ccbc

Please sign in to comment.