Class SmtTextBuilder

  • All Implemented Interfaces:
    ExprTreeVisitor, TreeVisitor

    public final class SmtTextBuilder
    extends java.lang.Object
    implements ExprTreeVisitor
    The SMTTextBuilder class implements logic that generates SMT-LIB code from a syntax structure.

    Generated code is saved to a text file.

    • Method Detail

      • saveToFile

        public static void saveToFile​(java.lang.String fileName,
                                      java.util.List<java.lang.String> header,
                                      java.util.Collection<? extends Node> formulas,
                                      java.util.Map<java.lang.Enum<?>,​SolverOperation> operations)
        Saves the specified data to the file.
        Parameters:
        fileName - The file name.
        header - The data header.
        formulas - The formulas to be saved.
        operations - The operations to be saved. // * @throws IOException
      • saveToFile

        public void saveToFile​(java.lang.String fileName,
                               java.lang.StringBuilder textBuilder)
                        throws java.io.IOException
        Saves the generated SMT-LIB representation to a text file.
        Parameters:
        fileName - The name of the target file.
        textBuilder - Build to put text to be printed in the console.
        Throws:
        java.io.IOException - if failed to create the output file.
      • getStatus

        public TreeVisitor.Status getStatus()
        Description copied from interface: TreeVisitor
        Returns the current status of the visitor. The status guides further actions of the walker.
        Specified by:
        getStatus in interface TreeVisitor
        Returns:
        Current visitor status.
      • onBegin

        public void onBegin()
        Description copied from interface: TreeVisitor
        Notifies that processing of a hierarchical structure has been started.
        Specified by:
        onBegin in interface TreeVisitor
      • onEnd

        public void onEnd()
        Description copied from interface: TreeVisitor
        Notifies that processing of a hierarchical structure has been finished.
        Specified by:
        onEnd in interface TreeVisitor
      • getOperandOrder

        public int[] getOperandOrder()
        Description copied from interface: ExprTreeVisitor
        Returns an array of operand indexes that specify in which order the operands of the currently visited operator should be visited. If the order is standard (i.e. [0..N-1]), null is returned.
        Specified by:
        getOperandOrder in interface ExprTreeVisitor
        Returns:
        Array of operand indexes or null for the standard order.
      • onOperandBegin

        public void onOperandBegin​(NodeOperation expr,
                                   Node node,
                                   int index)
        Description copied from interface: ExprTreeVisitor
        Notifies that visiting an expression operand has started.
        Specified by:
        onOperandBegin in interface ExprTreeVisitor
        Parameters:
        expr - Operation node.
        node - Operand node.
        index - Operand index.
      • onOperandEnd

        public void onOperandEnd​(NodeOperation expr,
                                 Node node,
                                 int index)
        Description copied from interface: ExprTreeVisitor
        Notifies that visiting an expression operand has finished.
        Specified by:
        onOperandEnd in interface ExprTreeVisitor
        Parameters:
        expr - Operation node.
        node - Operand node.
        index - Operand index.
      • onValue

        public void onValue​(NodeValue value)
        Description copied from interface: ExprTreeVisitor
        Notifies that a value node has been visited.
        Specified by:
        onValue in interface ExprTreeVisitor
        Parameters:
        value - Value node.
      • onBoundVariableBegin

        public void onBoundVariableBegin​(NodeBinding node,
                                         NodeVariable variable,
                                         Node value)
        Description copied from interface: ExprTreeVisitor
        Notifies that visiting a bound variable has started. Bound value expression will be visited next as general expression.

        Bound variables are not visited at all.

        Specified by:
        onBoundVariableBegin in interface ExprTreeVisitor
        Parameters:
        node - Binding node.
        variable - Bound variable reference.
        value - Bound value expression.
      • onBoundVariableEnd

        public void onBoundVariableEnd​(NodeBinding node,
                                       NodeVariable variable,
                                       Node value)
        Description copied from interface: ExprTreeVisitor
        Notifies that visiting a bound variable has finished.
        Specified by:
        onBoundVariableEnd in interface ExprTreeVisitor
        Parameters:
        node - Binding node.
        variable - Bound variable reference.
        value - Bound value expression.