/usr/lib/ruby/vendor_ruby/rugments/lexers/r.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 | module Rugments
module Lexers
class R < RegexLexer
title 'R'
desc 'The R statistics language (r-project.org)'
tag 'r'
aliases 'r', 'R', 's', 'S'
filenames '*.R', '*.S', '.Rhistory', '.Rprofile'
mimetypes 'text/x-r-source', 'text/x-r', 'text/x-R'
mimetypes 'text/x-r', 'application/x-r'
def self.keywords
@keywords ||= %w(
if else for while repeat in next break return switch function
)
end
def self.analyze_text(text)
return 1 if text.shebang? 'Rscript'
return 0.1 if text.include? '->'
end
state :root do
rule /#.*?\n/, Comment::Single
rule /\s+/m, Text
rule /[.]?[a-zA-Z_][\w.]*/ do |m|
if self.class.keywords.include? m[0]
token Keyword
else
token Name
end
end
rule /`.*?`/, Str::Backtick
rule /'(\\.|.)*?'/m, Str::Single
rule /"(\\.|.)*?"/m, Str::Double
rule /\b(NULL|Inf|TRUE|FALSE|NaN)\b/, Keyword::Constant
rule /\bNA(_(integer|real|complex|character)_)?\b/,
Keyword::Constant
rule /\b[TF]\b/, Keyword::Variable
rule /0[xX][a-fA-F0-9]+([pP][0-9]+)?[Li]?/, Num::Hex
rule /[+-]?(\d+([.]\d+)?|[.]\d+)([eE][+-]?\d+)?[Li]?/,
Num
rule /[\[\]{}();,]/, Punctuation
rule %r{[-<>?*+^/!=~$@:%&|]}, Operator
rule /[.][.][.]/, Keyword
end
end
end
end
|