Team Ai
Datasetpublic

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.

sourceHugging Faceupdated 2mo agoView on Hugging Face
0likes3.1kdownloads
compiler.ts699 linesDownload Raw Back to stringify
1import {2  type CssAllNodesAST,3  type CssCharsetAST,4  type CssCommentAST,5  type CssCommonPositionAST,6  type CssContainerAST,7  type CssCounterStyleAST,8  type CssCustomMediaAST,9  type CssDeclarationAST,10  type CssDocumentAST,11  type CssFontFaceAST,12  type CssFontFeatureValuesAST,13  type CssGenericAtRuleAST,14  type CssHostAST,15  type CssImportAST,16  type CssKeyframeAST,17  type CssKeyframesAST,18  type CssLayerAST,19  type CssMediaAST,20  type CssNamespaceAST,21  type CssPageAST,22  type CssPageMarginBoxAST,23  type CssPositionTryAST,24  type CssPropertyAST,25  type CssRuleAST,26  type CssScopeAST,27  type CssStartingStyleAST,28  type CssStylesheetAST,29  type CssSupportsAST,30  CssTypes,31  type CssViewTransitionAST,32} from '../type';33 34export type CompilerOptions = {35  indent?: string;36  compress?: boolean;37};38 39class Compiler {40  level = 0;41  indentation = '  ';42  compress = false;43 44  constructor(options?: CompilerOptions) {45    if (typeof options?.indent === 'string') {46      this.indentation = options?.indent;47    }48    if (options?.compress) {49      this.compress = true;50    }51  }52 53  // We disable no-unused-vars for _position. We keep position for potential reintroduction of source-map54  // eslint-disable-next-line @typescript-eslint/no-unused-vars55  emit(str: string, _position?: CssCommonPositionAST['position']) {56    return str;57  }58 59  /**60   * Increase, decrease or return current indentation.61   */62  indent(level?: number) {63    this.level = this.level || 1;64 65    if (level) {66      this.level += level;67      return '';68    }69 70    return Array(this.level).join(this.indentation);71  }72 73  visit(node: CssAllNodesAST): string {74    switch (node.type) {75      case CssTypes.stylesheet:76        return this.stylesheet(node);77      case CssTypes.rule:78        return this.rule(node);79      case CssTypes.declaration:80        return this.declaration(node);81      case CssTypes.comment:82        return this.comment(node);83      case CssTypes.container:84        return this.container(node);85      case CssTypes.charset:86        return this.charset(node);87      case CssTypes.counterStyle:88        return this.counterStyle(node);89      case CssTypes.document:90        return this.document(node);91      case CssTypes.customMedia:92        return this.customMedia(node);93      case CssTypes.fontFace:94        return this.fontFace(node);95      case CssTypes.fontFeatureValues:96        return this.fontFeatureValues(node);97      case CssTypes.host:98        return this.host(node);99      case CssTypes.import:100        return this.import(node);101      case CssTypes.keyframes:102        return this.keyframes(node);103      case CssTypes.keyframe:104        return this.keyframe(node);105      case CssTypes.layer:106        return this.layer(node);107      case CssTypes.media:108        return this.media(node);109      case CssTypes.namespace:110        return this.namespace(node);111      case CssTypes.page:112        return this.page(node);113      case CssTypes.pageMarginBox:114        return this.pageMarginBox(node);115      case CssTypes.positionTry:116        return this.positionTry(node);117      case CssTypes.property:118        return this.property(node);119      case CssTypes.scope:120        return this.scope(node);121      case CssTypes.startingStyle:122        return this.startingStyle(node);123      case CssTypes.supports:124        return this.supports(node);125      case CssTypes.viewTransition:126        return this.viewTransition(node);127      case CssTypes.atRule:128        return this.genericAtRule(node);129    }130  }131 132  mapVisit(nodes: Array<CssAllNodesAST>, delim?: string) {133    let buf = '';134    delim = delim || '';135 136    for (let i = 0, length = nodes.length; i < length; i++) {137      buf += this.visit(nodes[i]);138      if (delim && i < length - 1) {139        buf += this.emit(delim);140      }141    }142 143    return buf;144  }145 146  compile(node: CssStylesheetAST) {147    if (this.compress) {148      return node.stylesheet.rules.map(this.visit, this).join('');149    }150 151    return this.stylesheet(node);152  }153 154  /**155   * Visit stylesheet node.156   */157  stylesheet(node: CssStylesheetAST) {158    return this.mapVisit(node.stylesheet.rules, '\n\n');159  }160 161  /**162   * Visit comment node.163   */164  comment(node: CssCommentAST) {165    if (this.compress) {166      return this.emit('', node.position);167    }168    return this.emit(`${this.indent()}/*${node.comment}*/`, node.position);169  }170 171  /**172   * Visit container node.173   */174  container(node: CssContainerAST) {175    if (this.compress) {176      return (177        this.emit(`@container ${node.container}`, node.position) +178        this.emit('{') +179        this.mapVisit(node.rules) +180        this.emit('}')181      );182    }183    return (184      this.emit(`${this.indent()}@container ${node.container}`, node.position) +185      this.emit(` {\n${this.indent(1)}`) +186      this.mapVisit(node.rules, '\n\n') +187      this.emit(`\n${this.indent(-1)}${this.indent()}}`)188    );189  }190 191  /**192   * Visit container node.193   */194  layer(node: CssLayerAST) {195    if (this.compress) {196      return (197        this.emit(`@layer ${node.layer}`, node.position) +198        (node.rules199          ? this.emit('{') +200            this.mapVisit(<CssAllNodesAST[]>node.rules) +201            this.emit('}')202          : ';')203      );204    }205    return (206      this.emit(`${this.indent()}@layer ${node.layer}`, node.position) +207      (node.rules208        ? this.emit(` {\n${this.indent(1)}`) +209          this.mapVisit(<CssAllNodesAST[]>node.rules, '\n\n') +210          this.emit(`\n${this.indent(-1)}${this.indent()}}`)211        : ';')212    );213  }214 215  /**216   * Visit import node.217   */218  import(node: CssImportAST) {219    return this.emit(`@import ${node.import};`, node.position);220  }221 222  /**223   * Visit media node.224   */225  media(node: CssMediaAST) {226    if (this.compress) {227      return (228        this.emit(`@media ${node.media}`, node.position) +229        this.emit('{') +230        this.mapVisit(node.rules) +231        this.emit('}')232      );233    }234    return (235      this.emit(`${this.indent()}@media ${node.media}`, node.position) +236      this.emit(` {\n${this.indent(1)}`) +237      this.mapVisit(node.rules, '\n\n') +238      this.emit(`\n${this.indent(-1)}${this.indent()}}`)239    );240  }241 242  /**243   * Visit document node.244   */245  document(node: CssDocumentAST) {246    const doc = `@${node.vendor || ''}document ${node.document}`;247    if (this.compress) {248      return (249        this.emit(doc, node.position) +250        this.emit('{') +251        this.mapVisit(node.rules) +252        this.emit('}')253      );254    }255    return (256      this.emit(doc, node.position) +257      this.emit(`  {\n${this.indent(1)}`) +258      this.mapVisit(node.rules, '\n\n') +259      this.emit(`${this.indent(-1)}\n}`)260    );261  }262 263  /**264   * Visit charset node.265   */266  charset(node: CssCharsetAST) {267    return this.emit(`@charset ${node.charset};`, node.position);268  }269 270  /**271   * Visit namespace node.272   */273  namespace(node: CssNamespaceAST) {274    return this.emit(`@namespace ${node.namespace};`, node.position);275  }276 277  /**278   * Visit container node.279   */280  startingStyle(node: CssStartingStyleAST) {281    if (this.compress) {282      return (283        this.emit('@starting-style', node.position) +284        this.emit('{') +285        this.mapVisit(node.rules) +286        this.emit('}')287      );288    }289    return (290      this.emit(`${this.indent()}@starting-style`, node.position) +291      this.emit(` {\n${this.indent(1)}`) +292      this.mapVisit(node.rules, '\n\n') +293      this.emit(`\n${this.indent(-1)}${this.indent()}}`)294    );295  }296 297  /**298   * Visit supports node.299   */300  supports(node: CssSupportsAST) {301    if (this.compress) {302      return (303        this.emit(`@supports ${node.supports}`, node.position) +304        this.emit('{') +305        this.mapVisit(node.rules) +306        this.emit('}')307      );308    }309    return (310      this.emit(`${this.indent()}@supports ${node.supports}`, node.position) +311      this.emit(` {\n${this.indent(1)}`) +312      this.mapVisit(node.rules, '\n\n') +313      this.emit(`\n${this.indent(-1)}${this.indent()}}`)314    );315  }316 317  /**318   * Visit keyframes node.319   */320  keyframes(node: CssKeyframesAST) {321    if (this.compress) {322      return (323        this.emit(324          `@${node.vendor || ''}keyframes ${node.name}`,325          node.position,326        ) +327        this.emit('{') +328        this.mapVisit(node.keyframes) +329        this.emit('}')330      );331    }332    return (333      this.emit(`@${node.vendor || ''}keyframes ${node.name}`, node.position) +334      this.emit(` {\n${this.indent(1)}`) +335      this.mapVisit(node.keyframes, '\n') +336      this.emit(`${this.indent(-1)}}`)337    );338  }339 340  /**341   * Visit keyframe node.342   */343  keyframe(node: CssKeyframeAST) {344    const decls = node.declarations;345    if (this.compress) {346      return (347        this.emit(node.values.join(','), node.position) +348        this.emit('{') +349        this.mapVisit(decls) +350        this.emit('}')351      );352    }353 354    return (355      this.emit(this.indent()) +356      this.emit(node.values.join(', '), node.position) +357      this.emit(` {\n${this.indent(1)}`) +358      this.mapVisit(decls, '\n') +359      this.emit(`${this.indent(-1)}\n${this.indent()}}\n`)360    );361  }362 363  /**364   * Visit page node.365   */366  page(node: CssPageAST) {367    if (this.compress) {368      const sel = node.selectors.length ? node.selectors.join(', ') : '';369 370      return (371        this.emit(`@page ${sel}`, node.position) +372        this.emit('{') +373        this.mapVisit(node.declarations) +374        this.emit('}')375      );376    }377    const sel = node.selectors.length ? `${node.selectors.join(', ')} ` : '';378 379    return (380      this.emit(`@page ${sel}`, node.position) +381      this.emit('{\n') +382      this.emit(this.indent(1)) +383      this.mapVisit(node.declarations, '\n') +384      this.emit(this.indent(-1)) +385      this.emit('\n}')386    );387  }388 389  /**390   * Visit @page margin box node (@top-left, @bottom-right, etc.).391   */392  pageMarginBox(node: CssPageMarginBoxAST) {393    if (this.compress) {394      return (395        this.emit(`@${node.name}`, node.position) +396        this.emit('{') +397        this.mapVisit(node.declarations) +398        this.emit('}')399      );400    }401    return (402      this.emit(`${this.indent()}@${node.name} `, node.position) +403      this.emit('{\n') +404      this.emit(this.indent(1)) +405      this.mapVisit(node.declarations, '\n') +406      this.emit(this.indent(-1)) +407      this.emit(`\n${this.indent()}}`)408    );409  }410 411  /**412   * Visit font-face node.413   */414  fontFace(node: CssFontFaceAST) {415    if (this.compress) {416      return (417        this.emit('@font-face', node.position) +418        this.emit('{') +419        this.mapVisit(node.declarations) +420        this.emit('}')421      );422    }423    return (424      this.emit('@font-face ', node.position) +425      this.emit('{\n') +426      this.emit(this.indent(1)) +427      this.mapVisit(node.declarations, '\n') +428      this.emit(this.indent(-1)) +429      this.emit('\n}')430    );431  }432 433  /**434   * Visit host node.435   */436  host(node: CssHostAST) {437    if (this.compress) {438      return (439        this.emit('@host', node.position) +440        this.emit('{') +441        this.mapVisit(node.rules) +442        this.emit('}')443      );444    }445    return (446      this.emit('@host', node.position) +447      this.emit(` {\n${this.indent(1)}`) +448      this.mapVisit(node.rules, '\n\n') +449      this.emit(`${this.indent(-1)}\n}`)450    );451  }452 453  /**454   * Visit custom-media node.455   */456  customMedia(node: CssCustomMediaAST) {457    return this.emit(458      `@custom-media ${node.name} ${node.media};`,459      node.position,460    );461  }462 463  /**464   * Visit @property node.465   */466  property(node: CssPropertyAST) {467    if (this.compress) {468      return (469        this.emit(`@property ${node.name}`, node.position) +470        this.emit('{') +471        this.mapVisit(node.declarations) +472        this.emit('}')473      );474    }475    return (476      this.emit(`@property ${node.name} `, node.position) +477      this.emit('{\n') +478      this.emit(this.indent(1)) +479      this.mapVisit(node.declarations, '\n') +480      this.emit(this.indent(-1)) +481      this.emit('\n}')482    );483  }484 485  /**486   * Visit @counter-style node.487   */488  counterStyle(node: CssCounterStyleAST) {489    if (this.compress) {490      return (491        this.emit(`@counter-style ${node.name}`, node.position) +492        this.emit('{') +493        this.mapVisit(node.declarations) +494        this.emit('}')495      );496    }497    return (498      this.emit(`@counter-style ${node.name} `, node.position) +499      this.emit('{\n') +500      this.emit(this.indent(1)) +501      this.mapVisit(node.declarations, '\n') +502      this.emit(this.indent(-1)) +503      this.emit('\n}')504    );505  }506 507  /**508   * Visit @font-feature-values node.509   */510  fontFeatureValues(node: CssFontFeatureValuesAST) {511    if (this.compress) {512      return (513        this.emit(`@font-feature-values ${node.fontFamily}`, node.position) +514        this.emit('{') +515        this.mapVisit(node.rules) +516        this.emit('}')517      );518    }519    return (520      this.emit(521        `${this.indent()}@font-feature-values ${node.fontFamily}`,522        node.position,523      ) +524      this.emit(` {\n${this.indent(1)}`) +525      this.mapVisit(node.rules, '\n\n') +526      this.emit(`\n${this.indent(-1)}${this.indent()}}`)527    );528  }529 530  /**531   * Visit @scope node.532   */533  scope(node: CssScopeAST) {534    const prelude = node.scope ? ` ${node.scope}` : '';535    if (this.compress) {536      return (537        this.emit(`@scope${prelude}`, node.position) +538        this.emit('{') +539        this.mapVisit(node.rules) +540        this.emit('}')541      );542    }543    return (544      this.emit(`${this.indent()}@scope${prelude}`, node.position) +545      this.emit(` {\n${this.indent(1)}`) +546      this.mapVisit(node.rules, '\n\n') +547      this.emit(`\n${this.indent(-1)}${this.indent()}}`)548    );549  }550 551  /**552   * Visit @view-transition node.553   */554  viewTransition(node: CssViewTransitionAST) {555    if (this.compress) {556      return (557        this.emit('@view-transition', node.position) +558        this.emit('{') +559        this.mapVisit(node.declarations) +560        this.emit('}')561      );562    }563    return (564      this.emit('@view-transition ', node.position) +565      this.emit('{\n') +566      this.emit(this.indent(1)) +567      this.mapVisit(node.declarations, '\n') +568      this.emit(this.indent(-1)) +569      this.emit('\n}')570    );571  }572 573  /**574   * Visit @position-try node.575   */576  positionTry(node: CssPositionTryAST) {577    if (this.compress) {578      return (579        this.emit(`@position-try ${node.name}`, node.position) +580        this.emit('{') +581        this.mapVisit(node.declarations) +582        this.emit('}')583      );584    }585    return (586      this.emit(`@position-try ${node.name} `, node.position) +587      this.emit('{\n') +588      this.emit(this.indent(1)) +589      this.mapVisit(node.declarations, '\n') +590      this.emit(this.indent(-1)) +591      this.emit('\n}')592    );593  }594 595  /**596   * Visit generic at-rule node (fallback for any unrecognized at-rule).597   */598  genericAtRule(node: CssGenericAtRuleAST) {599    const prelude = node.prelude ? ` ${node.prelude}` : '';600    if (this.compress) {601      return (602        this.emit(`@${node.name}${prelude}`, node.position) +603        (node.rules604          ? this.emit('{') +605            this.mapVisit(<CssAllNodesAST[]>node.rules) +606            this.emit('}')607          : ';')608      );609    }610    if (!node.rules) {611      return this.emit(612        `${this.indent()}@${node.name}${prelude};`,613        node.position,614      );615    }616    const hasNestedRules = node.rules.some(617      (r) => r.type !== CssTypes.declaration && r.type !== CssTypes.comment,618    );619    const delim = hasNestedRules ? '\n\n' : '\n';620    return (621      this.emit(`${this.indent()}@${node.name}${prelude}`, node.position) +622      this.emit(hasNestedRules ? ` {\n${this.indent(1)}` : ' {\n') +623      this.emit(hasNestedRules ? '' : this.indent(1)) +624      this.mapVisit(<CssAllNodesAST[]>node.rules, delim) +625      this.emit(626        hasNestedRules627          ? `\n${this.indent(-1)}${this.indent()}}`628          : `${this.indent(-1)}\n${this.indent()}}`,629      )630    );631  }632 633  /**634   * Visit rule node.635   */636  rule(node: CssRuleAST) {637    const decls = node.declarations;638    if (!decls.length) {639      return '';640    }641 642    if (this.compress) {643      return (644        this.emit(node.selectors.join(','), node.position) +645        this.emit('{') +646        this.mapVisit(decls) +647        this.emit('}')648      );649    }650    const indent = this.indent();651 652    return (653      this.emit(654        node.selectors655          .map((s) => {656            return indent + s;657          })658          .join(',\n'),659        node.position,660      ) +661      this.emit(' {\n') +662      this.emit(this.indent(1)) +663      this.mapVisit(decls, '\n') +664      this.emit(this.indent(-1)) +665      this.emit(`\n${this.indent()}}`)666    );667  }668 669  /**670   * Visit declaration node.671   */672  declaration(node: CssDeclarationAST) {673    if (this.compress) {674      return (675        this.emit(`${node.property}:${node.value}`, node.position) +676        this.emit(';')677      );678    }679    if (node.property === 'grid-template-areas')680      return (681        this.emit(this.indent()) +682        this.emit(683          node.property +684            ': ' +685            node.value.split('\n').join('\n'.padEnd(22) + this.indent()),686          node.position,687        ) +688        this.emit(';')689      );690    return (691      this.emit(this.indent()) +692      this.emit(`${node.property}: ${node.value}`, node.position) +693      this.emit(';')694    );695  }696}697 698export default Compiler;699 
Brunobkr/llama.cpp_AlgMor24_github · Team Ai