mirror of
https://github.com/chrisnov-it/quantumbotx.git
synced 2026-08-01 13:17:45 +00:00
aa984c4909
- Update `.gitignore` to include `lab/` for backtesting and raw data. - Refactor `app.py` to improve error handling and logging. - Remove deprecated files: `core/bot_logic.py`, `core/bots/base_bot.py`, `core/bots/manager.py`, `core/db/database.py`, `core/routes/api_analysis.py`, `core/routes/api_bots_analysis.py`, `core/strategies/logic_ma.py`, `core/strategies/logic_rsi.py`. - Modify multiple files to enhance bot management, routing, and strategy handling. - Update JavaScript and HTML templates for better UI and functionality.
52 lines
1.1 KiB
JavaScript
52 lines
1.1 KiB
JavaScript
import { getTokenizer } from '../utils/get-tokenizer.js';
|
|
|
|
const astToTokens = {
|
|
decorator(handlers) {
|
|
const tokens = [];
|
|
let curNode = null;
|
|
|
|
return {
|
|
...handlers,
|
|
node(node) {
|
|
const tmp = curNode;
|
|
curNode = node;
|
|
handlers.node.call(this, node);
|
|
curNode = tmp;
|
|
},
|
|
emit(value, type, auto) {
|
|
tokens.push({
|
|
type,
|
|
value,
|
|
node: auto ? null : curNode
|
|
});
|
|
},
|
|
result() {
|
|
return tokens;
|
|
}
|
|
};
|
|
}
|
|
};
|
|
|
|
function stringToTokens(str, syntax) {
|
|
const tokens = [];
|
|
const tokenize = getTokenizer(syntax);
|
|
|
|
tokenize(str, (type, start, end) =>
|
|
tokens.push({
|
|
type,
|
|
value: str.slice(start, end),
|
|
node: null
|
|
})
|
|
);
|
|
|
|
return tokens;
|
|
}
|
|
|
|
export default function(value, syntax) {
|
|
if (typeof value === 'string') {
|
|
return stringToTokens(value, syntax);
|
|
}
|
|
|
|
return syntax.generate(value, astToTokens);
|
|
};
|