prism-solidity.js 1.1 KB

12345678910111213141516171819202122
  1. Prism.languages.solidity = Prism.languages.extend('clike', {
  2. 'class-name': {
  3. pattern: /(\b(?:contract|enum|interface|library|new|struct|using)\s+)(?!\d)[\w$]+/,
  4. lookbehind: true
  5. },
  6. 'keyword': /\b(?:_|anonymous|as|assembly|assert|break|calldata|case|constant|constructor|continue|contract|default|delete|do|else|emit|enum|event|external|for|from|function|if|import|indexed|inherited|interface|internal|is|let|library|mapping|memory|modifier|new|payable|pragma|private|public|pure|require|returns?|revert|selfdestruct|solidity|storage|struct|suicide|switch|this|throw|using|var|view|while)\b/,
  7. 'operator': /=>|->|:=|=:|\*\*|\+\+|--|\|\||&&|<<=?|>>=?|[-+*/%^&|<>!=]=?|[~?]/
  8. });
  9. Prism.languages.insertBefore('solidity', 'keyword', {
  10. 'builtin': /\b(?:address|bool|byte|u?int(?:8|16|24|32|40|48|56|64|72|80|88|96|104|112|120|128|136|144|152|160|168|176|184|192|200|208|216|224|232|240|248|256)?|string|bytes(?:[1-9]|[12]\d|3[0-2])?)\b/
  11. });
  12. Prism.languages.insertBefore('solidity', 'number', {
  13. 'version': {
  14. pattern: /([<>]=?|\^)\d+\.\d+\.\d+\b/,
  15. lookbehind: true,
  16. alias: 'number',
  17. }
  18. });
  19. Prism.languages.sol = Prism.languages.solidity;