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 
32 namespace CVC4 {
33 
34 class Command;
35 class Type;
36 class FunctionType;
37 
38 namespace parser {
39 
41 
42 public:
43  InputStreamException(const std::string& msg);
44  virtual ~InputStreamException() throw() { }
45 };
46 
49 
51  std::string d_name;
52 
55  bool d_fileIsTemporary;
56 
57 protected:
58 
60  InputStream(std::string name, bool isTemporary=false) :
61  d_name(name),
62  d_fileIsTemporary(isTemporary) {
63  }
64 
65 public:
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 
78 class 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 
100 public:
101 
108  static Input* newFileInput(InputLanguage lang,
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 
154 protected:
155 
160  Input(InputStream& inputStream);
161 
163  InputStream *getInputStream();
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 */
Class encapsulating CVC4 expressions and methods for constructing new expressions.
Definition: expr.h:227
Exception class for parse errors.
Definition: modes.h:25
#define CVC4_UNUSED
Definition: cvc4_public.h:63
Wrapper around an input stream.
Definition: input.h:48
STL namespace.
#define CVC4_PUBLIC
Definition: cvc4_public.h:30
Definition of input and output languages.
A builder for input language parsers.
expr_manager.h
An input to be parsed.
Definition: input.h:86
expr.h
Macros that should be defined everywhere during the building of the libraries and driver binary...
void * Type
InputStream(std::string name, bool isTemporary=false)
Initialize the input stream with a name.
Definition: input.h:60
This class encapsulates all of the state of a parser, including the name of the file, line number and column information, and in-scope declarations.
Definition: parser.h:106
virtual ~InputStream()
Destructor.
Definition: input.h:68