UNPKG

@runtimeverificationinc/tsk

Version:

TypeScript/JavaScript library for K Framework functionality

90 lines (89 loc) 3.46 kB
import { KInner } from "../kast/inner"; import { PrettyPrinter } from "../kast/pretty"; import { CTerm } from "./cterm"; /** * Printer function type that takes a KInner and returns a string representation. */ export type Printer = (kast: KInner) => string; /** * Configuration class for controlling how CTerm instances are displayed. * * This class provides various options for customizing the output when displaying * symbolic program states, including minimization, cell collection breaking, * and label omission. */ export declare class CTermShow { private readonly _printer; private readonly _minimize; private readonly _breakCellCollections; private readonly _omitLabels; constructor(printer: Printer, minimize?: boolean, breakCellCollections?: boolean, omitLabels?: Iterable<string>); /** * Split the printed representation of a KInner into lines. * * @param kast - The KInner term to print. * @returns An array of strings representing the lines of output. */ printLines(kast: KInner): string[]; /** * Create a new CTermShow instance with modified settings. * * @param options - Options to override from the current instance. * @returns A new CTermShow instance with the specified options applied. */ let(options?: { minimize?: boolean; breakCellCollections?: boolean; omitLabels?: Iterable<string>; }): CTermShow; /** * Generate a complete string representation of a CTerm. * * @param cterm - The CTerm to display. * @returns An array of strings representing the formatted output. */ show(cterm: CTerm): string[]; /** * Generate a string representation of the configuration part of a CTerm. * * @param cterm - The CTerm whose configuration should be displayed. * @returns An array of strings representing the formatted configuration. */ showConfig(cterm: CTerm): string[]; /** * Generate a string representation of the constraints part of a CTerm. * * @param cterm - The CTerm whose constraints should be displayed. * @returns An array of strings representing the formatted constraints. */ showConstraints(cterm: CTerm): string[]; /** * Visitor function that breaks down cell collections for better readability. * * When a cell contains a collection (_Set_, _List_, or _Map_), this function * will flatten the collection and represent each item on a separate line. * * @param kast - The KInner term to potentially transform. * @returns The transformed term or the original term if no transformation is needed. */ private _breakCellsVisitor; /** * Visitor function that replaces specified labels with dots (...). * * This is useful for hiding parts of the configuration that are not * relevant to the current analysis or display. * * @param kast - The KInner term to potentially transform. * @returns DOTS if the term's label should be omitted, otherwise the original term. */ private _omitLabelsVisitor; } /** * Create an iterative CTermShow that completely avoids deep recursion * by using the PrettyPrinter's iterative methods */ export declare function createIterativeCTermShow(prettyPrinter: PrettyPrinter, options?: { minimize?: boolean; breakCellCollections?: boolean; omitLabels?: Iterable<string>; }): CTermShow;