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
php.js626 linesDownload Raw Back to languages
1/*2Language: PHP3Author: Victor Karamzin <Victor.Karamzin@enterra-inc.com>4Contributors: Evgeny Stepanischev <imbolk@gmail.com>, Ivan Sagalaev <maniac@softwaremaniacs.org>5Website: https://www.php.net6Category: common7*/8 9/**10 * @param {HLJSApi} hljs11 * @returns {LanguageDetail}12 * */13function php(hljs) {14  const regex = hljs.regex;15  // negative look-ahead tries to avoid matching patterns that are not16  // Perl at all like $ident$, @ident@, etc.17  const NOT_PERL_ETC = /(?![A-Za-z0-9])(?![$])/;18  const IDENT_RE = regex.concat(19    /[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*/,20    NOT_PERL_ETC);21  // Will not detect camelCase classes22  const PASCAL_CASE_CLASS_NAME_RE = regex.concat(23    /(\\?[A-Z][a-z0-9_\x7f-\xff]+|\\?[A-Z]+(?=[A-Z][a-z0-9_\x7f-\xff])){1,}/,24    NOT_PERL_ETC);25  const UPCASE_NAME_RE = regex.concat(26    /[A-Z]+/,27    NOT_PERL_ETC);28  const VARIABLE = {29    scope: 'variable',30    match: '\\$+' + IDENT_RE,31  };32  const PREPROCESSOR = {33    scope: "meta",34    variants: [35      { begin: /<\?php/, relevance: 10 }, // boost for obvious PHP36      { begin: /<\?=/ },37      // less relevant per PSR-1 which says not to use short-tags38      { begin: /<\?/, relevance: 0.1 },39      { begin: /\?>/ } // end php tag40    ]41  };42  const SUBST = {43    scope: 'subst',44    variants: [45      { begin: /\$\w+/ },46      {47        begin: /\{\$/,48        end: /\}/49      }50    ]51  };52  const SINGLE_QUOTED = hljs.inherit(hljs.APOS_STRING_MODE, { illegal: null, });53  const DOUBLE_QUOTED = hljs.inherit(hljs.QUOTE_STRING_MODE, {54    illegal: null,55    contains: hljs.QUOTE_STRING_MODE.contains.concat(SUBST),56  });57 58  const HEREDOC = {59    begin: /<<<[ \t]*(?:(\w+)|"(\w+)")\n/,60    end: /[ \t]*(\w+)\b/,61    contains: hljs.QUOTE_STRING_MODE.contains.concat(SUBST),62    'on:begin': (m, resp) => { resp.data._beginMatch = m[1] || m[2]; },63    'on:end': (m, resp) => { if (resp.data._beginMatch !== m[1]) resp.ignoreMatch(); },64  };65 66  const NOWDOC = hljs.END_SAME_AS_BEGIN({67    begin: /<<<[ \t]*'(\w+)'\n/,68    end: /[ \t]*(\w+)\b/,69  });70  // list of valid whitespaces because non-breaking space might be part of a IDENT_RE71  const WHITESPACE = '[ \t\n]';72  const STRING = {73    scope: 'string',74    variants: [75      DOUBLE_QUOTED,76      SINGLE_QUOTED,77      HEREDOC,78      NOWDOC79    ]80  };81  const NUMBER = {82    scope: 'number',83    variants: [84      { begin: `\\b0[bB][01]+(?:_[01]+)*\\b` }, // Binary w/ underscore support85      { begin: `\\b0[oO][0-7]+(?:_[0-7]+)*\\b` }, // Octals w/ underscore support86      { begin: `\\b0[xX][\\da-fA-F]+(?:_[\\da-fA-F]+)*\\b` }, // Hex w/ underscore support87      // Decimals w/ underscore support, with optional fragments and scientific exponent (e) suffix.88      { begin: `(?:\\b\\d+(?:_\\d+)*(\\.(?:\\d+(?:_\\d+)*))?|\\B\\.\\d+)(?:[eE][+-]?\\d+)?` }89    ],90    relevance: 091  };92  const LITERALS = [93    "false",94    "null",95    "true"96  ];97  const KWS = [98    // Magic constants:99    // <https://www.php.net/manual/en/language.constants.predefined.php>100    "__CLASS__",101    "__DIR__",102    "__FILE__",103    "__FUNCTION__",104    "__COMPILER_HALT_OFFSET__",105    "__LINE__",106    "__METHOD__",107    "__NAMESPACE__",108    "__TRAIT__",109    // Function that look like language construct or language construct that look like function:110    // List of keywords that may not require parenthesis111    "die",112    "echo",113    "exit",114    "include",115    "include_once",116    "print",117    "require",118    "require_once",119    // These are not language construct (function) but operate on the currently-executing function and can access the current symbol table120    // 'compact extract func_get_arg func_get_args func_num_args get_called_class get_parent_class ' +121    // Other keywords:122    // <https://www.php.net/manual/en/reserved.php>123    // <https://www.php.net/manual/en/language.types.type-juggling.php>124    "array",125    "abstract",126    "and",127    "as",128    "binary",129    "bool",130    "boolean",131    "break",132    "callable",133    "case",134    "catch",135    "class",136    "clone",137    "const",138    "continue",139    "declare",140    "default",141    "do",142    "double",143    "else",144    "elseif",145    "empty",146    "enddeclare",147    "endfor",148    "endforeach",149    "endif",150    "endswitch",151    "endwhile",152    "enum",153    "eval",154    "extends",155    "final",156    "finally",157    "float",158    "for",159    "foreach",160    "from",161    "global",162    "goto",163    "if",164    "implements",165    "instanceof",166    "insteadof",167    "int",168    "integer",169    "interface",170    "isset",171    "iterable",172    "list",173    "match|0",174    "mixed",175    "new",176    "never",177    "object",178    "or",179    "private",180    "protected",181    "public",182    "readonly",183    "real",184    "return",185    "string",186    "switch",187    "throw",188    "trait",189    "try",190    "unset",191    "use",192    "var",193    "void",194    "while",195    "xor",196    "yield"197  ];198 199  const BUILT_INS = [200    // Standard PHP library:201    // <https://www.php.net/manual/en/book.spl.php>202    "Error|0",203    "AppendIterator",204    "ArgumentCountError",205    "ArithmeticError",206    "ArrayIterator",207    "ArrayObject",208    "AssertionError",209    "BadFunctionCallException",210    "BadMethodCallException",211    "CachingIterator",212    "CallbackFilterIterator",213    "CompileError",214    "Countable",215    "DirectoryIterator",216    "DivisionByZeroError",217    "DomainException",218    "EmptyIterator",219    "ErrorException",220    "Exception",221    "FilesystemIterator",222    "FilterIterator",223    "GlobIterator",224    "InfiniteIterator",225    "InvalidArgumentException",226    "IteratorIterator",227    "LengthException",228    "LimitIterator",229    "LogicException",230    "MultipleIterator",231    "NoRewindIterator",232    "OutOfBoundsException",233    "OutOfRangeException",234    "OuterIterator",235    "OverflowException",236    "ParentIterator",237    "ParseError",238    "RangeException",239    "RecursiveArrayIterator",240    "RecursiveCachingIterator",241    "RecursiveCallbackFilterIterator",242    "RecursiveDirectoryIterator",243    "RecursiveFilterIterator",244    "RecursiveIterator",245    "RecursiveIteratorIterator",246    "RecursiveRegexIterator",247    "RecursiveTreeIterator",248    "RegexIterator",249    "RuntimeException",250    "SeekableIterator",251    "SplDoublyLinkedList",252    "SplFileInfo",253    "SplFileObject",254    "SplFixedArray",255    "SplHeap",256    "SplMaxHeap",257    "SplMinHeap",258    "SplObjectStorage",259    "SplObserver",260    "SplPriorityQueue",261    "SplQueue",262    "SplStack",263    "SplSubject",264    "SplTempFileObject",265    "TypeError",266    "UnderflowException",267    "UnexpectedValueException",268    "UnhandledMatchError",269    // Reserved interfaces:270    // <https://www.php.net/manual/en/reserved.interfaces.php>271    "ArrayAccess",272    "BackedEnum",273    "Closure",274    "Fiber",275    "Generator",276    "Iterator",277    "IteratorAggregate",278    "Serializable",279    "Stringable",280    "Throwable",281    "Traversable",282    "UnitEnum",283    "WeakReference",284    "WeakMap",285    // Reserved classes:286    // <https://www.php.net/manual/en/reserved.classes.php>287    "Directory",288    "__PHP_Incomplete_Class",289    "parent",290    "php_user_filter",291    "self",292    "static",293    "stdClass"294  ];295 296  /** Dual-case keywords297   *298   * ["then","FILE"] =>299   *     ["then", "THEN", "FILE", "file"]300   *301   * @param {string[]} items */302  const dualCase = (items) => {303    /** @type string[] */304    const result = [];305    items.forEach(item => {306      result.push(item);307      if (item.toLowerCase() === item) {308        result.push(item.toUpperCase());309      } else {310        result.push(item.toLowerCase());311      }312    });313    return result;314  };315 316  const KEYWORDS = {317    keyword: KWS,318    literal: dualCase(LITERALS),319    built_in: BUILT_INS,320  };321 322  /**323   * @param {string[]} items */324  const normalizeKeywords = (items) => {325    return items.map(item => {326      return item.replace(/\|\d+$/, "");327    });328  };329 330  const CONSTRUCTOR_CALL = { variants: [331    {332      match: [333        /new/,334        regex.concat(WHITESPACE, "+"),335        // to prevent built ins from being confused as the class constructor call336        regex.concat("(?!", normalizeKeywords(BUILT_INS).join("\\b|"), "\\b)"),337        PASCAL_CASE_CLASS_NAME_RE,338      ],339      scope: {340        1: "keyword",341        4: "title.class",342      },343    }344  ] };345 346  const CONSTANT_REFERENCE = regex.concat(IDENT_RE, "\\b(?!\\()");347 348  const LEFT_AND_RIGHT_SIDE_OF_DOUBLE_COLON = { variants: [349    {350      match: [351        regex.concat(352          /::/,353          regex.lookahead(/(?!class\b)/)354        ),355        CONSTANT_REFERENCE,356      ],357      scope: { 2: "variable.constant", },358    },359    {360      match: [361        /::/,362        /class/,363      ],364      scope: { 2: "variable.language", },365    },366    {367      match: [368        PASCAL_CASE_CLASS_NAME_RE,369        regex.concat(370          /::/,371          regex.lookahead(/(?!class\b)/)372        ),373        CONSTANT_REFERENCE,374      ],375      scope: {376        1: "title.class",377        3: "variable.constant",378      },379    },380    {381      match: [382        PASCAL_CASE_CLASS_NAME_RE,383        regex.concat(384          "::",385          regex.lookahead(/(?!class\b)/)386        ),387      ],388      scope: { 1: "title.class", },389    },390    {391      match: [392        PASCAL_CASE_CLASS_NAME_RE,393        /::/,394        /class/,395      ],396      scope: {397        1: "title.class",398        3: "variable.language",399      },400    }401  ] };402 403  const NAMED_ARGUMENT = {404    scope: 'attr',405    match: regex.concat(IDENT_RE, regex.lookahead(':'), regex.lookahead(/(?!::)/)),406  };407  const PARAMS_MODE = {408    relevance: 0,409    begin: /\(/,410    end: /\)/,411    keywords: KEYWORDS,412    contains: [413      NAMED_ARGUMENT,414      VARIABLE,415      LEFT_AND_RIGHT_SIDE_OF_DOUBLE_COLON,416      hljs.C_BLOCK_COMMENT_MODE,417      STRING,418      NUMBER,419      CONSTRUCTOR_CALL,420    ],421  };422  const FUNCTION_INVOKE = {423    relevance: 0,424    match: [425      /\b/,426      // to prevent keywords from being confused as the function title427      regex.concat("(?!fn\\b|function\\b|", normalizeKeywords(KWS).join("\\b|"), "|", normalizeKeywords(BUILT_INS).join("\\b|"), "\\b)"),428      IDENT_RE,429      regex.concat(WHITESPACE, "*"),430      regex.lookahead(/(?=\()/)431    ],432    scope: { 3: "title.function.invoke", },433    contains: [ PARAMS_MODE ]434  };435  PARAMS_MODE.contains.push(FUNCTION_INVOKE);436 437  const ATTRIBUTE_CONTAINS = [438    NAMED_ARGUMENT,439    LEFT_AND_RIGHT_SIDE_OF_DOUBLE_COLON,440    hljs.C_BLOCK_COMMENT_MODE,441    STRING,442    NUMBER,443    CONSTRUCTOR_CALL,444  ];445 446  const ATTRIBUTES = {447    begin: regex.concat(/#\[\s*\\?/,448      regex.either(449        PASCAL_CASE_CLASS_NAME_RE,450        UPCASE_NAME_RE451      )452    ),453    beginScope: "meta",454    end: /]/,455    endScope: "meta",456    keywords: {457      literal: LITERALS,458      keyword: [459        'new',460        'array',461      ]462    },463    contains: [464      {465        begin: /\[/,466        end: /]/,467        keywords: {468          literal: LITERALS,469          keyword: [470            'new',471            'array',472          ]473        },474        contains: [475          'self',476          ...ATTRIBUTE_CONTAINS,477        ]478      },479      ...ATTRIBUTE_CONTAINS,480      {481        scope: 'meta',482        variants: [483          { match: PASCAL_CASE_CLASS_NAME_RE },484          { match: UPCASE_NAME_RE }485        ]486      }487    ]488  };489 490  return {491    case_insensitive: false,492    keywords: KEYWORDS,493    contains: [494      ATTRIBUTES,495      hljs.HASH_COMMENT_MODE,496      hljs.COMMENT('//', '$'),497      hljs.COMMENT(498        '/\\*',499        '\\*/',500        { contains: [501          {502            scope: 'doctag',503            match: '@[A-Za-z]+'504          }505        ] }506      ),507      {508        match: /__halt_compiler\(\);/,509        keywords: '__halt_compiler',510        starts: {511          scope: "comment",512          end: hljs.MATCH_NOTHING_RE,513          contains: [514            {515              match: /\?>/,516              scope: "meta",517              endsParent: true518            }519          ]520        }521      },522      PREPROCESSOR,523      {524        scope: 'variable.language',525        match: /\$this\b/526      },527      VARIABLE,528      FUNCTION_INVOKE,529      LEFT_AND_RIGHT_SIDE_OF_DOUBLE_COLON,530      {531        match: [532          /const/,533          /\s/,534          IDENT_RE,535        ],536        scope: {537          1: "keyword",538          3: "variable.constant",539        },540      },541      CONSTRUCTOR_CALL,542      {543        scope: 'function',544        relevance: 0,545        beginKeywords: 'fn function',546        end: /[;{]/,547        excludeEnd: true,548        illegal: '[$%\\[]',549        contains: [550          { beginKeywords: 'use', },551          hljs.UNDERSCORE_TITLE_MODE,552          {553            begin: '=>', // No markup, just a relevance booster554            endsParent: true555          },556          {557            scope: 'params',558            begin: '\\(',559            end: '\\)',560            excludeBegin: true,561            excludeEnd: true,562            keywords: KEYWORDS,563            contains: [564              'self',565              ATTRIBUTES,566              VARIABLE,567              LEFT_AND_RIGHT_SIDE_OF_DOUBLE_COLON,568              hljs.C_BLOCK_COMMENT_MODE,569              STRING,570              NUMBER571            ]572          },573        ]574      },575      {576        scope: 'class',577        variants: [578          {579            beginKeywords: "enum",580            illegal: /[($"]/581          },582          {583            beginKeywords: "class interface trait",584            illegal: /[:($"]/585          }586        ],587        relevance: 0,588        end: /\{/,589        excludeEnd: true,590        contains: [591          { beginKeywords: 'extends implements' },592          hljs.UNDERSCORE_TITLE_MODE593        ]594      },595      // both use and namespace still use "old style" rules (vs multi-match)596      // because the namespace name can include `\` and we still want each597      // element to be treated as its own *individual* title598      {599        beginKeywords: 'namespace',600        relevance: 0,601        end: ';',602        illegal: /[.']/,603        contains: [ hljs.inherit(hljs.UNDERSCORE_TITLE_MODE, { scope: "title.class" }) ]604      },605      {606        beginKeywords: 'use',607        relevance: 0,608        end: ';',609        contains: [610          // TODO: title.function vs title.class611          {612            match: /\b(as|const|function)\b/,613            scope: "keyword"614          },615          // TODO: could be title.class or title.function616          hljs.UNDERSCORE_TITLE_MODE617        ]618      },619      STRING,620      NUMBER,621    ]622  };623}624 625export { php as default };626 
Brunobkr/llama.cpp_AlgMor24_github · Team Ai