27b20734248d71bd257b9e09d6ea8e5263764123
[cvc5.git] / src / parser / input.cpp
1 /********************* */
2 /*! \file input.cpp
3 ** \verbatim
4 ** Original author: dejan
5 ** Major contributors: mdeters, cconway
6 ** Minor contributors (to current version): none
7 ** This file is part of the CVC4 prototype.
8 ** Copyright (c) 2009, 2010, 2011 The Analysis of Computer Systems Group (ACSys)
9 ** Courant Institute of Mathematical Sciences
10 ** New York University
11 ** See the file COPYING in the top-level source directory for licensing
12 ** information.\endverbatim
13 **
14 ** \brief A super-class for input language parsers.
15 **
16 ** A super-class for input language parsers
17 **/
18
19 #include "input.h"
20 #include "parser_exception.h"
21 #include "parser.h"
22
23 #include "expr/command.h"
24 #include "expr/type.h"
25 #include "parser/antlr_input.h"
26 #include "util/output.h"
27 #include "util/Assert.h"
28
29 using namespace std;
30 using namespace CVC4;
31 using namespace CVC4::parser;
32 using namespace CVC4::kind;
33
34 namespace CVC4 {
35 namespace parser {
36
37 InputStreamException::InputStreamException(const std::string& msg) :
38 Exception(msg) {
39 }
40
41 const std::string InputStream::getName() const {
42 return d_name;
43 }
44
45 Input::Input(InputStream& inputStream) :
46 d_inputStream( &inputStream ) {
47 }
48
49 Input::~Input() {
50 delete d_inputStream;
51 }
52
53 InputStream *Input::getInputStream() {
54 return d_inputStream;
55 }
56
57 Input* Input::newFileInput(InputLanguage lang,
58 const std::string& filename,
59 bool useMmap)
60 throw (InputStreamException, AssertionException) {
61 AntlrInputStream *inputStream =
62 AntlrInputStream::newFileInputStream(filename,useMmap);
63 return AntlrInput::newInput(lang,*inputStream);
64 }
65
66 Input* Input::newStreamInput(InputLanguage lang,
67 std::istream& input,
68 const std::string& name)
69 throw (InputStreamException, AssertionException) {
70 AntlrInputStream *inputStream =
71 AntlrInputStream::newStreamInputStream(input,name);
72 return AntlrInput::newInput(lang,*inputStream);
73 }
74
75 Input* Input::newStringInput(InputLanguage lang,
76 const std::string& str,
77 const std::string& name)
78 throw (InputStreamException, AssertionException) {
79 AntlrInputStream *inputStream = AntlrInputStream::newStringInputStream(str,name);
80 return AntlrInput::newInput(lang,*inputStream);
81 }
82
83 }/* CVC4::parser namespace */
84 }/* CVC4 namespace */