simc-ast-builder
Version:
Parser and AST generator for SimulationCraft files
68 lines • 2.02 kB
TypeScript
import { ASTNode, OptimizerOptions, ParserOptions, SyntaxTree } from "./types";
/**
* Generate an Abstract Syntax Tree (AST) from SimC code with optimization
*
* @param input - The SimC code to parse
* @param options - Parser options
* @returns A SyntaxTree containing the parsed AST and any errors
*
* @example
* ```typescript
* import { generateAST } from 'simc-parser';
*
* const code = 'actions=frost_strike,if=runic_power>=80';
* const result = generateAST(code);
* console.log(result.root);
* ```
*/
export declare function generateAST(input: string, options?: ParserOptions): SyntaxTree;
/**
* Optimize an AST node (primarily for condition optimization)
*
* @param node - The AST node to optimize
* @param options - Optimization options
* @returns The optimized AST node
*
* @example
* ```typescript
* import { parse, optimize } from 'simc-parser';
*
* const code = 'actions=frost_strike,if=runic_power>=80&(buff.killing_machine.up|!talent.obliteration)';
* const ast = parse(code);
*
* // Optimize with default options
* const optimizedAst = optimize(ast);
*
* // With specific optimization options
* const customOptimizedAst = optimize(ast, {
* doubleNegation: true,
* deMorgansLaw: false,
* commonSubexpressions: true
* });
* ```
*/
export declare function optimize(node: ASTNode, options?: OptimizerOptions): ASTNode;
/**
* Parse SimC code into an AST without optimization
*
* @param input - The SimC code to parse
* @returns The parsed AST node
*
* @example
* ```typescript
* import { parse } from 'simc-parser';
*
* const code = 'actions=frost_strike,if=runic_power>=80';
* const ast = parse(code);
* console.log(ast);
* ```
*/
export declare function parse(input: string): ASTNode;
/**
* Streamlined exports for main API surface
*/
export * from "./parser";
export * from "./types";
export { ConditionOptimizer } from "./utils/ConditionOptimizer";
export type { NodeTypes } from "./parser/visitors/ast/node-types";
//# sourceMappingURL=index.d.ts.map