pddl-workspace
Version:
122 lines (121 loc) • 5.53 kB
TypeScript
import { PddlToken, PddlTokenType, TextRange } from "./PddlTokenizer";
/** Single node in the syntax tree that wraps one PDDL tokenizer token. */
export declare class PddlSyntaxNode extends TextRange {
private token;
private parent?;
private children;
private maxChildEnd;
/**
* Creates the syntax tree node.
* @param token pddl token wrapped by this node
* @param parent parent node, unless this is the root node
*/
constructor(token: PddlToken, parent?: PddlSyntaxNode | undefined);
static createRoot(): PddlSyntaxNode;
isRoot(): boolean;
getParent(): PddlSyntaxNode | undefined;
isLeaveBracket(): boolean;
getToken(): PddlToken;
addChild(childNode: PddlSyntaxNode): void;
recalculateEnd(childNode: TextRange): void;
getChildren(): PddlSyntaxNode[];
getNestedChildren(): PddlSyntaxNode[];
getSingleChild(): PddlSyntaxNode;
getNonWhitespaceChildren(): PddlSyntaxNode[];
getNonWhitespaceNonCommentChildren(): PddlSyntaxNode[];
getSingleNonWhitespaceChild(): PddlSyntaxNode;
getChildrenOfType(type: PddlTokenType, pattern: RegExp): PddlSyntaxNode[];
getFirstChild(type: PddlTokenType, pattern: RegExp): PddlSyntaxNode | undefined;
getFirstChildOrThrow(type: PddlTokenType, pattern: RegExp): PddlSyntaxNode;
getFirstOpenBracket(keyword: string): PddlBracketNode;
getFirstOpenBracketOrThrow(keyword: string): PddlBracketNode;
getChildrenRecursively(test: (node: PddlSyntaxNode) => boolean, callback: (node: PddlSyntaxNode) => void): void;
/**
* Finds the bracket nested inside the `:keyword`.
* @param keyword keyword name e.g. 'precondition' to match ':precondition (*)'
*/
getKeywordOpenBracket(keyword: string): PddlBracketNode | undefined;
/**
* Get all keyword open brackets e.g. `(:action ...)`
* @param keyword keyword name e.g. `action` to match `(:action ...)`
*/
getKeywordOpenBrackets(keyword: string): PddlBracketNode[];
hasChildren(): boolean;
getNestedText(): string;
getNestedNonCommentText(): string;
getText(): string;
getNonCommentText(): string;
getStart(): number;
getEnd(): number;
/** @returns number of characters in this node (including its children) */
get length(): number;
findAncestor(type: PddlTokenType, pattern: RegExp): PddlSyntaxNode | undefined;
getAncestors(includeTypes: PddlTokenType[], pattern?: RegExp): PddlSyntaxNode[];
findParametrisableScope(parameterName: string): PddlSyntaxNode | undefined;
findAllParametrisableScopes(): PddlSyntaxNode[];
private static findParametrisableAncestor;
getParameterDefinition(): PddlSyntaxNode | undefined;
/**
* Checks whether this scope node defines given parameter.
* @param parameterName parameter name without the `?` sign
*/
declaresParameter(parameterName: string): boolean;
/**
* Expands to the encompassing bracket pair, unless this node is the top level Document node.
*/
expand(): PddlSyntaxNode;
/**
* Gets all preceding siblings (in order of appearance, not backwards)
* @param type node type filter
* @param centralNode optional node from which the siblings are split to preceding/following (by default this node is `this` node)
*/
getPrecedingSiblings(type?: PddlTokenType, centralNode?: PddlSyntaxNode): PddlSyntaxNode[];
/**
* Gets all following siblings
* @param type node type filter
* @param centralNode optional node from which the siblings are split to preceding/following (by default this node is `this` node)
*/
getFollowingSiblings(type?: PddlTokenType, centralNode?: PddlSyntaxNode): PddlSyntaxNode[];
/**
* Gets the just preceding sibling, or `undefined`, if none.
* @param type node type filter
* @param centralNode optional node from which the siblings are split to preceding/following (by default this node is `this` node)
*/
getPrecedingSibling(type?: PddlTokenType, centralNode?: PddlSyntaxNode): PddlSyntaxNode | undefined;
/**
* Gets the just following sibling, or `undefined`, if none.
* @param type node type filter
* @param centralNode optional node from which the siblings are split to preceding/following (by default this node is `this` node)
*/
getFollowingSibling(type?: PddlTokenType, centralNode?: PddlSyntaxNode): PddlSyntaxNode | undefined;
/**
* Gets the siblings of this node.
* @param type optional node type filter
* @param centralNode optional node from which the siblings are split to preceding/following (by default this node is `this` node)
*/
private getSiblings;
isDocument(): boolean;
isType(type: PddlTokenType): boolean;
isNotType(type: PddlTokenType): boolean;
isAnyOf(types: PddlTokenType[]): boolean;
isNoneOf(types: PddlTokenType[]): boolean;
isNumericExpression(): boolean;
isLogicalExpression(): boolean;
isTemporalExpression(): boolean;
toString(): string;
}
/** Specialized tree node for open/close bracket pair. */
export declare class PddlBracketNode extends PddlSyntaxNode {
private closeToken;
private _isClosed;
/**
* Sets the bracket close token.
* @param token pddl bracket close token
*/
setCloseBracket(token: PddlToken): void;
getCloseBracket(): PddlToken | undefined;
get isClosed(): boolean;
getNestedChildren(): PddlSyntaxNode[];
getText(): string;
getNonCommentText(): string;
}