This file is indexed.

/usr/lib/ruby/1.8/rd/rdblockparser.ry is in librd-ruby1.8 0.6.22-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
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
class RDParser

  preclow
    nonassoc DUMMY
    left     ITEMLISTLINE ENUMLISTLINE DESCLISTLINE METHODLISTLINE STRINGLINE
  prechigh

  token STRINGLINE ITEMLISTLINE ENUMLISTLINE DESCLISTLINE METHODLISTLINE
	WHITELINE SUBTREE HEADLINE INCLUDE INDENT DEDENT DUMMY

  rule
  document : blocks  { result = DocumentElement.new
		       add_children_to_element(result, *val[0])
                     }
	     |         {
                         raise ParseError,
                         "Error: file empty."
			  }
             ;
    blocks : blocks block  { result.concat(val[1]) }
           | block
           ;
    block : textblock	  { result = val }
          | verbatim      { result = val }
          | lists 
          | headline      { result = val }
          | include       { result = val }
          | WHITELINE     { result = [] }
          | SUBTREE       { result = val[0].blocks }
          ;

    headline : HEADLINE { # val[0] is like [level, title]
			  title = @inline_parser.parse(val[0][1])
			  result = Headline.new(val[0][0])
			  add_children_to_element(result, *title)
                          }
             ;
    include : INCLUDE { result = Include.new(val[0]) }
	    ;

    textblock : textblockcontent = DUMMY
			{ # val[0] is Array of String
			  content = cut_off(val[0]).join("")
			  contents = @inline_parser.parse(content)
			  result = TextBlock.new()
			  add_children_to_element(result, *contents)
                         }
              ;
    textblockcontent : textblockcontent STRINGLINE
				 { result.push(val[1]) }
                     | STRINGLINE { result = val }
                     ;

    verbatim : INDENT verbatimcontent DEDENT
			{ # val[1] is Array of String
			  content = cut_off(val[1])
			  result = Verbatim.new(content)
			  # imform to lexer.
			  @in_verbatim = false }
             ;
    verbatim_after_lists : verbatimcontent
			{ # val[0] is Array of String
			  content = cut_off(val[0])
			  result = Verbatim.new(content)
			  # imform to lexer.
			  @in_verbatim = false }
             ;
    verbatimcontent : verbatimcontent STRINGLINE
					{ result.push(val[1]) }
                    | verbatimcontent INDENT verbatimcontent DEDENT
 					{ result.concat(val[2]) }
                    | verbatimcontent WHITELINE
					{ result.push("\n") }
                    | STRINGLINE      { result = val
					# imform to lexer.
					@in_verbatim = true }
  		    ;

    list : itemlist
         | enumlist
         | desclist
         | methodlist
         ; 
    lists : lists2 = DUMMY
	  | INDENT lists2 DEDENT { result = val[1] }
	  | INDENT lists2 verbatim_after_lists DEDENT
		  		{ result = val[1].push(val[2]) }
	  ;

    lists2 : lists2 list { result.push(val[1]) }
	   | list	 { result = val }
	   ;

    itemlist :  itemlistitems  = DUMMY { 
                          result = ItemList.new
			  add_children_to_element(result, *val[0])
                           }
	 ;
    itemlistitems : itemlistitems itemlistitem
			{ result.push(val[1]) }
              | itemlistitem { result = val }
              ;
    itemlistitem : first_textblock_in_itemlist other_blocks_in_list DEDENT
		{ 
                  result = ItemListItem.new
		  add_children_to_element(result, val[0], *val[1])
                 }
                 ;

    enumlist :  enumlistitems  = DUMMY { 
                          result = EnumList.new
			  add_children_to_element(result, *val[0])
                           }
	 ;
    enumlistitems : enumlistitems enumlistitem
			{ result.push(val[1]) }
              | enumlistitem { result = val }
              ;
    enumlistitem : first_textblock_in_enumlist other_blocks_in_list DEDENT
		{ 
                  result = EnumListItem.new
		  add_children_to_element(result, val[0], *val[1])
                 }
                 ;
    
    desclist : desclistitems  = DUMMY { 
                          result = DescList.new
			  add_children_to_element(result, *val[0])
                           }
	 ;
    desclistitems : desclistitems desclistitem { 
			result.push(val[1]) }
              | desclistitem { result = val }
              ;
    desclistitem : DESCLISTLINE description_part DEDENT
			{ 
                          term = DescListItem::Term.new
                          term_contents = @inline_parser.parse(val[0].strip)
			  add_children_to_element(term, *term_contents)

			  result = DescListItem.new
                          set_term_to_element(result, term)
		          add_children_to_element(result, *val[1])
                         }
		 ;

    methodlist : methodlistitems  = DUMMY { 
                          result = MethodList.new
			  add_children_to_element(result, *val[0])
                           }
	 ;
    methodlistitems : methodlistitems methodlistitem
			{ result.push(val[1]) }
              | methodlistitem { result = val }
              ;
    methodlistitem : METHODLISTLINE description_part DEDENT
			{ 
			  term = MethodListItem::Term.new(val[0].strip)
			  result = MethodListItem.new
                          set_term_to_element(result, term)
			  add_children_to_element(result, *val[1])
			 }
		 ;

    description_part : whitelines textblock blocks_in_list
				 { result = [val[1]].concat(val[2]) }
		     | whitelines textblock { result = [val[1]] }
		     | whitelines INDENT blocks_in_list DEDENT
				{ result = val[2] }
		     | whitelines { result = [] }
		     ;

    blocks_in_list : blocks_in_list block_in_list { result.concat(val[1]) }
                   | block_in_list
                   ;
    block_in_list : textblock	    { result = val }
                  | verbatim        { result = val }
                  | lists
                  | WHITELINE       { result = [] }
                  ;
    whitelines  : whitelines2
  		| 
		;
    whitelines2 : WHITELINE whitelines2
		| WHITELINE
		;

    first_textblock_in_itemlist : ITEMLISTLINE textblockcontent

		{ content = cut_off([val[0]].concat(val[1])).join("")
		  contents = @inline_parser.parse(content)
                  result = TextBlock.new()
		  add_children_to_element(result, *contents)
                 }
				| ITEMLISTLINE

		{ content = cut_off([val[0]]).join("")
		  contents = @inline_parser.parse(content)
		  result = TextBlock.new()
		  add_children_to_element(result, *contents)
		}
				 ;
    first_textblock_in_enumlist : ENUMLISTLINE textblockcontent

		{ content = cut_off([val[0]].concat(val[1])).join("")
		  contents = @inline_parser.parse(content)
	          result = TextBlock.new()
		  add_children_to_element(result, *contents)
		 }
				 | ENUMLISTLINE

		{ content = cut_off([val[0]]).join("")
		  contents = @inline_parser.parse(content)
	          result = TextBlock.new()
		  add_children_to_element(result, *contents)
		 }
				 ;
    other_blocks_in_list : verbatim blocks_in_list 
				    { result = [val[0]].concat(val[1]) }
			 | lists blocks_in_list    { result.concat(val[1]) }
			 | WHITELINE blocks_in_list { result = val[1] }
			 | verbatim { result = val }
			 | lists
			 | WHITELINE { result = [] }
			 | { result = [] }
			 ;
end

---- inner
include ParserUtility

TMPFILE = ["rdtmp", $$, 0]

attr_reader :tree

def initialize
  @inline_parser = RDInlineParser.new(self)
end

def parse(src, tree)
  @src = src
  @src.push(false)
  # RDtree
  @tree = tree
  
  # @i: index(line no.) of src
  @i = 0
  # stack for current indentation
  @indent_stack = []
  # how indented.
  @current_indent = @indent_stack.join("")
  # RDParser for tmp src
  @subparser = nil
  # which part is in now
  @in_part = nil
  @part_content = []

  @in_verbatim = false

  @yydebug = true
  do_parse
end

def next_token
  # preprocessing
  # if it is not in RD part
  # => method
  while @in_part != "rd"
    line = @src[@i]
    @i += 1 # next line
    
    case line
    # src end
    when false
      return [false, false]
    # RD part begin
    when /^=begin\s*(?:\bRD\b.*)?\s*$/
      if @in_part # if in non-RD part
	@part_content.push(line)
      else
	@in_part = "rd"
	return [:WHITELINE, "=begin\n"] # <= for textblockand
      end
    # non-RD part begin
    when /^=begin\s+(\w+)/
      part = $1
      if @in_part # if in non-RD part
	@part_content.push(line)
      else
	@in_part = part if @tree.filter[part] # if filter exists
#	p "BEGIN_PART: #{@in_part}" # DEBUG
      end
    # non-RD part end
    when /^=end/
      if @in_part # if in non-RD part
#	p "END_PART: #{@in_part}" # DEBUG
	# make Part-in object
	part = RD::Part.new(@part_content.join(""), @tree, "r")
	@part_content.clear
	# call filter, part_out is output(Part object)
	part_out = @tree.filter[@in_part].call(part)
	
	if @tree.filter[@in_part].mode == :rd # if output is RD formated
	  subtree = parse_subtree(part_out.to_a)
	else # if output is target formated
	  basename = TMPFILE.join('.')
	  TMPFILE[-1] += 1
	  tmpfile = open(@tree.tmp_dir + "/" + basename + ".#{@in_part}", "w")
	  tmpfile.print(part_out)
	  tmpfile.close
	  subtree = parse_subtree(["=begin\n", "<<< #{basename}\n", "=end\n"])
	end
	@in_part = nil
	return [:SUBTREE, subtree]
      end
    else
      if @in_part # if in non-RD part
	@part_content.push(line)
      end
    end
  end

  @current_indent = @indent_stack.join("")
  line = @src[@i]
  case line
  when false
    if_current_indent_equal("") do
      [false, false]
    end
  when /^=end/
    if_current_indent_equal("") do
      @in_part = nil
      [:WHITELINE, "=end"] # MUST CHANGE??
    end
  when /^\s*$/
    @i += 1 # next line
    return [:WHITELINE, ':WHITELINE']
  when /^\#/  # comment line
    @i += 1 # next line
    self.next_token()
  when /^(={1,4})(?!=)\s*(?=\S)/, /^(\+{1,2})(?!\+)\s*(?=\S)/
    rest = $'                    # '
    rest.strip!
    mark = $1
    if_current_indent_equal("") do
      return [:HEADLINE, [Headline.mark_to_level(mark), rest]]
    end
  when /^<<<\s*(\S+)/
    file = $1
    if_current_indent_equal("") do
      suffix = file[-3 .. -1] 
      if suffix == ".rd" or suffix == ".rb"
	subtree = parse_subtree(get_included(file))
	[:SUBTREE, subtree]
      else
	[:INCLUDE, file]
      end
    end
  when /^(\s*)\*(\s*)/
    rest = $'                   # '
    newIndent = $2
    if_current_indent_equal($1) do
      if @in_verbatim
	[:STRINGLINE, line]
      else
	@indent_stack.push("\s" << newIndent)
	[:ITEMLISTLINE, rest]
      end
    end
  when /^(\s*)(\(\d+\))(\s*)/
    rest = $'                     # '
    mark = $2
    newIndent = $3
    if_current_indent_equal($1) do
      if @in_verbatim
	[:STRINGLINE, line]
      else
	@indent_stack.push("\s" * mark.size << newIndent)
	[:ENUMLISTLINE, rest]
      end
    end
  when /^(\s*):(\s*)/
    rest = $'                    # '
    newIndent = $2
    if_current_indent_equal($1) do
      if @in_verbatim
	[:STRINGLINE, line]
      else
	@indent_stack.push("\s" <<$2)
	[:DESCLISTLINE, rest]
      end
    end
  when /^(\s*)---(?!-|\s*$)/
    indent = $1
    rest = $'
    /\s*/ === rest
    term = $'
    new_indent = $&
    if_current_indent_equal(indent) do
      if @in_verbatim
	[:STRINGLINE, line]
      else
	@indent_stack.push("\s\s\s" + new_indent)
	[:METHODLISTLINE, term]
      end
    end
  when /^(\s*)/
    if_current_indent_equal($1) do
      [:STRINGLINE, line]
    end
  else
    raise "[BUG] parsing error may occured."
  end
end

=begin private
  --- RDParser#if_current_indent_equal(indent)
        if (({@current_indent == ((|indent|))})) then yield block, otherwise
        process indentation.
=end
# always @current_indent = @indent_stack.join("") 
def if_current_indent_equal(indent)
  indent = indent.sub(/\t/, "\s" * 8)
  if @current_indent == indent
    @i += 1 # next line
    yield
  elsif indent.index(@current_indent) == 0
    @indent_stack.push(indent[@current_indent.size .. -1])
    [:INDENT, ":INDENT"]
  else
    @indent_stack.pop
    [:DEDENT, ":DEDENT"]
  end
end
private :if_current_indent_equal

def cut_off(src)
  ret = []
  whiteline_buf = []
  line = src.shift
  /^\s*/ =~ line
  indent = Regexp.quote($&)
  ret.push($')                 # '
  while line = src.shift
    if /^(\s*)$/ =~ line
      whiteline_buf.push(line)
    elsif /^#{indent}/ =~ line
      unless whiteline_buf.empty?
	ret.concat(whiteline_buf)
	whiteline_buf.clear
      end
      ret.push($')            # '
    else
      raise "[BUG]: probably Parser Error while cutting off.\n"
    end
  end
  ret
end
private :cut_off

def set_term_to_element(parent, term)
#  parent.set_term_under_document_struct(term, @tree.document_struct)
  parent.set_term_without_document_struct(term)
end
private :set_term_to_element

def on_error( et, ev, _values )
  line = @src[@i]
  prv, cur, nxt = format_line_num(@i, @i+1, @i+2)
  
  raise ParseError, <<Msg

RD syntax error: line #{@i+1}:
  #{prv}  |#{@src[@i-1].chomp}
  #{cur}=>|#{@src[@i].chomp}
  #{nxt}  |#{@src[@i+1].chomp}

Msg
end

def line_index
  @i
end

def parse_subtree(src)
  @subparser = RD::RDParser.new() unless @subparser
  
  @subparser.parse(src, @tree)
end
private :parse_subtree

def get_included(file)
  included = ""
  @tree.include_path.each do |dir|
    file_name = dir + "/" + file
    if test(?e, file_name)
      included = IO.readlines(file_name)
      break
    end
  end
  included
end
private :get_included

def format_line_num(*args)
  width = args.collect{|i| i.to_s.length }.max
  args.collect{|i| sprintf("%#{width}d", i) }
end
private :format_line_num

---- header
require "rd/rdinlineparser.tab.rb"
require "rd/parser-util"

module RD
---- footer
end # end of module RD