Class RDoc::Fortran95parser
In: parsers/parse_f95.rb
Parent: Object

See rdoc/parsers/parse_f95.rb

Methods

new   scan  

Classes and Modules

Class RDoc::Fortran95parser::Fortran95Definition

Constants

COMMENTS_ARE_UPPER = false  
"false":Comments are below source code
"true" :Comments are upper source code
INTERNAL_ALIAS_MES = "Alias for"   Internal alias message
EXTERNAL_ALIAS_MES = "The entity is"   External alias message

Public Class methods

prepare to parse a Fortran 95 file

[Source]

     # File parsers/parse_f95.rb, line 453
453:     def initialize(top_level, file_name, body, options, stats)
454:       @body = body
455:       @stats = stats
456:       @file_name  = file_name
457:       @options = options
458:       @top_level = top_level
459:       @progress = $stderr unless options.quiet
460:     end

Public Instance methods

devine code constructs

[Source]

     # File parsers/parse_f95.rb, line 463
463:     def scan
464: 
465:       # remove private comment
466:       remaining_code = remove_private_comments(@body)
467: 
468:       # continuation lines are united to one line
469:       remaining_code = united_to_one_line(remaining_code)
470: 
471:       # collect comment for file entity
472:       whole_comment, remaining_code = collect_first_comment(remaining_code)
473:       @top_level.comment = whole_comment
474: 
475:       # "module" parts are parsed
476:       #
477:       while remaining_code =~ /^\s*?module\s+(\w+)\s*?(!.*?)?$(.*?)^\s*?end\s+module.*?$/im
478:         remaining_code = $~.pre_match
479:         remaining_code << $~.post_match
480:         module_code = remove_empty_head_lines($&)
481:         module_name = $1
482:         f9x_trailing = find_comments($2)
483:         next if f9x_trailing =~ /^:nodoc:/
484:         progress "m"
485:         @stats.num_modules += 1
486:         f9x_module = @top_level.add_module NormalClass, module_name
487:         f9x_module.record_location @top_level
488: 
489:         f9x_comment = COMMENTS_ARE_UPPER ? 
490:           find_comments($~.pre_match)  + "\n" + f9x_trailing :
491:             f9x_trailing + "\n" + find_comments(module_code.sub(/^.*$\n/i, ''))
492:         f9x_module.comment = f9x_comment
493:         parse_program_or_module(f9x_module, module_code)
494: 
495:         TopLevel.all_files.each do |name, toplevel|
496:           if toplevel.include_includes?(module_name, @options.ignore_case)
497:             if !toplevel.include_requires?(@file_name, @options.ignore_case)
498:               toplevel.add_require(Require.new(@file_name, ""))
499:             end
500:           end
501:           toplevel.each_classmodule{|m|
502:             if m.include_includes?(module_name, @options.ignore_case)
503:               if !m.include_requires?(@file_name, @options.ignore_case)
504:                 m.add_require(Require.new(@file_name, ""))
505:               end
506:             end
507:           }
508:         end
509:       end
510: 
511:       # "program" parts are parsed
512:       #
513:       # contains 以下の内部サブルーチンが存在するなど,
514:       # サブプログラムの集まりとは少々違うため.
515:       #
516:       while remaining_code =~ /^\s*?program\s+(\w+)\s*?(!.*?)?$(.*?)^\s*?end\s+program.*?$/im
517:         remaining_code = $~.pre_match
518:         remaining_code << $~.post_match
519:         program_code = remove_empty_head_lines($&)
520:         progress "p"
521:         program_name = $1
522:         program_trailing = find_comments($2)
523:         program_comment = COMMENTS_ARE_UPPER ? 
524:           find_comments($~.pre_match) + "\n" + program_trailing : 
525:             program_trailing + "\n" + find_comments(program_code.sub(/^.*$\n/i, ''))
526:         program_comment = "\n\n= <i>Program</i> <tt>#{program_name}</tt>\n\n" \
527:                           + program_comment
528:         @top_level.comment << program_comment
529:         parse_program_or_module(@top_level, program_code, :private)
530:       end
531: 
532:       # External subprograms and functions are parsed
533:       #
534:       # 単一のファイル内において program や module に格納されない,
535:       # 外部サブルーチン, 外部関数部分の解析.
536:       #
537:       parse_program_or_module(@top_level, remaining_code, :public, true)
538: 
539:       @top_level
540:     end

[Validate]