Branch data Line data Source code
1 : : /****************************************************************************** 2 : : * This file is part of the cvc5 project. 3 : : * 4 : : * Copyright (c) 2009-2026 by the authors listed in the file AUTHORS 5 : : * in the top-level source directory and their institutional affiliations. 6 : : * All rights reserved. See the file COPYING in the top-level source 7 : : * directory for licensing information. 8 : : * **************************************************************************** 9 : : * 10 : : * The flex smt2 parser. 11 : : */ 12 : : 13 : : #include "parser/smt2/smt2_parser.h" 14 : : 15 : : #include "base/output.h" 16 : : #include "parser/commands.h" 17 : : 18 : : namespace cvc5 { 19 : : namespace parser { 20 : : 21 : 24382 : Smt2Parser::Smt2Parser(Solver* solver, 22 : : SymManager* sm, 23 : : ParsingMode parsingMode, 24 : 24382 : bool isSygus) 25 : : : Parser(solver, sm), 26 : 24382 : d_slex(parsingMode == ParsingMode::STRICT, isSygus), 27 : 24382 : d_state(this, solver, sm, parsingMode, isSygus), 28 : 24382 : d_termParser(d_slex, d_state), 29 : 48764 : d_cmdParser(d_slex, d_state, d_termParser) 30 : : { 31 : 24382 : d_lex = &d_slex; 32 : 24382 : } 33 : : 34 : 154 : void Smt2Parser::setLogic(const std::string& logic) { d_state.setLogic(logic); } 35 : : 36 : 690713 : std::unique_ptr<Cmd> Smt2Parser::parseNextCommand() 37 : : { 38 : 690713 : return d_cmdParser.parseNextCommand(); 39 : : } 40 : : 41 : 133 : Term Smt2Parser::parseNextTerm() 42 : : { 43 : : // check for EOF here and return null if so 44 : 133 : Token tok = d_slex.peekToken(); 45 [ + + ]: 128 : if (tok == Token::EOF_TOK) 46 : : { 47 : 42 : return Term(); 48 : : } 49 : : // check that the logic has been set 50 : 86 : d_state.checkThatLogicIsSet(); 51 : : // Parse the term. 52 : 86 : return d_termParser.parseTerm(); 53 : : } 54 : : 55 : : } // namespace parser 56 : : } // namespace cvc5