/usr/lib/ruby/vendor_ruby/rugments/lexers/io.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 | module Rugments
module Lexers
class IO < RegexLexer
tag 'io'
title 'Io'
desc 'The IO programming language (http://iolanguage.com)'
mimetypes 'text/x-iosrc'
filenames '*.io'
def self.analyze_text(text)
return 1 if text.shebang? 'io'
end
def self.constants
@constants ||= Set.new %w(nil false true)
end
def self.builtins
@builtins ||= Set.new %w(
args call clone do doFile doString else elseif for if list
method return super then
)
end
state :root do
rule /\s+/m, Text
rule %r{//.*?\n}, Comment::Single
rule %r{#.*?\n}, Comment::Single
rule %r{/(\\\n)?[*].*?[*](\\\n)?/}m, Comment::Multiline
rule %r{/[+]}, Comment::Multiline, :nested_comment
rule /"(\\\\|\\"|[^"])*"/, Str
rule %r{:?:=}, Keyword
rule /[()]/, Punctuation
rule %r([-=;,*+><!/|^.%&\[\]{}]), Operator
rule /[A-Z]\w*/, Name::Class
rule /[a-z_]\w*/ do |m|
name = m[0]
if self.class.constants.include? name
token Keyword::Constant
elsif self.class.builtins.include? name
token Name::Builtin
else
token Name
end
end
rule %r{(\d+[.]?\d*|\d*[.]\d+)(e[+-]?[0-9]+)?}i, Num::Float
rule /\d+/, Num::Integer
rule /@@?/, Keyword
end
state :nested_comment do
rule %r{[^/+]+}m, Comment::Multiline
rule %r{/[+]}, Comment::Multiline, :nested_comment
rule %r{[+]/}, Comment::Multiline, :pop!
end
end
end
end
|