/usr/lib/ruby/vendor_ruby/rugments/lexers/java.rb is in ruby-rugments 1.0.0~beta8-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 | module Rugments
module Lexers
class Java < RegexLexer
title 'Java'
desc 'The Java programming language (java.com)'
tag 'java'
filenames '*.java'
mimetypes 'text/x-java'
keywords = %w(
assert break case catch continue default do else finally for
if goto instanceof new return switch this throw try while
)
declarations = %w(
abstract const enum extends final implements native private protected
public static strictfp super synchronized throws transient volatile
)
types = %w(boolean byte char double float int long short void)
id = /[a-zA-Z_][a-zA-Z0-9_]*/
state :root do
rule %r{^
(\s*(?:[a-zA-Z_][a-zA-Z0-9_.\[\]]*\s+)+?) # return arguments
([a-zA-Z_][a-zA-Z0-9_]*) # method name
(\s*)(\() # signature start
}mx do |m|
# TODO: do this better, this shouldn't need a delegation
delegate Java, m[1]
token Name::Function, m[2]
token Text, m[3]
token Punctuation, m[4]
end
rule /\s+/, Text
rule %r{//.*?$}, Comment::Single
rule %r{/\*.*?\*/}m, Comment::Multiline
rule /@#{id}/, Name::Decorator
rule /(?:#{keywords.join('|')})\b/, Keyword
rule /(?:#{declarations.join('|')})\b/, Keyword::Declaration
rule /(?:#{types.join('|')})\b/, Keyword::Type
rule /package\b/, Keyword::Namespace
rule /(?:true|false|null)\b/, Keyword::Constant
rule /(?:class|interface)\b/, Keyword::Declaration, :class
rule /import\b/, Keyword::Namespace, :import
rule /"(\\\\|\\"|[^"])*"/, Str
rule /'(?:\\.|[^\\]|\\u[0-9a-f]{4})'/, Str::Char
rule /(\.)(#{id})/ do
groups Operator, Name::Attribute
end
rule /#{id}:/, Name::Label
rule /\$?#{id}/, Name
rule /[~^*!%&\[\](){}<>\|+=:;,.\/?-]/, Operator
rule /[0-9][0-9]*\.[0-9]+([eE][0-9]+)?[fd]?/, Num::Float
rule /0x[0-9a-f]+/, Num::Hex
rule /[0-9]+L?/, Num::Integer
# rule /\n/, Text
end
state :class do
rule /\s+/m, Text
rule id, Name::Class, :pop!
end
state :import do
rule /\s+/m, Text
rule /[a-z0-9_.]+\*?/i, Name::Namespace, :pop!
end
end
end
end
|