This file is indexed.

/usr/lib/ruby/vendor_ruby/rugments/lexers/sml.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
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
module Rugments
  module Lexers
    class SML < RegexLexer
      title 'SML'
      desc 'Standard ML'
      tag 'sml'
      aliases 'ml'
      filenames '*.sml', '*.sig', '*.fun'

      mimetypes 'text/x-standardml', 'application/x-standardml'

      def self.keywords
        @keywords ||= Set.new %w(
          abstype and andalso as case datatype do else end exception
          fn fun handle if in infix infixr let local nonfix of op open
          orelse raise rec then type val with withtype while
          eqtype functor include sharing sig signature struct structure
          where
        )
      end

      def self.symbolic_reserved
        @symbolic_reserved ||= Set.new %w(: | = => -> # :>)
      end

      id = /[\w']+/i
      symbol = %r{[!%&$#/:<=>?@\\~`^|*+-]+}

      def self.analyze_text(_text)
        0
      end

      state :whitespace do
        rule /\s+/m, Text
        rule /[(][*]/, Comment, :comment
      end

      state :delimiters do
        rule /[(\[{]/, Punctuation, :main
        rule /[)\]}]/, Punctuation, :pop!

        rule /\b(let|if|local)\b(?!')/, Keyword::Reserved do
          push; push
        end

        rule /\b(struct|sig|while)\b(?!')/ do
          token Keyword::Reserved
          push
        end

        rule /\b(do|else|end|in|then)\b(?!')/, Keyword::Reserved, :pop!
      end

      def token_for_id_with_dot(id)
        if self.class.keywords.include? id
          Error
        else
          Name::Namespace
        end
      end

      def token_for_final_id(id)
        if self.class.keywords.include?(id) || self.class.symbolic_reserved.include?(id)
          Error
        else
          Name
        end
      end

      def token_for_id(id)
        if self.class.keywords.include? id
          Keyword::Reserved
        elsif self.class.symbolic_reserved.include? id
          Punctuation
        else
          Name
        end
      end

      state :core do
        rule /[()\[\]{},;_]|[.][.][.]/, Punctuation
        rule /#"/, Str::Char, :char
        rule /"/, Str::Double, :string
        rule /~?0x[0-9a-fA-F]+/, Num::Hex
        rule /0wx[0-9a-fA-F]+/, Num::Hex
        rule /0w\d+/, Num::Integer
        rule /~?\d+([.]\d+)?[eE]~?\d+/, Num::Float
        rule /~?\d+[.]\d+/, Num::Float
        rule /~?\d+/, Num::Integer

        rule /#\s*[1-9][0-9]*/, Name::Label
        rule /#\s*#{id}/, Name::Label
        rule /#\s+#{symbol}/, Name::Label

        rule /\b(datatype|abstype)\b(?!')/, Keyword::Reserved, :dname
        rule(/(?=\bexception\b(?!'))/) { push :ename }
        rule /\b(functor|include|open|signature|structure)\b(?!')/,
             Keyword::Reserved, :sname
        rule /\b(type|eqtype)\b(?!')/, Keyword::Reserved, :tname

        rule /'#{id}/, Name::Decorator
        rule /(#{id})([.])/ do |m|
          groups(token_for_id_with_dot(m[1]), Punctuation)
          push :dotted
        end

        rule id do |m|
          token token_for_id(m[0])
        end

        rule symbol do |m|
          token token_for_id(m[0])
        end
      end

      state :dotted do
        rule /(#{id})([.])/ do |m|
          groups(token_for_id_with_dot(m[1]), Punctuation)
        end

        rule id do |m|
          token token_for_id(m[0])
          pop!
        end

        rule symbol do |m|
          token token_for_id(m[0])
          pop!
        end
      end

      state :root do
        rule /#!.*?\n/, Comment::Preproc
        rule(//) { push :main }
      end

      state :main do
        mixin :whitespace

        rule /\b(val|and)\b(?!')/, Keyword::Reserved, :vname
        rule /\b(fun)\b(?!')/ do
          token Keyword::Reserved
          goto :main_fun
          push :fname
        end

        mixin :delimiters
        mixin :core
      end

      state :main_fun do
        mixin :whitespace
        rule /\b(fun|and)\b(?!')/, Keyword::Reserved, :fname
        rule /\bval\b(?!')/ do
          token Keyword::Reserved
          goto :main
          push :vname
        end

        rule /[|]/, Punctuation, :fname
        rule /\b(case|handle)\b(?!')/ do
          token Keyword::Reserved
          goto :main
        end

        mixin :delimiters
        mixin :core
      end

      state :has_escapes do
        rule /\\[\\"abtnvfr]/, Str::Escape
        rule /\\\^[\x40-\x5e]/, Str::Escape
        rule /\\[0-9]{3}/, Str::Escape
        rule /\\u\h{4}/, Str::Escape
        rule /\\\s+\\/, Str::Interpol
      end

      state :string do
        rule /[^"\\]+/, Str::Double
        rule /"/, Str::Double, :pop!
        mixin :has_escapes
      end

      state :char do
        rule /[^"\\]+/, Str::Char
        rule /"/, Str::Char, :pop!
        mixin :has_escapes
      end

      state :breakout do
        rule /(?=\w+\b(#{SML.keywords.to_a.join('|')})\b(?!'))/ do
          pop!
        end
      end

      state :sname do
        mixin :whitespace
        mixin :breakout
        rule id, Name::Namespace
        rule(//) { pop! }
      end

      state :has_annotations do
        rule /'[\w']*/, Name::Decorator
        rule /[(]/, Punctuation, :tyvarseq
      end

      state :fname do
        mixin :whitespace
        mixin :has_annotations

        rule id, Name::Function, :pop!
        rule symbol, Name::Function, :pop!
      end

      state :vname do
        mixin :whitespace
        mixin :has_annotations

        rule /(#{id})(\s*)(=(?!#{symbol}))/m do
          groups Name::Variable, Text, Punctuation
          pop!
        end

        rule /(#{symbol})(\s*)(=(?!#{symbol}))/m do
          groups Name::Variable, Text, Punctuation
        end

        rule id, Name::Variable, :pop!
        rule symbol, Name::Variable, :pop!

        rule(//) { pop! }
      end

      state :tname do
        mixin :whitespace
        mixin :breakout
        mixin :has_annotations

        rule /'[\w']*/, Name::Decorator
        rule /[(]/, Punctuation, :tyvarseq

        rule %r{=(?!#{symbol})} do
          token Punctuation
          goto :typbind
        end

        rule id, Keyword::Type
        rule symbol, Keyword::Type
      end

      state :typbind do
        mixin :whitespace

        rule /\b(and)\b(?!')/ do
          token Keyword::Reserved
          goto :tname
        end

        mixin :breakout
        mixin :core
      end

      state :dname do
        mixin :whitespace
        mixin :breakout
        mixin :has_annotations

        rule /(=)(\s*)(datatype)\b/ do
          groups Punctuation, Text, Keyword::Reserved
          pop!
        end

        rule %r{=(?!#{symbol})} do
          token Punctuation
          goto :datbind
          push :datcon
        end

        rule id, Keyword::Type
        rule symbol, Keyword::Type
      end

      state :datbind do
        mixin :whitespace
        rule /\b(and)\b(?!')/ do
          token Keyword::Reserved; goto :dname
        end
        rule /\b(withtype)\b(?!')/ do
          token Keyword::Reserved; goto :tname
        end
        rule /\bof\b(?!')/, Keyword::Reserved
        rule /([|])(\s*)(#{id})/ do
          groups(Punctuation, Text, Name::Class)
        end

        rule /([|])(\s+)(#{symbol})/ do
          groups(Punctuation, Text, Name::Class)
        end

        mixin :breakout
        mixin :core
      end

      state :ename do
        mixin :whitespace
        rule /(exception|and)(\s+)(#{id})/ do
          groups Keyword::Reserved, Text, Name::Class
        end

        rule /(exception|and)(\s*)(#{symbol})/ do
          groups Keyword::Reserved, Text, Name::Class
        end

        rule /\b(of)\b(?!')/, Keyword::Reserved
        mixin :breakout
        mixin :core
      end

      state :datcon do
        mixin :whitespace
        rule id, Name::Class, :pop!
        rule symbol, Name::Class, :pop!
      end

      state :tyvarseq do
        mixin :whitespace
        rule /'[\w']*/, Name::Decorator
        rule id, Name
        rule /,/, Punctuation
        rule /[)]/, Punctuation, :pop!
        rule symbol, Name
      end

      state :comment do
        rule /[^(*)]+/, Comment::Multiline
        rule /[(][*]/ do
          token Comment::Multiline; push
        end
        rule /[*][)]/, Comment::Multiline, :pop!
        rule /[(*)]/, Comment::Multiline
      end
    end
  end
end