Branch data Line data Source code
1 : : /****************************************************************************** 2 : : * Top contributors (to current version): 3 : : * Andrew Reynolds, Aina Niemetz 4 : : * 5 : : * This file is part of the cvc5 project. 6 : : * 7 : : * Copyright (c) 2009-2025 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 : : * The flex smt2 parser. 14 : : */ 15 : : 16 : : #include "parser/smt2/smt2_parser.h" 17 : : 18 : : #include "base/output.h" 19 : : #include "parser/commands.h" 20 : : 21 : : namespace cvc5 { 22 : : namespace parser { 23 : : 24 : 24318 : Smt2Parser::Smt2Parser(Solver* solver, 25 : : SymManager* sm, 26 : : ParsingMode parsingMode, 27 : 24318 : bool isSygus) 28 : : : Parser(solver, sm), 29 : : d_slex(parsingMode == ParsingMode::STRICT, isSygus), 30 : : d_state(this, solver, sm, parsingMode, isSygus), 31 : 24318 : d_termParser(d_slex, d_state), 32 : 24318 : d_cmdParser(d_slex, d_state, d_termParser) 33 : : { 34 : 24318 : d_lex = &d_slex; 35 : 24318 : } 36 : : 37 : 154 : void Smt2Parser::setLogic(const std::string& logic) { d_state.setLogic(logic); } 38 : : 39 : 725846 : std::unique_ptr<Cmd> Smt2Parser::parseNextCommand() 40 : : { 41 : 725846 : return d_cmdParser.parseNextCommand(); 42 : : } 43 : : 44 : 133 : Term Smt2Parser::parseNextTerm() 45 : : { 46 : : // check for EOF here and return null if so 47 : 133 : Token tok = d_slex.peekToken(); 48 [ + + ]: 128 : if (tok == Token::EOF_TOK) 49 : : { 50 : 42 : return Term(); 51 : : } 52 : : // check that the logic has been set 53 : 86 : d_state.checkThatLogicIsSet(); 54 : : // Parse the term. 55 : 86 : return d_termParser.parseTerm(); 56 : : } 57 : : 58 : : } // namespace parser 59 : : } // namespace cvc5