1 |
|
/****************************************************************************** |
2 |
|
* Top contributors (to current version): |
3 |
|
* Francois Bobot, Morgan Deters, Andrew Reynolds |
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/tptp/tptp_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/tptp/TptpLexer.h" |
27 |
|
#include "parser/tptp/TptpParser.h" |
28 |
|
#include "parser/tptp/tptp.h" |
29 |
|
|
30 |
|
namespace cvc5 { |
31 |
|
namespace parser { |
32 |
|
|
33 |
|
/* Use lookahead=2 */ |
34 |
43 |
TptpInput::TptpInput(AntlrInputStream& inputStream) : |
35 |
43 |
AntlrInput(inputStream, 2) { |
36 |
43 |
pANTLR3_INPUT_STREAM input = inputStream.getAntlr3InputStream(); |
37 |
43 |
Assert(input != NULL); |
38 |
|
|
39 |
43 |
d_pTptpLexer = TptpLexerNew(input); |
40 |
43 |
if( d_pTptpLexer == NULL ) { |
41 |
|
throw ParserException("Failed to create TPTP lexer."); |
42 |
|
} |
43 |
|
|
44 |
43 |
setAntlr3Lexer( d_pTptpLexer->pLexer ); |
45 |
|
|
46 |
43 |
pANTLR3_COMMON_TOKEN_STREAM tokenStream = getTokenStream(); |
47 |
43 |
Assert(tokenStream != NULL); |
48 |
|
|
49 |
43 |
d_pTptpParser = TptpParserNew(tokenStream); |
50 |
43 |
if( d_pTptpParser == NULL ) { |
51 |
|
throw ParserException("Failed to create TPTP parser."); |
52 |
|
} |
53 |
|
|
54 |
43 |
setAntlr3Parser(d_pTptpParser->pParser); |
55 |
43 |
} |
56 |
|
|
57 |
|
|
58 |
129 |
TptpInput::~TptpInput() { |
59 |
43 |
d_pTptpLexer->free(d_pTptpLexer); |
60 |
43 |
d_pTptpParser->free(d_pTptpParser); |
61 |
86 |
} |
62 |
|
|
63 |
1750 |
Command* TptpInput::parseCommand() { |
64 |
1750 |
return d_pTptpParser->parseCommand(d_pTptpParser); |
65 |
|
} |
66 |
|
|
67 |
|
api::Term TptpInput::parseExpr() |
68 |
|
{ |
69 |
|
return d_pTptpParser->parseExpr(d_pTptpParser); |
70 |
|
} |
71 |
|
|
72 |
|
} // namespace parser |
73 |
28179 |
} // namespace cvc5 |