/usr/lib/ruby/vendor_ruby/rugments/token.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 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 | module Rugments
class Token
class << self
attr_reader :name
attr_reader :parent
attr_reader :shortname
def cache
@cache ||= {}
end
def sub_tokens
@sub_tokens ||= {}
end
def [](qualname)
return qualname unless qualname.is_a?(::String)
Token.cache[qualname]
end
def inspect
"<Token #{qualname}>"
end
def matches?(other)
other.token_chain.include? self
end
def token_chain
@token_chain ||= ancestors.take_while { |x| x != Token }.reverse
end
def qualname
@qualname ||= token_chain.map(&:name).join('.')
end
def register!
Token.cache[qualname] = self
parent.sub_tokens[name] = self
end
def make_token(name, shortname, &b)
parent = self
Class.new(parent) do
@parent = parent
@name = name
@shortname = shortname
register!
class_eval(&b) if b
end
end
def token(name, shortname, &b)
tok = make_token(name, shortname, &b)
const_set(name, tok)
end
def each_token(&b)
Token.cache.each do |(_, t)|
b.call(t)
end
end
end
module Tokens
def self.token(name, shortname, &b)
tok = Token.make_token(name, shortname, &b)
const_set(name, tok)
end
# IMPORTANT:
# For compatibility, this list must be kept in sync with
# pygments.token.STANDARD_TYPES
# please see https://github.com/jayferd/rouge/wiki/List-of-tokens
token :Text, '' do
token :Whitespace, 'w'
end
token :Error, 'err'
token :Other, 'x'
token :Keyword, 'k' do
token :Constant, 'kc'
token :Declaration, 'kd'
token :Namespace, 'kn'
token :Pseudo, 'kp'
token :Reserved, 'kr'
token :Type, 'kt'
token :Variable, 'kv'
end
token :Name, 'n' do
token :Attribute, 'na'
token :Builtin, 'nb' do
token :Pseudo, 'bp'
end
token :Class, 'nc'
token :Constant, 'no'
token :Decorator, 'nd'
token :Entity, 'ni'
token :Exception, 'ne'
token :Function, 'nf'
token :Property, 'py'
token :Label, 'nl'
token :Namespace, 'nn'
token :Other, 'nx'
token :Tag, 'nt'
token :Variable, 'nv' do
token :Class, 'vc'
token :Global, 'vg'
token :Instance, 'vi'
end
end
token :Literal, 'l' do
token :Date, 'ld'
token :String, 's' do
token :Backtick, 'sb'
token :Char, 'sc'
token :Doc, 'sd'
token :Double, 's2'
token :Escape, 'se'
token :Heredoc, 'sh'
token :Interpol, 'si'
token :Other, 'sx'
token :Regex, 'sr'
token :Single, 's1'
token :Symbol, 'ss'
end
token :Number, 'm' do
token :Float, 'mf'
token :Hex, 'mh'
token :Integer, 'mi' do
token :Long, 'il'
end
token :Oct, 'mo'
token :Bin, 'mb'
token :Other, 'mx'
end
end
token :Operator, 'o' do
token :Word, 'ow'
end
token :Punctuation, 'p' do
token :Indicator, 'pi'
end
token :Comment, 'c' do
token :Doc, 'cd'
token :Multiline, 'cm'
token :Preproc, 'cp'
token :Single, 'c1'
token :Special, 'cs'
end
token :Generic, 'g' do
token :Deleted, 'gd'
token :Emph, 'ge'
token :Error, 'gr'
token :Heading, 'gh'
token :Inserted, 'gi'
token :Output, 'go'
token :Prompt, 'gp'
token :Strong, 'gs'
token :Subheading, 'gu'
token :Traceback, 'gt'
token :Lineno, 'gl'
end
# convenience
Num = Literal::Number
Str = Literal::String
end
end
end
|