blob: 4b77abcd6e93bfdd099e6a32d816e5a61f72c413 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
|
/***************************************************************************
* Copyright (C) 2002 by Roberto Raggi *
* [email protected] *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************/
#include "backgroundparser.h"
#include "problemreporter.h"
#include "AdaLexer.h"
#include "AdaParser.h"
#include "AdaAST.h"
#include <kdebug.h>
#include <tqfile.h>
#include <config.h>
#include <sstream>
BackgroundParser::BackgroundParser( ProblemReporter* reporter,
const TQString& source,
const TQString& filename )
: m_reporter( reporter ),
m_source( source.unicode(), source.length() ),
m_fileName( filename )
{
}
BackgroundParser::~BackgroundParser()
{
}
void BackgroundParser::run()
{
TQCString _fn = TQFile::encodeName(m_fileName);
std::string fn( _fn.data() );
std::istringstream stream( m_source.utf8().data() );
AdaLexer lexer( stream );
lexer.setFilename( fn );
lexer.setProblemReporter( m_reporter );
AdaParser parser( lexer );
parser.setFilename( fn );
parser.setProblemReporter( m_reporter );
// make an ast factory
antlr::ASTFactory ast_factory;
// initialize and put it in the parser...
parser.initializeASTFactory (ast_factory);
parser.setASTFactory (&ast_factory);
// parser.setASTNodeType ("RefAdaAST");
try{
lexer.resetErrors();
parser.resetErrors();
parser.compilation_unit();
} catch( antlr::ANTLRException& ex ){
kdDebug() << "*exception*: " << ex.toString().c_str() << endl;
m_reporter->reportError( TQString::fromLatin1( ex.getMessage().c_str() ),
m_fileName,
lexer.getLine(),
lexer.getColumn() );
}
kdDebug() << "BackgroundParser::run() FINISHED." << endl;
}
|