UNPKG

highlightjs-solidity

Version:

highlight.js syntax definition for Ethereum's Solidity language

30 lines 2.74 kB
hljs.registerLanguage("yul",(()=>{"use strict";function e(){try{return!0 }catch(e){return!1}} var a=/-?(\b0[xX]([a-fA-F0-9]_?)*[a-fA-F0-9]|(\b[1-9](_?\d)*(\.((\d_?)*\d)?)?|\.\d(_?\d)*)([eE][-+]?\d(_?\d)*)?|\b0)(?!\w|\$)/ ;e()&&(a=a.source.replace(/\\b/g,"(?<!\\$)\\b"));var s={className:"number", begin:a,relevance:0},t={ keyword:"assembly let function if switch case default for leave break continue u256 jump jumpi stop return revert selfdestruct invalid", built_in:"add sub mul div sdiv mod smod exp not lt gt slt sgt eq iszero and or xor byte shl shr sar addmod mulmod signextend keccak256 pc pop dup1 dup2 dup3 dup4 dup5 dup6 dup7 dup8 dup9 dup10 dup11 dup12 dup13 dup14 dup15 dup16 swap1 swap2 swap3 swap4 swap5 swap6 swap7 swap8 swap9 swap10 swap11 swap12 swap13 swap14 swap15 swap16 mload mstore mstore8 sload sstore msize gas address balance selfbalance caller callvalue calldataload calldatasize calldatacopy codesize codecopy extcodesize extcodecopy returndatasize returndatacopy extcodehash create create2 call callcode delegatecall staticcall log0 log1 log2 log3 log4 chainid origin gasprice basefee blockhash coinbase timestamp number difficulty prevrandao gaslimit", literal:"true false"},i={className:"string", begin:/\bhex'(([0-9a-fA-F]{2}_?)*[0-9a-fA-F]{2})?'/},l={className:"string", begin:/\bhex"(([0-9a-fA-F]{2}_?)*[0-9a-fA-F]{2})?"/};function d(e){ return e.inherit(e.APOS_STRING_MODE,{begin:/(\bunicode)?'/})}function r(e){ return e.inherit(e.QUOTE_STRING_MODE,{begin:/(\bunicode)?"/})}var n={ SOL_ASSEMBLY_KEYWORDS:t,baseAssembly:e=>{ var a=d(e),n=r(e),o=/[A-Za-z_$][A-Za-z_$0-9.]*/,c=e.inherit(e.TITLE_MODE,{ begin:/[A-Za-z$_][0-9A-Za-z$_]*/,lexemes:o,keywords:t}),u={className:"params", begin:/\(/,end:/\)/,excludeBegin:!0,excludeEnd:!0,lexemes:o,keywords:t, contains:[e.C_LINE_COMMENT_MODE,e.C_BLOCK_COMMENT_MODE,a,n,s]},p={ className:"operator",begin:/:=|->/};return{keywords:t,lexemes:o, contains:[a,n,i,l,e.C_LINE_COMMENT_MODE,e.C_BLOCK_COMMENT_MODE,s,p,{ className:"function",lexemes:o,beginKeywords:"function",end:"{",excludeEnd:!0, contains:[c,u,e.C_LINE_COMMENT_MODE,e.C_BLOCK_COMMENT_MODE,p]}]}}, solAposStringMode:d,solQuoteStringMode:r,HEX_APOS_STRING_MODE:i, HEX_QUOTE_STRING_MODE:l,SOL_NUMBER:s,isNegativeLookbehindAvailable:e} ;const{SOL_ASSEMBLY_KEYWORDS:o,baseAssembly:c,isNegativeLookbehindAvailable:u}=n ;return e=>{var a={keyword:o.keyword+" object code data", built_in:o.built_in+" datasize dataoffset datacopy setimmutable loadimmutable linkersymbol memoryguard", literal:o.literal},s=/\bverbatim_[1-9]?[0-9]i_[1-9]?[0-9]o\b(?!\$)/ ;u()&&(s=s.source.replace(/\\b/,"(?<!\\$)\\b"));var t={className:"built_in", begin:s},i=c(e);return e.inherit(i,{keywords:a,contains:i.contains.concat([t])}) }})());