UNPKG

@eagleoutice/flowr

Version:

Static Dataflow Analyzer and Program Slicer for the R Programming Language

57 lines (56 loc) 2.6 kB
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'; /** Either `line:column`, `line@variable-name`, or `$id` */ export type SlicingCriterion = `${number}:${number}` | `${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"; /** * Takes a criterion in the form of `line:column` or `line@variable-name` and returns 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. * @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; }; /** * A slicing criterion is a list of single slicing criteria, which can be in the form of `line:column`, `line@variable-name`, or `$id`. */ 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: { /** * 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); }