@eagleoutice/flowr
Version:
Static Dataflow Analyzer and Program Slicer for the R Programming Language
26 lines (25 loc) • 1.52 kB
TypeScript
/**
* Just to avoid another library for splitting arguments, we use this module to provide what we need.
* @module
*/
/**
* This splits an input string on the given split string (e.g., ` `), but checks if the string is quoted or escaped.
*
* Given an input string like `a "b c" d`, with a space character as split, and escapeQuote set to true,
* this splits the arguments similar to common shell interpreters (i.e., `a`, `b c`, and `d`).
*
* When escapeQuote is set to false instead, we keep quotation marks in the result (i.e., `a`, `"b c"`, and `d`.).
* @param inputString - The string to split
* @param escapeQuote - Keep quotes in args
* @param split - The character or character sequence to split on (can not be backslash or quote!)
*/
export declare function splitAtEscapeSensitive(inputString: string, escapeQuote?: boolean, split?: RegExp | string): string[];
/**
* Splits the given string on 'and', but only if not nested inside `<>`, `[]`, `()`, or quotes.
* This also handles escaped quotes.
* @param str - The string to split
* @param splitOn - The string to split on (default: 'and')
* @param closes - The matching of closing characters for nesting, structures with different open and close characters only can be nested
* of each other, while those with the same open and close character (like quotes) can not be nested inside themselves.
*/
export declare function splitOnNestingSensitive(str: string, splitOn?: string, closes?: Record<string, string>): string[];