pddl-workspace
Version:
65 lines (64 loc) • 2.35 kB
TypeScript
export declare enum PddlTokenType {
/** Open bracket with the operator name, e.g. `(+` or `(:action` or `(increase` */
OpenBracketOperator = "OPEN_BRACKET_OPERATOR",
/** Open bracket `(` */
OpenBracket = "OPEN_BRACKET",
/** Close bracket `)` */
CloseBracket = "CLOSE_BRACKET",
/** Keyword e.g. `:parameters` or `:effect` */
Keyword = "KEYWORD",
/** Dash character. */
Dash = "DASH",
/** Parameter name e.g. `?p1`. */
Parameter = "PARAMETER",
/** Vertical or horizontal whitespace. */
Whitespace = "WHITESPACE",
/** Other unclassified token. */
Other = "OTHER",
/** Comment i.e. anything after `;`, including the semicolon */
Comment = "COMMENT",
/** Document is the root node type. */
Document = "DOCUMENT"
}
export declare abstract class TextRange {
/** Index of first character of the token. */
abstract getStart(): number;
/** Index in the document text just after the last character of the token. */
abstract getEnd(): number;
includesIndex(symbolIndex: number): boolean;
}
/** PDDL syntax token. */
export declare class PddlToken extends TextRange {
readonly type: PddlTokenType;
readonly tokenText: string;
private readonly start;
/** Index in the document text just after the last character of the token. */
private readonly end;
/**
* Constructs.
* @param type token type
* @param tokenText token content
* @param start first character of the token
*/
constructor(type: PddlTokenType, tokenText: string, start: number);
/**
* Creates token from a regex match result.
* @param type token type
* @param match regex match
*/
static from(type: PddlTokenType, match: RegExpExecArray): PddlToken;
getStart(): number;
getEnd(): number;
toString(): string;
}
/** Tokenizes PDDL documents. */
export declare class PddlTokenizer {
/**
* Starts tokenizing.
* @param pddlText input PDDL text
* @param callback callback to call when a new token is encountered
* @param lastIndexOfInterest last index of interest or `undefined` to parse the entire document
*/
constructor(pddlText: string, callback: (token: PddlToken) => void, lastIndexOfInterest?: number);
}
export declare function isOpenBracket(token: PddlToken): boolean;