GCC Code Coverage Report
Directory: . Exec Total Coverage
File: src/parser/cvc/cvc_input.cpp Lines: 22 24 91.7 %
Date: 2021-05-22 Branches: 14 56 25.0 %

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