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 359
359:     def initialize(top_level, file_name, body, options, stats)
360:       @body = body
361:       @stats = stats
362:       @file_name  = file_name
363:       @options = options
364:       @top_level = top_level
365:       @progress = $stderr unless options.quiet
366:     end

Public Instance methods

devine code constructs

[Source]

     # File parsers/parse_f95.rb, line 369
369:     def scan
370: 
371:       # remove private comment
372:       remaining_code = remove_private_comments(@body)
373: 
374:       # continuation lines are united to one line
375:       remaining_code = united_to_one_line(remaining_code)
376: 
377:       # collect comment for file entity
378:       whole_comment, remaining_code = collect_first_comment(remaining_code)
379:       @top_level.comment = whole_comment
380: 
381:       # "module" parts are parsed
382:       #
383:       while remaining_code =~ /^\s*module\s+(\w+)\s*(!.*?)?$(.*?)^\s*end\s+module.*?$/im
384:         remaining_code = $~.pre_match
385:         remaining_code << $~.post_match
386:         module_code = remove_empty_head_lines($&)
387:         module_name = $1
388:         progress "m"
389:         @stats.num_modules += 1
390:         f9x_module = @top_level.add_module NormalClass, module_name
391:         f9x_module.record_location @top_level
392:         f9x_trailing = find_comments($2)
393:         f9x_comment = COMMENTS_ARE_UPPER ? 
394:           find_comments($~.pre_match)  + "\n" + f9x_trailing :
395:             f9x_trailing + "\n" + find_comments(module_code.sub(/^.*$\n/i, ''))
396:         f9x_module.comment = f9x_comment
397:         parse_program_or_module(f9x_module, module_code)
398: 
399:         TopLevel.all_files.each do |name, toplevel|
400:           if toplevel.include_includes?(module_name, @options.ignore_case)
401:             if !toplevel.include_requires?(@file_name, @options.ignore_case)
402:               toplevel.add_require(Require.new(@file_name, ""))
403:             end
404:           end
405:           toplevel.each_classmodule{|m|
406:             if m.include_includes?(module_name, @options.ignore_case)
407:               if !m.include_requires?(@file_name, @options.ignore_case)
408:                 m.add_require(Require.new(@file_name, ""))
409:               end
410:             end
411:           }
412:         end
413:       end
414: 
415:       # "program" parts are parsed
416:       #
417:       # contains 以下の内部サブルーチンが存在するなど,
418:       # サブプログラムの集まりとは少々違うため.
419:       #
420:       while remaining_code =~ /^\s*program\s+(\w+)\s*(!.*?)?$(.*?)^\s*end\s+program.*?$/im
421:         remaining_code = $~.pre_match
422:         remaining_code << $~.post_match
423:         program_code = remove_empty_head_lines($&)
424:         progress "p"
425:         program_name = $1
426:         program_trailing = find_comments($2)
427:         program_comment = COMMENTS_ARE_UPPER ? 
428:           find_comments($~.pre_match) + "\n" + program_trailing : 
429:             program_trailing + "\n" + find_comments(program_code.sub(/^.*$\n/i, ''))
430:         program_comment = "\n\n= <i>Program</i> <tt>#{program_name}</tt>\n\n" \
431:                           + program_comment
432:         @top_level.comment << program_comment
433:         parse_program_or_module(@top_level, program_code, :private)
434:       end
435: 
436:       # External subprograms and functions are parsed
437:       #
438:       # 単一のファイル内において program や module に格納されない,
439:       # 外部サブルーチン, 外部関数部分の解析.
440:       #
441:       parse_program_or_module(@top_level, remaining_code, :public, true)
442: 
443:       @top_level
444:     end

[Validate]