def definition_info(text)
return nil unless text
lines = "#{text}"
defs = Array.new
comment = ""
trailing_comment = ""
under_comment_valid = false
lines.split("\n").each{ |line|
if /^\s*?!\s?(.*)/ =~ line
if COMMENTS_ARE_UPPER
comment << remove_header_marker($1)
comment << "\n"
elsif defs[-1] && under_comment_valid
defs[-1].comment << "\n"
defs[-1].comment << remove_header_marker($1)
end
next
elsif /^\s*?$/ =~ line
comment = ""
under_comment_valid = false
next
end
type = ""
characters = ""
if line =~ /^\s*?
(
character\s*?(\([\w\s\=\(\)\*]+?\))?[\s\,]*
| type\s*?\([\w\s]+?\)[\s\,]*
| integer\s*?(\([\w\s\=\(\)\*]+?\))?[\s\,]*
| real\s*?(\([\w\s\=\(\)\*]+?\))?[\s\,]*
| double\s+precision[\s\,]*
| logical\s*?(\([\w\s\=\(\)\*]+?\))?[\s\,]*
| complex\s*?(\([\w\s\=\(\)\*]+?\))?[\s\,]*
)
(.*?::)?
(.+)$
/ix
characters = $8
type = $1
type << $7.gsub(/::/, '').gsub(/^\s*?\,/, '') if $7
else
under_comment_valid = false
next
end
squote = false ; dquote = false ; bracket = 0
iniflag = false; commentflag = false
varname = "" ; arraysuffix = "" ; inivalue = ""
start_pos = defs.size
characters.split("").each { |char|
if !(squote) && !(dquote) && bracket <= 0 && !(iniflag) && !(commentflag)
case char
when "!" ; commentflag = true
when "(" ; bracket += 1 ; arraysuffix = char
when "\""; dquote = true
when "\'"; squote = true
when "=" ; iniflag = true ; inivalue << char
when ","
defs << Fortran95Definition.new(varname, type, inivalue, arraysuffix, comment)
varname = "" ; arraysuffix = "" ; inivalue = ""
under_comment_valid = true
when " " ; next
else ; varname << char
end
elsif commentflag
comment << remove_header_marker(char)
trailing_comment << remove_header_marker(char)
elsif iniflag
if dquote
case char
when "\"" ; dquote = false ; inivalue << char
else ; inivalue << char
end
elsif squote
case char
when "\'" ; squote = false ; inivalue << char
else ; inivalue << char
end
elsif bracket > 0
case char
when "(" ; bracket += 1 ; inivalue << char
when ")" ; bracket -= 1 ; inivalue << char
else ; inivalue << char
end
else
case char
when ","
defs << Fortran95Definition.new(varname, type, inivalue, arraysuffix, comment)
varname = "" ; arraysuffix = "" ; inivalue = ""
iniflag = false
under_comment_valid = true
when "(" ; bracket += 1 ; inivalue << char
when "\""; dquote = true ; inivalue << char
when "\'"; squote = true ; inivalue << char
when "!" ; commentflag = true
else ; inivalue << char
end
end
elsif !(squote) && !(dquote) && bracket > 0
case char
when "(" ; bracket += 1 ; arraysuffix << char
when ")" ; bracket -= 1 ; arraysuffix << char
else ; arraysuffix << char
end
elsif squote
case char
when "\'"; squote = false ; inivalue << char
else ; inivalue << char
end
elsif dquote
case char
when "\""; dquote = false ; inivalue << char
else ; inivalue << char
end
end
}
defs << Fortran95Definition.new(varname, type, inivalue, arraysuffix, comment)
if trailing_comment =~ /^:nodoc:/
defs[start_pos..-1].collect!{ |defitem|
defitem.nodoc = true
}
end
varname = "" ; arraysuffix = "" ; inivalue = ""
comment = ""
under_comment_valid = true
trailing_comment = ""
}
return defs
end