GCC Code Coverage Report
Directory: . Exec Total Coverage
File: src/parser/smt2/sygus_input.cpp Lines: 20 24 83.3 %
Date: 2021-08-14 Branches: 14 56 25.0 %

Line Exec Source
1
/******************************************************************************
2
 * Top contributors (to current version):
3
 *   Morgan Deters, Andrew Reynolds, Mathias Preiner
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 file-specific comments here ]]
16
 */
17
18
#include "parser/smt2/sygus_input.h"
19
20
#include <antlr3.h>
21
22
#include "base/check.h"
23
#include "parser/input.h"
24
#include "parser/parser.h"
25
#include "parser/parser_exception.h"
26
#include "parser/smt2/Smt2Lexer.h"
27
#include "parser/smt2/Smt2Parser.h"
28
#include "parser/smt2/sygus_input.h"
29
30
namespace cvc5 {
31
namespace parser {
32
33
/* Use lookahead=2 */
34
194
SygusInput::SygusInput(AntlrInputStream& inputStream) :
35
194
  AntlrInput(inputStream, 2) {
36
37
194
  pANTLR3_INPUT_STREAM input = inputStream.getAntlr3InputStream();
38
194
  Assert(input != NULL);
39
40
194
  d_pSmt2Lexer = Smt2LexerNew(input);
41
194
  if( d_pSmt2Lexer == NULL ) {
42
    throw ParserException("Failed to create SMT2 lexer.");
43
  }
44
45
194
  setAntlr3Lexer( d_pSmt2Lexer->pLexer );
46
47
194
  pANTLR3_COMMON_TOKEN_STREAM tokenStream = getTokenStream();
48
194
  Assert(tokenStream != NULL);
49
50
194
  d_pSmt2Parser = Smt2ParserNew(tokenStream);
51
194
  if( d_pSmt2Parser == NULL ) {
52
    throw ParserException("Failed to create SMT2 parser.");
53
  }
54
55
194
  setAntlr3Parser(d_pSmt2Parser->pParser);
56
194
}
57
58
582
SygusInput::~SygusInput() {
59
194
  d_pSmt2Lexer->free(d_pSmt2Lexer);
60
194
  d_pSmt2Parser->free(d_pSmt2Parser);
61
388
}
62
63
2187
Command* SygusInput::parseCommand() {
64
2187
  return d_pSmt2Parser->parseSygus(d_pSmt2Parser);
65
}
66
67
api::Term SygusInput::parseExpr()
68
{
69
  return d_pSmt2Parser->parseExpr(d_pSmt2Parser);
70
}
71
72
}  // namespace parser
73
29325
}  // namespace cvc5