KDevelop API Documentation

languages/pascal/backgroundparser.cpp

Go to the documentation of this file.
00001 /*************************************************************************** 00002 * Copyright (C) 2002 by Roberto Raggi * 00003 * roberto@kdevelop.org * 00004 * * 00005 * This program is free software; you can redistribute it and/or modify * 00006 * it under the terms of the GNU General Public License as published by * 00007 * the Free Software Foundation; either version 2 of the License, or * 00008 * (at your option) any later version. * 00009 * * 00010 ***************************************************************************/ 00011 00012 #include <strstream> 00013 00014 #include "backgroundparser.h" 00015 #include "problemreporter.h" 00016 #include "PascalLexer.hpp" 00017 #include "PascalParser.hpp" 00018 #include "PascalAST.hpp" 00019 #include <kdebug.h> 00020 #include <qfile.h> 00021 #include <antlr/ASTFactory.hpp> 00022 00023 BackgroundParser::BackgroundParser( ProblemReporter* reporter, 00024 const QString& source, 00025 const QString& filename ) 00026 : m_reporter( reporter ), 00027 m_source( source.unicode(), source.length() ), 00028 m_fileName( filename ) 00029 { 00030 } 00031 00032 BackgroundParser::~BackgroundParser() 00033 { 00034 } 00035 00036 void BackgroundParser::run() 00037 { 00038 kdDebug() << "11" << endl; 00039 00040 QCString _fn = QFile::encodeName(m_fileName); 00041 std::string fn( _fn.data() ); 00042 00043 QCString text = m_source.utf8(); 00044 std::istrstream stream( text ); 00045 00046 kdDebug() << "12" << endl; 00047 00048 PascalLexer lexer( stream ); 00049 lexer.setFilename( fn ); 00050 lexer.setProblemReporter( m_reporter ); 00051 00052 kdDebug() << "13" << endl; 00053 00054 PascalParser parser( lexer ); 00055 parser.setFilename( fn ); 00056 parser.setProblemReporter( m_reporter ); 00057 00058 antlr::ASTFactory my_factory( "PascalAST", PascalAST::factory ); 00059 parser.initializeASTFactory(my_factory); 00060 parser.setASTFactory( &my_factory ); 00061 00062 kdDebug() << "14" << endl; 00063 00064 try{ 00065 00066 kdDebug() << "15" << endl; 00067 00068 lexer.resetErrors(); 00069 parser.resetErrors(); 00070 00071 kdDebug() << "16" << endl; 00072 00073 parser.compilationUnit(); 00074 00075 kdDebug() << "17" << endl; 00076 00077 int errors = lexer.numberOfErrors() + parser.numberOfErrors(); 00078 00079 kdDebug() << "18" << endl; 00080 } catch( antlr::ANTLRException& ex ){ 00081 00082 kdDebug() << "19" << endl; 00083 00084 kdDebug() << "*exception*: " << ex.toString().c_str() << endl; 00085 m_reporter->reportError( ex.getMessage().c_str(), 00086 m_fileName, 00087 lexer.getLine(), 00088 lexer.getColumn() ); 00089 } 00090 00091 kdDebug(9013) << "FINISHED!!" << endl; 00092 } 00093 00094 00095
KDE Logo
This file is part of the documentation for KDevelop Version 3.0.4.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Wed Oct 6 17:39:00 2004 by doxygen 1.3.7 written by Dimitri van Heesch, © 1997-2003