cvc4-1.4
input.h
Go to the documentation of this file.
1/********************* */
17#include "cvc4parser_public.h"
18
19#ifndef __CVC4__PARSER__INPUT_H
20#define __CVC4__PARSER__INPUT_H
21
22#include <iostream>
23#include <string>
24#include <stdio.h>
25#include <vector>
26
27#include "expr/expr.h"
28#include "expr/expr_manager.h"
30#include "util/language.h"
31
32namespace CVC4 {
33
34class Command;
35class Type;
36class FunctionType;
37
38namespace parser {
39
41
42public:
43 InputStreamException(const std::string& msg);
44 virtual ~InputStreamException() throw() { }
45};
46
49
51 std::string d_name;
52
55 bool d_fileIsTemporary;
56
57protected:
58
60 InputStream(std::string name, bool isTemporary=false) :
61 d_name(name),
62 d_fileIsTemporary(isTemporary) {
63 }
64
65public:
66
68 virtual ~InputStream() {
69 if( d_fileIsTemporary ) {
70 remove(d_name.c_str());
71 }
72 }
73
75 const std::string getName() const;
76};/* class InputStream */
77
78class Parser;
79
87 friend class Parser; // for parseError, parseCommand, parseExpr
88 friend class ParserBuilder;
89
91 InputStream *d_inputStream;
92
93 /* Since we own d_inputStream and it needs to be freed, we need to prevent
94 * copy construction and assignment. Mark them private and do not define
95 * them.
96 */
97 Input(const Input& input) CVC4_UNUSED;
98 Input& operator=(const Input& input) CVC4_UNUSED;
99
100public:
101
109 const std::string& filename,
110 bool useMmap = false)
111 throw (InputStreamException);
112
122 static Input* newStreamInput(InputLanguage lang,
123 std::istream& input,
124 const std::string& name,
125 bool lineBuffered = false)
126 throw (InputStreamException);
127
134 static Input* newStringInput(InputLanguage lang,
135 const std::string& input,
136 const std::string& name)
137 throw (InputStreamException);
138
139
141 virtual ~Input();
142
144 virtual std::string getUnparsedText() = 0;
145
147 virtual InputLanguage getLanguage() const throw() = 0;
148
150 const std::string getInputStreamName(){
151 return getInputStream()->getName();
152 }
153
154protected:
155
160 Input(InputStream& inputStream);
161
164
171 virtual Command* parseCommand() = 0;
172
176 virtual void warning(const std::string& msg) = 0;
177
181 virtual void parseError(const std::string& msg, bool eofException = false)
182 throw (ParserException) = 0;
183
190 virtual Expr parseExpr() = 0;
191
193 virtual void setParser(Parser& parser) = 0;
194
195};/* class Input */
196
197}/* CVC4::parser namespace */
198}/* CVC4 namespace */
199
200#endif /* __CVC4__PARSER__ANTLR_INPUT_H */
void * Type
Class encapsulating CVC4 expressions and methods for constructing new expressions.
Definition expr.h:227
InputStreamException(const std::string &msg)
Wrapper around an input stream.
Definition input.h:48
virtual ~InputStream()
Destructor.
Definition input.h:68
const std::string getName() const
Get the name of this input stream.
InputStream(std::string name, bool isTemporary=false)
Initialize the input stream with a name.
Definition input.h:60
An input to be parsed.
Definition input.h:86
virtual Command * parseCommand()=0
Parse a command from the input by invoking the implementation-specific parsing method.
virtual void warning(const std::string &msg)=0
Issue a warning to the user, with source file, line, and column info.
InputStream * getInputStream()
Retrieve the input stream for this parser.
static Input * newFileInput(InputLanguage lang, const std::string &filename, bool useMmap=false)
Create an input for the given file.
Input(InputStream &inputStream)
Create an input.
virtual void parseError(const std::string &msg, bool eofException=false)=0
Throws a ParserException with the given message.
A builder for input language parsers.
This class encapsulates all of the state of a parser, including the name of the file,...
Definition parser.h:106
#define CVC4_PUBLIC
Definition cvc4_public.h:30
#define CVC4_UNUSED
Definition cvc4_public.h:63
Macros that should be defined everywhere during the building of the libraries and driver binary,...
Definition of input and output languages.
Definition expr.h:106
STL namespace.
Exception class for parse errors.