From 9d65a6fae9d1cc94517bc1340ad7477fe7863fdb Mon Sep 17 00:00:00 2001 From: august radjoe Date: Thu, 30 Mar 2023 15:08:28 -0400 Subject: [PATCH 1/2] Create solidity.js --- js/languages/solidity.js | 92 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 92 insertions(+) create mode 100644 js/languages/solidity.js diff --git a/js/languages/solidity.js b/js/languages/solidity.js new file mode 100644 index 0000000..e0a1fbd --- /dev/null +++ b/js/languages/solidity.js @@ -0,0 +1,92 @@ +/* +Language: Solidity +Author: Your Name +Description: language definition for Solidity programming language used for developing smart contracts on the Ethereum blockchain +Website: https://soliditylang.org/ +Category: common, blockchain +*/ + +hljs.registerLanguage('solidity', function(hljs) { + var NUMBER = {className: 'number', relevance: 0, variants: [ + {begin: '\\b(0[bB][01]+)'}, // binary + {begin: '\\b(0[oO][0-7]+)'}, // octal + {begin: '\\b(0[xX][0-9a-fA-F]+)'}, // hex + {begin: '\\b([0-9]+(\\.[0-9]+)?([eE][+-]?[0-9]+)?)'} // decimal + ]}; + var KEYWORDS = { + keyword: + 'pragma return assembly break continue do else for if import ' + + 'new try catch throw while emit event mapping struct enum ' + + 'constructor modifier function selfdestruct payable view pure ' + + 'constant external public private internal indexed memory storage ' + + 'function view payable returns', + built_in: + 'assert require revert block coinbase difficulty gaslimit ' + + 'gasprice number timestamp tx blockhash' + }; + return { + aliases: ['solidity', 'sol'], + case_insensitive: true, + keywords: KEYWORDS, + contains: [ + hljs.C_LINE_COMMENT_MODE, + hljs.C_BLOCK_COMMENT_MODE, + hljs.QUOTE_STRING_MODE, + hljs.APOS_STRING_MODE, + { + className: 'string', + begin: '"""', end: '"""', + relevance: 10 + }, + NUMBER, + { + className: 'meta', + begin: '^\\s*#', end: '$', + contains: [ + { + className: 'meta-string', + variants: [ + { begin: /<.*?>/ }, + { begin: /\".*\"/ }, + { begin: /\'.*\'/ } + ] + } + ] + }, + { + className: 'function', + beginKeywords: 'function', end: /\{/, excludeEnd: true, + illegal: /\[|%/, + contains: [ + hljs.TITLE_MODE, + { + className: 'params', + begin: /\(/, end: /\)/, + excludeBegin: true, + excludeEnd: true, + contains: [ + hljs.SELF_CONTAINED, + { + className: 'param', + begin: /(\b[a-zA-Z_$][\w$]*)\s*:/, end: /,/, + returnBegin: true, excludeEnd: true + } + ] + } + ] + }, + { + className: 'class', + beginKeywords: 'contract interface', end: /\{/, excludeEnd: true, + contains: [ + hljs.TITLE_MODE, + { + className: 'inheritance', + begin: /is/, end: /(\s|\{|$)/, + keywords: {keyword: 'is'} + } + ] + } + ] + }; +}) From 59fad29d7d2f0052010f48465bf53db832f71e00 Mon Sep 17 00:00:00 2001 From: august radjoe Date: Thu, 30 Mar 2023 15:09:19 -0400 Subject: [PATCH 2/2] Update background.js --- js/background.js | 1 + 1 file changed, 1 insertion(+) diff --git a/js/background.js b/js/background.js index fecaca6..c125261 100644 --- a/js/background.js +++ b/js/background.js @@ -56,6 +56,7 @@ r: ['r'], ruby: ['rakefile', 'gemfile', 'rb'], scala: ['scala', 'scl', 'sca', 'scb'], + solidity: ['sol'], scss: ['scss', 'sass'], smalltalk: ['st', 'sm', 'sll'], sml: ['sml'],