@eagleoutice/flowr-dev
Version:
Static Dataflow Analyzer and Program Slicer for the R Programming Language
67 lines (66 loc) • 3.33 kB
TypeScript
import { NodeId } from '../../r-bridge/lang-4.x/ast/model/processing/node-id';
import type { AstIdMap } from '../../r-bridge/lang-4.x/ast/model/processing/decorate';
/** An optional `(file-regex)` suffix restricting a criterion to nodes stemming from a matching file. */
type FileFilterSuffix = '' | `(${string})`;
/** see {@link SlicingCriterion.tryParse} for what each of these formats resolves to */
export type SlicingCriterion = `${number}:${number}${FileFilterSuffix}` | `${number}~${number}${FileFilterSuffix}` | `${number}^${FileFilterSuffix}` | `${number}@${string}` | `$${NodeId | number}`;
/**
* The helper object associated with {@link SlicingCriterion} which makes it easy
* to parse, validate and resolve slicing criteria.
*/
export declare const SlicingCriterion: {
readonly name: "SlicingCriterion";
/**
* Checks whether a value has a valid slicing criterion syntax.
* This does not check whether the slicing criterion exists (represents a valid node ID).
* @see {@link SlicingCriterion.parse} to parse a slicing criterion to a node ID
*/
readonly isValid: (this: void, criterion: unknown) => criterion is SlicingCriterion;
/**
* Resolves a slicing criterion to the corresponding node id.
* @see {@link SlicingCriterion.tryParse} for a version that does not throw an error
*/
readonly parse: (this: void, criterion: SlicingCriterion, idMap: AstIdMap) => NodeId;
/**
* Tries to resolve a slicing criterion to an id, but does not throw an error if it fails.
* The formats and what each of them resolves to are documented in the
* {@link https://github.com/flowr-analysis/flowr/wiki/Terminology#slicing-criterion|wiki}.
* @see {@link SlicingCriterion.parse} for the version that throws an error
*/
readonly tryParse: (this: void, criterion: SlicingCriterion | NodeId, idMap: AstIdMap) => NodeId | undefined;
/**
* Converts a node id to a slicing criterion in the form of `$id`
*/
readonly fromId: (this: void, id: NodeId) => SlicingCriterion;
};
/** several {@link SlicingCriterion}s, all of which are sliced for at once */
export type SlicingCriteria = SlicingCriterion[];
export interface DecodedCriterion {
criterion: SlicingCriterion;
id: NodeId;
}
export type DecodedCriteria = ReadonlyArray<DecodedCriterion>;
/**
* The helper object associated with {@link SlicingCriteria} which makes it easy to parse, validate and resolve slicing criteria.
*/
export declare const SlicingCriteria: {
readonly name: "SlicingCriteria";
/**
* Decodes all slicing criteria to their corresponding node ids
* @throws CriteriaParseError if any of the criteria can not be resolved
* @see {@link SlicingCriteria.convertAll}
*/
readonly decodeAll: (this: void, criteria: SlicingCriteria, decorated: AstIdMap) => DecodedCriteria;
/**
* Converts all criteria to their id in the AST if possible, this keeps the original criterion if it can not be resolved.
* @see {@link SlicingCriteria.decodeAll}
*/
readonly convertAll: (this: void, criteria: SlicingCriteria, decorated: AstIdMap) => NodeId[];
};
/**
* Thrown if the given slicing criteria can not be found
*/
export declare class CriteriaParseError extends Error {
constructor(message: string);
}
export {};