input.h
Go to the documentation of this file.
/********************* */
#include "cvc4parser_public.h"
#ifndef __CVC4__PARSER__INPUT_H
#define __CVC4__PARSER__INPUT_H
#include <iostream>
#include <string>
#include <stdio.h>
#include <vector>
#include "expr/expr.h"
#include "expr/expr_manager.h"
#include "parser/parser_exception.h"
#include "util/language.h"
namespace CVC4 {
class Command;
class Type;
class FunctionType;
namespace parser {
class CVC4_PUBLIC InputStreamException : public Exception {
public:
InputStreamException(const std::string& msg);
virtual ~InputStreamException() throw() { }
};
class CVC4_PUBLIC InputStream {
std::string d_name;
bool d_fileIsTemporary;
protected:
InputStream(std::string name, bool isTemporary=false) :
d_name(name),
d_fileIsTemporary(isTemporary) {
}
public:
virtual ~InputStream() {
if( d_fileIsTemporary ) {
remove(d_name.c_str());
}
}
const std::string getName() const;
};/* class InputStream */
class Parser;
class CVC4_PUBLIC Input {
friend class Parser; // for parseError, parseCommand, parseExpr
friend class ParserBuilder;
InputStream *d_inputStream;
/* Since we own d_inputStream and it needs to be freed, we need to prevent
* copy construction and assignment. Mark them private and do not define
* them.
*/
Input(const Input& input) CVC4_UNUSED;
Input& operator=(const Input& input) CVC4_UNUSED;
public:
static Input* newFileInput(InputLanguage lang,
const std::string& filename,
bool useMmap = false)
throw (InputStreamException);
static Input* newStreamInput(InputLanguage lang,
std::istream& input,
const std::string& name,
bool lineBuffered = false)
throw (InputStreamException);
static Input* newStringInput(InputLanguage lang,
const std::string& input,
const std::string& name)
throw (InputStreamException);
virtual ~Input();
virtual std::string getUnparsedText() = 0;
virtual InputLanguage getLanguage() const throw() = 0;
const std::string getInputStreamName(){
return getInputStream()->getName();
}
protected:
Input(InputStream& inputStream);
InputStream *getInputStream();
virtual Command* parseCommand() = 0;
virtual void warning(const std::string& msg) = 0;
virtual void parseError(const std::string& msg, bool eofException = false)
throw (ParserException) = 0;
virtual Expr parseExpr() = 0;
virtual void setParser(Parser& parser) = 0;
};/* class Input */
}/* CVC4::parser namespace */
}/* CVC4 namespace */
#endif /* __CVC4__PARSER__ANTLR_INPUT_H */
Type
void * Type
Definition c_interface_defs.h:48
CVC4::Command
Definition command.h:184
CVC4::Exception
Definition exception.h:32
CVC4::Expr
Class encapsulating CVC4 expressions and methods for constructing new expressions.
Definition expr.h:227
CVC4::parser::InputStreamException
Definition input.h:40
CVC4::parser::InputStreamException::~InputStreamException
virtual ~InputStreamException()
Definition input.h:44
CVC4::parser::InputStreamException::InputStreamException
InputStreamException(const std::string &msg)
CVC4::parser::InputStream
Wrapper around an input stream.
Definition input.h:48
CVC4::parser::InputStream::~InputStream
virtual ~InputStream()
Destructor.
Definition input.h:68
CVC4::parser::InputStream::getName
const std::string getName() const
Get the name of this input stream.
CVC4::parser::InputStream::InputStream
InputStream(std::string name, bool isTemporary=false)
Initialize the input stream with a name.
Definition input.h:60
CVC4::parser::Input
An input to be parsed.
Definition input.h:86
CVC4::parser::Input::parseCommand
virtual Command * parseCommand()=0
Parse a command from the input by invoking the implementation-specific parsing method.
CVC4::parser::Input::warning
virtual void warning(const std::string &msg)=0
Issue a warning to the user, with source file, line, and column info.
CVC4::parser::Input::getInputStream
InputStream * getInputStream()
Retrieve the input stream for this parser.
CVC4::parser::Input::newFileInput
static Input * newFileInput(InputLanguage lang, const std::string &filename, bool useMmap=false)
Create an input for the given file.
CVC4::parser::Input::Input
Input(InputStream &inputStream)
Create an input.
CVC4::parser::Input::parseError
virtual void parseError(const std::string &msg, bool eofException=false)=0
Throws a ParserException with the given message.
CVC4::parser::ParserBuilder
A builder for input language parsers.
Definition parser_builder.h:42
CVC4::parser::ParserException
Definition parser_exception.h:31
CVC4::parser::Parser
This class encapsulates all of the state of a parser, including the name of the file,...
Definition parser.h:106
CVC4_PUBLIC
#define CVC4_PUBLIC
Definition cvc4_public.h:30
CVC4_UNUSED
#define CVC4_UNUSED
Definition cvc4_public.h:63
cvc4parser_public.h
Macros that should be defined everywhere during the building of the libraries and driver binary,...
expr.h
expr_manager.h
language.h
Definition of input and output languages.
CVC4::language::input::Language
Language
Definition language.h:33
CVC4
Definition expr.h:106
std
STL namespace.
parser_exception.h
Exception class for parse errors.