@eagleoutice/flowr
Version:
Static Dataflow Analyzer and Program Slicer for the R Programming Language
51 lines (50 loc) • 2.25 kB
TypeScript
import type { JsonEntry, NamedJsonEntry } from '../json/format';
import { SourceRange } from '../../../../../util/range';
import { type RawRType } from '../../model/type';
import type { RNode } from '../../model/model';
import type { RExpressionList } from '../../model/nodes/r-expression-list';
/**
* Given a JSON element, extract the source location of the corresponding element in the R-ast
*/
export declare function extractLocation(ast: JsonEntry): SourceRange;
/**
* The JSON object that represents the input contains various meta-information.
* This function extracts the meta-information and returns it.
* @param entry - The JSON object to extract the meta-information from
* @returns An object containing the passed entry, the location of the corresponding R-ast element, and the content of the passed entry
*/
export declare function retrieveMetaStructure(entry: JsonEntry): {
location: SourceRange;
content: string;
};
/**
* Ensure that the given token is of the expected type.
*/
export declare function assureTokenType(token: string, expectedName: RawRType): void;
/**
* Extract the token-type of the given object. This is based on the knowledge, that all JSON objects created
* from the R XML have a name attached.
* @param content - the JSON object to extract the token-type from
*/
export declare function getTokenType(content: JsonEntry): RawRType;
/**
* Given a list of JSON objects, extract their token-types and return them alongside the original objects.
*/
export declare function getWithTokenType(obj: JsonEntry[]): {
name: RawRType;
content: JsonEntry;
}[];
/**
* Extract the operation name from the given operator node.
*/
export declare function retrieveOpName(operator: NamedJsonEntry): string;
/**
* Ensure that the first child is completely before the second child.
* @param first - the first child which should be the lhs
* @param second - the second child which should be the rhs
*/
export declare function ensureChildrenAreLhsAndRhsOrdered(first: JsonEntry, second: JsonEntry): void;
/**
* Ensure that the given node is an expression list. If it is not, wrap it in an expression list.
*/
export declare function ensureExpressionList<Info>(node: RNode<Info>): RExpressionList<Info>;