blob: 65d36690cce1abc0c23e5b88bf429dcd51c6c189 (
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
74
75
76
|
/********************* -*- C++ -*- */
/** smt_parser.cpp
** This file is part of the CVC4 prototype.
** Copyright (c) 2009 The Analysis of Computer Systems Group (ACSys)
** Courant Institute of Mathematical Sciences
** New York University
** See the file COPYING in the top-level source directory for licensing
** information.
**
** SMT-LIB language parser implementation.
**/
#include <iostream>
#include <fstream>
#include "parser/parser.h"
#include "util/command.h"
#include "util/Assert.h"
#include "parser/parser_exception.h"
#include "parser/antlr_parser.h"
#include "parser/smt/smt_parser.h"
#include "parser/smt/generated/AntlrSmtParser.hpp"
#include "parser/smt/generated/AntlrSmtLexer.hpp"
using namespace std;
namespace CVC4 {
namespace parser {
Command* SmtParser::parseNextCommand() throw(ParserException) {
Command* cmd = 0;
if(!done()) {
try {
cmd = d_antlr_parser->benchmark();
setDone();
} catch(antlr::ANTLRException& e) {
setDone();
throw ParserException(e.toString());
}
}
return cmd;
}
Expr SmtParser::parseNextExpression() throw(ParserException) {
Expr result;
if(!done()) {
try {
result = d_antlr_parser->an_formula();
} catch(antlr::ANTLRException& e) {
setDone();
throw ParserException(e.toString());
}
}
return result;
}
SmtParser::~SmtParser() {
delete d_antlr_parser;
delete d_antlr_lexer;
}
SmtParser::SmtParser(ExprManager* em, istream& input, const char* file_name) :
Parser(em), d_input(input) {
if(!d_input) {
throw ParserException(string("Read error") +
((file_name != NULL) ? (string(" on ") + file_name) : ""));
}
d_antlr_lexer = new AntlrSmtLexer(input);
d_antlr_lexer->setFilename(file_name);
d_antlr_parser = new AntlrSmtParser(*d_antlr_lexer);
d_antlr_parser->setExpressionManager(d_expr_manager);
d_antlr_parser->setFilename(file_name);
}
}/* CVC4::parser namespace */
}/* CVC4 namespace */
|