Method: RDoc::Parser::C#gen_body_table

Defined in:
lib/rdoc/parser/c.rb

#gen_body_table(file_content) ⇒ Object

Generate a Ruby-method table



575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
# File 'lib/rdoc/parser/c.rb', line 575

def gen_body_table file_content
  table = {}
  file_content.scan(%r{
    ((?>/\*.*?\*/\s*)?)
    ((?:\w+\s+){0,2} VALUE\s+(\w+)
      \s*(?:\([^\)]*\))(?:[^\);]|$))
  | ((?>/\*.*?\*/\s*))^\s*(\#\s*define\s+(\w+)\s+(\w+))
  | ^\s*\#\s*define\s+(\w+)\s+(\w+)
  }xm) do
    case
    when name = $3
      table[name] = [:func_def, $1, $2, $~.offset(2)] if !(t = table[name]) || t[0] != :func_def
    when name = $6
      table[name] = [:macro_def, $4, $5, $~.offset(5), $7] if !(t = table[name]) || t[0] == :macro_alias
    when name = $8
      table[name] ||= [:macro_alias, $9]
    end
  end
  table
end