Merge branch '1.0.x'
[cvc5.git] / src / parser / smt1 / smt1_input.cpp
1 /********************* */
2 /*! \file smt1_input.cpp
3 ** \verbatim
4 ** Original author: cconway
5 ** Major contributors: mdeters
6 ** Minor contributors (to current version): none
7 ** This file is part of the CVC4 prototype.
8 ** Copyright (c) 2009-2012 New York University and The University of Iowa
9 ** See the file COPYING in the top-level source directory for licensing
10 ** information.\endverbatim
11 **
12 ** \brief [[ Add file-specific comments here ]].
13 **
14 ** [[ Add file-specific comments here ]]
15 **/
16
17 #include <antlr3.h>
18
19 #include "parser/smt1/smt1_input.h"
20 #include "expr/expr_manager.h"
21 #include "parser/input.h"
22 #include "parser/parser.h"
23 #include "parser/parser_exception.h"
24 #include "parser/smt1/generated/Smt1Lexer.h"
25 #include "parser/smt1/generated/Smt1Parser.h"
26
27 namespace CVC4 {
28 namespace parser {
29
30 /* Use lookahead=2 */
31 Smt1Input::Smt1Input(AntlrInputStream& inputStream) :
32 AntlrInput(inputStream, 2) {
33 pANTLR3_INPUT_STREAM input = inputStream.getAntlr3InputStream();
34 assert( input != NULL );
35
36 d_pSmt1Lexer = Smt1LexerNew(input);
37 if( d_pSmt1Lexer == NULL ) {
38 throw ParserException("Failed to create SMT lexer.");
39 }
40
41 setAntlr3Lexer( d_pSmt1Lexer->pLexer );
42
43 pANTLR3_COMMON_TOKEN_STREAM tokenStream = getTokenStream();
44 assert( tokenStream != NULL );
45
46 d_pSmt1Parser = Smt1ParserNew(tokenStream);
47 if( d_pSmt1Parser == NULL ) {
48 throw ParserException("Failed to create SMT parser.");
49 }
50
51 setAntlr3Parser(d_pSmt1Parser->pParser);
52 }
53
54
55 Smt1Input::~Smt1Input() {
56 d_pSmt1Lexer->free(d_pSmt1Lexer);
57 d_pSmt1Parser->free(d_pSmt1Parser);
58 }
59
60 Command* Smt1Input::parseCommand() {
61 return d_pSmt1Parser->parseCommand(d_pSmt1Parser);
62 }
63
64 Expr Smt1Input::parseExpr() {
65 return d_pSmt1Parser->parseExpr(d_pSmt1Parser);
66 }
67
68 }/* CVC4::parser namespace */
69 }/* CVC4 namespace */