Loading...
Searching...
No Matches
blast-parser-driver.h
Go to the documentation of this file.
/*
Copyright (C) 2011 Laszlo Kajan, Technical University of Munich, Germany
This file is part of librostlab.
librostlab is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef ROSTLAB_BLAST_PARSER_DRIVER_H
#define ROSTLAB_BLAST_PARSER_DRIVER_H 1
#include <stdio.h>
#include <string>
#include <map>
#include <rostlab/rostlab_stdexcept.h>
#include "rostlab/blast-parser-parser.h"
#include "rostlab/blast-result.h"
// Tell Flex the lexer's prototype ...
#define YY_DECL \
rostlab::blast::parser::token_type \
yylex( rostlab::blast::parser::semantic_type* __yylval, \
rostlab::blast::parser::location_type* __yylloc, \
rostlab::blast::parser_driver& __drv, \
void* yyscanner )
// ... and declare it for the parser's sake.
YY_DECL;
#define YY_DECL_FRIEND \
rostlab::blast::parser::token_type \
(::yylex)( rostlab::blast::parser::semantic_type* __yylval, \
rostlab::blast::parser::location_type* __yylloc, \
rostlab::blast::parser_driver& __drv, \
void* yyscanner )
namespace rostlab {
namespace blast {
class parser_error : public rostlab::runtime_error
{
public:
parser_error( const std::string& __msg ) : rostlab::runtime_error(__msg){}
};
class parser_driver {
friend class rostlab::blast::parser;
friend YY_DECL_FRIEND;
public:
typedef rostlab::blast::result result_type;
private:
std::string _istream_name; // a name for error reporting
FILE* _istream;
result_type _result;
void* _scanner; // yyscan_t
private:
// this is a resource - disable copy contructor and copy assignment
parser_driver( const parser_driver& ){};
parser_driver& operator=(const parser_driver&){return *this;};
std::string _buffer;
int _n1, _n2;
void _scan_init();
void _scan_destroy();
public:
parser_driver( FILE* __istream = stdin, const std::string& __istream_name = "stdin" ) : _istream_name(__istream_name), _istream(__istream)
{
_scan_init();
}
virtual ~parser_driver()
{
_scan_destroy();
}
const result_type&
parse( bool __trace_parsing = false, bool __trace_scanning = false );
bool trace_scanning();
void trace_scanning( bool __b );
void error( const rostlab::blast::location& __loc, const std::string __msg )
{
std::cerr << __loc << ": " << __msg << "\n";
}
void error( const std::string __msg )
{
std::cerr << __msg << "\n";
}
const result_type&
result() const { return _result; }
};
} // namespace blast
} // namespace rostlab
#endif // ROSTLAB_BLAST_PARSER_DRIVER_H
// vim:et:ts=4:ai:
YY_DECL
#define YY_DECL
Definition blast-parser-driver.h:30
blast-parser-parser.h
blast-result.h
rostlab::blast::location
Two points in a source file.
Definition blast-parser-location.h:167
rostlab::blast::parser_driver
Blast (default, -m 0) output parser.
Definition blast-parser-driver.h:59
rostlab::blast::parser_driver::parse
const result_type & parse(bool __trace_parsing=false, bool __trace_scanning=false)
Parse one result from the input stream.
rostlab::blast::parser_driver::trace_scanning
void trace_scanning(bool __b)
Set tracing of scanning.
rostlab::blast::parser_driver::error
void error(const rostlab::blast::location &__loc, const std::string __msg)
Print error message for given location.
Definition blast-parser-driver.h:99
rostlab::blast::parser_driver::error
void error(const std::string __msg)
Print error message.
Definition blast-parser-driver.h:105
rostlab::blast::parser_driver::trace_scanning
bool trace_scanning()
Get tracing of scanning.
rostlab::blast::parser_driver::parser_driver
parser_driver(FILE *__istream=stdin, const std::string &__istream_name="stdin")
Definition blast-parser-driver.h:79
rostlab::blast::parser_driver::result
const result_type & result() const
Read-only access to results.
Definition blast-parser-driver.h:113
rostlab::blast::parser_driver::result_type
rostlab::blast::result result_type
Definition blast-parser-driver.h:63
rostlab::blast::parser_driver::~parser_driver
virtual ~parser_driver()
Definition blast-parser-driver.h:83
rostlab::blast::parser_error::parser_error
parser_error(const std::string &__msg)
Definition blast-parser-driver.h:52
rostlab::blast::parser
A Bison parser.
Definition blast-parser-parser.h:197
rostlab::blast
Definition blast-parser-driver.h:47
rostlab
Definition blast-parser-driver.h:45
rostlab::blast::result
Blast result for one query.
Definition blast-result.h:164