Skip to content

Commit

Permalink
Fix handling of ::class in Kotlin lexer (#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 <[email protected]>
  • Loading branch information
contradictioned and pyrmont authored Sep 8, 2020
1 parent f039145 commit eef2a4f
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 eef2a4f

Please sign in to comment.