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
swift.js973 linesDownload Raw Back to languages
1/**2 * @param {string} value3 * @returns {RegExp}4 * */5 6/**7 * @param {RegExp | string } re8 * @returns {string}9 */10function source(re) {11  if (!re) return null;12  if (typeof re === "string") return re;13 14  return re.source;15}16 17/**18 * @param {RegExp | string } re19 * @returns {string}20 */21function lookahead(re) {22  return concat('(?=', re, ')');23}24 25/**26 * @param {...(RegExp | string) } args27 * @returns {string}28 */29function concat(...args) {30  const joined = args.map((x) => source(x)).join("");31  return joined;32}33 34/**35 * @param { Array<string | RegExp | Object> } args36 * @returns {object}37 */38function stripOptionsFromArgs(args) {39  const opts = args[args.length - 1];40 41  if (typeof opts === 'object' && opts.constructor === Object) {42    args.splice(args.length - 1, 1);43    return opts;44  } else {45    return {};46  }47}48 49/** @typedef { {capture?: boolean} } RegexEitherOptions */50 51/**52 * Any of the passed expresssions may match53 *54 * Creates a huge this | this | that | that match55 * @param {(RegExp | string)[] | [...(RegExp | string)[], RegexEitherOptions]} args56 * @returns {string}57 */58function either(...args) {59  /** @type { object & {capture?: boolean} }  */60  const opts = stripOptionsFromArgs(args);61  const joined = '('62    + (opts.capture ? "" : "?:")63    + args.map((x) => source(x)).join("|") + ")";64  return joined;65}66 67const keywordWrapper = keyword => concat(68  /\b/,69  keyword,70  /\w$/.test(keyword) ? /\b/ : /\B/71);72 73// Keywords that require a leading dot.74const dotKeywords = [75  'Protocol', // contextual76  'Type' // contextual77].map(keywordWrapper);78 79// Keywords that may have a leading dot.80const optionalDotKeywords = [81  'init',82  'self'83].map(keywordWrapper);84 85// should register as keyword, not type86const keywordTypes = [87  'Any',88  'Self'89];90 91// Regular keywords and literals.92const keywords = [93  // strings below will be fed into the regular `keywords` engine while regex94  // will result in additional modes being created to scan for those keywords to95  // avoid conflicts with other rules96  'actor',97  'any', // contextual98  'associatedtype',99  'async',100  'await',101  /as\?/, // operator102  /as!/, // operator103  'as', // operator104  'borrowing', // contextual105  'break',106  'case',107  'catch',108  'class',109  'consume', // contextual110  'consuming', // contextual111  'continue',112  'convenience', // contextual113  'copy', // contextual114  'default',115  'defer',116  'deinit',117  'didSet', // contextual118  'distributed',119  'do',120  'dynamic', // contextual121  'each',122  'else',123  'enum',124  'extension',125  'fallthrough',126  /fileprivate\(set\)/,127  'fileprivate',128  'final', // contextual129  'for',130  'func',131  'get', // contextual132  'guard',133  'if',134  'import',135  'indirect', // contextual136  'infix', // contextual137  /init\?/,138  /init!/,139  'inout',140  /internal\(set\)/,141  'internal',142  'in',143  'is', // operator144  'isolated', // contextual145  'nonisolated', // contextual146  'lazy', // contextual147  'let',148  'macro',149  'mutating', // contextual150  'nonmutating', // contextual151  /open\(set\)/, // contextual152  'open', // contextual153  'operator',154  'optional', // contextual155  'override', // contextual156  'package',157  'postfix', // contextual158  'precedencegroup',159  'prefix', // contextual160  /private\(set\)/,161  'private',162  'protocol',163  /public\(set\)/,164  'public',165  'repeat',166  'required', // contextual167  'rethrows',168  'return',169  'set', // contextual170  'some', // contextual171  'static',172  'struct',173  'subscript',174  'super',175  'switch',176  'throws',177  'throw',178  /try\?/, // operator179  /try!/, // operator180  'try', // operator181  'typealias',182  /unowned\(safe\)/, // contextual183  /unowned\(unsafe\)/, // contextual184  'unowned', // contextual185  'var',186  'weak', // contextual187  'where',188  'while',189  'willSet' // contextual190];191 192// NOTE: Contextual keywords are reserved only in specific contexts.193// Ideally, these should be matched using modes to avoid false positives.194 195// Literals.196const literals = [197  'false',198  'nil',199  'true'200];201 202// Keywords used in precedence groups.203const precedencegroupKeywords = [204  'assignment',205  'associativity',206  'higherThan',207  'left',208  'lowerThan',209  'none',210  'right'211];212 213// Keywords that start with a number sign (#).214// #(un)available is handled separately.215const numberSignKeywords = [216  '#colorLiteral',217  '#column',218  '#dsohandle',219  '#else',220  '#elseif',221  '#endif',222  '#error',223  '#file',224  '#fileID',225  '#fileLiteral',226  '#filePath',227  '#function',228  '#if',229  '#imageLiteral',230  '#keyPath',231  '#line',232  '#selector',233  '#sourceLocation',234  '#warning'235];236 237// Global functions in the Standard Library.238const builtIns = [239  'abs',240  'all',241  'any',242  'assert',243  'assertionFailure',244  'debugPrint',245  'dump',246  'fatalError',247  'getVaList',248  'isKnownUniquelyReferenced',249  'max',250  'min',251  'numericCast',252  'pointwiseMax',253  'pointwiseMin',254  'precondition',255  'preconditionFailure',256  'print',257  'readLine',258  'repeatElement',259  'sequence',260  'stride',261  'swap',262  'swift_unboxFromSwiftValueWithType',263  'transcode',264  'type',265  'unsafeBitCast',266  'unsafeDowncast',267  'withExtendedLifetime',268  'withUnsafeMutablePointer',269  'withUnsafePointer',270  'withVaList',271  'withoutActuallyEscaping',272  'zip'273];274 275// Valid first characters for operators.276const operatorHead = either(277  /[/=\-+!*%<>&|^~?]/,278  /[\u00A1-\u00A7]/,279  /[\u00A9\u00AB]/,280  /[\u00AC\u00AE]/,281  /[\u00B0\u00B1]/,282  /[\u00B6\u00BB\u00BF\u00D7\u00F7]/,283  /[\u2016-\u2017]/,284  /[\u2020-\u2027]/,285  /[\u2030-\u203E]/,286  /[\u2041-\u2053]/,287  /[\u2055-\u205E]/,288  /[\u2190-\u23FF]/,289  /[\u2500-\u2775]/,290  /[\u2794-\u2BFF]/,291  /[\u2E00-\u2E7F]/,292  /[\u3001-\u3003]/,293  /[\u3008-\u3020]/,294  /[\u3030]/295);296 297// Valid characters for operators.298const operatorCharacter = either(299  operatorHead,300  /[\u0300-\u036F]/,301  /[\u1DC0-\u1DFF]/,302  /[\u20D0-\u20FF]/,303  /[\uFE00-\uFE0F]/,304  /[\uFE20-\uFE2F]/305  // TODO: The following characters are also allowed, but the regex isn't supported yet.306  // /[\u{E0100}-\u{E01EF}]/u307);308 309// Valid operator.310const operator = concat(operatorHead, operatorCharacter, '*');311 312// Valid first characters for identifiers.313const identifierHead = either(314  /[a-zA-Z_]/,315  /[\u00A8\u00AA\u00AD\u00AF\u00B2-\u00B5\u00B7-\u00BA]/,316  /[\u00BC-\u00BE\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u00FF]/,317  /[\u0100-\u02FF\u0370-\u167F\u1681-\u180D\u180F-\u1DBF]/,318  /[\u1E00-\u1FFF]/,319  /[\u200B-\u200D\u202A-\u202E\u203F-\u2040\u2054\u2060-\u206F]/,320  /[\u2070-\u20CF\u2100-\u218F\u2460-\u24FF\u2776-\u2793]/,321  /[\u2C00-\u2DFF\u2E80-\u2FFF]/,322  /[\u3004-\u3007\u3021-\u302F\u3031-\u303F\u3040-\uD7FF]/,323  /[\uF900-\uFD3D\uFD40-\uFDCF\uFDF0-\uFE1F\uFE30-\uFE44]/,324  /[\uFE47-\uFEFE\uFF00-\uFFFD]/ // Should be /[\uFE47-\uFFFD]/, but we have to exclude FEFF.325  // The following characters are also allowed, but the regexes aren't supported yet.326  // /[\u{10000}-\u{1FFFD}\u{20000-\u{2FFFD}\u{30000}-\u{3FFFD}\u{40000}-\u{4FFFD}]/u,327  // /[\u{50000}-\u{5FFFD}\u{60000-\u{6FFFD}\u{70000}-\u{7FFFD}\u{80000}-\u{8FFFD}]/u,328  // /[\u{90000}-\u{9FFFD}\u{A0000-\u{AFFFD}\u{B0000}-\u{BFFFD}\u{C0000}-\u{CFFFD}]/u,329  // /[\u{D0000}-\u{DFFFD}\u{E0000-\u{EFFFD}]/u330);331 332// Valid characters for identifiers.333const identifierCharacter = either(334  identifierHead,335  /\d/,336  /[\u0300-\u036F\u1DC0-\u1DFF\u20D0-\u20FF\uFE20-\uFE2F]/337);338 339// Valid identifier.340const identifier = concat(identifierHead, identifierCharacter, '*');341 342// Valid type identifier.343const typeIdentifier = concat(/[A-Z]/, identifierCharacter, '*');344 345// Built-in attributes, which are highlighted as keywords.346// @available is handled separately.347// https://docs.swift.org/swift-book/documentation/the-swift-programming-language/attributes348const keywordAttributes = [349  'attached',350  'autoclosure',351  concat(/convention\(/, either('swift', 'block', 'c'), /\)/),352  'discardableResult',353  'dynamicCallable',354  'dynamicMemberLookup',355  'escaping',356  'freestanding',357  'frozen',358  'GKInspectable',359  'IBAction',360  'IBDesignable',361  'IBInspectable',362  'IBOutlet',363  'IBSegueAction',364  'inlinable',365  'main',366  'nonobjc',367  'NSApplicationMain',368  'NSCopying',369  'NSManaged',370  concat(/objc\(/, identifier, /\)/),371  'objc',372  'objcMembers',373  'propertyWrapper',374  'requires_stored_property_inits',375  'resultBuilder',376  'Sendable',377  'testable',378  'UIApplicationMain',379  'unchecked',380  'unknown',381  'usableFromInline',382  'warn_unqualified_access'383];384 385// Contextual keywords used in @available and #(un)available.386const availabilityKeywords = [387  'iOS',388  'iOSApplicationExtension',389  'macOS',390  'macOSApplicationExtension',391  'macCatalyst',392  'macCatalystApplicationExtension',393  'watchOS',394  'watchOSApplicationExtension',395  'tvOS',396  'tvOSApplicationExtension',397  'swift'398];399 400/*401Language: Swift402Description: Swift is a general-purpose programming language built using a modern approach to safety, performance, and software design patterns.403Author: Steven Van Impe <steven.vanimpe@icloud.com>404Contributors: Chris Eidhof <chris@eidhof.nl>, Nate Cook <natecook@gmail.com>, Alexander Lichter <manniL@gmx.net>, Richard Gibson <gibson042@github>405Website: https://swift.org406Category: common, system407*/408 409 410/** @type LanguageFn */411function swift(hljs) {412  const WHITESPACE = {413    match: /\s+/,414    relevance: 0415  };416  // https://docs.swift.org/swift-book/ReferenceManual/LexicalStructure.html#ID411417  const BLOCK_COMMENT = hljs.COMMENT(418    '/\\*',419    '\\*/',420    { contains: [ 'self' ] }421  );422  const COMMENTS = [423    hljs.C_LINE_COMMENT_MODE,424    BLOCK_COMMENT425  ];426 427  // https://docs.swift.org/swift-book/ReferenceManual/LexicalStructure.html#ID413428  // https://docs.swift.org/swift-book/ReferenceManual/zzSummaryOfTheGrammar.html429  const DOT_KEYWORD = {430    match: [431      /\./,432      either(...dotKeywords, ...optionalDotKeywords)433    ],434    className: { 2: "keyword" }435  };436  const KEYWORD_GUARD = {437    // Consume .keyword to prevent highlighting properties and methods as keywords.438    match: concat(/\./, either(...keywords)),439    relevance: 0440  };441  const PLAIN_KEYWORDS = keywords442    .filter(kw => typeof kw === 'string')443    .concat([ "_|0" ]); // seems common, so 0 relevance444  const REGEX_KEYWORDS = keywords445    .filter(kw => typeof kw !== 'string') // find regex446    .concat(keywordTypes)447    .map(keywordWrapper);448  const KEYWORD = { variants: [449    {450      className: 'keyword',451      match: either(...REGEX_KEYWORDS, ...optionalDotKeywords)452    }453  ] };454  // find all the regular keywords455  const KEYWORDS = {456    $pattern: either(457      /\b\w+/, // regular keywords458      /#\w+/ // number keywords459    ),460    keyword: PLAIN_KEYWORDS461      .concat(numberSignKeywords),462    literal: literals463  };464  const KEYWORD_MODES = [465    DOT_KEYWORD,466    KEYWORD_GUARD,467    KEYWORD468  ];469 470  // https://github.com/apple/swift/tree/main/stdlib/public/core471  const BUILT_IN_GUARD = {472    // Consume .built_in to prevent highlighting properties and methods.473    match: concat(/\./, either(...builtIns)),474    relevance: 0475  };476  const BUILT_IN = {477    className: 'built_in',478    match: concat(/\b/, either(...builtIns), /(?=\()/)479  };480  const BUILT_INS = [481    BUILT_IN_GUARD,482    BUILT_IN483  ];484 485  // https://docs.swift.org/swift-book/ReferenceManual/LexicalStructure.html#ID418486  const OPERATOR_GUARD = {487    // Prevent -> from being highlighting as an operator.488    match: /->/,489    relevance: 0490  };491  const OPERATOR = {492    className: 'operator',493    relevance: 0,494    variants: [495      { match: operator },496      {497        // dot-operator: only operators that start with a dot are allowed to use dots as498        // characters (..., ...<, .*, etc). So there rule here is: a dot followed by one or more499        // characters that may also include dots.500        match: `\\.(\\.|${operatorCharacter})+` }501    ]502  };503  const OPERATORS = [504    OPERATOR_GUARD,505    OPERATOR506  ];507 508  // https://docs.swift.org/swift-book/ReferenceManual/LexicalStructure.html#grammar_numeric-literal509  // TODO: Update for leading `-` after lookbehind is supported everywhere510  const decimalDigits = '([0-9]_*)+';511  const hexDigits = '([0-9a-fA-F]_*)+';512  const NUMBER = {513    className: 'number',514    relevance: 0,515    variants: [516      // decimal floating-point-literal (subsumes decimal-literal)517      { match: `\\b(${decimalDigits})(\\.(${decimalDigits}))?` + `([eE][+-]?(${decimalDigits}))?\\b` },518      // hexadecimal floating-point-literal (subsumes hexadecimal-literal)519      { match: `\\b0x(${hexDigits})(\\.(${hexDigits}))?` + `([pP][+-]?(${decimalDigits}))?\\b` },520      // octal-literal521      { match: /\b0o([0-7]_*)+\b/ },522      // binary-literal523      { match: /\b0b([01]_*)+\b/ }524    ]525  };526 527  // https://docs.swift.org/swift-book/ReferenceManual/LexicalStructure.html#grammar_string-literal528  const ESCAPED_CHARACTER = (rawDelimiter = "") => ({529    className: 'subst',530    variants: [531      { match: concat(/\\/, rawDelimiter, /[0\\tnr"']/) },532      { match: concat(/\\/, rawDelimiter, /u\{[0-9a-fA-F]{1,8}\}/) }533    ]534  });535  const ESCAPED_NEWLINE = (rawDelimiter = "") => ({536    className: 'subst',537    match: concat(/\\/, rawDelimiter, /[\t ]*(?:[\r\n]|\r\n)/)538  });539  const INTERPOLATION = (rawDelimiter = "") => ({540    className: 'subst',541    label: "interpol",542    begin: concat(/\\/, rawDelimiter, /\(/),543    end: /\)/544  });545  const MULTILINE_STRING = (rawDelimiter = "") => ({546    begin: concat(rawDelimiter, /"""/),547    end: concat(/"""/, rawDelimiter),548    contains: [549      ESCAPED_CHARACTER(rawDelimiter),550      ESCAPED_NEWLINE(rawDelimiter),551      INTERPOLATION(rawDelimiter)552    ]553  });554  const SINGLE_LINE_STRING = (rawDelimiter = "") => ({555    begin: concat(rawDelimiter, /"/),556    end: concat(/"/, rawDelimiter),557    contains: [558      ESCAPED_CHARACTER(rawDelimiter),559      INTERPOLATION(rawDelimiter)560    ]561  });562  const STRING = {563    className: 'string',564    variants: [565      MULTILINE_STRING(),566      MULTILINE_STRING("#"),567      MULTILINE_STRING("##"),568      MULTILINE_STRING("###"),569      SINGLE_LINE_STRING(),570      SINGLE_LINE_STRING("#"),571      SINGLE_LINE_STRING("##"),572      SINGLE_LINE_STRING("###")573    ]574  };575 576  const REGEXP_CONTENTS = [577    hljs.BACKSLASH_ESCAPE,578    {579      begin: /\[/,580      end: /\]/,581      relevance: 0,582      contains: [ hljs.BACKSLASH_ESCAPE ]583    }584  ];585 586  const BARE_REGEXP_LITERAL = {587    begin: /\/[^\s](?=[^/\n]*\/)/,588    end: /\//,589    contains: REGEXP_CONTENTS590  };591 592  const EXTENDED_REGEXP_LITERAL = (rawDelimiter) => {593    const begin = concat(rawDelimiter, /\//);594    const end = concat(/\//, rawDelimiter);595    return {596      begin,597      end,598      contains: [599        ...REGEXP_CONTENTS,600        {601          scope: "comment",602          begin: `#(?!.*${end})`,603          end: /$/,604        },605      ],606    };607  };608 609  // https://docs.swift.org/swift-book/documentation/the-swift-programming-language/lexicalstructure/#Regular-Expression-Literals610  const REGEXP = {611    scope: "regexp",612    variants: [613      EXTENDED_REGEXP_LITERAL('###'),614      EXTENDED_REGEXP_LITERAL('##'),615      EXTENDED_REGEXP_LITERAL('#'),616      BARE_REGEXP_LITERAL617    ]618  };619 620  // https://docs.swift.org/swift-book/ReferenceManual/LexicalStructure.html#ID412621  const QUOTED_IDENTIFIER = { match: concat(/`/, identifier, /`/) };622  const IMPLICIT_PARAMETER = {623    className: 'variable',624    match: /\$\d+/625  };626  const PROPERTY_WRAPPER_PROJECTION = {627    className: 'variable',628    match: `\\$${identifierCharacter}+`629  };630  const IDENTIFIERS = [631    QUOTED_IDENTIFIER,632    IMPLICIT_PARAMETER,633    PROPERTY_WRAPPER_PROJECTION634  ];635 636  // https://docs.swift.org/swift-book/ReferenceManual/Attributes.html637  const AVAILABLE_ATTRIBUTE = {638    match: /(@|#(un)?)available/,639    scope: 'keyword',640    starts: { contains: [641      {642        begin: /\(/,643        end: /\)/,644        keywords: availabilityKeywords,645        contains: [646          ...OPERATORS,647          NUMBER,648          STRING649        ]650      }651    ] }652  };653 654  const KEYWORD_ATTRIBUTE = {655    scope: 'keyword',656    match: concat(/@/, either(...keywordAttributes), lookahead(either(/\(/, /\s+/))),657  };658 659  const USER_DEFINED_ATTRIBUTE = {660    scope: 'meta',661    match: concat(/@/, identifier)662  };663 664  const ATTRIBUTES = [665    AVAILABLE_ATTRIBUTE,666    KEYWORD_ATTRIBUTE,667    USER_DEFINED_ATTRIBUTE668  ];669 670  // https://docs.swift.org/swift-book/ReferenceManual/Types.html671  const TYPE = {672    match: lookahead(/\b[A-Z]/),673    relevance: 0,674    contains: [675      { // Common Apple frameworks, for relevance boost676        className: 'type',677        match: concat(/(AV|CA|CF|CG|CI|CL|CM|CN|CT|MK|MP|MTK|MTL|NS|SCN|SK|UI|WK|XC)/, identifierCharacter, '+')678      },679      { // Type identifier680        className: 'type',681        match: typeIdentifier,682        relevance: 0683      },684      { // Optional type685        match: /[?!]+/,686        relevance: 0687      },688      { // Variadic parameter689        match: /\.\.\./,690        relevance: 0691      },692      { // Protocol composition693        match: concat(/\s+&\s+/, lookahead(typeIdentifier)),694        relevance: 0695      }696    ]697  };698  const GENERIC_ARGUMENTS = {699    begin: /</,700    end: />/,701    keywords: KEYWORDS,702    contains: [703      ...COMMENTS,704      ...KEYWORD_MODES,705      ...ATTRIBUTES,706      OPERATOR_GUARD,707      TYPE708    ]709  };710  TYPE.contains.push(GENERIC_ARGUMENTS);711 712  // https://docs.swift.org/swift-book/ReferenceManual/Expressions.html#ID552713  // Prevents element names from being highlighted as keywords.714  const TUPLE_ELEMENT_NAME = {715    match: concat(identifier, /\s*:/),716    keywords: "_|0",717    relevance: 0718  };719  // Matches tuples as well as the parameter list of a function type.720  const TUPLE = {721    begin: /\(/,722    end: /\)/,723    relevance: 0,724    keywords: KEYWORDS,725    contains: [726      'self',727      TUPLE_ELEMENT_NAME,728      ...COMMENTS,729      REGEXP,730      ...KEYWORD_MODES,731      ...BUILT_INS,732      ...OPERATORS,733      NUMBER,734      STRING,735      ...IDENTIFIERS,736      ...ATTRIBUTES,737      TYPE738    ]739  };740 741  const GENERIC_PARAMETERS = {742    begin: /</,743    end: />/,744    keywords: 'repeat each',745    contains: [746      ...COMMENTS,747      TYPE748    ]749  };750  const FUNCTION_PARAMETER_NAME = {751    begin: either(752      lookahead(concat(identifier, /\s*:/)),753      lookahead(concat(identifier, /\s+/, identifier, /\s*:/))754    ),755    end: /:/,756    relevance: 0,757    contains: [758      {759        className: 'keyword',760        match: /\b_\b/761      },762      {763        className: 'params',764        match: identifier765      }766    ]767  };768  const FUNCTION_PARAMETERS = {769    begin: /\(/,770    end: /\)/,771    keywords: KEYWORDS,772    contains: [773      FUNCTION_PARAMETER_NAME,774      ...COMMENTS,775      ...KEYWORD_MODES,776      ...OPERATORS,777      NUMBER,778      STRING,779      ...ATTRIBUTES,780      TYPE,781      TUPLE782    ],783    endsParent: true,784    illegal: /["']/785  };786  // https://docs.swift.org/swift-book/ReferenceManual/Declarations.html#ID362787  // https://docs.swift.org/swift-book/documentation/the-swift-programming-language/declarations/#Macro-Declaration788  const FUNCTION_OR_MACRO = {789    match: [790      /(func|macro)/,791      /\s+/,792      either(QUOTED_IDENTIFIER.match, identifier, operator)793    ],794    className: {795      1: "keyword",796      3: "title.function"797    },798    contains: [799      GENERIC_PARAMETERS,800      FUNCTION_PARAMETERS,801      WHITESPACE802    ],803    illegal: [804      /\[/,805      /%/806    ]807  };808 809  // https://docs.swift.org/swift-book/ReferenceManual/Declarations.html#ID375810  // https://docs.swift.org/swift-book/ReferenceManual/Declarations.html#ID379811  const INIT_SUBSCRIPT = {812    match: [813      /\b(?:subscript|init[?!]?)/,814      /\s*(?=[<(])/,815    ],816    className: { 1: "keyword" },817    contains: [818      GENERIC_PARAMETERS,819      FUNCTION_PARAMETERS,820      WHITESPACE821    ],822    illegal: /\[|%/823  };824  // https://docs.swift.org/swift-book/ReferenceManual/Declarations.html#ID380825  const OPERATOR_DECLARATION = {826    match: [827      /operator/,828      /\s+/,829      operator830    ],831    className: {832      1: "keyword",833      3: "title"834    }835  };836 837  // https://docs.swift.org/swift-book/ReferenceManual/Declarations.html#ID550838  const PRECEDENCEGROUP = {839    begin: [840      /precedencegroup/,841      /\s+/,842      typeIdentifier843    ],844    className: {845      1: "keyword",846      3: "title"847    },848    contains: [ TYPE ],849    keywords: [850      ...precedencegroupKeywords,851      ...literals852    ],853    end: /}/854  };855 856  const CLASS_FUNC_DECLARATION = {857    match: [858      /class\b/,          859      /\s+/,860      /func\b/,861      /\s+/,862      /\b[A-Za-z_][A-Za-z0-9_]*\b/ 863    ],864    scope: {865      1: "keyword",866      3: "keyword",867      5: "title.function"868    }869  };870 871  const CLASS_VAR_DECLARATION = {872    match: [873      /class\b/,874      /\s+/,          875      /var\b/, 876    ],877    scope: {878      1: "keyword",879      3: "keyword"880    }881  };882 883  const TYPE_DECLARATION = {884    begin: [885      /(struct|protocol|class|extension|enum|actor)/,886      /\s+/,887      identifier,888      /\s*/,889    ],890    beginScope: {891      1: "keyword",892      3: "title.class"893    },894    keywords: KEYWORDS,895    contains: [896      GENERIC_PARAMETERS,897      ...KEYWORD_MODES,898      {899        begin: /:/,900        end: /\{/,901        keywords: KEYWORDS,902        contains: [903          {904            scope: "title.class.inherited",905            match: typeIdentifier,906          },907          ...KEYWORD_MODES,908        ],909        relevance: 0,910      },911    ]912  };913 914  // Add supported submodes to string interpolation.915  for (const variant of STRING.variants) {916    const interpolation = variant.contains.find(mode => mode.label === "interpol");917    // TODO: Interpolation can contain any expression, so there's room for improvement here.918    interpolation.keywords = KEYWORDS;919    const submodes = [920      ...KEYWORD_MODES,921      ...BUILT_INS,922      ...OPERATORS,923      NUMBER,924      STRING,925      ...IDENTIFIERS926    ];927    interpolation.contains = [928      ...submodes,929      {930        begin: /\(/,931        end: /\)/,932        contains: [933          'self',934          ...submodes935        ]936      }937    ];938  }939 940  return {941    name: 'Swift',942    keywords: KEYWORDS,943    contains: [944      ...COMMENTS,945      FUNCTION_OR_MACRO,946      INIT_SUBSCRIPT,947      CLASS_FUNC_DECLARATION,948      CLASS_VAR_DECLARATION,949      TYPE_DECLARATION,950      OPERATOR_DECLARATION,951      PRECEDENCEGROUP,952      {953        beginKeywords: 'import',954        end: /$/,955        contains: [ ...COMMENTS ],956        relevance: 0957      },958      REGEXP,959      ...KEYWORD_MODES,960      ...BUILT_INS,961      ...OPERATORS,962      NUMBER,963      STRING,964      ...IDENTIFIERS,965      ...ATTRIBUTES,966      TYPE,967      TUPLE968    ]969  };970}971 972export { swift as default };973 
Brunobkr/llama.cpp_AlgMor24_github · Team Ai