kythe.io@v0.0.68-0.20240422202219-7225dbc01741/kythe/cxx/verifier/souffle_interpreter.h (about)

     1  /*
     2   * Copyright 2020 The Kythe Authors. All rights reserved.
     3   *
     4   * Licensed under the Apache License, Version 2.0 (the "License");
     5   * you may not use this file except in compliance with the License.
     6   * You may obtain a copy of the License at
     7   *
     8   *   http://www.apache.org/licenses/LICENSE-2.0
     9   *
    10   * Unless required by applicable law or agreed to in writing, software
    11   * distributed under the License is distributed on an "AS IS" BASIS,
    12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    13   * See the License for the specific language governing permissions and
    14   * limitations under the License.
    15   */
    16  
    17  #ifndef KYTHE_CXX_VERIFIER_SOUFFLE_INTERPRETER_H_
    18  #define KYTHE_CXX_VERIFIER_SOUFFLE_INTERPRETER_H_
    19  
    20  #include <optional>
    21  #include <string_view>
    22  
    23  #include "kythe/cxx/verifier/assertion_ast.h"
    24  
    25  namespace kythe::verifier {
    26  struct SouffleResult {
    27    bool success;
    28    size_t highest_goal_reached;
    29    size_t highest_group_reached;
    30  };
    31  
    32  /// \brief Runs the Souffle interpreter on parsed facts and goal groups.
    33  /// \param symbol_table the symbol table for expanding idents
    34  /// \param goal_groups the goal groups to solve
    35  /// \param database the facts to solve against
    36  /// \param anchors a map of anchors
    37  /// \param inspections the list of EVars that have been marked explicitly
    38  /// (`@foo ref Foo?`) or implicitly for inspection.
    39  /// \param inspect the inspection callback that will be used against the
    40  /// provided list of inspections; a false return value stops iterating through
    41  /// inspection results and fails the solution, while a true result continues.
    42  /// `value` is a string representation of the assignment of the EVar to
    43  /// which the inspection refers.
    44  /// \param get_symbol returns a string representation of the given symbol
    45  /// \return a `SouffleResult` describing how the run went.
    46  SouffleResult RunSouffle(
    47      const SymbolTable& symbol_table, const std::vector<GoalGroup>& goal_groups,
    48      const Database& database, const AnchorMap& anchors,
    49      const std::vector<Inspection>& inspections,
    50      std::function<bool(const Inspection&, std::string_view value)> inspect,
    51      std::function<std::string(size_t)> get_symbol);
    52  }  // namespace kythe::verifier
    53  
    54  #endif  // defined(KYTHE_CXX_VERIFIER_SOUFFLE_INTERPRETER_H_)