@eagleoutice/flowr
Version:
Static Dataflow Analyzer and Program Slicer for the R Programming Language
75 lines (74 loc) • 2.73 kB
TypeScript
import { RType } from '../r-bridge/lang-4.x/ast/model/type';
import type { VertexType } from '../dataflow/graph/vertex';
import type { NormalizedAst, ParentInformation } from '../r-bridge/lang-4.x/ast/model/processing/decorate';
import type { DataflowInformation } from '../dataflow/info';
import type { RNode } from '../r-bridge/lang-4.x/ast/model/model';
export type FlowrFilterName = keyof typeof FlowrFilters;
export declare enum FlowrFilter {
DropEmptyArguments = "drop-empty-arguments"
}
export declare const ValidFlowrFilters: Set<string>;
export declare const ValidFlowrFiltersReverse: {
[k: string]: string;
};
export declare const FlowrFilters: {
readonly "drop-empty-arguments": (n: RNode<ParentInformation>) => boolean;
};
type ValidFilterTypes = FlowrFilterName | RType | VertexType;
/**
* By default, we provide filter for every {@link RType} and {@link VertexType}.
*/
export type FlowrFilterExpression = FlowrFilterCombinator | ValidFilterTypes;
interface BooleanBinaryNode<Composite> {
readonly type: 'and' | 'or' | 'xor';
readonly left: Composite;
readonly right: Composite;
}
interface BooleanUnaryNode<Composite> {
readonly type: 'not';
readonly operand: Composite;
}
type LeafRType = {
readonly type: 'r-type';
readonly value: RType;
};
type LeafVertexType = {
readonly type: 'vertex-type';
readonly value: VertexType;
};
type LeafSpecial = {
readonly type: 'special';
readonly value: string;
};
type Leaf = LeafRType | LeafVertexType | LeafSpecial;
type BooleanNode = BooleanBinaryNode<BooleanNode> | BooleanUnaryNode<BooleanNode> | Leaf;
type BooleanNodeOrCombinator = BooleanNode | FlowrFilterCombinator;
/**
* @see {@link FlowrFilterCombinator.is}
* @see {@link evalFilter}
* @see {@link binaryTreeToString}
*/
export declare class FlowrFilterCombinator {
private tree;
protected constructor(init: BooleanNodeOrCombinator);
static is(value: BooleanNodeOrCombinator | ValidFilterTypes): FlowrFilterCombinator;
and(right: BooleanNodeOrCombinator | ValidFilterTypes): this;
or(right: BooleanNodeOrCombinator | ValidFilterTypes): this;
xor(right: BooleanNodeOrCombinator | ValidFilterTypes): this;
private binaryRight;
not(): this;
private unary;
private unpack;
get(): BooleanNode;
}
export declare function binaryTreeToString(tree: BooleanNode): string;
export declare function isBinaryTree(tree: unknown): tree is {
tree: BooleanNode;
};
interface FilterData {
readonly node: RNode<ParentInformation>;
readonly normalize: NormalizedAst;
readonly dataflow: DataflowInformation;
}
export declare function evalFilter(filter: FlowrFilterExpression, data: FilterData): boolean;
export {};