Class | RDoc::Fortran95parser |
In: |
parsers/parse_f95.rb
|
Parent: | Object |
COMMENTS_ARE_UPPER | = | false |
|
|||||
INTERNAL_ALIAS_MES | = | "Alias for" | Internal alias message | |||||
EXTERNAL_ALIAS_MES | = | "The entity is" | External alias message |
prepare to parse a Fortran 95 file
# File parsers/parse_f95.rb, line 386 386: def initialize(top_level, file_name, body, options, stats) 387: @body = body 388: @stats = stats 389: @file_name = file_name 390: @options = options 391: @top_level = top_level 392: @progress = $stderr unless options.quiet 393: end
devine code constructs
# File parsers/parse_f95.rb, line 396 396: def scan 397: 398: # remove private comment 399: remaining_code = remove_private_comments(@body) 400: 401: # continuation lines are united to one line 402: remaining_code = united_to_one_line(remaining_code) 403: 404: # collect comment for file entity 405: whole_comment, remaining_code = collect_first_comment(remaining_code) 406: @top_level.comment = whole_comment 407: 408: # "module" parts are parsed 409: # 410: while remaining_code =~ /^\s*?module\s+(\w+)\s*?(!.*?)?$(.*?)^\s*?end\s+module.*?$/im 411: remaining_code = $~.pre_match 412: remaining_code << $~.post_match 413: module_code = remove_empty_head_lines($&) 414: module_name = $1 415: f9x_trailing = find_comments($2) 416: next if f9x_trailing =~ /^:nodoc:/ 417: progress "m" 418: @stats.num_modules += 1 419: f9x_module = @top_level.add_module NormalClass, module_name 420: f9x_module.record_location @top_level 421: 422: f9x_comment = COMMENTS_ARE_UPPER ? 423: find_comments($~.pre_match) + "\n" + f9x_trailing : 424: f9x_trailing + "\n" + find_comments(module_code.sub(/^.*$\n/i, '')) 425: f9x_module.comment = f9x_comment 426: parse_program_or_module(f9x_module, module_code) 427: 428: TopLevel.all_files.each do |name, toplevel| 429: if toplevel.include_includes?(module_name, @options.ignore_case) 430: if !toplevel.include_requires?(@file_name, @options.ignore_case) 431: toplevel.add_require(Require.new(@file_name, "")) 432: end 433: end 434: toplevel.each_classmodule{|m| 435: if m.include_includes?(module_name, @options.ignore_case) 436: if !m.include_requires?(@file_name, @options.ignore_case) 437: m.add_require(Require.new(@file_name, "")) 438: end 439: end 440: } 441: end 442: end 443: 444: # "program" parts are parsed 445: # 446: # contains 以下の内部サブルーチンが存在するなど, 447: # サブプログラムの集まりとは少々違うため. 448: # 449: while remaining_code =~ /^\s*?program\s+(\w+)\s*?(!.*?)?$(.*?)^\s*?end\s+program.*?$/im 450: remaining_code = $~.pre_match 451: remaining_code << $~.post_match 452: program_code = remove_empty_head_lines($&) 453: progress "p" 454: program_name = $1 455: program_trailing = find_comments($2) 456: program_comment = COMMENTS_ARE_UPPER ? 457: find_comments($~.pre_match) + "\n" + program_trailing : 458: program_trailing + "\n" + find_comments(program_code.sub(/^.*$\n/i, '')) 459: program_comment = "\n\n= <i>Program</i> <tt>#{program_name}</tt>\n\n" \ 460: + program_comment 461: @top_level.comment << program_comment 462: parse_program_or_module(@top_level, program_code, :private) 463: end 464: 465: # External subprograms and functions are parsed 466: # 467: # 単一のファイル内において program や module に格納されない, 468: # 外部サブルーチン, 外部関数部分の解析. 469: # 470: parse_program_or_module(@top_level, remaining_code, :public, true) 471: 472: @top_level 473: end