@maniascript/parser
Version:
Maniascript parser
100 lines (99 loc) • 3.63 kB
TypeScript
import { type AST, Node } from './ast.js';
import { type Type } from './type.js';
import { SourceLocationRange } from './position.js';
declare enum SymbolKind {
Base = "Base",
Structure = "Structure",
Label = "Label",
Typed = "Typed",
Setting = "Setting",
Command = "Command",
Constant = "Constant",
Variable = "Variable",
Parameter = "Parameter",
Scope = "Scope",
Block = "Block",
LabelBlock = "LabelBlock",
Namespace = "Namespace",
Function = "Function",
ControlFlow = "ControlFlow"
}
declare class BaseSymbol {
#private;
_parent: ScopeSymbol | null;
readonly kind: SymbolKind;
constructor(name: string, node: Node, kind?: SymbolKind);
get name(): string;
get source(): SourceLocationRange;
get parent(): ScopeSymbol | null;
}
declare class StructureSymbol extends BaseSymbol {
constructor(name: string, node: Node, kind?: SymbolKind);
}
declare class LabelSymbol extends BaseSymbol {
constructor(name: string, node: Node, kind?: SymbolKind);
}
declare class TypedSymbol extends BaseSymbol {
type: Type;
constructor(name: string, node: Node, kind?: SymbolKind, type?: Type);
}
declare class SettingSymbol extends TypedSymbol {
constructor(name: string, node: Node, kind?: SymbolKind);
}
declare class CommandSymbol extends TypedSymbol {
constructor(name: string, node: Node, kind?: SymbolKind);
}
declare class ConstantSymbol extends TypedSymbol {
constructor(name: string, node: Node, kind?: SymbolKind);
}
declare class VariableSymbol extends TypedSymbol {
constructor(name: string, node: Node, kind?: SymbolKind);
}
declare class ParameterSymbol extends TypedSymbol {
constructor(name: string, node: Node, kind?: SymbolKind);
}
declare class ScopeSymbol extends BaseSymbol {
constructor(name: string, node: Node, kind?: SymbolKind);
protected _children: BaseSymbol[];
get children(): BaseSymbol[];
addSymbol(symbol: BaseSymbol): void;
removeSymbol(symbol: BaseSymbol): void;
/**
* Get a list of symbols visible at the given position
* @param line line number 1..n
* @param column column number 0..n
* @returns A list of symbols
*/
getSymbolsAtPosition(line: number, column: number): BaseSymbol[];
}
declare class BlockSymbol extends ScopeSymbol {
constructor(name: string, node: Node, kind?: SymbolKind);
}
declare class LabelBlockSymbol extends ScopeSymbol {
constructor(name: string, node: Node, kind?: SymbolKind);
}
declare class NamespaceSymbol extends ScopeSymbol {
constructor(name: string, node: Node, kind?: SymbolKind);
}
declare class FunctionSymbol extends ScopeSymbol {
type: Type;
constructor(name: string, node: Node, kind?: SymbolKind, type?: Type);
}
declare class ControlFlowSymbol extends ScopeSymbol {
constructor(node: Node, kind?: SymbolKind);
}
declare class SymbolTable extends ScopeSymbol {
#private;
get labels(): LabelSymbol[];
addLabel(symbol: LabelSymbol): void;
removeLabel(symbol: LabelSymbol): void;
/**
* Get a list of symbols visible at the given position
* @param line line number 1..n
* @param column column number 0..n
* @returns A list of symbols
*/
getSymbolsAtPosition(line: number, column: number): BaseSymbol[];
}
declare function build(ast: AST): SymbolTable | null;
export { BaseSymbol, StructureSymbol, LabelSymbol, SettingSymbol, CommandSymbol, ConstantSymbol, VariableSymbol, ParameterSymbol, ScopeSymbol, BlockSymbol, LabelBlockSymbol, NamespaceSymbol, FunctionSymbol, ControlFlowSymbol, SymbolTable, SymbolKind, build };