1 |
|
/****************************************************************************** |
2 |
|
* Top contributors (to current version): |
3 |
|
* Christopher L. Conway, Tim King, Morgan Deters |
4 |
|
* |
5 |
|
* This file is part of the cvc5 project. |
6 |
|
* |
7 |
|
* Copyright (c) 2009-2021 by the authors listed in the file AUTHORS |
8 |
|
* in the top-level source directory and their institutional affiliations. |
9 |
|
* All rights reserved. See the file COPYING in the top-level source |
10 |
|
* directory for licensing information. |
11 |
|
* **************************************************************************** |
12 |
|
* |
13 |
|
* A super-class for input language parsers |
14 |
|
*/ |
15 |
|
|
16 |
|
// This must be included first. |
17 |
|
#include "parser/antlr_input.h" |
18 |
|
|
19 |
|
#include "parser/input.h" |
20 |
|
|
21 |
|
#include "base/output.h" |
22 |
|
#include "parser/parser.h" |
23 |
|
#include "parser/parser_exception.h" |
24 |
|
|
25 |
|
|
26 |
|
using namespace std; |
27 |
|
using namespace cvc5; |
28 |
|
using namespace cvc5::parser; |
29 |
|
using namespace cvc5::kind; |
30 |
|
|
31 |
|
namespace cvc5 { |
32 |
|
namespace parser { |
33 |
|
|
34 |
|
InputStreamException::InputStreamException(const std::string& msg) : |
35 |
|
Exception(msg) { |
36 |
|
} |
37 |
|
|
38 |
144 |
const std::string InputStream::getName() const { |
39 |
144 |
return d_name; |
40 |
|
} |
41 |
|
|
42 |
6428 |
Input::Input(InputStream& inputStream) : |
43 |
6428 |
d_inputStream( &inputStream ) { |
44 |
6428 |
} |
45 |
|
|
46 |
12856 |
Input::~Input() { |
47 |
6428 |
delete d_inputStream; |
48 |
6428 |
} |
49 |
|
|
50 |
144 |
InputStream *Input::getInputStream() { |
51 |
144 |
return d_inputStream; |
52 |
|
} |
53 |
|
|
54 |
6137 |
Input* Input::newFileInput(InputLanguage lang, |
55 |
|
const std::string& filename, |
56 |
|
bool useMmap) |
57 |
|
{ |
58 |
|
AntlrInputStream *inputStream = |
59 |
6137 |
AntlrInputStream::newFileInputStream(filename, useMmap); |
60 |
6137 |
return AntlrInput::newInput(lang, *inputStream); |
61 |
|
} |
62 |
|
|
63 |
4 |
Input* Input::newStreamInput(InputLanguage lang, |
64 |
|
std::istream& input, |
65 |
|
const std::string& name) |
66 |
|
{ |
67 |
|
AntlrInputStream* inputStream = |
68 |
4 |
AntlrInputStream::newStreamInputStream(input, name); |
69 |
4 |
return AntlrInput::newInput(lang, *inputStream); |
70 |
|
} |
71 |
|
|
72 |
287 |
Input* Input::newStringInput(InputLanguage lang, |
73 |
|
const std::string& str, |
74 |
|
const std::string& name) |
75 |
|
{ |
76 |
287 |
AntlrInputStream *inputStream = AntlrInputStream::newStringInputStream(str, name); |
77 |
287 |
return AntlrInput::newInput(lang, *inputStream); |
78 |
|
} |
79 |
|
|
80 |
|
} // namespace parser |
81 |
29334 |
} // namespace cvc5 |