Brunobkr/llama.cpp_AlgMor24_github
ΩFFFΣLLIa • llama.cpp • AlgMor24 ██████╗ ███████╗███████╗███████╗██╗ ██╗ ██╗ █████╗ ██╔═══██╗██╔════╝██╔════╝██╔════╝██║ ██║ ██║██╔══██╗ ██║ ██║█████╗ █████╗ █████╗ ██║ ██║ ██║███████║ ██║ ██║██╔══╝ ██╔══╝ ██╔══╝ ██║ ██║ ██║██╔══██║ ╚██████╔╝██║ ██║ ███████╗███████╗███████╗██║██║ ██║ ╚═════╝ ╚═╝ ╚═╝ ╚══════╝╚══════╝╚══════╝╚═╝╚═╝ ╚═╝ High-Performance LLM / VLM Inference & Autonomous Agentic Ecosystem… See the full description on the dataset page: https://huggingface.co/datasets/Brunobkr/llama.cpp_AlgMor24_github.
03.1k
1/** @import { BaseNode, Command, Visitors } from './types' */2 3export const margin = 0;4export const newline = 1;5export const indent = 2;6export const dedent = 3;7export const space = 4;8 9export class Context {10 #visitors;11 #commands;12 #has_newline = false;13 14 multiline = false;15 16 /**17 *18 * @param {Visitors} visitors19 * @param {Command[]} commands20 */21 constructor(visitors, commands = []) {22 this.#visitors = visitors;23 this.#commands = commands;24 }25 26 indent() {27 this.#commands.push(indent);28 }29 30 dedent() {31 this.#commands.push(dedent);32 }33 34 margin() {35 this.#commands.push(margin);36 }37 38 newline() {39 this.#has_newline = true;40 this.#commands.push(newline);41 }42 43 space() {44 this.#commands.push(space);45 }46 47 /**48 * @param {Context} context49 */50 append(context) {51 this.#commands.push(context.#commands);52 53 if (this.#has_newline || context.multiline) {54 this.multiline = true;55 }56 }57 58 /**59 *60 * @param {string} content61 * @param {BaseNode} [node]62 */63 write(content, node) {64 if (node?.loc) {65 this.location(node.loc.start.line, node.loc.start.column);66 this.#commands.push(content);67 this.location(node.loc.end.line, node.loc.end.column);68 } else {69 this.#commands.push(content);70 }71 72 if (this.#has_newline) {73 this.multiline = true;74 }75 }76 77 /**78 *79 * @param {number} line80 * @param {number} column81 */82 location(line, column) {83 this.#commands.push({ type: 'Location', line, column });84 }85 86 /**87 * @param {{ type: string }} node88 */89 visit(node) {90 const visitor = this.#visitors[node.type];91 92 if (!visitor) {93 let message = `Not implemented: ${node.type}`;94 95 if (node.type.includes('TS')) {96 message += ` (consider using 'esrap/languages/ts')`;97 }98 99 if (node.type.includes('JSX')) {100 message += ` (consider using 'esrap/languages/tsx')`;101 }102 103 throw new Error(message);104 }105 106 if (this.#visitors._) {107 // @ts-ignore108 this.#visitors._(node, this, (node) => visitor(node, this));109 } else {110 // @ts-ignore111 visitor(node, this);112 }113 }114 115 empty() {116 return !this.#commands.some(has_content);117 }118 119 measure() {120 return measure(this.#commands);121 }122 123 new() {124 return new Context(this.#visitors);125 }126}127 128/**129 *130 * @param {Command[]} commands131 * @param {number} [from]132 * @param {number} [to]133 */134function measure(commands, from = 0, to = commands.length) {135 let total = 0;136 137 for (let i = from; i < to; i += 1) {138 const command = commands[i];139 140 if (typeof command === 'string') {141 total += command.length;142 } else if (Array.isArray(command)) {143 total += measure(command);144 }145 }146 147 return total;148}149 150/**151 * @param {Command} command152 */153function has_content(command) {154 if (Array.isArray(command)) {155 return command.some(has_content);156 }157 158 if (typeof command === 'string') {159 return command.length > 0;160 }161 162 return false;163}164 