56 lines
6.1 KiB
JavaScript
56 lines
6.1 KiB
JavaScript
/*! `php` grammar compiled for Highlight.js 11.7.0 */
|
|
(()=>{var e=(()=>{"use strict";return e=>{
|
|
const t=e.regex,a=/(?![A-Za-z0-9])(?![$])/,r=t.concat(/[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*/,a),n=t.concat(/(\\?[A-Z][a-z0-9_\x7f-\xff]+|\\?[A-Z]+(?=[A-Z][a-z0-9_\x7f-\xff])){1,}/,a),o={
|
|
scope:"variable",match:"\\$+"+r},c={scope:"subst",variants:[{begin:/\$\w+/},{
|
|
begin:/\{\$/,end:/\}/}]},i=e.inherit(e.APOS_STRING_MODE,{illegal:null
|
|
}),s="[ \t\n]",l={scope:"string",variants:[e.inherit(e.QUOTE_STRING_MODE,{
|
|
illegal:null,contains:e.QUOTE_STRING_MODE.contains.concat(c)
|
|
}),i,e.END_SAME_AS_BEGIN({begin:/<<<[ \t]*(\w+)\n/,end:/[ \t]*(\w+)\b/,
|
|
contains:e.QUOTE_STRING_MODE.contains.concat(c)})]},_={scope:"number",
|
|
variants:[{begin:"\\b0[bB][01]+(?:_[01]+)*\\b"},{
|
|
begin:"\\b0[oO][0-7]+(?:_[0-7]+)*\\b"},{
|
|
begin:"\\b0[xX][\\da-fA-F]+(?:_[\\da-fA-F]+)*\\b"},{
|
|
begin:"(?:\\b\\d+(?:_\\d+)*(\\.(?:\\d+(?:_\\d+)*))?|\\B\\.\\d+)(?:[eE][+-]?\\d+)?"
|
|
}],relevance:0
|
|
},d=["false","null","true"],p=["__CLASS__","__DIR__","__FILE__","__FUNCTION__","__COMPILER_HALT_OFFSET__","__LINE__","__METHOD__","__NAMESPACE__","__TRAIT__","die","echo","exit","include","include_once","print","require","require_once","array","abstract","and","as","binary","bool","boolean","break","callable","case","catch","class","clone","const","continue","declare","default","do","double","else","elseif","empty","enddeclare","endfor","endforeach","endif","endswitch","endwhile","enum","eval","extends","final","finally","float","for","foreach","from","global","goto","if","implements","instanceof","insteadof","int","integer","interface","isset","iterable","list","match|0","mixed","new","never","object","or","private","protected","public","readonly","real","return","string","switch","throw","trait","try","unset","use","var","void","while","xor","yield"],b=["Error|0","AppendIterator","ArgumentCountError","ArithmeticError","ArrayIterator","ArrayObject","AssertionError","BadFunctionCallException","BadMethodCallException","CachingIterator","CallbackFilterIterator","CompileError","Countable","DirectoryIterator","DivisionByZeroError","DomainException","EmptyIterator","ErrorException","Exception","FilesystemIterator","FilterIterator","GlobIterator","InfiniteIterator","InvalidArgumentException","IteratorIterator","LengthException","LimitIterator","LogicException","MultipleIterator","NoRewindIterator","OutOfBoundsException","OutOfRangeException","OuterIterator","OverflowException","ParentIterator","ParseError","RangeException","RecursiveArrayIterator","RecursiveCachingIterator","RecursiveCallbackFilterIterator","RecursiveDirectoryIterator","RecursiveFilterIterator","RecursiveIterator","RecursiveIteratorIterator","RecursiveRegexIterator","RecursiveTreeIterator","RegexIterator","RuntimeException","SeekableIterator","SplDoublyLinkedList","SplFileInfo","SplFileObject","SplFixedArray","SplHeap","SplMaxHeap","SplMinHeap","SplObjectStorage","SplObserver","SplPriorityQueue","SplQueue","SplStack","SplSubject","SplTempFileObject","TypeError","UnderflowException","UnexpectedValueException","UnhandledMatchError","ArrayAccess","BackedEnum","Closure","Fiber","Generator","Iterator","IteratorAggregate","Serializable","Stringable","Throwable","Traversable","UnitEnum","WeakReference","WeakMap","Directory","__PHP_Incomplete_Class","parent","php_user_filter","self","static","stdClass"],E={
|
|
keyword:p,literal:(e=>{const t=[];return e.forEach((e=>{
|
|
t.push(e),e.toLowerCase()===e?t.push(e.toUpperCase()):t.push(e.toLowerCase())
|
|
})),t})(d),built_in:b},u=e=>e.map((e=>e.replace(/\|\d+$/,""))),g={variants:[{
|
|
match:[/new/,t.concat(s,"+"),t.concat("(?!",u(b).join("\\b|"),"\\b)"),n],scope:{
|
|
1:"keyword",4:"title.class"}}]},h=t.concat(r,"\\b(?!\\()"),m={variants:[{
|
|
match:[t.concat(/::/,t.lookahead(/(?!class\b)/)),h],scope:{2:"variable.constant"
|
|
}},{match:[/::/,/class/],scope:{2:"variable.language"}},{
|
|
match:[n,t.concat(/::/,t.lookahead(/(?!class\b)/)),h],scope:{1:"title.class",
|
|
3:"variable.constant"}},{match:[n,t.concat("::",t.lookahead(/(?!class\b)/))],
|
|
scope:{1:"title.class"}},{match:[n,/::/,/class/],scope:{1:"title.class",
|
|
3:"variable.language"}}]},I={scope:"attr",
|
|
match:t.concat(r,t.lookahead(":"),t.lookahead(/(?!::)/))},f={relevance:0,
|
|
begin:/\(/,end:/\)/,keywords:E,contains:[I,o,m,e.C_BLOCK_COMMENT_MODE,l,_,g]
|
|
},O={relevance:0,
|
|
match:[/\b/,t.concat("(?!fn\\b|function\\b|",u(p).join("\\b|"),"|",u(b).join("\\b|"),"\\b)"),r,t.concat(s,"*"),t.lookahead(/(?=\()/)],
|
|
scope:{3:"title.function.invoke"},contains:[f]};f.contains.push(O)
|
|
;const v=[I,m,e.C_BLOCK_COMMENT_MODE,l,_,g];return{case_insensitive:!1,
|
|
keywords:E,contains:[{begin:t.concat(/#\[\s*/,n),beginScope:"meta",end:/]/,
|
|
endScope:"meta",keywords:{literal:d,keyword:["new","array"]},contains:[{
|
|
begin:/\[/,end:/]/,keywords:{literal:d,keyword:["new","array"]},
|
|
contains:["self",...v]},...v,{scope:"meta",match:n}]
|
|
},e.HASH_COMMENT_MODE,e.COMMENT("//","$"),e.COMMENT("/\\*","\\*/",{contains:[{
|
|
scope:"doctag",match:"@[A-Za-z]+"}]}),{match:/__halt_compiler\(\);/,
|
|
keywords:"__halt_compiler",starts:{scope:"comment",end:e.MATCH_NOTHING_RE,
|
|
contains:[{match:/\?>/,scope:"meta",endsParent:!0}]}},{scope:"meta",variants:[{
|
|
begin:/<\?php/,relevance:10},{begin:/<\?=/},{begin:/<\?/,relevance:.1},{
|
|
begin:/\?>/}]},{scope:"variable.language",match:/\$this\b/},o,O,m,{
|
|
match:[/const/,/\s/,r],scope:{1:"keyword",3:"variable.constant"}},g,{
|
|
scope:"function",relevance:0,beginKeywords:"fn function",end:/[;{]/,
|
|
excludeEnd:!0,illegal:"[$%\\[]",contains:[{beginKeywords:"use"
|
|
},e.UNDERSCORE_TITLE_MODE,{begin:"=>",endsParent:!0},{scope:"params",
|
|
begin:"\\(",end:"\\)",excludeBegin:!0,excludeEnd:!0,keywords:E,
|
|
contains:["self",o,m,e.C_BLOCK_COMMENT_MODE,l,_]}]},{scope:"class",variants:[{
|
|
beginKeywords:"enum",illegal:/[($"]/},{beginKeywords:"class interface trait",
|
|
illegal:/[:($"]/}],relevance:0,end:/\{/,excludeEnd:!0,contains:[{
|
|
beginKeywords:"extends implements"},e.UNDERSCORE_TITLE_MODE]},{
|
|
beginKeywords:"namespace",relevance:0,end:";",illegal:/[.']/,
|
|
contains:[e.inherit(e.UNDERSCORE_TITLE_MODE,{scope:"title.class"})]},{
|
|
beginKeywords:"use",relevance:0,end:";",contains:[{
|
|
match:/\b(as|const|function)\b/,scope:"keyword"},e.UNDERSCORE_TITLE_MODE]},l,_]}
|
|
}})();hljs.registerLanguage("php",e)})(); |