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
1import {COMMENT, RULESET, DECLARATION} from './Enum.js'2import {abs, charat, trim, from, sizeof, strlen, substr, append, replace} from './Utility.js'3import {node, char, prev, next, peek, token, caret, alloc, dealloc, delimit, whitespace, escaping, identifier, commenter} from './Tokenizer.js'4 5/**6 * @param {string} value7 * @return {object[]}8 */9export function compile (value) {10 return dealloc(parse('', null, null, null, [''], value = alloc(value), 0, [0], value))11}12 13/**14 * @param {string} value15 * @param {object} root16 * @param {object?} parent17 * @param {string[]} rule18 * @param {string[]} rules19 * @param {string[]} rulesets20 * @param {number[]} pseudo21 * @param {number[]} points22 * @param {string[]} declarations23 * @return {object}24 */25export function parse (value, root, parent, rule, rules, rulesets, pseudo, points, declarations) {26 var index = 027 var offset = 028 var length = pseudo29 var atrule = 030 var property = 031 var previous = 032 var variable = 133 var scanning = 134 var ampersand = 135 var parens = 036 var character = 037 var type = ''38 var props = rules39 var children = rulesets40 var reference = rule41 var characters = type42 43 while (scanning)44 switch (previous = character, character = next()) {45 // (46 case 40:47 if (previous != 108 && charat(characters, length - 1) == 58) parens++, characters += '('48 else characters += delimit(character)49 break50 // )51 case 41:52 parens--, characters += ')'53 break54 // " ' [55 case 34: case 39: case 91:56 characters += delimit(character)57 break58 // \t \n \r \s59 case 9: case 10: case 13: case 32:60 if (parens > 0) {61 characters += from(character)62 break63 }64 characters += whitespace(previous)65 break66 // \67 case 92:68 characters += escaping(caret() - 1, 7)69 continue70 // /71 case 47:72 switch (peek()) {73 case 42: case 47:74 append(comment(commenter(next(), caret()), root, parent, declarations), declarations)75 if ((token(previous || 1) == 5 || token(peek() || 1) == 5) && strlen(characters) && substr(characters, -1, void 0) !== ' ') characters += ' '76 break77 default:78 characters += '/'79 }80 break81 // {82 case 123 * variable:83 points[index++] = strlen(characters) * ampersand84 // } ; \085 case 125 * variable: case 59: case 0:86 if (parens > 0 && character) {87 characters += from(character)88 break89 }90 switch (character) {91 // \0 }92 case 0: case 125: scanning = 093 // ;94 case 59 + offset: if (ampersand == -1) characters = replace(characters, /\f/g, '')95 if (property > 0 && (strlen(characters) - length || variable === 0))96 append(property > 32 ? declaration(characters + ';', rule, parent, length - 1, declarations) : declaration(replace(characters, ' ', '') + ';', rule, parent, length - 2, declarations), declarations)97 break98 // @ ;99 case 59: characters += ';'100 // { rule/at-rule101 default:102 append(reference = ruleset(characters, root, parent, index, offset, rules, points, type, props = [], children = [], length, rulesets), rulesets)103 104 if (character === 123)105 if (offset === 0)106 parse(characters, root, reference, reference, props, rulesets, length, points, children)107 else {108 switch (atrule) {109 // c(ontainer)110 case 99:111 if (charat(characters, 3) === 110) break112 // l(ayer)113 case 108:114 if (charat(characters, 2) === 97) break115 default:116 offset = 0117 // d(ocument) m(edia) s(upports)118 case 100: case 109: case 115:119 }120 if (offset) parse(value, reference, reference, rule && append(ruleset(value, reference, reference, 0, 0, rules, points, type, rules, props = [], length, children), children), rules, children, length, points, rule ? props : children)121 else parse(characters, reference, reference, reference, [''], children, 0, points, children)122 }123 }124 125 index = offset = property = 0, variable = ampersand = 1, type = characters = '', length = pseudo126 break127 // :128 case 58:129 length = 1 + strlen(characters), property = previous130 default:131 if (variable < 1)132 if (character == 123)133 --variable134 else if (character == 125 && variable++ == 0 && prev() == 125)135 continue136 137 switch (characters += from(character), character * variable) {138 // &139 case 38:140 ampersand = offset > 0 ? 1 : (characters += '\f', -1)141 break142 // ,143 case 44:144 if (parens > 0) break145 points[index++] = (strlen(characters) - 1) * ampersand, ampersand = 1146 break147 // @148 case 64:149 // -150 if (peek() === 45)151 characters += delimit(next())152 153 atrule = peek(), offset = length = strlen(type = characters += identifier(caret())), character++154 break155 // -156 case 45:157 if (previous === 45 && strlen(characters) == 2)158 variable = 0159 }160 }161 162 return rulesets163}164 165/**166 * @param {string} value167 * @param {object} root168 * @param {object?} parent169 * @param {number} index170 * @param {number} offset171 * @param {string[]} rules172 * @param {number[]} points173 * @param {string} type174 * @param {string[]} props175 * @param {string[]} children176 * @param {number} length177 * @param {object[]} siblings178 * @return {object}179 */180export function ruleset (value, root, parent, index, offset, rules, points, type, props, children, length, siblings) {181 var post = offset - 1182 var rule = offset === 0 ? rules : ['']183 var size = sizeof(rule)184 185 for (var i = 0, j = 0, k = 0; i < index; ++i)186 for (var x = 0, y = substr(value, post + 1, post = abs(j = points[i])), z = value; x < size; ++x)187 if (z = trim(j > 0 ? rule[x] + ' ' + y : replace(y, /&\f/g, rule[x])))188 props[k++] = z189 190 return node(value, root, parent, offset === 0 ? RULESET : type, props, children, length, siblings)191}192 193/**194 * @param {number} value195 * @param {object} root196 * @param {object?} parent197 * @param {object[]} siblings198 * @return {object}199 */200export function comment (value, root, parent, siblings) {201 return node(value, root, parent, COMMENT, from(char()), substr(value, 2, -2), 0, siblings)202}203 204/**205 * @param {string} value206 * @param {object} root207 * @param {object?} parent208 * @param {number} length209 * @param {object[]} siblings210 * @return {object}211 */212export function declaration (value, root, parent, length, siblings) {213 return node(value, root, parent, DECLARATION, substr(value, 0, length), substr(value, length + 1, -1), length, siblings)214}215 