Remove antlr_undefines.h. (#2664)
[cvc5.git] / src / parser / cvc / cvc_input.cpp
1 /********************* */
2 /*! \file cvc_input.cpp
3 ** \verbatim
4 ** Top contributors (to current version):
5 ** Christopher L. Conway, Morgan Deters, Tim King
6 ** This file is part of the CVC4 project.
7 ** Copyright (c) 2009-2018 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.\endverbatim
11 **
12 ** \brief [[ Add file-specific comments here ]].
13 **
14 ** [[ Add file-specific comments here ]]
15 **/
16
17 #include "parser/cvc/cvc_input.h"
18
19 #include <antlr3.h>
20
21 #include "expr/expr_manager.h"
22 #include "parser/antlr_input.h"
23 #include "parser/parser_exception.h"
24 #include "parser/cvc/CvcLexer.h"
25 #include "parser/cvc/CvcParser.h"
26
27 namespace CVC4 {
28 namespace parser {
29
30 /* Use lookahead=3 */
31 CvcInput::CvcInput(AntlrInputStream& inputStream) :
32 AntlrInput(inputStream,6) {
33 pANTLR3_INPUT_STREAM input = inputStream.getAntlr3InputStream();
34 assert( input != NULL );
35
36 d_pCvcLexer = CvcLexerNew(input);
37 if( d_pCvcLexer == NULL ) {
38 throw ParserException("Failed to create CVC lexer.");
39 }
40
41 setAntlr3Lexer( d_pCvcLexer->pLexer );
42
43 pANTLR3_COMMON_TOKEN_STREAM tokenStream = getTokenStream();
44 assert( tokenStream != NULL );
45
46 d_pCvcParser = CvcParserNew(tokenStream);
47 if( d_pCvcParser == NULL ) {
48 throw ParserException("Failed to create CVC parser.");
49 }
50
51 setAntlr3Parser(d_pCvcParser->pParser);
52 }
53
54
55 CvcInput::~CvcInput() {
56 d_pCvcLexer->free(d_pCvcLexer);
57 d_pCvcParser->free(d_pCvcParser);
58 }
59
60 Command* CvcInput::parseCommand() {
61 return d_pCvcParser->parseCommand(d_pCvcParser);
62 }
63
64 Expr CvcInput::parseExpr() {
65 return d_pCvcParser->parseExpr(d_pCvcParser);
66 }
67
68 /*
69 pANTLR3_LEXER CvcInput::getLexer() {
70 return d_pCvcLexer->pLexer;
71 }
72 */
73
74 }/* CVC4::parser namespace */
75 }/* CVC4 namespace */