diff options
author | toma <toma@283d02a7-25f6-0310-bc7c-ecb5cbfe19da> | 2009-11-25 17:56:58 +0000 |
---|---|---|
committer | toma <toma@283d02a7-25f6-0310-bc7c-ecb5cbfe19da> | 2009-11-25 17:56:58 +0000 |
commit | 114a878c64ce6f8223cfd22d76a20eb16d177e5e (patch) | |
tree | acaf47eb0fa12142d3896416a69e74cbf5a72242 /languages/pascal/backgroundparser.cpp | |
download | tdevelop-114a878c64ce6f8223cfd22d76a20eb16d177e5e.tar.gz tdevelop-114a878c64ce6f8223cfd22d76a20eb16d177e5e.zip |
Copy the KDE 3.5 branch to branches/trinity for new KDE 3.5 features.
BUG:215923
git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/kdevelop@1054174 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
Diffstat (limited to 'languages/pascal/backgroundparser.cpp')
-rw-r--r-- | languages/pascal/backgroundparser.cpp | 95 |
1 files changed, 95 insertions, 0 deletions
diff --git a/languages/pascal/backgroundparser.cpp b/languages/pascal/backgroundparser.cpp new file mode 100644 index 00000000..a61c9774 --- /dev/null +++ b/languages/pascal/backgroundparser.cpp @@ -0,0 +1,95 @@ +/*************************************************************************** + * Copyright (C) 2002 by Roberto Raggi * + * roberto@kdevelop.org * + * * + * 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 <sstream> + +#include "backgroundparser.h" +#include "problemreporter.h" +#include "PascalLexer.hpp" +#include "PascalParser.hpp" +#include "PascalAST.hpp" +#include <kdebug.h> +#include <qfile.h> +#include <antlr/ASTFactory.hpp> + +BackgroundParser::BackgroundParser( ProblemReporter* reporter, + const QString& source, + const QString& filename ) + : m_reporter( reporter ), + m_source( source.unicode(), source.length() ), + m_fileName( filename ) +{ +} + +BackgroundParser::~BackgroundParser() +{ +} + +void BackgroundParser::run() +{ + kdDebug() << "11" << endl; + + QCString _fn = QFile::encodeName(m_fileName); + std::string fn( _fn.data() ); + + QCString text = m_source.utf8(); + std::istringstream stream( text.data() ); + + kdDebug() << "12" << endl; + + PascalLexer lexer( stream ); + lexer.setFilename( fn ); + lexer.setProblemReporter( m_reporter ); + + kdDebug() << "13" << endl; + + PascalParser parser( lexer ); + parser.setFilename( fn ); + parser.setProblemReporter( m_reporter ); + + antlr::ASTFactory my_factory( "PascalAST", PascalAST::factory ); + parser.initializeASTFactory(my_factory); + parser.setASTFactory( &my_factory ); + + kdDebug() << "14" << endl; + + try{ + + kdDebug() << "15" << endl; + + lexer.resetErrors(); + parser.resetErrors(); + + kdDebug() << "16" << endl; + + parser.compilationUnit(); + + kdDebug() << "17" << endl; + + int errors = lexer.numberOfErrors() + parser.numberOfErrors(); + + kdDebug() << "18" << endl; + } catch( antlr::ANTLRException& ex ){ + + kdDebug() << "19" << endl; + + kdDebug() << "*exception*: " << ex.toString().c_str() << endl; + m_reporter->reportError( ex.getMessage().c_str(), + m_fileName, + lexer.getLine(), + lexer.getColumn() ); + } + + kdDebug(9013) << "FINISHED!!" << endl; +} + + + |