1 /********************* */
2 /*! \file cvc_input.cpp
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
12 ** \brief [[ Add file-specific comments here ]].
14 ** [[ Add file-specific comments here ]]
17 #include "parser/cvc/cvc_input.h"
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"
31 CvcInput::CvcInput(AntlrInputStream
& inputStream
) :
32 AntlrInput(inputStream
,6) {
33 pANTLR3_INPUT_STREAM input
= inputStream
.getAntlr3InputStream();
34 assert( input
!= NULL
);
36 d_pCvcLexer
= CvcLexerNew(input
);
37 if( d_pCvcLexer
== NULL
) {
38 throw ParserException("Failed to create CVC lexer.");
41 setAntlr3Lexer( d_pCvcLexer
->pLexer
);
43 pANTLR3_COMMON_TOKEN_STREAM tokenStream
= getTokenStream();
44 assert( tokenStream
!= NULL
);
46 d_pCvcParser
= CvcParserNew(tokenStream
);
47 if( d_pCvcParser
== NULL
) {
48 throw ParserException("Failed to create CVC parser.");
51 setAntlr3Parser(d_pCvcParser
->pParser
);
55 CvcInput::~CvcInput() {
56 d_pCvcLexer
->free(d_pCvcLexer
);
57 d_pCvcParser
->free(d_pCvcParser
);
60 Command
* CvcInput::parseCommand() {
61 return d_pCvcParser
->parseCommand(d_pCvcParser
);
64 Expr
CvcInput::parseExpr() {
65 return d_pCvcParser
->parseExpr(d_pCvcParser
);
69 pANTLR3_LEXER CvcInput::getLexer() {
70 return d_pCvcLexer->pLexer;
74 }/* CVC4::parser namespace */