00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
#include "fixedformparser.h"
00013
00014
#include <qfile.h>
00015
#include <qtextstream.h>
00016
#include <kdebug.h>
00017
#include <codemodel.h>
00018
00019
00020 FixedFormParser::FixedFormParser(
CodeModel* model)
00021 {
00022
m_model = model;
00023
00024
functionre.setPattern(
"(integer|real|logical|complex|character|"
00025
"double(precision)?)function([^(]+).*");
00026
subroutinere.setPattern(
"subroutine([^(]+).*");
00027
00028
functionre.setCaseSensitive(
false );
00029
subroutinere.setCaseSensitive(
false );
00030 }
00031
00032
00033 void FixedFormParser::process(
const QCString &line,
const QString &fileName,
int lineNum)
00034 {
00035
QCString simplified;
00036
int l = line.length();
00037
for (
int i=0; i < l; ++i)
00038
if (line[i] !=
' ')
00039 simplified += line[i];
00040
00041
if ( simplified.isEmpty() )
return;
00042
00043
QString name;
00044
if (
functionre.search(simplified) != -1)
00045 name =
functionre.cap(3);
00046
else if (
subroutinere.search(simplified) != -1)
00047 name =
subroutinere.cap(1);
00048
else
00049
return;
00050
00051
FunctionDom method =
m_model->
create<
FunctionModel>();
00052 method->setName(name);
00053 method->setFileName(fileName);
00054 method->setStartPosition(lineNum, 0);
00055
00056
if( !
m_file->hasFunction(method->name()) )
00057
m_file->addFunction(method);
00058 }
00059
00060
00061 void FixedFormParser::parse(
const QString &fileName)
00062 {
00063
QFile f(QFile::encodeName(fileName));
00064
if (!f.open(IO_ReadOnly))
00065
return;
00066
QTextStream stream(&f);
00067
00068
m_file =
m_model->
create<
FileModel>();
00069
m_file->setName( fileName );
00070
00071
QCString line;
00072
int lineNum=0, startLineNum=0;
00073
while (!stream.atEnd()) {
00074 ++lineNum;
00075
QCString str = stream.readLine().local8Bit();
00076
if (!str.isEmpty() &&
QCString(
"*Cc#!").find(str[0]) != -1)
00077
continue;
00078
00079
if (str.length() > 6 && str.left(5) ==
" " && str[5] !=
' ') {
00080 line += str.right(str.length()-6);
00081
continue;
00082 }
00083
00084
00085
process(line, fileName, startLineNum);
00086 line = str.right(str.length()-6);
00087 startLineNum = lineNum-1;
00088 }
00089
process(line, fileName, startLineNum);
00090
00091 f.close();
00092
00093
m_model->
addFile(
m_file );
00094 }