mirror of
https://github.com/SillyTavern/SillyTavern.git
synced 2025-06-05 21:59:27 +02:00
40 lines
1.1 KiB
JavaScript
40 lines
1.1 KiB
JavaScript
import { MacroLexer } from './MacroLexer.js';
|
|
import { MacroParser } from './MacroParser.js';
|
|
|
|
class MacroEngine {
|
|
static instance = new MacroEngine();
|
|
|
|
constructor() {
|
|
this.parser = MacroParser;
|
|
}
|
|
|
|
parseDocument(input) {
|
|
const lexingResult = MacroLexer.tokenize(input);
|
|
this.parser.input = lexingResult.tokens;
|
|
// const cst = this.parser.document();
|
|
// return cst;
|
|
}
|
|
|
|
evaluate(input) {
|
|
const lexingResult = MacroLexer.tokenize(input);
|
|
this.parser.input = lexingResult.tokens;
|
|
// const cst = this.parser.macro();
|
|
|
|
// if (this.parser.errors.length > 0) {
|
|
// throw new Error('Parsing errors detected');
|
|
// }
|
|
|
|
// return this.execute(cst);
|
|
}
|
|
|
|
execute(cstNode) {
|
|
// Implement execution logic here, traversing the CST and replacing macros with their values
|
|
// For now, we'll just return a placeholder result
|
|
return 'Executed Macro';
|
|
}
|
|
}
|
|
|
|
const macroEngineInstance = MacroEngine.instance;
|
|
|
|
export { MacroEngine, macroEngineInstance };
|