blob: 7a28c30f1d15e493a447bc6e80741f01ab4ff2b4 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
|
/*
* smt_parser.cpp
*
* Created on: Mar 5, 2010
* Author: chris
*/
#include <antlr3.h>
#include "expr/expr_manager.h"
#include "parser/parser_exception.h"
#include "parser/smt/smt_input.h"
#include "parser/smt/generated/SmtLexer.h"
#include "parser/smt/generated/SmtParser.h"
namespace CVC4 {
namespace parser {
/* Use lookahead=2 */
SmtInput::SmtInput(ExprManager* exprManager, const std::string& filename, bool useMmap) :
AntlrInput(exprManager,filename,2,useMmap) {
init();
}
SmtInput::SmtInput(ExprManager* exprManager, const std::string& input, const std::string& name) :
AntlrInput(exprManager,input,name,2) {
init();
}
void SmtInput::init() {
pANTLR3_INPUT_STREAM input = getInputStream();
AlwaysAssert( input != NULL );
d_pSmtLexer = SmtLexerNew(input);
if( d_pSmtLexer == NULL ) {
throw ParserException("Failed to create SMT lexer.");
}
setLexer( d_pSmtLexer->pLexer );
pANTLR3_COMMON_TOKEN_STREAM tokenStream = getTokenStream();
AlwaysAssert( tokenStream != NULL );
d_pSmtParser = SmtParserNew(tokenStream);
if( d_pSmtParser == NULL ) {
throw ParserException("Failed to create SMT parser.");
}
setParser(d_pSmtParser->pParser);
SetSmtInput(this);
}
SmtInput::~SmtInput() {
d_pSmtLexer->free(d_pSmtLexer);
d_pSmtParser->free(d_pSmtParser);
}
Command* SmtInput::doParseCommand() throw (ParserException) {
return d_pSmtParser->parseCommand(d_pSmtParser);
}
Expr SmtInput::doParseExpr() throw (ParserException) {
return d_pSmtParser->parseExpr(d_pSmtParser);
}
pANTLR3_LEXER SmtInput::getLexer() {
return d_pSmtLexer->pLexer;
}
} // namespace parser
} // namespace CVC4
|