1
/***************************************************************************
2
* Copyright (C) 2001 by Bernd Gehrmann *
5
* This program is free software; you can redistribute it and/or modify *
6
* it under the terms of the GNU General Public License as published by *
7
* the Free Software Foundation; either version 2 of the License, or *
8
* (at your option) any later version. *
10
***************************************************************************/
12
#include "fixedformparser.h"
15
#include <qtextstream.h>
17
#include <codemodel.h>
20
FixedFormParser::FixedFormParser(CodeModel* model)
24
functionre.setPattern("(integer|real|logical|complex|character|"
25
"double(precision)?)function([^(]+).*");
26
subroutinere.setPattern("subroutine([^(]+).*");
28
functionre.setCaseSensitive( false );
29
subroutinere.setCaseSensitive( false );
33
void FixedFormParser::process(const QCString &line, const QString &fileName, int lineNum)
36
int l = line.length();
37
for (int i=0; i < l; ++i)
39
simplified += line[i];
41
if ( simplified.isEmpty() ) return;
44
if (functionre.search(simplified) != -1)
45
name = functionre.cap(3);
46
else if (subroutinere.search(simplified) != -1)
47
name = subroutinere.cap(1);
51
FunctionDom method = m_model->create<FunctionModel>();
52
method->setName(name);
53
method->setFileName(fileName);
54
method->setStartPosition(lineNum, 0);
56
if( !m_file->hasFunction(method->name()) )
57
m_file->addFunction(method);
61
void FixedFormParser::parse(const QString &fileName)
63
QFile f(QFile::encodeName(fileName));
64
if (!f.open(IO_ReadOnly))
66
QTextStream stream(&f);
68
m_file = m_model->create<FileModel>();
69
m_file->setName( fileName );
72
int lineNum=0, startLineNum=0;
73
while (!stream.atEnd()) {
75
QCString str = stream.readLine().local8Bit();
76
if (!str.isEmpty() && QCString("*Cc#!").find(str[0]) != -1)
79
if (str.length() > 6 && str.left(5) == " " && str[5] != ' ') {
80
line += str.right(str.length()-6);
83
// An initial or invalid line. We don't care
85
process(line, fileName, startLineNum);
86
line = str.right(str.length()-6);
87
startLineNum = lineNum-1;
89
process(line, fileName, startLineNum);
93
m_model->addFile( m_file );