1 |
|
/****************************************************************************** |
2 |
|
* Top contributors (to current version): |
3 |
|
* Christopher L. Conway, Andrew Reynolds, 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 |
|
* [[ Add one-line brief description here ]] |
14 |
|
* |
15 |
|
* [[ Add file-specific comments here ]] |
16 |
|
*/ |
17 |
|
|
18 |
|
#include "parser/smt2/smt2_input.h" |
19 |
|
|
20 |
|
#include <antlr3.h> |
21 |
|
|
22 |
|
#include "base/check.h" |
23 |
|
#include "parser/input.h" |
24 |
|
#include "parser/parser.h" |
25 |
|
#include "parser/parser_exception.h" |
26 |
|
#include "parser/smt2/Smt2Lexer.h" |
27 |
|
#include "parser/smt2/Smt2Parser.h" |
28 |
|
#include "parser/smt2/smt2.h" |
29 |
|
|
30 |
|
namespace cvc5 { |
31 |
|
namespace parser { |
32 |
|
|
33 |
|
/* Use lookahead=2 */ |
34 |
5230 |
Smt2Input::Smt2Input(AntlrInputStream& inputStream) : AntlrInput(inputStream, 2) |
35 |
|
{ |
36 |
5230 |
pANTLR3_INPUT_STREAM input = inputStream.getAntlr3InputStream(); |
37 |
5230 |
Assert(input != NULL); |
38 |
|
|
39 |
5230 |
d_pSmt2Lexer = Smt2LexerNew(input); |
40 |
5230 |
if( d_pSmt2Lexer == NULL ) { |
41 |
|
throw ParserException("Failed to create SMT2 lexer."); |
42 |
|
} |
43 |
|
|
44 |
5230 |
setAntlr3Lexer( d_pSmt2Lexer->pLexer ); |
45 |
|
|
46 |
5230 |
pANTLR3_COMMON_TOKEN_STREAM tokenStream = getTokenStream(); |
47 |
5230 |
Assert(tokenStream != NULL); |
48 |
|
|
49 |
5230 |
d_pSmt2Parser = Smt2ParserNew(tokenStream); |
50 |
5230 |
if( d_pSmt2Parser == NULL ) { |
51 |
|
throw ParserException("Failed to create SMT2 parser."); |
52 |
|
} |
53 |
|
|
54 |
5230 |
setAntlr3Parser(d_pSmt2Parser->pParser); |
55 |
5230 |
} |
56 |
|
|
57 |
15690 |
Smt2Input::~Smt2Input() { |
58 |
5230 |
d_pSmt2Lexer->free(d_pSmt2Lexer); |
59 |
5230 |
d_pSmt2Parser->free(d_pSmt2Parser); |
60 |
10460 |
} |
61 |
|
|
62 |
277366 |
Command* Smt2Input::parseCommand() { |
63 |
277366 |
return d_pSmt2Parser->parseCommand(d_pSmt2Parser); |
64 |
|
} |
65 |
|
|
66 |
116 |
api::Term Smt2Input::parseExpr() |
67 |
|
{ |
68 |
116 |
return d_pSmt2Parser->parseExpr(d_pSmt2Parser); |
69 |
|
} |
70 |
|
|
71 |
|
} // namespace parser |
72 |
29271 |
} // namespace cvc5 |