├── .gitignore ├── .npmignore ├── .travis.yml ├── CHANGELOG.md ├── LICENSE ├── README.md ├── build.js ├── build ├── legacy │ ├── v1.1.8 │ │ ├── src-brace │ │ │ ├── mode-javascript.js │ │ │ └── mode-solidity.js │ │ ├── src-noconflict │ │ │ ├── mode-javascript.js │ │ │ └── mode-solidity.js │ │ └── src │ │ │ ├── mode-javascript.js │ │ │ └── mode-solidity.js │ ├── v1.1.9 │ │ ├── src-brace │ │ │ ├── mode-javascript.js │ │ │ └── mode-solidity.js │ │ ├── src-noconflict │ │ │ ├── mode-javascript.js │ │ │ └── mode-solidity.js │ │ └── src │ │ │ ├── mode-javascript.js │ │ │ └── mode-solidity.js │ ├── v1.2.0 │ │ ├── src-brace │ │ │ ├── mode-javascript.js │ │ │ └── mode-solidity.js │ │ ├── src-noconflict │ │ │ ├── mode-javascript.js │ │ │ └── mode-solidity.js │ │ └── src │ │ │ ├── mode-javascript.js │ │ │ └── mode-solidity.js │ ├── v1.2.1 │ │ ├── src-brace │ │ │ ├── mode-javascript.js │ │ │ └── mode-solidity.js │ │ ├── src-noconflict │ │ │ ├── mode-javascript.js │ │ │ └── mode-solidity.js │ │ └── src │ │ │ ├── mode-javascript.js │ │ │ └── mode-solidity.js │ ├── v1.2.2 │ │ ├── src-brace │ │ │ ├── mode-javascript.js │ │ │ └── mode-solidity.js │ │ ├── src-noconflict │ │ │ ├── mode-javascript.js │ │ │ └── mode-solidity.js │ │ └── src │ │ │ ├── mode-javascript.js │ │ │ └── mode-solidity.js │ ├── v1.2.3 │ │ ├── src-brace │ │ │ ├── mode-javascript.js │ │ │ └── mode-solidity.js │ │ ├── src-noconflict │ │ │ ├── mode-javascript.js │ │ │ └── mode-solidity.js │ │ └── src │ │ │ ├── mode-javascript.js │ │ │ └── mode-solidity.js │ ├── v1.2.4 │ │ ├── src-brace │ │ │ ├── mode-javascript.js │ │ │ └── mode-solidity.js │ │ ├── src-noconflict │ │ │ ├── mode-javascript.js │ │ │ └── mode-solidity.js │ │ └── src │ │ │ ├── mode-javascript.js │ │ │ └── mode-solidity.js │ ├── v1.2.5 │ │ ├── src-brace │ │ │ ├── mode-javascript.js │ │ │ └── mode-solidity.js │ │ ├── src-noconflict │ │ │ ├── mode-javascript.js │ │ │ └── mode-solidity.js │ │ └── src │ │ │ ├── mode-javascript.js │ │ │ └── mode-solidity.js │ ├── v1.2.6 │ │ ├── src-brace │ │ │ ├── mode-javascript.js │ │ │ └── mode-solidity.js │ │ ├── src-noconflict │ │ │ ├── mode-javascript.js │ │ │ └── mode-solidity.js │ │ └── src │ │ │ ├── mode-javascript.js │ │ │ └── mode-solidity.js │ ├── v1.2.7 │ │ ├── src-brace │ │ │ ├── mode-javascript.js │ │ │ └── mode-solidity.js │ │ ├── src-noconflict │ │ │ ├── mode-javascript.js │ │ │ └── mode-solidity.js │ │ └── src │ │ │ ├── mode-javascript.js │ │ │ └── mode-solidity.js │ ├── v1.2.8 │ │ ├── src-brace │ │ │ ├── mode-javascript.js │ │ │ └── mode-solidity.js │ │ ├── src-noconflict │ │ │ ├── mode-javascript.js │ │ │ └── mode-solidity.js │ │ └── src │ │ │ ├── mode-javascript.js │ │ │ └── mode-solidity.js │ ├── v1.2.9 │ │ ├── src-brace │ │ │ ├── mode-javascript.js │ │ │ └── mode-solidity.js │ │ ├── src-noconflict │ │ │ ├── mode-javascript.js │ │ │ └── mode-solidity.js │ │ └── src │ │ │ ├── mode-javascript.js │ │ │ └── mode-solidity.js │ ├── v1.3.0 │ │ ├── src-brace │ │ │ ├── mode-javascript.js │ │ │ └── mode-solidity.js │ │ ├── src-noconflict │ │ │ ├── mode-javascript.js │ │ │ └── mode-solidity.js │ │ └── src │ │ │ ├── mode-javascript.js │ │ │ └── mode-solidity.js │ ├── v1.3.1 │ │ ├── src-brace │ │ │ ├── mode-javascript.js │ │ │ └── mode-solidity.js │ │ ├── src-noconflict │ │ │ ├── mode-javascript.js │ │ │ └── mode-solidity.js │ │ └── src │ │ │ ├── mode-javascript.js │ │ │ └── mode-solidity.js │ ├── v1.3.2 │ │ ├── src-brace │ │ │ ├── mode-javascript.js │ │ │ └── mode-solidity.js │ │ ├── src-noconflict │ │ │ ├── mode-javascript.js │ │ │ └── mode-solidity.js │ │ └── src │ │ │ ├── mode-javascript.js │ │ │ └── mode-solidity.js │ └── v1.3.3 │ │ ├── src-brace │ │ ├── mode-javascript.js │ │ └── mode-solidity.js │ │ ├── src-noconflict │ │ ├── mode-javascript.js │ │ └── mode-solidity.js │ │ └── src │ │ ├── mode-javascript.js │ │ └── mode-solidity.js ├── remix-ide │ └── mode-solidity.js ├── v1.2.4 │ ├── src-min-noconflict │ │ ├── mode-javascript.js │ │ └── mode-solidity.js │ ├── src-min │ │ ├── mode-javascript.js │ │ └── mode-solidity.js │ ├── src-noconflict │ │ ├── mode-javascript.js │ │ └── mode-solidity.js │ └── src │ │ ├── mode-javascript.js │ │ └── mode-solidity.js ├── v1.2.5 │ ├── src-min-noconflict │ │ ├── mode-javascript.js │ │ └── mode-solidity.js │ ├── src-min │ │ ├── mode-javascript.js │ │ └── mode-solidity.js │ ├── src-noconflict │ │ ├── mode-javascript.js │ │ └── mode-solidity.js │ └── src │ │ ├── mode-javascript.js │ │ └── mode-solidity.js ├── v1.2.6 │ ├── src-min-noconflict │ │ ├── mode-javascript.js │ │ └── mode-solidity.js │ ├── src-min │ │ ├── mode-javascript.js │ │ └── mode-solidity.js │ ├── src-noconflict │ │ ├── mode-javascript.js │ │ └── mode-solidity.js │ └── src │ │ ├── mode-javascript.js │ │ └── mode-solidity.js ├── v1.2.7 │ ├── src-min-noconflict │ │ ├── mode-javascript.js │ │ └── mode-solidity.js │ ├── src-min │ │ ├── mode-javascript.js │ │ └── mode-solidity.js │ ├── src-noconflict │ │ ├── mode-javascript.js │ │ └── mode-solidity.js │ └── src │ │ ├── mode-javascript.js │ │ └── mode-solidity.js ├── v1.2.8 │ ├── src-min-noconflict │ │ ├── mode-javascript.js │ │ └── mode-solidity.js │ ├── src-min │ │ ├── mode-javascript.js │ │ └── mode-solidity.js │ ├── src-noconflict │ │ ├── mode-javascript.js │ │ └── mode-solidity.js │ └── src │ │ ├── mode-javascript.js │ │ └── mode-solidity.js ├── v1.2.9 │ ├── src-min-noconflict │ │ ├── mode-javascript.js │ │ └── mode-solidity.js │ ├── src-min │ │ ├── mode-javascript.js │ │ └── mode-solidity.js │ ├── src-noconflict │ │ ├── mode-javascript.js │ │ └── mode-solidity.js │ └── src │ │ ├── mode-javascript.js │ │ └── mode-solidity.js ├── v1.3.0 │ ├── src-min-noconflict │ │ ├── mode-javascript.js │ │ └── mode-solidity.js │ ├── src-min │ │ ├── mode-javascript.js │ │ └── mode-solidity.js │ ├── src-noconflict │ │ ├── mode-javascript.js │ │ └── mode-solidity.js │ └── src │ │ ├── mode-javascript.js │ │ └── mode-solidity.js ├── v1.3.1 │ ├── src-min-noconflict │ │ ├── mode-javascript.js │ │ └── mode-solidity.js │ ├── src-min │ │ ├── mode-javascript.js │ │ └── mode-solidity.js │ ├── src-noconflict │ │ ├── mode-javascript.js │ │ └── mode-solidity.js │ └── src │ │ ├── mode-javascript.js │ │ └── mode-solidity.js ├── v1.3.2 │ ├── src-min-noconflict │ │ ├── mode-javascript.js │ │ └── mode-solidity.js │ ├── src-min │ │ ├── mode-javascript.js │ │ └── mode-solidity.js │ ├── src-noconflict │ │ ├── mode-javascript.js │ │ └── mode-solidity.js │ └── src │ │ ├── mode-javascript.js │ │ └── mode-solidity.js └── v1.3.3 │ ├── src-min-noconflict │ ├── mode-javascript.js │ └── mode-solidity.js │ ├── src-min │ ├── mode-javascript.js │ └── mode-solidity.js │ ├── src-noconflict │ ├── mode-javascript.js │ └── mode-solidity.js │ └── src │ ├── mode-javascript.js │ └── mode-solidity.js ├── build_cache └── .gitignore ├── build_support ├── astTraversal.js ├── buildForRemixIde.js ├── buildLegacy.js ├── buildWithAce.js ├── coreFilesByVersion.js ├── coreFilesByVersion.json ├── exampleAst.js ├── getExportsSuffix.js ├── ignoreCoreFileRequires.js ├── localAceRepository.js ├── normalizeRequires.js ├── parseRequires.js ├── renderCode.js ├── stopBuild.js └── writeFile.js ├── lib └── ace │ └── mode │ ├── solidity.js │ └── solidity_highlight_rules.js ├── package-lock.json ├── package.json ├── project.js ├── remix-ide └── test_browserify ├── .gitignore ├── build.js ├── cache └── .gitignore ├── collect-solidity-snippets.js ├── data ├── Block.json ├── Block.sol ├── Comments.json ├── Comments.sol ├── ContractDefinition.json ├── ContractDefinition.sol ├── DoWhileStatement.json ├── DoWhileStatement.sol ├── EnumDefinition.json ├── EnumDefinition.sol ├── EventDefinition.json ├── EventDefinition.sol ├── Expression.json ├── Expression.sol ├── ForStatement.json ├── ForStatement.sol ├── FunctionArguments.json ├── FunctionArguments.sol ├── FunctionDefinition.json ├── FunctionDefinition.sol ├── GlobalFunctions.json ├── GlobalFunctions.sol ├── GlobalVariables.json ├── GlobalVariables.sol ├── IfStatement.json ├── IfStatement.sol ├── ImportDirective.json ├── ImportDirective.sol ├── ModifierDefinition.json ├── ModifierDefinition.sol ├── NatSpec.json ├── NatSpec.sol ├── PragmaDirective.json ├── PragmaDirective.sol ├── ReservedKeywords.json ├── ReservedKeywords.sol ├── StateVariableDeclaration.json ├── StateVariableDeclaration.sol ├── StructDefinition.json ├── StructDefinition.sol ├── UsingForDeclaration.json ├── UsingForDeclaration.sol ├── VariableDefinition.json ├── VariableDefinition.sol ├── WhileStatement.json └── WhileStatement.sol ├── gather-tokenizations.js ├── overwrite-expected-tokenizations.js ├── public ├── bundle.js ├── favicon.ico ├── index.css └── index.html ├── reports-prep.js ├── reports-serve.js ├── reports ├── by-string-value.html ├── by-string-value.js ├── diff-summary.html ├── diff-summary.js ├── index.html ├── new-tokenizations.json ├── old-tokenizations.json └── style.css ├── run.js ├── serve-editor.js └── src └── solidity-editor.js /.gitignore: -------------------------------------------------------------------------------- 1 | # Logs 2 | logs 3 | *.log 4 | npm-debug.log* 5 | yarn-debug.log* 6 | yarn-error.log* 7 | 8 | # Runtime data 9 | pids 10 | *.pid 11 | *.seed 12 | *.pid.lock 13 | 14 | # Directory for instrumented libs generated by jscoverage/JSCover 15 | lib-cov 16 | 17 | # Coverage directory used by tools like istanbul 18 | coverage 19 | 20 | # nyc test coverage 21 | .nyc_output 22 | 23 | # Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files) 24 | .grunt 25 | 26 | # Bower dependency directory (https://bower.io/) 27 | bower_components 28 | 29 | # node-waf configuration 30 | .lock-wscript 31 | 32 | # Compiled binary addons (https://nodejs.org/api/addons.html) 33 | build/Release 34 | 35 | # Dependency directories 36 | node_modules/ 37 | jspm_packages/ 38 | 39 | # TypeScript v1 declaration files 40 | typings/ 41 | 42 | # Optional npm cache directory 43 | .npm 44 | 45 | # Optional eslint cache 46 | .eslintcache 47 | 48 | # Optional REPL history 49 | .node_repl_history 50 | 51 | # Output of 'npm pack' 52 | *.tgz 53 | 54 | # Yarn Integrity file 55 | .yarn-integrity 56 | 57 | # dotenv environment variables file 58 | .env 59 | 60 | # next.js build output 61 | .next 62 | 63 | # Project-specific 64 | /ace/ 65 | -------------------------------------------------------------------------------- /.npmignore: -------------------------------------------------------------------------------- 1 | .vscode 2 | /build_cache/ 3 | node_modules 4 | npm-debug.log* 5 | package-lock.json 6 | .DS_Store 7 | build/**/mode-javascript.js 8 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: node_js 2 | node_js: 3 | - "8" 4 | branches: 5 | only: 6 | - master 7 | script: 8 | - npm test 9 | cache: 10 | directories: 11 | - node_modules # NPM packages 12 | -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # 0.1.1 / 2018-11-21 2 | 3 | * Update version of indirect dependency [`cached-path-relative`](https://www.npmjs.com/package/cached-path-relative) in `package-lock.json` from `1.0.1` to `1.0.2` due to [CVE-2018-16472](https://nvd.nist.gov/vuln/detail/CVE-2018-16472). 4 | 5 | # 0.1.0 / 2018-07-17 6 | 7 | * First minor version release as sign of commitment to having `build/remix-ide/mode-solidity.js` as entry point for Remix IDE. 8 | 9 | # 0.0.1-alpha.4 / 2018-07-17 10 | 11 | * Add 2 build systems 12 | 1. piggy-backing on the actual ACE build system 13 | 2. re-creating the ACE build system to be able to build legacy versions. 14 | * Bug fixes in Solidity syntax highlighter. 15 | 16 | # 0.0.1-alpha.3 / 2018-07-12 17 | 18 | * Remove `reports` subdir from `.npmignore` 19 | 20 | # 0.0.1-alpha.2 / 2018-07-12 21 | 22 | * Majority of refactoring: 23 | - Remove cruft left over from copy'n'pasting `ace/mode/javascript` 24 | - Add missing Solidity syntax highlighting 25 | - Correct wrong Solidity syntax highlighting 26 | 27 | # 0.0.1-alpha.1 / 2018-06-16 28 | 29 | * Claim NPM package name 30 | * Copied `mode-solidity.js` from https://github.com/ethereum/remix-ide/blob/d8664909c1180e0095bec6b5c83f6a69c29b34a3/src/app/editor/mode-solidity.js 31 | * Fixed mode name from copy'n'pasted `ace/mode/javascript` to `ace/mode/solidity` 32 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2018 Raphael Huefner 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # ace/mode/solidity 2 | 3 | [![Build Status](https://travis-ci.org/raphaelhuefner/ace-mode-solidity.svg?branch=master)](https://travis-ci.org/raphaelhuefner/ace-mode-solidity) [![npm version](https://badge.fury.io/js/ace-mode-solidity.svg)](https://badge.fury.io/js/ace-mode-solidity) 4 | 5 | [Ace](https://ace.c9.io/) Edit Mode for [Ethereum's Solidity language](https://solidity.readthedocs.io/en/latest/). 6 | 7 | - The [`build`](./build/) directory holds prebuilt versions of the Solidity edit mode like you would find in the [ace-builds](https://github.com/ajaxorg/ace-builds/) repository. 8 | - The [`build/legacy`](./build/legacy/) directory has older versions which were built with a re-created ACE build process which does not crash on recent Node.js versions. 9 | - (At least for me, the ACE build fails <=v1.2.3 on my Node.js v8.11.3 . Re-creating that build process was a very good AST lesson for me, I'm happy I took that detour.) 10 | - As an added bonus, the `legacy` directory has also [brace](https://www.npmjs.com/package/brace) (ACE for browserify) versions, look for `src-brace` subdirs. 11 | - Please do not wonder about any `mode-javascript.js` files, they only exist to ensure the 2 build processes are consistent. 12 | - Currently the only tested build is `build/remix-ide/mode-solidity.js` because the main focus is to enable [Remix IDE](https://github.com/ethereum/remix-ide) to start using this NPM package. See [this GitHub issue](https://github.com/ethereum/remix-ide/issues/1359) for the progress on that. 13 | - After that transition succeeded I will extend the tests to the other ACE versions. 14 | - No support for EVM assembly yet. 15 | -------------------------------------------------------------------------------- /build.js: -------------------------------------------------------------------------------- 1 | const buildWithAce = require('./build_support/buildWithAce.js'); 2 | const buildLegacy = require('./build_support/buildLegacy.js'); 3 | const buildForRemixIde = require('./build_support/buildForRemixIde.js'); 4 | 5 | buildWithAce(); 6 | buildLegacy(); 7 | // TODO test that the results of buildWithAce() and buildLegacy() are the same for 1.2.4 - 1.3.3 8 | buildForRemixIde(); 9 | -------------------------------------------------------------------------------- /build/v1.2.4/src-min/mode-solidity.js: -------------------------------------------------------------------------------- 1 | define("ace/mode/solidity_highlight_rules",["require","exports","module","ace/lib/oop","ace/lib/lang","ace/mode/text_highlight_rules"],function(e,t,n){"use strict";var r=e("../lib/oop"),i=e("../lib/lang").deepCopy,s=e("./text_highlight_rules").TextHighlightRules,o=function(e){var t="byte|int|uint";for(var n=8;n<=256;n+=8)t+="|bytes"+n/8+"|uint"+n+"|int"+n;var r={"variable.language":"this|super",keyword:"as|emit|from|import|returns","keyword.control":"break|continue|do|else|for|if|return|while","keyword.control.deprecated":"throw","keyword.operator":"delete|new","keyword.other.reserved":"abstract|after|alias|apply|auto|case|catch|copyof|default|define|final|immutable|implements|in|inline|let|macro|match|mutable|null|of|override|partial|promise|reference|relocatable|sealed|sizeof|static|supports|switch|try|type|typedef|typeof|unchecked","storage.type":"contract|library|interface|function|constructor|event|modifier|struct|mapping|enum|var|bool|address|"+t,"storage.type.array.dynamic":"bytes|string","storage.modifier.inheritance":"is","storage.modifier.storagelocation":"storage|memory|calldata","storage.modifier.statemutability":"constant|payable|pure|view","storage.modifier.visibility":"private|public|external|internal","storage.modifier.event":"anonymous|indexed","support.function":"addmod|assert|blockhash|ecrecover|gasleft|keccak256|mulmod|require|revert|ripemd160|selfdestruct|sha256","support.function.deprecated":"sha3|suicide","support.variable":"now","constant.language.boolean":"true|false","constant.numeric.other.unit.currency":"wei|szabo|finney|ether","constant.numeric.other.unit.time":"seconds|minutes|hours|days|weeks","constant.numeric.other.unit.time.deprecated":"years"},s=this.createKeywordMapper(r,"identifier"),o=!1,u=function(t){var n=s(t);return o&&"identifier"==n&&(n="variable.parameter"),o=!0,n},a="[a-zA-Z_$][a-zA-Z_$0-9]*\\b|\\$",f="\\\\(?:x[0-9a-fA-F]{2}|u[0-9a-fA-F]{4}|.)",l=function(t){return{token:"comment."+t+".doc.documentation.tag.storage.type",regex:"\\b(?:TODO|FIXME|XXX|HACK)\\b"}},c=function(t){return{token:"comment."+t+".doc.documentation.tag",regex:"\\B@(?:author|dev|notice|param|return|title)\\b"}},h=function(e,t){return(e!="start"||t.length)&&t.unshift("function_arguments",e),o=!1,"function_arguments"};this.$rules={start:[{token:"comment.block.doc.documentation",regex:"\\/\\*(?=\\*)",push:"doc_comment"},{token:"comment.line.triple-slash.double-slash.doc.documentation",regex:"\\/\\/\\/",push:"doc_line_comment"},{token:"comment.block",regex:"\\/\\*",push:"comment"},{token:"comment.line.double-slash",regex:"\\/\\/",push:"line_comment"},{token:"text",regex:"\\s+|^$"},{token:"string.quoted.single",regex:"'(?=.)",push:"qstring"},{token:"string.quoted.double",regex:'"(?=.)',push:"qqstring"},{token:"storage.type.reserved",regex:"u?fixed(?:8x[0-8]|16x(?:1[0-6]|[0-9])|24x(?:2[0-4]|1[0-9]|[0-9])|32x(?:3[0-2]|[1-2][0-9]|[0-9])|40x(?:40|[1-3][0-9]|[0-9])|48x(?:4[0-8]|[1-3][0-9]|[0-9])|56x(?:5[0-6]|[1-4][0-9]|[0-9])|64x(?:6[0-4]|[1-5][0-9]|[0-9])|72x(?:7[0-2]|[1-6][0-9]|[0-9])|(?:80|88|96|104|112|120|128|136|144|152|160|168|176|184|192|200|208|216|224|232|240|248|256)x(?:80|[1-7][0-9]|[0-9]))?",inheritingStateRuleId:"fixedNumberType"},{token:"keyword.control",regex:/\b_\b/},{token:["string.other.hex","string.other.hex","string.other.hex","string.other.hex","string.other.hex"],regex:/(\b)(hex)(['"])((?:[0-9a-fA-F]{2})*)(\3)/},{token:"constant.numeric.hex",regex:/0[xX][0-9a-fA-F]+\b/},{token:"constant.numeric",regex:/[+-]?\d+(?:(?:\.\d*)?(?:[eE][+-]?\d+)?)?\b/},{token:["keyword","text","keyword","text","constant.other"],regex:"(pragma)(\\s+)(solidity|experimental)(\\s+)([^;]+)"},{token:["keyword","text","identifier","text","keyword","text","identifier"],regex:"(using)(\\s+)("+a+")(\\s+)(for)(\\s+)("+a+"|\\*)"},{token:"support.function.deprecated",regex:/block\s*\.\s*blockhash|\.\s*callcode/},{token:"support.function",regex:/abi\s*\.\s*(?:encodeWithSignature|encodeWithSelector|encodePacked|encode)|\.\s*(?:delegatecall|transfer|call|send)/},{token:"support.variable",regex:/block\s*\.\s*(?:difficulty|timestamp|coinbase|gaslimit|number)|msg\s*\.\s*(?:sender|value|data)|tx\s*\.\s*(?:gasprice|origin)|\.\s*balance/},{token:"support.variable.deprecated",regex:/msg\s*\.\s*gas/},{token:["storage.type","text","entity.name.function","text","paren.lparen"],regex:"(function)(\\s+)("+a+")(\\s*)(\\()",next:h},{token:["storage.type","text","paren.lparen"],regex:"(function)(\\s*)(\\()",next:h},{token:["keyword","text","paren.lparen"],regex:"(returns)(\\s*)(\\()",next:h},{token:s,regex:a,inheritingStateRuleId:"keywordMapper"},{token:"keyword.operator",regex:/--|\*\*|\+\+|=>|<<|>>|<<=|>>=|&&|\|\||[!&|+\-*\/%~^<>=]=?/},{token:"punctuation.operator",regex:/[?:;]/},{token:"punctuation.operator",regex:/[.,]/,inheritingStateRuleId:"punctuation"},{token:"paren.lparen",regex:/[\[{]/},{token:"paren.lparen",regex:/[(]/,inheritingStateRuleId:"lparen"},{token:"paren.rparen",regex:/[\]}]/},{token:"paren.rparen",regex:/[)]/,inheritingStateRuleId:"rparen"}],comment:[l("block"),{token:"comment.block",regex:"\\*\\/",next:"pop"},{defaultToken:"comment.block",caseInsensitive:!0}],line_comment:[l("line"),{token:"comment.line.double-slash",regex:"$|^",next:"pop"},{defaultToken:"comment.line.double-slash",caseInsensitive:!0}],doc_comment:[l("block"),c("block"),{token:"comment.block.doc.documentation",regex:"\\*\\/",next:"pop"},{defaultToken:"comment.block.doc.documentation",caseInsensitive:!0}],doc_line_comment:[l("line"),c("line"),{token:"comment.line.triple-slash.double-slash.doc.documentation",regex:"$|^",next:"pop"},{defaultToken:"comment.line.triple-slash.double-slash.doc.documentation",caseInsensitive:!0}],qqstring:[{token:"constant.language.escape",regex:f},{token:"string.quoted.double",regex:"\\\\$",next:"qqstring"},{token:"string.quoted.double",regex:'"|$',next:"pop"},{defaultToken:"string.quoted.double"}],qstring:[{token:"constant.language.escape",regex:f},{token:"string.quoted.single",regex:"\\\\$",next:"qstring"},{token:"string.quoted.single",regex:"'|$",next:"pop"},{defaultToken:"string.quoted.single"}]};var p=i(this.$rules.start);p.forEach(function(e,t){if(e.inheritingStateRuleId){switch(e.inheritingStateRuleId){case"keywordMapper":e.token=u;break;case"punctuation":e.onMatch=function(n,r,i){return o=!1,e.token};break;case"lparen":e.next=h;break;case"rparen":e.next="pop";break;case"fixedNumberType":e.onMatch=function(n,r,i){return o=!0,e.token}}delete e.inheritingStateRuleId,delete this.$rules.start[t].inheritingStateRuleId,p[t]=e}},this),this.$rules.function_arguments=p,this.normalizeRules()};r.inherits(o,s),t.SolidityHighlightRules=o}),define("ace/mode/matching_brace_outdent",["require","exports","module","ace/range"],function(e,t,n){"use strict";var r=e("../range").Range,i=function(){};(function(){this.checkOutdent=function(e,t){return/^\s+$/.test(e)?/^\s*\}/.test(t):!1},this.autoOutdent=function(e,t){var n=e.getLine(t),i=n.match(/^(\s*\})/);if(!i)return 0;var s=i[1].length,o=e.findMatchingBracket({row:t,column:s});if(!o||o.row==t)return 0;var u=this.$getIndent(e.getLine(o.row));e.replace(new r(t,0,t,s-1),u)},this.$getIndent=function(e){return e.match(/^\s*/)[0]}}).call(i.prototype),t.MatchingBraceOutdent=i}),define("ace/mode/folding/cstyle",["require","exports","module","ace/lib/oop","ace/range","ace/mode/folding/fold_mode"],function(e,t,n){"use strict";var r=e("../../lib/oop"),i=e("../../range").Range,s=e("./fold_mode").FoldMode,o=t.FoldMode=function(e){e&&(this.foldingStartMarker=new RegExp(this.foldingStartMarker.source.replace(/\|[^|]*?$/,"|"+e.start)),this.foldingStopMarker=new RegExp(this.foldingStopMarker.source.replace(/\|[^|]*?$/,"|"+e.end)))};r.inherits(o,s),function(){this.foldingStartMarker=/(\{|\[)[^\}\]]*$|^\s*(\/\*)/,this.foldingStopMarker=/^[^\[\{]*(\}|\])|^[\s\*]*(\*\/)/,this.singleLineBlockCommentRe=/^\s*(\/\*).*\*\/\s*$/,this.tripleStarBlockCommentRe=/^\s*(\/\*\*\*).*\*\/\s*$/,this.startRegionRe=/^\s*(\/\*|\/\/)#?region\b/,this._getFoldWidgetBase=this.getFoldWidget,this.getFoldWidget=function(e,t,n){var r=e.getLine(n);if(this.singleLineBlockCommentRe.test(r)&&!this.startRegionRe.test(r)&&!this.tripleStarBlockCommentRe.test(r))return"";var i=this._getFoldWidgetBase(e,t,n);return!i&&this.startRegionRe.test(r)?"start":i},this.getFoldWidgetRange=function(e,t,n,r){var i=e.getLine(n);if(this.startRegionRe.test(i))return this.getCommentRegionBlock(e,i,n);var s=i.match(this.foldingStartMarker);if(s){var o=s.index;if(s[1])return this.openingBracketBlock(e,s[1],n,o);var u=e.getCommentFoldRange(n,o+s[0].length,1);return u&&!u.isMultiLine()&&(r?u=this.getSectionRange(e,n):t!="all"&&(u=null)),u}if(t==="markbegin")return;var s=i.match(this.foldingStopMarker);if(s){var o=s.index+s[0].length;return s[1]?this.closingBracketBlock(e,s[1],n,o):e.getCommentFoldRange(n,o,-1)}},this.getSectionRange=function(e,t){var n=e.getLine(t),r=n.search(/\S/),s=t,o=n.length;t+=1;var u=t,a=e.getLength();while(++tf)break;var l=this.getFoldWidgetRange(e,"all",t);if(l){if(l.start.row<=s)break;if(l.isMultiLine())t=l.end.row;else if(r==f)break}u=t}return new i(s,o,u,e.getLine(u).length)},this.getCommentRegionBlock=function(e,t,n){var r=t.search(/\s*$/),s=e.getLength(),o=n,u=/^\s*(?:\/\*|\/\/|--)#?(end)?region\b/,a=1;while(++no)return new i(o,r,l,t.length)}}.call(o.prototype)}),define("ace/mode/solidity",["require","exports","module","ace/lib/oop","ace/mode/text","ace/mode/solidity_highlight_rules","ace/mode/matching_brace_outdent","ace/range","ace/worker/worker_client","ace/mode/behaviour/cstyle","ace/mode/folding/cstyle"],function(e,t,n){"use strict";var r=e("../lib/oop"),i=e("./text").Mode,s=e("./solidity_highlight_rules").SolidityHighlightRules,o=e("./matching_brace_outdent").MatchingBraceOutdent,u=e("../range").Range,a=e("../worker/worker_client").WorkerClient,f=e("./behaviour/cstyle").CstyleBehaviour,l=e("./folding/cstyle").FoldMode,c=function(){this.HighlightRules=s,this.$outdent=new o,this.$behaviour=new f,this.foldingRules=new l};r.inherits(c,i),function(){this.lineCommentStart="//",this.blockComment={start:"/*",end:"*/"},this.getNextLineIndent=function(e,t,n){var r=this.$getIndent(t),i=this.getTokenizer().getLineTokens(t,e),s=i.tokens,o=i.state;if(s.length&&s[s.length-1].type=="comment")return r;if(e=="start"){var u=t.match(/^.*(?:\bcase\b.*\:|[\{\(\[])\s*$/);u&&(r+=n)}else if(e=="doc_comment"){if(o=="start")return"";var u=t.match(/^\s*(\/?)\*/);u&&(u[1]&&(r+=" "),r+="* ")}return r},this.checkOutdent=function(e,t,n){return this.$outdent.checkOutdent(t,n)},this.autoOutdent=function(e,t,n){this.$outdent.autoOutdent(t,n)},this.$id="ace/mode/solidity"}.call(c.prototype),t.Mode=c}) -------------------------------------------------------------------------------- /build/v1.2.5/src-min/mode-solidity.js: -------------------------------------------------------------------------------- 1 | define("ace/mode/solidity_highlight_rules",["require","exports","module","ace/lib/oop","ace/lib/lang","ace/mode/text_highlight_rules"],function(e,t,n){"use strict";var r=e("../lib/oop"),i=e("../lib/lang").deepCopy,s=e("./text_highlight_rules").TextHighlightRules,o=function(e){var t="byte|int|uint";for(var n=8;n<=256;n+=8)t+="|bytes"+n/8+"|uint"+n+"|int"+n;var r={"variable.language":"this|super",keyword:"as|emit|from|import|returns","keyword.control":"break|continue|do|else|for|if|return|while","keyword.control.deprecated":"throw","keyword.operator":"delete|new","keyword.other.reserved":"abstract|after|alias|apply|auto|case|catch|copyof|default|define|final|immutable|implements|in|inline|let|macro|match|mutable|null|of|override|partial|promise|reference|relocatable|sealed|sizeof|static|supports|switch|try|type|typedef|typeof|unchecked","storage.type":"contract|library|interface|function|constructor|event|modifier|struct|mapping|enum|var|bool|address|"+t,"storage.type.array.dynamic":"bytes|string","storage.modifier.inheritance":"is","storage.modifier.storagelocation":"storage|memory|calldata","storage.modifier.statemutability":"constant|payable|pure|view","storage.modifier.visibility":"private|public|external|internal","storage.modifier.event":"anonymous|indexed","support.function":"addmod|assert|blockhash|ecrecover|gasleft|keccak256|mulmod|require|revert|ripemd160|selfdestruct|sha256","support.function.deprecated":"sha3|suicide","support.variable":"now","constant.language.boolean":"true|false","constant.numeric.other.unit.currency":"wei|szabo|finney|ether","constant.numeric.other.unit.time":"seconds|minutes|hours|days|weeks","constant.numeric.other.unit.time.deprecated":"years"},s=this.createKeywordMapper(r,"identifier"),o=!1,u=function(t){var n=s(t);return o&&"identifier"==n&&(n="variable.parameter"),o=!0,n},a="[a-zA-Z_$][a-zA-Z_$0-9]*\\b|\\$",f="\\\\(?:x[0-9a-fA-F]{2}|u[0-9a-fA-F]{4}|.)",l=function(t){return{token:"comment."+t+".doc.documentation.tag.storage.type",regex:"\\b(?:TODO|FIXME|XXX|HACK)\\b"}},c=function(t){return{token:"comment."+t+".doc.documentation.tag",regex:"\\B@(?:author|dev|notice|param|return|title)\\b"}},h=function(e,t){return(e!="start"||t.length)&&t.unshift("function_arguments",e),o=!1,"function_arguments"};this.$rules={start:[{token:"comment.block.doc.documentation",regex:"\\/\\*(?=\\*)",push:"doc_comment"},{token:"comment.line.triple-slash.double-slash.doc.documentation",regex:"\\/\\/\\/",push:"doc_line_comment"},{token:"comment.block",regex:"\\/\\*",push:"comment"},{token:"comment.line.double-slash",regex:"\\/\\/",push:"line_comment"},{token:"text",regex:"\\s+|^$"},{token:"string.quoted.single",regex:"'(?=.)",push:"qstring"},{token:"string.quoted.double",regex:'"(?=.)',push:"qqstring"},{token:"storage.type.reserved",regex:"u?fixed(?:8x[0-8]|16x(?:1[0-6]|[0-9])|24x(?:2[0-4]|1[0-9]|[0-9])|32x(?:3[0-2]|[1-2][0-9]|[0-9])|40x(?:40|[1-3][0-9]|[0-9])|48x(?:4[0-8]|[1-3][0-9]|[0-9])|56x(?:5[0-6]|[1-4][0-9]|[0-9])|64x(?:6[0-4]|[1-5][0-9]|[0-9])|72x(?:7[0-2]|[1-6][0-9]|[0-9])|(?:80|88|96|104|112|120|128|136|144|152|160|168|176|184|192|200|208|216|224|232|240|248|256)x(?:80|[1-7][0-9]|[0-9]))?",inheritingStateRuleId:"fixedNumberType"},{token:"keyword.control",regex:/\b_\b/},{token:["string.other.hex","string.other.hex","string.other.hex","string.other.hex","string.other.hex"],regex:/(\b)(hex)(['"])((?:[0-9a-fA-F]{2})*)(\3)/},{token:"constant.numeric.hex",regex:/0[xX][0-9a-fA-F]+\b/},{token:"constant.numeric",regex:/[+-]?\d+(?:(?:\.\d*)?(?:[eE][+-]?\d+)?)?\b/},{token:["keyword","text","keyword","text","constant.other"],regex:"(pragma)(\\s+)(solidity|experimental)(\\s+)([^;]+)"},{token:["keyword","text","identifier","text","keyword","text","identifier"],regex:"(using)(\\s+)("+a+")(\\s+)(for)(\\s+)("+a+"|\\*)"},{token:"support.function.deprecated",regex:/block\s*\.\s*blockhash|\.\s*callcode/},{token:"support.function",regex:/abi\s*\.\s*(?:encodeWithSignature|encodeWithSelector|encodePacked|encode)|\.\s*(?:delegatecall|transfer|call|send)/},{token:"support.variable",regex:/block\s*\.\s*(?:difficulty|timestamp|coinbase|gaslimit|number)|msg\s*\.\s*(?:sender|value|data)|tx\s*\.\s*(?:gasprice|origin)|\.\s*balance/},{token:"support.variable.deprecated",regex:/msg\s*\.\s*gas/},{token:["storage.type","text","entity.name.function","text","paren.lparen"],regex:"(function)(\\s+)("+a+")(\\s*)(\\()",next:h},{token:["storage.type","text","paren.lparen"],regex:"(function)(\\s*)(\\()",next:h},{token:["keyword","text","paren.lparen"],regex:"(returns)(\\s*)(\\()",next:h},{token:s,regex:a,inheritingStateRuleId:"keywordMapper"},{token:"keyword.operator",regex:/--|\*\*|\+\+|=>|<<|>>|<<=|>>=|&&|\|\||[!&|+\-*\/%~^<>=]=?/},{token:"punctuation.operator",regex:/[?:;]/},{token:"punctuation.operator",regex:/[.,]/,inheritingStateRuleId:"punctuation"},{token:"paren.lparen",regex:/[\[{]/},{token:"paren.lparen",regex:/[(]/,inheritingStateRuleId:"lparen"},{token:"paren.rparen",regex:/[\]}]/},{token:"paren.rparen",regex:/[)]/,inheritingStateRuleId:"rparen"}],comment:[l("block"),{token:"comment.block",regex:"\\*\\/",next:"pop"},{defaultToken:"comment.block",caseInsensitive:!0}],line_comment:[l("line"),{token:"comment.line.double-slash",regex:"$|^",next:"pop"},{defaultToken:"comment.line.double-slash",caseInsensitive:!0}],doc_comment:[l("block"),c("block"),{token:"comment.block.doc.documentation",regex:"\\*\\/",next:"pop"},{defaultToken:"comment.block.doc.documentation",caseInsensitive:!0}],doc_line_comment:[l("line"),c("line"),{token:"comment.line.triple-slash.double-slash.doc.documentation",regex:"$|^",next:"pop"},{defaultToken:"comment.line.triple-slash.double-slash.doc.documentation",caseInsensitive:!0}],qqstring:[{token:"constant.language.escape",regex:f},{token:"string.quoted.double",regex:"\\\\$",next:"qqstring"},{token:"string.quoted.double",regex:'"|$',next:"pop"},{defaultToken:"string.quoted.double"}],qstring:[{token:"constant.language.escape",regex:f},{token:"string.quoted.single",regex:"\\\\$",next:"qstring"},{token:"string.quoted.single",regex:"'|$",next:"pop"},{defaultToken:"string.quoted.single"}]};var p=i(this.$rules.start);p.forEach(function(e,t){if(e.inheritingStateRuleId){switch(e.inheritingStateRuleId){case"keywordMapper":e.token=u;break;case"punctuation":e.onMatch=function(n,r,i){return o=!1,e.token};break;case"lparen":e.next=h;break;case"rparen":e.next="pop";break;case"fixedNumberType":e.onMatch=function(n,r,i){return o=!0,e.token}}delete e.inheritingStateRuleId,delete this.$rules.start[t].inheritingStateRuleId,p[t]=e}},this),this.$rules.function_arguments=p,this.normalizeRules()};r.inherits(o,s),t.SolidityHighlightRules=o}),define("ace/mode/matching_brace_outdent",["require","exports","module","ace/range"],function(e,t,n){"use strict";var r=e("../range").Range,i=function(){};(function(){this.checkOutdent=function(e,t){return/^\s+$/.test(e)?/^\s*\}/.test(t):!1},this.autoOutdent=function(e,t){var n=e.getLine(t),i=n.match(/^(\s*\})/);if(!i)return 0;var s=i[1].length,o=e.findMatchingBracket({row:t,column:s});if(!o||o.row==t)return 0;var u=this.$getIndent(e.getLine(o.row));e.replace(new r(t,0,t,s-1),u)},this.$getIndent=function(e){return e.match(/^\s*/)[0]}}).call(i.prototype),t.MatchingBraceOutdent=i}),define("ace/mode/folding/cstyle",["require","exports","module","ace/lib/oop","ace/range","ace/mode/folding/fold_mode"],function(e,t,n){"use strict";var r=e("../../lib/oop"),i=e("../../range").Range,s=e("./fold_mode").FoldMode,o=t.FoldMode=function(e){e&&(this.foldingStartMarker=new RegExp(this.foldingStartMarker.source.replace(/\|[^|]*?$/,"|"+e.start)),this.foldingStopMarker=new RegExp(this.foldingStopMarker.source.replace(/\|[^|]*?$/,"|"+e.end)))};r.inherits(o,s),function(){this.foldingStartMarker=/(\{|\[)[^\}\]]*$|^\s*(\/\*)/,this.foldingStopMarker=/^[^\[\{]*(\}|\])|^[\s\*]*(\*\/)/,this.singleLineBlockCommentRe=/^\s*(\/\*).*\*\/\s*$/,this.tripleStarBlockCommentRe=/^\s*(\/\*\*\*).*\*\/\s*$/,this.startRegionRe=/^\s*(\/\*|\/\/)#?region\b/,this._getFoldWidgetBase=this.getFoldWidget,this.getFoldWidget=function(e,t,n){var r=e.getLine(n);if(this.singleLineBlockCommentRe.test(r)&&!this.startRegionRe.test(r)&&!this.tripleStarBlockCommentRe.test(r))return"";var i=this._getFoldWidgetBase(e,t,n);return!i&&this.startRegionRe.test(r)?"start":i},this.getFoldWidgetRange=function(e,t,n,r){var i=e.getLine(n);if(this.startRegionRe.test(i))return this.getCommentRegionBlock(e,i,n);var s=i.match(this.foldingStartMarker);if(s){var o=s.index;if(s[1])return this.openingBracketBlock(e,s[1],n,o);var u=e.getCommentFoldRange(n,o+s[0].length,1);return u&&!u.isMultiLine()&&(r?u=this.getSectionRange(e,n):t!="all"&&(u=null)),u}if(t==="markbegin")return;var s=i.match(this.foldingStopMarker);if(s){var o=s.index+s[0].length;return s[1]?this.closingBracketBlock(e,s[1],n,o):e.getCommentFoldRange(n,o,-1)}},this.getSectionRange=function(e,t){var n=e.getLine(t),r=n.search(/\S/),s=t,o=n.length;t+=1;var u=t,a=e.getLength();while(++tf)break;var l=this.getFoldWidgetRange(e,"all",t);if(l){if(l.start.row<=s)break;if(l.isMultiLine())t=l.end.row;else if(r==f)break}u=t}return new i(s,o,u,e.getLine(u).length)},this.getCommentRegionBlock=function(e,t,n){var r=t.search(/\s*$/),s=e.getLength(),o=n,u=/^\s*(?:\/\*|\/\/|--)#?(end)?region\b/,a=1;while(++no)return new i(o,r,l,t.length)}}.call(o.prototype)}),define("ace/mode/solidity",["require","exports","module","ace/lib/oop","ace/mode/text","ace/mode/solidity_highlight_rules","ace/mode/matching_brace_outdent","ace/range","ace/worker/worker_client","ace/mode/behaviour/cstyle","ace/mode/folding/cstyle"],function(e,t,n){"use strict";var r=e("../lib/oop"),i=e("./text").Mode,s=e("./solidity_highlight_rules").SolidityHighlightRules,o=e("./matching_brace_outdent").MatchingBraceOutdent,u=e("../range").Range,a=e("../worker/worker_client").WorkerClient,f=e("./behaviour/cstyle").CstyleBehaviour,l=e("./folding/cstyle").FoldMode,c=function(){this.HighlightRules=s,this.$outdent=new o,this.$behaviour=new f,this.foldingRules=new l};r.inherits(c,i),function(){this.lineCommentStart="//",this.blockComment={start:"/*",end:"*/"},this.getNextLineIndent=function(e,t,n){var r=this.$getIndent(t),i=this.getTokenizer().getLineTokens(t,e),s=i.tokens,o=i.state;if(s.length&&s[s.length-1].type=="comment")return r;if(e=="start"){var u=t.match(/^.*(?:\bcase\b.*\:|[\{\(\[])\s*$/);u&&(r+=n)}else if(e=="doc_comment"){if(o=="start")return"";var u=t.match(/^\s*(\/?)\*/);u&&(u[1]&&(r+=" "),r+="* ")}return r},this.checkOutdent=function(e,t,n){return this.$outdent.checkOutdent(t,n)},this.autoOutdent=function(e,t,n){this.$outdent.autoOutdent(t,n)},this.$id="ace/mode/solidity"}.call(c.prototype),t.Mode=c}) -------------------------------------------------------------------------------- /build/v1.2.6/src-min/mode-solidity.js: -------------------------------------------------------------------------------- 1 | define("ace/mode/solidity_highlight_rules",["require","exports","module","ace/lib/oop","ace/lib/lang","ace/mode/text_highlight_rules"],function(e,t,n){"use strict";var r=e("../lib/oop"),i=e("../lib/lang").deepCopy,s=e("./text_highlight_rules").TextHighlightRules,o=function(e){var t="byte|int|uint";for(var n=8;n<=256;n+=8)t+="|bytes"+n/8+"|uint"+n+"|int"+n;var r={"variable.language":"this|super",keyword:"as|emit|from|import|returns","keyword.control":"break|continue|do|else|for|if|return|while","keyword.control.deprecated":"throw","keyword.operator":"delete|new","keyword.other.reserved":"abstract|after|alias|apply|auto|case|catch|copyof|default|define|final|immutable|implements|in|inline|let|macro|match|mutable|null|of|override|partial|promise|reference|relocatable|sealed|sizeof|static|supports|switch|try|type|typedef|typeof|unchecked","storage.type":"contract|library|interface|function|constructor|event|modifier|struct|mapping|enum|var|bool|address|"+t,"storage.type.array.dynamic":"bytes|string","storage.modifier.inheritance":"is","storage.modifier.storagelocation":"storage|memory|calldata","storage.modifier.statemutability":"constant|payable|pure|view","storage.modifier.visibility":"private|public|external|internal","storage.modifier.event":"anonymous|indexed","support.function":"addmod|assert|blockhash|ecrecover|gasleft|keccak256|mulmod|require|revert|ripemd160|selfdestruct|sha256","support.function.deprecated":"sha3|suicide","support.variable":"now","constant.language.boolean":"true|false","constant.numeric.other.unit.currency":"wei|szabo|finney|ether","constant.numeric.other.unit.time":"seconds|minutes|hours|days|weeks","constant.numeric.other.unit.time.deprecated":"years"},s=this.createKeywordMapper(r,"identifier"),o=!1,u=function(t){var n=s(t);return o&&"identifier"==n&&(n="variable.parameter"),o=!0,n},a="[a-zA-Z_$][a-zA-Z_$0-9]*\\b|\\$",f="\\\\(?:x[0-9a-fA-F]{2}|u[0-9a-fA-F]{4}|.)",l=function(t){return{token:"comment."+t+".doc.documentation.tag.storage.type",regex:"\\b(?:TODO|FIXME|XXX|HACK)\\b"}},c=function(t){return{token:"comment."+t+".doc.documentation.tag",regex:"\\B@(?:author|dev|notice|param|return|title)\\b"}},h=function(e,t){return(e!="start"||t.length)&&t.unshift("function_arguments",e),o=!1,"function_arguments"};this.$rules={start:[{token:"comment.block.doc.documentation",regex:"\\/\\*(?=\\*)",push:"doc_comment"},{token:"comment.line.triple-slash.double-slash.doc.documentation",regex:"\\/\\/\\/",push:"doc_line_comment"},{token:"comment.block",regex:"\\/\\*",push:"comment"},{token:"comment.line.double-slash",regex:"\\/\\/",push:"line_comment"},{token:"text",regex:"\\s+|^$"},{token:"string.quoted.single",regex:"'(?=.)",push:"qstring"},{token:"string.quoted.double",regex:'"(?=.)',push:"qqstring"},{token:"storage.type.reserved",regex:"u?fixed(?:8x[0-8]|16x(?:1[0-6]|[0-9])|24x(?:2[0-4]|1[0-9]|[0-9])|32x(?:3[0-2]|[1-2][0-9]|[0-9])|40x(?:40|[1-3][0-9]|[0-9])|48x(?:4[0-8]|[1-3][0-9]|[0-9])|56x(?:5[0-6]|[1-4][0-9]|[0-9])|64x(?:6[0-4]|[1-5][0-9]|[0-9])|72x(?:7[0-2]|[1-6][0-9]|[0-9])|(?:80|88|96|104|112|120|128|136|144|152|160|168|176|184|192|200|208|216|224|232|240|248|256)x(?:80|[1-7][0-9]|[0-9]))?",inheritingStateRuleId:"fixedNumberType"},{token:"keyword.control",regex:/\b_\b/},{token:["string.other.hex","string.other.hex","string.other.hex","string.other.hex","string.other.hex"],regex:/(\b)(hex)(['"])((?:[0-9a-fA-F]{2})*)(\3)/},{token:"constant.numeric.hex",regex:/0[xX][0-9a-fA-F]+\b/},{token:"constant.numeric",regex:/[+-]?\d+(?:(?:\.\d*)?(?:[eE][+-]?\d+)?)?\b/},{token:["keyword","text","keyword","text","constant.other"],regex:"(pragma)(\\s+)(solidity|experimental)(\\s+)([^;]+)"},{token:["keyword","text","identifier","text","keyword","text","identifier"],regex:"(using)(\\s+)("+a+")(\\s+)(for)(\\s+)("+a+"|\\*)"},{token:"support.function.deprecated",regex:/block\s*\.\s*blockhash|\.\s*callcode/},{token:"support.function",regex:/abi\s*\.\s*(?:encodeWithSignature|encodeWithSelector|encodePacked|encode)|\.\s*(?:delegatecall|transfer|call|send)/},{token:"support.variable",regex:/block\s*\.\s*(?:difficulty|timestamp|coinbase|gaslimit|number)|msg\s*\.\s*(?:sender|value|data)|tx\s*\.\s*(?:gasprice|origin)|\.\s*balance/},{token:"support.variable.deprecated",regex:/msg\s*\.\s*gas/},{token:["storage.type","text","entity.name.function","text","paren.lparen"],regex:"(function)(\\s+)("+a+")(\\s*)(\\()",next:h},{token:["storage.type","text","paren.lparen"],regex:"(function)(\\s*)(\\()",next:h},{token:["keyword","text","paren.lparen"],regex:"(returns)(\\s*)(\\()",next:h},{token:s,regex:a,inheritingStateRuleId:"keywordMapper"},{token:"keyword.operator",regex:/--|\*\*|\+\+|=>|<<|>>|<<=|>>=|&&|\|\||[!&|+\-*\/%~^<>=]=?/},{token:"punctuation.operator",regex:/[?:;]/},{token:"punctuation.operator",regex:/[.,]/,inheritingStateRuleId:"punctuation"},{token:"paren.lparen",regex:/[\[{]/},{token:"paren.lparen",regex:/[(]/,inheritingStateRuleId:"lparen"},{token:"paren.rparen",regex:/[\]}]/},{token:"paren.rparen",regex:/[)]/,inheritingStateRuleId:"rparen"}],comment:[l("block"),{token:"comment.block",regex:"\\*\\/",next:"pop"},{defaultToken:"comment.block",caseInsensitive:!0}],line_comment:[l("line"),{token:"comment.line.double-slash",regex:"$|^",next:"pop"},{defaultToken:"comment.line.double-slash",caseInsensitive:!0}],doc_comment:[l("block"),c("block"),{token:"comment.block.doc.documentation",regex:"\\*\\/",next:"pop"},{defaultToken:"comment.block.doc.documentation",caseInsensitive:!0}],doc_line_comment:[l("line"),c("line"),{token:"comment.line.triple-slash.double-slash.doc.documentation",regex:"$|^",next:"pop"},{defaultToken:"comment.line.triple-slash.double-slash.doc.documentation",caseInsensitive:!0}],qqstring:[{token:"constant.language.escape",regex:f},{token:"string.quoted.double",regex:"\\\\$",next:"qqstring"},{token:"string.quoted.double",regex:'"|$',next:"pop"},{defaultToken:"string.quoted.double"}],qstring:[{token:"constant.language.escape",regex:f},{token:"string.quoted.single",regex:"\\\\$",next:"qstring"},{token:"string.quoted.single",regex:"'|$",next:"pop"},{defaultToken:"string.quoted.single"}]};var p=i(this.$rules.start);p.forEach(function(e,t){if(e.inheritingStateRuleId){switch(e.inheritingStateRuleId){case"keywordMapper":e.token=u;break;case"punctuation":e.onMatch=function(n,r,i){return o=!1,e.token};break;case"lparen":e.next=h;break;case"rparen":e.next="pop";break;case"fixedNumberType":e.onMatch=function(n,r,i){return o=!0,e.token}}delete e.inheritingStateRuleId,delete this.$rules.start[t].inheritingStateRuleId,p[t]=e}},this),this.$rules.function_arguments=p,this.normalizeRules()};r.inherits(o,s),t.SolidityHighlightRules=o}),define("ace/mode/matching_brace_outdent",["require","exports","module","ace/range"],function(e,t,n){"use strict";var r=e("../range").Range,i=function(){};(function(){this.checkOutdent=function(e,t){return/^\s+$/.test(e)?/^\s*\}/.test(t):!1},this.autoOutdent=function(e,t){var n=e.getLine(t),i=n.match(/^(\s*\})/);if(!i)return 0;var s=i[1].length,o=e.findMatchingBracket({row:t,column:s});if(!o||o.row==t)return 0;var u=this.$getIndent(e.getLine(o.row));e.replace(new r(t,0,t,s-1),u)},this.$getIndent=function(e){return e.match(/^\s*/)[0]}}).call(i.prototype),t.MatchingBraceOutdent=i}),define("ace/mode/folding/cstyle",["require","exports","module","ace/lib/oop","ace/range","ace/mode/folding/fold_mode"],function(e,t,n){"use strict";var r=e("../../lib/oop"),i=e("../../range").Range,s=e("./fold_mode").FoldMode,o=t.FoldMode=function(e){e&&(this.foldingStartMarker=new RegExp(this.foldingStartMarker.source.replace(/\|[^|]*?$/,"|"+e.start)),this.foldingStopMarker=new RegExp(this.foldingStopMarker.source.replace(/\|[^|]*?$/,"|"+e.end)))};r.inherits(o,s),function(){this.foldingStartMarker=/(\{|\[)[^\}\]]*$|^\s*(\/\*)/,this.foldingStopMarker=/^[^\[\{]*(\}|\])|^[\s\*]*(\*\/)/,this.singleLineBlockCommentRe=/^\s*(\/\*).*\*\/\s*$/,this.tripleStarBlockCommentRe=/^\s*(\/\*\*\*).*\*\/\s*$/,this.startRegionRe=/^\s*(\/\*|\/\/)#?region\b/,this._getFoldWidgetBase=this.getFoldWidget,this.getFoldWidget=function(e,t,n){var r=e.getLine(n);if(this.singleLineBlockCommentRe.test(r)&&!this.startRegionRe.test(r)&&!this.tripleStarBlockCommentRe.test(r))return"";var i=this._getFoldWidgetBase(e,t,n);return!i&&this.startRegionRe.test(r)?"start":i},this.getFoldWidgetRange=function(e,t,n,r){var i=e.getLine(n);if(this.startRegionRe.test(i))return this.getCommentRegionBlock(e,i,n);var s=i.match(this.foldingStartMarker);if(s){var o=s.index;if(s[1])return this.openingBracketBlock(e,s[1],n,o);var u=e.getCommentFoldRange(n,o+s[0].length,1);return u&&!u.isMultiLine()&&(r?u=this.getSectionRange(e,n):t!="all"&&(u=null)),u}if(t==="markbegin")return;var s=i.match(this.foldingStopMarker);if(s){var o=s.index+s[0].length;return s[1]?this.closingBracketBlock(e,s[1],n,o):e.getCommentFoldRange(n,o,-1)}},this.getSectionRange=function(e,t){var n=e.getLine(t),r=n.search(/\S/),s=t,o=n.length;t+=1;var u=t,a=e.getLength();while(++tf)break;var l=this.getFoldWidgetRange(e,"all",t);if(l){if(l.start.row<=s)break;if(l.isMultiLine())t=l.end.row;else if(r==f)break}u=t}return new i(s,o,u,e.getLine(u).length)},this.getCommentRegionBlock=function(e,t,n){var r=t.search(/\s*$/),s=e.getLength(),o=n,u=/^\s*(?:\/\*|\/\/|--)#?(end)?region\b/,a=1;while(++no)return new i(o,r,l,t.length)}}.call(o.prototype)}),define("ace/mode/solidity",["require","exports","module","ace/lib/oop","ace/mode/text","ace/mode/solidity_highlight_rules","ace/mode/matching_brace_outdent","ace/range","ace/worker/worker_client","ace/mode/behaviour/cstyle","ace/mode/folding/cstyle"],function(e,t,n){"use strict";var r=e("../lib/oop"),i=e("./text").Mode,s=e("./solidity_highlight_rules").SolidityHighlightRules,o=e("./matching_brace_outdent").MatchingBraceOutdent,u=e("../range").Range,a=e("../worker/worker_client").WorkerClient,f=e("./behaviour/cstyle").CstyleBehaviour,l=e("./folding/cstyle").FoldMode,c=function(){this.HighlightRules=s,this.$outdent=new o,this.$behaviour=new f,this.foldingRules=new l};r.inherits(c,i),function(){this.lineCommentStart="//",this.blockComment={start:"/*",end:"*/"},this.getNextLineIndent=function(e,t,n){var r=this.$getIndent(t),i=this.getTokenizer().getLineTokens(t,e),s=i.tokens,o=i.state;if(s.length&&s[s.length-1].type=="comment")return r;if(e=="start"){var u=t.match(/^.*(?:\bcase\b.*\:|[\{\(\[])\s*$/);u&&(r+=n)}else if(e=="doc_comment"){if(o=="start")return"";var u=t.match(/^\s*(\/?)\*/);u&&(u[1]&&(r+=" "),r+="* ")}return r},this.checkOutdent=function(e,t,n){return this.$outdent.checkOutdent(t,n)},this.autoOutdent=function(e,t,n){this.$outdent.autoOutdent(t,n)},this.$id="ace/mode/solidity"}.call(c.prototype),t.Mode=c}) -------------------------------------------------------------------------------- /build/v1.2.7/src-min/mode-solidity.js: -------------------------------------------------------------------------------- 1 | define("ace/mode/solidity_highlight_rules",["require","exports","module","ace/lib/oop","ace/lib/lang","ace/mode/text_highlight_rules"],function(e,t,n){"use strict";var r=e("../lib/oop"),i=e("../lib/lang").deepCopy,s=e("./text_highlight_rules").TextHighlightRules,o=function(e){var t="byte|int|uint";for(var n=8;n<=256;n+=8)t+="|bytes"+n/8+"|uint"+n+"|int"+n;var r={"variable.language":"this|super",keyword:"as|emit|from|import|returns","keyword.control":"break|continue|do|else|for|if|return|while","keyword.control.deprecated":"throw","keyword.operator":"delete|new","keyword.other.reserved":"abstract|after|alias|apply|auto|case|catch|copyof|default|define|final|immutable|implements|in|inline|let|macro|match|mutable|null|of|override|partial|promise|reference|relocatable|sealed|sizeof|static|supports|switch|try|type|typedef|typeof|unchecked","storage.type":"contract|library|interface|function|constructor|event|modifier|struct|mapping|enum|var|bool|address|"+t,"storage.type.array.dynamic":"bytes|string","storage.modifier.inheritance":"is","storage.modifier.storagelocation":"storage|memory|calldata","storage.modifier.statemutability":"constant|payable|pure|view","storage.modifier.visibility":"private|public|external|internal","storage.modifier.event":"anonymous|indexed","support.function":"addmod|assert|blockhash|ecrecover|gasleft|keccak256|mulmod|require|revert|ripemd160|selfdestruct|sha256","support.function.deprecated":"sha3|suicide","support.variable":"now","constant.language.boolean":"true|false","constant.numeric.other.unit.currency":"wei|szabo|finney|ether","constant.numeric.other.unit.time":"seconds|minutes|hours|days|weeks","constant.numeric.other.unit.time.deprecated":"years"},s=this.createKeywordMapper(r,"identifier"),o=!1,u=function(t){var n=s(t);return o&&"identifier"==n&&(n="variable.parameter"),o=!0,n},a="[a-zA-Z_$][a-zA-Z_$0-9]*\\b|\\$",f="\\\\(?:x[0-9a-fA-F]{2}|u[0-9a-fA-F]{4}|.)",l=function(t){return{token:"comment."+t+".doc.documentation.tag.storage.type",regex:"\\b(?:TODO|FIXME|XXX|HACK)\\b"}},c=function(t){return{token:"comment."+t+".doc.documentation.tag",regex:"\\B@(?:author|dev|notice|param|return|title)\\b"}},h=function(e,t){return(e!="start"||t.length)&&t.unshift("function_arguments",e),o=!1,"function_arguments"};this.$rules={start:[{token:"comment.block.doc.documentation",regex:"\\/\\*(?=\\*)",push:"doc_comment"},{token:"comment.line.triple-slash.double-slash.doc.documentation",regex:"\\/\\/\\/",push:"doc_line_comment"},{token:"comment.block",regex:"\\/\\*",push:"comment"},{token:"comment.line.double-slash",regex:"\\/\\/",push:"line_comment"},{token:"text",regex:"\\s+|^$"},{token:"string.quoted.single",regex:"'(?=.)",push:"qstring"},{token:"string.quoted.double",regex:'"(?=.)',push:"qqstring"},{token:"storage.type.reserved",regex:"u?fixed(?:8x[0-8]|16x(?:1[0-6]|[0-9])|24x(?:2[0-4]|1[0-9]|[0-9])|32x(?:3[0-2]|[1-2][0-9]|[0-9])|40x(?:40|[1-3][0-9]|[0-9])|48x(?:4[0-8]|[1-3][0-9]|[0-9])|56x(?:5[0-6]|[1-4][0-9]|[0-9])|64x(?:6[0-4]|[1-5][0-9]|[0-9])|72x(?:7[0-2]|[1-6][0-9]|[0-9])|(?:80|88|96|104|112|120|128|136|144|152|160|168|176|184|192|200|208|216|224|232|240|248|256)x(?:80|[1-7][0-9]|[0-9]))?",inheritingStateRuleId:"fixedNumberType"},{token:"keyword.control",regex:/\b_\b/},{token:["string.other.hex","string.other.hex","string.other.hex","string.other.hex","string.other.hex"],regex:/(\b)(hex)(['"])((?:[0-9a-fA-F]{2})*)(\3)/},{token:"constant.numeric.hex",regex:/0[xX][0-9a-fA-F]+\b/},{token:"constant.numeric",regex:/[+-]?\d+(?:(?:\.\d*)?(?:[eE][+-]?\d+)?)?\b/},{token:["keyword","text","keyword","text","constant.other"],regex:"(pragma)(\\s+)(solidity|experimental)(\\s+)([^;]+)"},{token:["keyword","text","identifier","text","keyword","text","identifier"],regex:"(using)(\\s+)("+a+")(\\s+)(for)(\\s+)("+a+"|\\*)"},{token:"support.function.deprecated",regex:/block\s*\.\s*blockhash|\.\s*callcode/},{token:"support.function",regex:/abi\s*\.\s*(?:encodeWithSignature|encodeWithSelector|encodePacked|encode)|\.\s*(?:delegatecall|transfer|call|send)/},{token:"support.variable",regex:/block\s*\.\s*(?:difficulty|timestamp|coinbase|gaslimit|number)|msg\s*\.\s*(?:sender|value|data)|tx\s*\.\s*(?:gasprice|origin)|\.\s*balance/},{token:"support.variable.deprecated",regex:/msg\s*\.\s*gas/},{token:["storage.type","text","entity.name.function","text","paren.lparen"],regex:"(function)(\\s+)("+a+")(\\s*)(\\()",next:h},{token:["storage.type","text","paren.lparen"],regex:"(function)(\\s*)(\\()",next:h},{token:["keyword","text","paren.lparen"],regex:"(returns)(\\s*)(\\()",next:h},{token:s,regex:a,inheritingStateRuleId:"keywordMapper"},{token:"keyword.operator",regex:/--|\*\*|\+\+|=>|<<|>>|<<=|>>=|&&|\|\||[!&|+\-*\/%~^<>=]=?/},{token:"punctuation.operator",regex:/[?:;]/},{token:"punctuation.operator",regex:/[.,]/,inheritingStateRuleId:"punctuation"},{token:"paren.lparen",regex:/[\[{]/},{token:"paren.lparen",regex:/[(]/,inheritingStateRuleId:"lparen"},{token:"paren.rparen",regex:/[\]}]/},{token:"paren.rparen",regex:/[)]/,inheritingStateRuleId:"rparen"}],comment:[l("block"),{token:"comment.block",regex:"\\*\\/",next:"pop"},{defaultToken:"comment.block",caseInsensitive:!0}],line_comment:[l("line"),{token:"comment.line.double-slash",regex:"$|^",next:"pop"},{defaultToken:"comment.line.double-slash",caseInsensitive:!0}],doc_comment:[l("block"),c("block"),{token:"comment.block.doc.documentation",regex:"\\*\\/",next:"pop"},{defaultToken:"comment.block.doc.documentation",caseInsensitive:!0}],doc_line_comment:[l("line"),c("line"),{token:"comment.line.triple-slash.double-slash.doc.documentation",regex:"$|^",next:"pop"},{defaultToken:"comment.line.triple-slash.double-slash.doc.documentation",caseInsensitive:!0}],qqstring:[{token:"constant.language.escape",regex:f},{token:"string.quoted.double",regex:"\\\\$",next:"qqstring"},{token:"string.quoted.double",regex:'"|$',next:"pop"},{defaultToken:"string.quoted.double"}],qstring:[{token:"constant.language.escape",regex:f},{token:"string.quoted.single",regex:"\\\\$",next:"qstring"},{token:"string.quoted.single",regex:"'|$",next:"pop"},{defaultToken:"string.quoted.single"}]};var p=i(this.$rules.start);p.forEach(function(e,t){if(e.inheritingStateRuleId){switch(e.inheritingStateRuleId){case"keywordMapper":e.token=u;break;case"punctuation":e.onMatch=function(n,r,i){return o=!1,e.token};break;case"lparen":e.next=h;break;case"rparen":e.next="pop";break;case"fixedNumberType":e.onMatch=function(n,r,i){return o=!0,e.token}}delete e.inheritingStateRuleId,delete this.$rules.start[t].inheritingStateRuleId,p[t]=e}},this),this.$rules.function_arguments=p,this.normalizeRules()};r.inherits(o,s),t.SolidityHighlightRules=o}),define("ace/mode/matching_brace_outdent",["require","exports","module","ace/range"],function(e,t,n){"use strict";var r=e("../range").Range,i=function(){};(function(){this.checkOutdent=function(e,t){return/^\s+$/.test(e)?/^\s*\}/.test(t):!1},this.autoOutdent=function(e,t){var n=e.getLine(t),i=n.match(/^(\s*\})/);if(!i)return 0;var s=i[1].length,o=e.findMatchingBracket({row:t,column:s});if(!o||o.row==t)return 0;var u=this.$getIndent(e.getLine(o.row));e.replace(new r(t,0,t,s-1),u)},this.$getIndent=function(e){return e.match(/^\s*/)[0]}}).call(i.prototype),t.MatchingBraceOutdent=i}),define("ace/mode/folding/cstyle",["require","exports","module","ace/lib/oop","ace/range","ace/mode/folding/fold_mode"],function(e,t,n){"use strict";var r=e("../../lib/oop"),i=e("../../range").Range,s=e("./fold_mode").FoldMode,o=t.FoldMode=function(e){e&&(this.foldingStartMarker=new RegExp(this.foldingStartMarker.source.replace(/\|[^|]*?$/,"|"+e.start)),this.foldingStopMarker=new RegExp(this.foldingStopMarker.source.replace(/\|[^|]*?$/,"|"+e.end)))};r.inherits(o,s),function(){this.foldingStartMarker=/(\{|\[)[^\}\]]*$|^\s*(\/\*)/,this.foldingStopMarker=/^[^\[\{]*(\}|\])|^[\s\*]*(\*\/)/,this.singleLineBlockCommentRe=/^\s*(\/\*).*\*\/\s*$/,this.tripleStarBlockCommentRe=/^\s*(\/\*\*\*).*\*\/\s*$/,this.startRegionRe=/^\s*(\/\*|\/\/)#?region\b/,this._getFoldWidgetBase=this.getFoldWidget,this.getFoldWidget=function(e,t,n){var r=e.getLine(n);if(this.singleLineBlockCommentRe.test(r)&&!this.startRegionRe.test(r)&&!this.tripleStarBlockCommentRe.test(r))return"";var i=this._getFoldWidgetBase(e,t,n);return!i&&this.startRegionRe.test(r)?"start":i},this.getFoldWidgetRange=function(e,t,n,r){var i=e.getLine(n);if(this.startRegionRe.test(i))return this.getCommentRegionBlock(e,i,n);var s=i.match(this.foldingStartMarker);if(s){var o=s.index;if(s[1])return this.openingBracketBlock(e,s[1],n,o);var u=e.getCommentFoldRange(n,o+s[0].length,1);return u&&!u.isMultiLine()&&(r?u=this.getSectionRange(e,n):t!="all"&&(u=null)),u}if(t==="markbegin")return;var s=i.match(this.foldingStopMarker);if(s){var o=s.index+s[0].length;return s[1]?this.closingBracketBlock(e,s[1],n,o):e.getCommentFoldRange(n,o,-1)}},this.getSectionRange=function(e,t){var n=e.getLine(t),r=n.search(/\S/),s=t,o=n.length;t+=1;var u=t,a=e.getLength();while(++tf)break;var l=this.getFoldWidgetRange(e,"all",t);if(l){if(l.start.row<=s)break;if(l.isMultiLine())t=l.end.row;else if(r==f)break}u=t}return new i(s,o,u,e.getLine(u).length)},this.getCommentRegionBlock=function(e,t,n){var r=t.search(/\s*$/),s=e.getLength(),o=n,u=/^\s*(?:\/\*|\/\/|--)#?(end)?region\b/,a=1;while(++no)return new i(o,r,l,t.length)}}.call(o.prototype)}),define("ace/mode/solidity",["require","exports","module","ace/lib/oop","ace/mode/text","ace/mode/solidity_highlight_rules","ace/mode/matching_brace_outdent","ace/range","ace/worker/worker_client","ace/mode/behaviour/cstyle","ace/mode/folding/cstyle"],function(e,t,n){"use strict";var r=e("../lib/oop"),i=e("./text").Mode,s=e("./solidity_highlight_rules").SolidityHighlightRules,o=e("./matching_brace_outdent").MatchingBraceOutdent,u=e("../range").Range,a=e("../worker/worker_client").WorkerClient,f=e("./behaviour/cstyle").CstyleBehaviour,l=e("./folding/cstyle").FoldMode,c=function(){this.HighlightRules=s,this.$outdent=new o,this.$behaviour=new f,this.foldingRules=new l};r.inherits(c,i),function(){this.lineCommentStart="//",this.blockComment={start:"/*",end:"*/"},this.getNextLineIndent=function(e,t,n){var r=this.$getIndent(t),i=this.getTokenizer().getLineTokens(t,e),s=i.tokens,o=i.state;if(s.length&&s[s.length-1].type=="comment")return r;if(e=="start"){var u=t.match(/^.*(?:\bcase\b.*\:|[\{\(\[])\s*$/);u&&(r+=n)}else if(e=="doc_comment"){if(o=="start")return"";var u=t.match(/^\s*(\/?)\*/);u&&(u[1]&&(r+=" "),r+="* ")}return r},this.checkOutdent=function(e,t,n){return this.$outdent.checkOutdent(t,n)},this.autoOutdent=function(e,t,n){this.$outdent.autoOutdent(t,n)},this.$id="ace/mode/solidity"}.call(c.prototype),t.Mode=c}) -------------------------------------------------------------------------------- /build/v1.2.8/src-min/mode-solidity.js: -------------------------------------------------------------------------------- 1 | define("ace/mode/solidity_highlight_rules",["require","exports","module","ace/lib/oop","ace/lib/lang","ace/mode/text_highlight_rules"],function(e,t,n){"use strict";var r=e("../lib/oop"),i=e("../lib/lang").deepCopy,s=e("./text_highlight_rules").TextHighlightRules,o=function(e){var t="byte|int|uint";for(var n=8;n<=256;n+=8)t+="|bytes"+n/8+"|uint"+n+"|int"+n;var r={"variable.language":"this|super",keyword:"as|emit|from|import|returns","keyword.control":"break|continue|do|else|for|if|return|while","keyword.control.deprecated":"throw","keyword.operator":"delete|new","keyword.other.reserved":"abstract|after|alias|apply|auto|case|catch|copyof|default|define|final|immutable|implements|in|inline|let|macro|match|mutable|null|of|override|partial|promise|reference|relocatable|sealed|sizeof|static|supports|switch|try|type|typedef|typeof|unchecked","storage.type":"contract|library|interface|function|constructor|event|modifier|struct|mapping|enum|var|bool|address|"+t,"storage.type.array.dynamic":"bytes|string","storage.modifier.inheritance":"is","storage.modifier.storagelocation":"storage|memory|calldata","storage.modifier.statemutability":"constant|payable|pure|view","storage.modifier.visibility":"private|public|external|internal","storage.modifier.event":"anonymous|indexed","support.function":"addmod|assert|blockhash|ecrecover|gasleft|keccak256|mulmod|require|revert|ripemd160|selfdestruct|sha256","support.function.deprecated":"sha3|suicide","support.variable":"now","constant.language.boolean":"true|false","constant.numeric.other.unit.currency":"wei|szabo|finney|ether","constant.numeric.other.unit.time":"seconds|minutes|hours|days|weeks","constant.numeric.other.unit.time.deprecated":"years"},s=this.createKeywordMapper(r,"identifier"),o=!1,u=function(t){var n=s(t);return o&&"identifier"==n&&(n="variable.parameter"),o=!0,n},a="[a-zA-Z_$][a-zA-Z_$0-9]*\\b|\\$",f="\\\\(?:x[0-9a-fA-F]{2}|u[0-9a-fA-F]{4}|.)",l=function(t){return{token:"comment."+t+".doc.documentation.tag.storage.type",regex:"\\b(?:TODO|FIXME|XXX|HACK)\\b"}},c=function(t){return{token:"comment."+t+".doc.documentation.tag",regex:"\\B@(?:author|dev|notice|param|return|title)\\b"}},h=function(e,t){return(e!="start"||t.length)&&t.unshift("function_arguments",e),o=!1,"function_arguments"};this.$rules={start:[{token:"comment.block.doc.documentation",regex:"\\/\\*(?=\\*)",push:"doc_comment"},{token:"comment.line.triple-slash.double-slash.doc.documentation",regex:"\\/\\/\\/",push:"doc_line_comment"},{token:"comment.block",regex:"\\/\\*",push:"comment"},{token:"comment.line.double-slash",regex:"\\/\\/",push:"line_comment"},{token:"text",regex:"\\s+|^$"},{token:"string.quoted.single",regex:"'(?=.)",push:"qstring"},{token:"string.quoted.double",regex:'"(?=.)',push:"qqstring"},{token:"storage.type.reserved",regex:"u?fixed(?:8x[0-8]|16x(?:1[0-6]|[0-9])|24x(?:2[0-4]|1[0-9]|[0-9])|32x(?:3[0-2]|[1-2][0-9]|[0-9])|40x(?:40|[1-3][0-9]|[0-9])|48x(?:4[0-8]|[1-3][0-9]|[0-9])|56x(?:5[0-6]|[1-4][0-9]|[0-9])|64x(?:6[0-4]|[1-5][0-9]|[0-9])|72x(?:7[0-2]|[1-6][0-9]|[0-9])|(?:80|88|96|104|112|120|128|136|144|152|160|168|176|184|192|200|208|216|224|232|240|248|256)x(?:80|[1-7][0-9]|[0-9]))?",inheritingStateRuleId:"fixedNumberType"},{token:"keyword.control",regex:/\b_\b/},{token:["string.other.hex","string.other.hex","string.other.hex","string.other.hex","string.other.hex"],regex:/(\b)(hex)(['"])((?:[0-9a-fA-F]{2})*)(\3)/},{token:"constant.numeric.hex",regex:/0[xX][0-9a-fA-F]+\b/},{token:"constant.numeric",regex:/[+-]?\d+(?:(?:\.\d*)?(?:[eE][+-]?\d+)?)?\b/},{token:["keyword","text","keyword","text","constant.other"],regex:"(pragma)(\\s+)(solidity|experimental)(\\s+)([^;]+)"},{token:["keyword","text","identifier","text","keyword","text","identifier"],regex:"(using)(\\s+)("+a+")(\\s+)(for)(\\s+)("+a+"|\\*)"},{token:"support.function.deprecated",regex:/block\s*\.\s*blockhash|\.\s*callcode/},{token:"support.function",regex:/abi\s*\.\s*(?:encodeWithSignature|encodeWithSelector|encodePacked|encode)|\.\s*(?:delegatecall|transfer|call|send)/},{token:"support.variable",regex:/block\s*\.\s*(?:difficulty|timestamp|coinbase|gaslimit|number)|msg\s*\.\s*(?:sender|value|data)|tx\s*\.\s*(?:gasprice|origin)|\.\s*balance/},{token:"support.variable.deprecated",regex:/msg\s*\.\s*gas/},{token:["storage.type","text","entity.name.function","text","paren.lparen"],regex:"(function)(\\s+)("+a+")(\\s*)(\\()",next:h},{token:["storage.type","text","paren.lparen"],regex:"(function)(\\s*)(\\()",next:h},{token:["keyword","text","paren.lparen"],regex:"(returns)(\\s*)(\\()",next:h},{token:s,regex:a,inheritingStateRuleId:"keywordMapper"},{token:"keyword.operator",regex:/--|\*\*|\+\+|=>|<<|>>|<<=|>>=|&&|\|\||[!&|+\-*\/%~^<>=]=?/},{token:"punctuation.operator",regex:/[?:;]/},{token:"punctuation.operator",regex:/[.,]/,inheritingStateRuleId:"punctuation"},{token:"paren.lparen",regex:/[\[{]/},{token:"paren.lparen",regex:/[(]/,inheritingStateRuleId:"lparen"},{token:"paren.rparen",regex:/[\]}]/},{token:"paren.rparen",regex:/[)]/,inheritingStateRuleId:"rparen"}],comment:[l("block"),{token:"comment.block",regex:"\\*\\/",next:"pop"},{defaultToken:"comment.block",caseInsensitive:!0}],line_comment:[l("line"),{token:"comment.line.double-slash",regex:"$|^",next:"pop"},{defaultToken:"comment.line.double-slash",caseInsensitive:!0}],doc_comment:[l("block"),c("block"),{token:"comment.block.doc.documentation",regex:"\\*\\/",next:"pop"},{defaultToken:"comment.block.doc.documentation",caseInsensitive:!0}],doc_line_comment:[l("line"),c("line"),{token:"comment.line.triple-slash.double-slash.doc.documentation",regex:"$|^",next:"pop"},{defaultToken:"comment.line.triple-slash.double-slash.doc.documentation",caseInsensitive:!0}],qqstring:[{token:"constant.language.escape",regex:f},{token:"string.quoted.double",regex:"\\\\$",next:"qqstring"},{token:"string.quoted.double",regex:'"|$',next:"pop"},{defaultToken:"string.quoted.double"}],qstring:[{token:"constant.language.escape",regex:f},{token:"string.quoted.single",regex:"\\\\$",next:"qstring"},{token:"string.quoted.single",regex:"'|$",next:"pop"},{defaultToken:"string.quoted.single"}]};var p=i(this.$rules.start);p.forEach(function(e,t){if(e.inheritingStateRuleId){switch(e.inheritingStateRuleId){case"keywordMapper":e.token=u;break;case"punctuation":e.onMatch=function(n,r,i){return o=!1,e.token};break;case"lparen":e.next=h;break;case"rparen":e.next="pop";break;case"fixedNumberType":e.onMatch=function(n,r,i){return o=!0,e.token}}delete e.inheritingStateRuleId,delete this.$rules.start[t].inheritingStateRuleId,p[t]=e}},this),this.$rules.function_arguments=p,this.normalizeRules()};r.inherits(o,s),t.SolidityHighlightRules=o}),define("ace/mode/matching_brace_outdent",["require","exports","module","ace/range"],function(e,t,n){"use strict";var r=e("../range").Range,i=function(){};(function(){this.checkOutdent=function(e,t){return/^\s+$/.test(e)?/^\s*\}/.test(t):!1},this.autoOutdent=function(e,t){var n=e.getLine(t),i=n.match(/^(\s*\})/);if(!i)return 0;var s=i[1].length,o=e.findMatchingBracket({row:t,column:s});if(!o||o.row==t)return 0;var u=this.$getIndent(e.getLine(o.row));e.replace(new r(t,0,t,s-1),u)},this.$getIndent=function(e){return e.match(/^\s*/)[0]}}).call(i.prototype),t.MatchingBraceOutdent=i}),define("ace/mode/folding/cstyle",["require","exports","module","ace/lib/oop","ace/range","ace/mode/folding/fold_mode"],function(e,t,n){"use strict";var r=e("../../lib/oop"),i=e("../../range").Range,s=e("./fold_mode").FoldMode,o=t.FoldMode=function(e){e&&(this.foldingStartMarker=new RegExp(this.foldingStartMarker.source.replace(/\|[^|]*?$/,"|"+e.start)),this.foldingStopMarker=new RegExp(this.foldingStopMarker.source.replace(/\|[^|]*?$/,"|"+e.end)))};r.inherits(o,s),function(){this.foldingStartMarker=/(\{|\[)[^\}\]]*$|^\s*(\/\*)/,this.foldingStopMarker=/^[^\[\{]*(\}|\])|^[\s\*]*(\*\/)/,this.singleLineBlockCommentRe=/^\s*(\/\*).*\*\/\s*$/,this.tripleStarBlockCommentRe=/^\s*(\/\*\*\*).*\*\/\s*$/,this.startRegionRe=/^\s*(\/\*|\/\/)#?region\b/,this._getFoldWidgetBase=this.getFoldWidget,this.getFoldWidget=function(e,t,n){var r=e.getLine(n);if(this.singleLineBlockCommentRe.test(r)&&!this.startRegionRe.test(r)&&!this.tripleStarBlockCommentRe.test(r))return"";var i=this._getFoldWidgetBase(e,t,n);return!i&&this.startRegionRe.test(r)?"start":i},this.getFoldWidgetRange=function(e,t,n,r){var i=e.getLine(n);if(this.startRegionRe.test(i))return this.getCommentRegionBlock(e,i,n);var s=i.match(this.foldingStartMarker);if(s){var o=s.index;if(s[1])return this.openingBracketBlock(e,s[1],n,o);var u=e.getCommentFoldRange(n,o+s[0].length,1);return u&&!u.isMultiLine()&&(r?u=this.getSectionRange(e,n):t!="all"&&(u=null)),u}if(t==="markbegin")return;var s=i.match(this.foldingStopMarker);if(s){var o=s.index+s[0].length;return s[1]?this.closingBracketBlock(e,s[1],n,o):e.getCommentFoldRange(n,o,-1)}},this.getSectionRange=function(e,t){var n=e.getLine(t),r=n.search(/\S/),s=t,o=n.length;t+=1;var u=t,a=e.getLength();while(++tf)break;var l=this.getFoldWidgetRange(e,"all",t);if(l){if(l.start.row<=s)break;if(l.isMultiLine())t=l.end.row;else if(r==f)break}u=t}return new i(s,o,u,e.getLine(u).length)},this.getCommentRegionBlock=function(e,t,n){var r=t.search(/\s*$/),s=e.getLength(),o=n,u=/^\s*(?:\/\*|\/\/|--)#?(end)?region\b/,a=1;while(++no)return new i(o,r,l,t.length)}}.call(o.prototype)}),define("ace/mode/solidity",["require","exports","module","ace/lib/oop","ace/mode/text","ace/mode/solidity_highlight_rules","ace/mode/matching_brace_outdent","ace/range","ace/worker/worker_client","ace/mode/behaviour/cstyle","ace/mode/folding/cstyle"],function(e,t,n){"use strict";var r=e("../lib/oop"),i=e("./text").Mode,s=e("./solidity_highlight_rules").SolidityHighlightRules,o=e("./matching_brace_outdent").MatchingBraceOutdent,u=e("../range").Range,a=e("../worker/worker_client").WorkerClient,f=e("./behaviour/cstyle").CstyleBehaviour,l=e("./folding/cstyle").FoldMode,c=function(){this.HighlightRules=s,this.$outdent=new o,this.$behaviour=new f,this.foldingRules=new l};r.inherits(c,i),function(){this.lineCommentStart="//",this.blockComment={start:"/*",end:"*/"},this.getNextLineIndent=function(e,t,n){var r=this.$getIndent(t),i=this.getTokenizer().getLineTokens(t,e),s=i.tokens,o=i.state;if(s.length&&s[s.length-1].type=="comment")return r;if(e=="start"){var u=t.match(/^.*(?:\bcase\b.*\:|[\{\(\[])\s*$/);u&&(r+=n)}else if(e=="doc_comment"){if(o=="start")return"";var u=t.match(/^\s*(\/?)\*/);u&&(u[1]&&(r+=" "),r+="* ")}return r},this.checkOutdent=function(e,t,n){return this.$outdent.checkOutdent(t,n)},this.autoOutdent=function(e,t,n){this.$outdent.autoOutdent(t,n)},this.$id="ace/mode/solidity"}.call(c.prototype),t.Mode=c}) -------------------------------------------------------------------------------- /build/v1.2.9/src-min/mode-solidity.js: -------------------------------------------------------------------------------- 1 | define("ace/mode/solidity_highlight_rules",["require","exports","module","ace/lib/oop","ace/lib/lang","ace/mode/text_highlight_rules"],function(e,t,n){"use strict";var r=e("../lib/oop"),i=e("../lib/lang").deepCopy,s=e("./text_highlight_rules").TextHighlightRules,o=function(e){var t="byte|int|uint";for(var n=8;n<=256;n+=8)t+="|bytes"+n/8+"|uint"+n+"|int"+n;var r={"variable.language":"this|super",keyword:"as|emit|from|import|returns","keyword.control":"break|continue|do|else|for|if|return|while","keyword.control.deprecated":"throw","keyword.operator":"delete|new","keyword.other.reserved":"abstract|after|alias|apply|auto|case|catch|copyof|default|define|final|immutable|implements|in|inline|let|macro|match|mutable|null|of|override|partial|promise|reference|relocatable|sealed|sizeof|static|supports|switch|try|type|typedef|typeof|unchecked","storage.type":"contract|library|interface|function|constructor|event|modifier|struct|mapping|enum|var|bool|address|"+t,"storage.type.array.dynamic":"bytes|string","storage.modifier.inheritance":"is","storage.modifier.storagelocation":"storage|memory|calldata","storage.modifier.statemutability":"constant|payable|pure|view","storage.modifier.visibility":"private|public|external|internal","storage.modifier.event":"anonymous|indexed","support.function":"addmod|assert|blockhash|ecrecover|gasleft|keccak256|mulmod|require|revert|ripemd160|selfdestruct|sha256","support.function.deprecated":"sha3|suicide","support.variable":"now","constant.language.boolean":"true|false","constant.numeric.other.unit.currency":"wei|szabo|finney|ether","constant.numeric.other.unit.time":"seconds|minutes|hours|days|weeks","constant.numeric.other.unit.time.deprecated":"years"},s=this.createKeywordMapper(r,"identifier"),o=!1,u=function(t){var n=s(t);return o&&"identifier"==n&&(n="variable.parameter"),o=!0,n},a="[a-zA-Z_$][a-zA-Z_$0-9]*\\b|\\$",f="\\\\(?:x[0-9a-fA-F]{2}|u[0-9a-fA-F]{4}|.)",l=function(t){return{token:"comment."+t+".doc.documentation.tag.storage.type",regex:"\\b(?:TODO|FIXME|XXX|HACK)\\b"}},c=function(t){return{token:"comment."+t+".doc.documentation.tag",regex:"\\B@(?:author|dev|notice|param|return|title)\\b"}},h=function(e,t){return(e!="start"||t.length)&&t.unshift("function_arguments",e),o=!1,"function_arguments"};this.$rules={start:[{token:"comment.block.doc.documentation",regex:"\\/\\*(?=\\*)",push:"doc_comment"},{token:"comment.line.triple-slash.double-slash.doc.documentation",regex:"\\/\\/\\/",push:"doc_line_comment"},{token:"comment.block",regex:"\\/\\*",push:"comment"},{token:"comment.line.double-slash",regex:"\\/\\/",push:"line_comment"},{token:"text",regex:"\\s+|^$"},{token:"string.quoted.single",regex:"'(?=.)",push:"qstring"},{token:"string.quoted.double",regex:'"(?=.)',push:"qqstring"},{token:"storage.type.reserved",regex:"u?fixed(?:8x[0-8]|16x(?:1[0-6]|[0-9])|24x(?:2[0-4]|1[0-9]|[0-9])|32x(?:3[0-2]|[1-2][0-9]|[0-9])|40x(?:40|[1-3][0-9]|[0-9])|48x(?:4[0-8]|[1-3][0-9]|[0-9])|56x(?:5[0-6]|[1-4][0-9]|[0-9])|64x(?:6[0-4]|[1-5][0-9]|[0-9])|72x(?:7[0-2]|[1-6][0-9]|[0-9])|(?:80|88|96|104|112|120|128|136|144|152|160|168|176|184|192|200|208|216|224|232|240|248|256)x(?:80|[1-7][0-9]|[0-9]))?",inheritingStateRuleId:"fixedNumberType"},{token:"keyword.control",regex:/\b_\b/},{token:["string.other.hex","string.other.hex","string.other.hex","string.other.hex","string.other.hex"],regex:/(\b)(hex)(['"])((?:[0-9a-fA-F]{2})*)(\3)/},{token:"constant.numeric.hex",regex:/0[xX][0-9a-fA-F]+\b/},{token:"constant.numeric",regex:/[+-]?\d+(?:(?:\.\d*)?(?:[eE][+-]?\d+)?)?\b/},{token:["keyword","text","keyword","text","constant.other"],regex:"(pragma)(\\s+)(solidity|experimental)(\\s+)([^;]+)"},{token:["keyword","text","identifier","text","keyword","text","identifier"],regex:"(using)(\\s+)("+a+")(\\s+)(for)(\\s+)("+a+"|\\*)"},{token:"support.function.deprecated",regex:/block\s*\.\s*blockhash|\.\s*callcode/},{token:"support.function",regex:/abi\s*\.\s*(?:encodeWithSignature|encodeWithSelector|encodePacked|encode)|\.\s*(?:delegatecall|transfer|call|send)/},{token:"support.variable",regex:/block\s*\.\s*(?:difficulty|timestamp|coinbase|gaslimit|number)|msg\s*\.\s*(?:sender|value|data)|tx\s*\.\s*(?:gasprice|origin)|\.\s*balance/},{token:"support.variable.deprecated",regex:/msg\s*\.\s*gas/},{token:["storage.type","text","entity.name.function","text","paren.lparen"],regex:"(function)(\\s+)("+a+")(\\s*)(\\()",next:h},{token:["storage.type","text","paren.lparen"],regex:"(function)(\\s*)(\\()",next:h},{token:["keyword","text","paren.lparen"],regex:"(returns)(\\s*)(\\()",next:h},{token:s,regex:a,inheritingStateRuleId:"keywordMapper"},{token:"keyword.operator",regex:/--|\*\*|\+\+|=>|<<|>>|<<=|>>=|&&|\|\||[!&|+\-*\/%~^<>=]=?/},{token:"punctuation.operator",regex:/[?:;]/},{token:"punctuation.operator",regex:/[.,]/,inheritingStateRuleId:"punctuation"},{token:"paren.lparen",regex:/[\[{]/},{token:"paren.lparen",regex:/[(]/,inheritingStateRuleId:"lparen"},{token:"paren.rparen",regex:/[\]}]/},{token:"paren.rparen",regex:/[)]/,inheritingStateRuleId:"rparen"}],comment:[l("block"),{token:"comment.block",regex:"\\*\\/",next:"pop"},{defaultToken:"comment.block",caseInsensitive:!0}],line_comment:[l("line"),{token:"comment.line.double-slash",regex:"$|^",next:"pop"},{defaultToken:"comment.line.double-slash",caseInsensitive:!0}],doc_comment:[l("block"),c("block"),{token:"comment.block.doc.documentation",regex:"\\*\\/",next:"pop"},{defaultToken:"comment.block.doc.documentation",caseInsensitive:!0}],doc_line_comment:[l("line"),c("line"),{token:"comment.line.triple-slash.double-slash.doc.documentation",regex:"$|^",next:"pop"},{defaultToken:"comment.line.triple-slash.double-slash.doc.documentation",caseInsensitive:!0}],qqstring:[{token:"constant.language.escape",regex:f},{token:"string.quoted.double",regex:"\\\\$",next:"qqstring"},{token:"string.quoted.double",regex:'"|$',next:"pop"},{defaultToken:"string.quoted.double"}],qstring:[{token:"constant.language.escape",regex:f},{token:"string.quoted.single",regex:"\\\\$",next:"qstring"},{token:"string.quoted.single",regex:"'|$",next:"pop"},{defaultToken:"string.quoted.single"}]};var p=i(this.$rules.start);p.forEach(function(e,t){if(e.inheritingStateRuleId){switch(e.inheritingStateRuleId){case"keywordMapper":e.token=u;break;case"punctuation":e.onMatch=function(n,r,i){return o=!1,e.token};break;case"lparen":e.next=h;break;case"rparen":e.next="pop";break;case"fixedNumberType":e.onMatch=function(n,r,i){return o=!0,e.token}}delete e.inheritingStateRuleId,delete this.$rules.start[t].inheritingStateRuleId,p[t]=e}},this),this.$rules.function_arguments=p,this.normalizeRules()};r.inherits(o,s),t.SolidityHighlightRules=o}),define("ace/mode/matching_brace_outdent",["require","exports","module","ace/range"],function(e,t,n){"use strict";var r=e("../range").Range,i=function(){};(function(){this.checkOutdent=function(e,t){return/^\s+$/.test(e)?/^\s*\}/.test(t):!1},this.autoOutdent=function(e,t){var n=e.getLine(t),i=n.match(/^(\s*\})/);if(!i)return 0;var s=i[1].length,o=e.findMatchingBracket({row:t,column:s});if(!o||o.row==t)return 0;var u=this.$getIndent(e.getLine(o.row));e.replace(new r(t,0,t,s-1),u)},this.$getIndent=function(e){return e.match(/^\s*/)[0]}}).call(i.prototype),t.MatchingBraceOutdent=i}),define("ace/mode/folding/cstyle",["require","exports","module","ace/lib/oop","ace/range","ace/mode/folding/fold_mode"],function(e,t,n){"use strict";var r=e("../../lib/oop"),i=e("../../range").Range,s=e("./fold_mode").FoldMode,o=t.FoldMode=function(e){e&&(this.foldingStartMarker=new RegExp(this.foldingStartMarker.source.replace(/\|[^|]*?$/,"|"+e.start)),this.foldingStopMarker=new RegExp(this.foldingStopMarker.source.replace(/\|[^|]*?$/,"|"+e.end)))};r.inherits(o,s),function(){this.foldingStartMarker=/([\{\[\(])[^\}\]\)]*$|^\s*(\/\*)/,this.foldingStopMarker=/^[^\[\{\(]*([\}\]\)])|^[\s\*]*(\*\/)/,this.singleLineBlockCommentRe=/^\s*(\/\*).*\*\/\s*$/,this.tripleStarBlockCommentRe=/^\s*(\/\*\*\*).*\*\/\s*$/,this.startRegionRe=/^\s*(\/\*|\/\/)#?region\b/,this._getFoldWidgetBase=this.getFoldWidget,this.getFoldWidget=function(e,t,n){var r=e.getLine(n);if(this.singleLineBlockCommentRe.test(r)&&!this.startRegionRe.test(r)&&!this.tripleStarBlockCommentRe.test(r))return"";var i=this._getFoldWidgetBase(e,t,n);return!i&&this.startRegionRe.test(r)?"start":i},this.getFoldWidgetRange=function(e,t,n,r){var i=e.getLine(n);if(this.startRegionRe.test(i))return this.getCommentRegionBlock(e,i,n);var s=i.match(this.foldingStartMarker);if(s){var o=s.index;if(s[1])return this.openingBracketBlock(e,s[1],n,o);var u=e.getCommentFoldRange(n,o+s[0].length,1);return u&&!u.isMultiLine()&&(r?u=this.getSectionRange(e,n):t!="all"&&(u=null)),u}if(t==="markbegin")return;var s=i.match(this.foldingStopMarker);if(s){var o=s.index+s[0].length;return s[1]?this.closingBracketBlock(e,s[1],n,o):e.getCommentFoldRange(n,o,-1)}},this.getSectionRange=function(e,t){var n=e.getLine(t),r=n.search(/\S/),s=t,o=n.length;t+=1;var u=t,a=e.getLength();while(++tf)break;var l=this.getFoldWidgetRange(e,"all",t);if(l){if(l.start.row<=s)break;if(l.isMultiLine())t=l.end.row;else if(r==f)break}u=t}return new i(s,o,u,e.getLine(u).length)},this.getCommentRegionBlock=function(e,t,n){var r=t.search(/\s*$/),s=e.getLength(),o=n,u=/^\s*(?:\/\*|\/\/|--)#?(end)?region\b/,a=1;while(++no)return new i(o,r,l,t.length)}}.call(o.prototype)}),define("ace/mode/solidity",["require","exports","module","ace/lib/oop","ace/mode/text","ace/mode/solidity_highlight_rules","ace/mode/matching_brace_outdent","ace/range","ace/worker/worker_client","ace/mode/behaviour/cstyle","ace/mode/folding/cstyle"],function(e,t,n){"use strict";var r=e("../lib/oop"),i=e("./text").Mode,s=e("./solidity_highlight_rules").SolidityHighlightRules,o=e("./matching_brace_outdent").MatchingBraceOutdent,u=e("../range").Range,a=e("../worker/worker_client").WorkerClient,f=e("./behaviour/cstyle").CstyleBehaviour,l=e("./folding/cstyle").FoldMode,c=function(){this.HighlightRules=s,this.$outdent=new o,this.$behaviour=new f,this.foldingRules=new l};r.inherits(c,i),function(){this.lineCommentStart="//",this.blockComment={start:"/*",end:"*/"},this.getNextLineIndent=function(e,t,n){var r=this.$getIndent(t),i=this.getTokenizer().getLineTokens(t,e),s=i.tokens,o=i.state;if(s.length&&s[s.length-1].type=="comment")return r;if(e=="start"){var u=t.match(/^.*(?:\bcase\b.*\:|[\{\(\[])\s*$/);u&&(r+=n)}else if(e=="doc_comment"){if(o=="start")return"";var u=t.match(/^\s*(\/?)\*/);u&&(u[1]&&(r+=" "),r+="* ")}return r},this.checkOutdent=function(e,t,n){return this.$outdent.checkOutdent(t,n)},this.autoOutdent=function(e,t,n){this.$outdent.autoOutdent(t,n)},this.$id="ace/mode/solidity"}.call(c.prototype),t.Mode=c}) -------------------------------------------------------------------------------- /build/v1.3.0/src-min/mode-solidity.js: -------------------------------------------------------------------------------- 1 | define("ace/mode/solidity_highlight_rules",["require","exports","module","ace/lib/oop","ace/lib/lang","ace/mode/text_highlight_rules"],function(e,t,n){"use strict";var r=e("../lib/oop"),i=e("../lib/lang").deepCopy,s=e("./text_highlight_rules").TextHighlightRules,o=function(e){var t="byte|int|uint";for(var n=8;n<=256;n+=8)t+="|bytes"+n/8+"|uint"+n+"|int"+n;var r={"variable.language":"this|super",keyword:"as|emit|from|import|returns","keyword.control":"break|continue|do|else|for|if|return|while","keyword.control.deprecated":"throw","keyword.operator":"delete|new","keyword.other.reserved":"abstract|after|alias|apply|auto|case|catch|copyof|default|define|final|immutable|implements|in|inline|let|macro|match|mutable|null|of|override|partial|promise|reference|relocatable|sealed|sizeof|static|supports|switch|try|type|typedef|typeof|unchecked","storage.type":"contract|library|interface|function|constructor|event|modifier|struct|mapping|enum|var|bool|address|"+t,"storage.type.array.dynamic":"bytes|string","storage.modifier.inheritance":"is","storage.modifier.storagelocation":"storage|memory|calldata","storage.modifier.statemutability":"constant|payable|pure|view","storage.modifier.visibility":"private|public|external|internal","storage.modifier.event":"anonymous|indexed","support.function":"addmod|assert|blockhash|ecrecover|gasleft|keccak256|mulmod|require|revert|ripemd160|selfdestruct|sha256","support.function.deprecated":"sha3|suicide","support.variable":"now","constant.language.boolean":"true|false","constant.numeric.other.unit.currency":"wei|szabo|finney|ether","constant.numeric.other.unit.time":"seconds|minutes|hours|days|weeks","constant.numeric.other.unit.time.deprecated":"years"},s=this.createKeywordMapper(r,"identifier"),o=!1,u=function(t){var n=s(t);return o&&"identifier"==n&&(n="variable.parameter"),o=!0,n},a="[a-zA-Z_$][a-zA-Z_$0-9]*\\b|\\$",f="\\\\(?:x[0-9a-fA-F]{2}|u[0-9a-fA-F]{4}|.)",l=function(t){return{token:"comment."+t+".doc.documentation.tag.storage.type",regex:"\\b(?:TODO|FIXME|XXX|HACK)\\b"}},c=function(t){return{token:"comment."+t+".doc.documentation.tag",regex:"\\B@(?:author|dev|notice|param|return|title)\\b"}},h=function(e,t){return(e!="start"||t.length)&&t.unshift("function_arguments",e),o=!1,"function_arguments"};this.$rules={start:[{token:"comment.block.doc.documentation",regex:"\\/\\*(?=\\*)",push:"doc_comment"},{token:"comment.line.triple-slash.double-slash.doc.documentation",regex:"\\/\\/\\/",push:"doc_line_comment"},{token:"comment.block",regex:"\\/\\*",push:"comment"},{token:"comment.line.double-slash",regex:"\\/\\/",push:"line_comment"},{token:"text",regex:"\\s+|^$"},{token:"string.quoted.single",regex:"'(?=.)",push:"qstring"},{token:"string.quoted.double",regex:'"(?=.)',push:"qqstring"},{token:"storage.type.reserved",regex:"u?fixed(?:8x[0-8]|16x(?:1[0-6]|[0-9])|24x(?:2[0-4]|1[0-9]|[0-9])|32x(?:3[0-2]|[1-2][0-9]|[0-9])|40x(?:40|[1-3][0-9]|[0-9])|48x(?:4[0-8]|[1-3][0-9]|[0-9])|56x(?:5[0-6]|[1-4][0-9]|[0-9])|64x(?:6[0-4]|[1-5][0-9]|[0-9])|72x(?:7[0-2]|[1-6][0-9]|[0-9])|(?:80|88|96|104|112|120|128|136|144|152|160|168|176|184|192|200|208|216|224|232|240|248|256)x(?:80|[1-7][0-9]|[0-9]))?",inheritingStateRuleId:"fixedNumberType"},{token:"keyword.control",regex:/\b_\b/},{token:["string.other.hex","string.other.hex","string.other.hex","string.other.hex","string.other.hex"],regex:/(\b)(hex)(['"])((?:[0-9a-fA-F]{2})*)(\3)/},{token:"constant.numeric.hex",regex:/0[xX][0-9a-fA-F]+\b/},{token:"constant.numeric",regex:/[+-]?\d+(?:(?:\.\d*)?(?:[eE][+-]?\d+)?)?\b/},{token:["keyword","text","keyword","text","constant.other"],regex:"(pragma)(\\s+)(solidity|experimental)(\\s+)([^;]+)"},{token:["keyword","text","identifier","text","keyword","text","identifier"],regex:"(using)(\\s+)("+a+")(\\s+)(for)(\\s+)("+a+"|\\*)"},{token:"support.function.deprecated",regex:/block\s*\.\s*blockhash|\.\s*callcode/},{token:"support.function",regex:/abi\s*\.\s*(?:encodeWithSignature|encodeWithSelector|encodePacked|encode)|\.\s*(?:delegatecall|transfer|call|send)/},{token:"support.variable",regex:/block\s*\.\s*(?:difficulty|timestamp|coinbase|gaslimit|number)|msg\s*\.\s*(?:sender|value|data)|tx\s*\.\s*(?:gasprice|origin)|\.\s*balance/},{token:"support.variable.deprecated",regex:/msg\s*\.\s*gas/},{token:["storage.type","text","entity.name.function","text","paren.lparen"],regex:"(function)(\\s+)("+a+")(\\s*)(\\()",next:h},{token:["storage.type","text","paren.lparen"],regex:"(function)(\\s*)(\\()",next:h},{token:["keyword","text","paren.lparen"],regex:"(returns)(\\s*)(\\()",next:h},{token:s,regex:a,inheritingStateRuleId:"keywordMapper"},{token:"keyword.operator",regex:/--|\*\*|\+\+|=>|<<|>>|<<=|>>=|&&|\|\||[!&|+\-*\/%~^<>=]=?/},{token:"punctuation.operator",regex:/[?:;]/},{token:"punctuation.operator",regex:/[.,]/,inheritingStateRuleId:"punctuation"},{token:"paren.lparen",regex:/[\[{]/},{token:"paren.lparen",regex:/[(]/,inheritingStateRuleId:"lparen"},{token:"paren.rparen",regex:/[\]}]/},{token:"paren.rparen",regex:/[)]/,inheritingStateRuleId:"rparen"}],comment:[l("block"),{token:"comment.block",regex:"\\*\\/",next:"pop"},{defaultToken:"comment.block",caseInsensitive:!0}],line_comment:[l("line"),{token:"comment.line.double-slash",regex:"$|^",next:"pop"},{defaultToken:"comment.line.double-slash",caseInsensitive:!0}],doc_comment:[l("block"),c("block"),{token:"comment.block.doc.documentation",regex:"\\*\\/",next:"pop"},{defaultToken:"comment.block.doc.documentation",caseInsensitive:!0}],doc_line_comment:[l("line"),c("line"),{token:"comment.line.triple-slash.double-slash.doc.documentation",regex:"$|^",next:"pop"},{defaultToken:"comment.line.triple-slash.double-slash.doc.documentation",caseInsensitive:!0}],qqstring:[{token:"constant.language.escape",regex:f},{token:"string.quoted.double",regex:"\\\\$",next:"qqstring"},{token:"string.quoted.double",regex:'"|$',next:"pop"},{defaultToken:"string.quoted.double"}],qstring:[{token:"constant.language.escape",regex:f},{token:"string.quoted.single",regex:"\\\\$",next:"qstring"},{token:"string.quoted.single",regex:"'|$",next:"pop"},{defaultToken:"string.quoted.single"}]};var p=i(this.$rules.start);p.forEach(function(e,t){if(e.inheritingStateRuleId){switch(e.inheritingStateRuleId){case"keywordMapper":e.token=u;break;case"punctuation":e.onMatch=function(n,r,i){return o=!1,e.token};break;case"lparen":e.next=h;break;case"rparen":e.next="pop";break;case"fixedNumberType":e.onMatch=function(n,r,i){return o=!0,e.token}}delete e.inheritingStateRuleId,delete this.$rules.start[t].inheritingStateRuleId,p[t]=e}},this),this.$rules.function_arguments=p,this.normalizeRules()};r.inherits(o,s),t.SolidityHighlightRules=o}),define("ace/mode/matching_brace_outdent",["require","exports","module","ace/range"],function(e,t,n){"use strict";var r=e("../range").Range,i=function(){};(function(){this.checkOutdent=function(e,t){return/^\s+$/.test(e)?/^\s*\}/.test(t):!1},this.autoOutdent=function(e,t){var n=e.getLine(t),i=n.match(/^(\s*\})/);if(!i)return 0;var s=i[1].length,o=e.findMatchingBracket({row:t,column:s});if(!o||o.row==t)return 0;var u=this.$getIndent(e.getLine(o.row));e.replace(new r(t,0,t,s-1),u)},this.$getIndent=function(e){return e.match(/^\s*/)[0]}}).call(i.prototype),t.MatchingBraceOutdent=i}),define("ace/mode/folding/cstyle",["require","exports","module","ace/lib/oop","ace/range","ace/mode/folding/fold_mode"],function(e,t,n){"use strict";var r=e("../../lib/oop"),i=e("../../range").Range,s=e("./fold_mode").FoldMode,o=t.FoldMode=function(e){e&&(this.foldingStartMarker=new RegExp(this.foldingStartMarker.source.replace(/\|[^|]*?$/,"|"+e.start)),this.foldingStopMarker=new RegExp(this.foldingStopMarker.source.replace(/\|[^|]*?$/,"|"+e.end)))};r.inherits(o,s),function(){this.foldingStartMarker=/([\{\[\(])[^\}\]\)]*$|^\s*(\/\*)/,this.foldingStopMarker=/^[^\[\{\(]*([\}\]\)])|^[\s\*]*(\*\/)/,this.singleLineBlockCommentRe=/^\s*(\/\*).*\*\/\s*$/,this.tripleStarBlockCommentRe=/^\s*(\/\*\*\*).*\*\/\s*$/,this.startRegionRe=/^\s*(\/\*|\/\/)#?region\b/,this._getFoldWidgetBase=this.getFoldWidget,this.getFoldWidget=function(e,t,n){var r=e.getLine(n);if(this.singleLineBlockCommentRe.test(r)&&!this.startRegionRe.test(r)&&!this.tripleStarBlockCommentRe.test(r))return"";var i=this._getFoldWidgetBase(e,t,n);return!i&&this.startRegionRe.test(r)?"start":i},this.getFoldWidgetRange=function(e,t,n,r){var i=e.getLine(n);if(this.startRegionRe.test(i))return this.getCommentRegionBlock(e,i,n);var s=i.match(this.foldingStartMarker);if(s){var o=s.index;if(s[1])return this.openingBracketBlock(e,s[1],n,o);var u=e.getCommentFoldRange(n,o+s[0].length,1);return u&&!u.isMultiLine()&&(r?u=this.getSectionRange(e,n):t!="all"&&(u=null)),u}if(t==="markbegin")return;var s=i.match(this.foldingStopMarker);if(s){var o=s.index+s[0].length;return s[1]?this.closingBracketBlock(e,s[1],n,o):e.getCommentFoldRange(n,o,-1)}},this.getSectionRange=function(e,t){var n=e.getLine(t),r=n.search(/\S/),s=t,o=n.length;t+=1;var u=t,a=e.getLength();while(++tf)break;var l=this.getFoldWidgetRange(e,"all",t);if(l){if(l.start.row<=s)break;if(l.isMultiLine())t=l.end.row;else if(r==f)break}u=t}return new i(s,o,u,e.getLine(u).length)},this.getCommentRegionBlock=function(e,t,n){var r=t.search(/\s*$/),s=e.getLength(),o=n,u=/^\s*(?:\/\*|\/\/|--)#?(end)?region\b/,a=1;while(++no)return new i(o,r,l,t.length)}}.call(o.prototype)}),define("ace/mode/solidity",["require","exports","module","ace/lib/oop","ace/mode/text","ace/mode/solidity_highlight_rules","ace/mode/matching_brace_outdent","ace/range","ace/worker/worker_client","ace/mode/behaviour/cstyle","ace/mode/folding/cstyle"],function(e,t,n){"use strict";var r=e("../lib/oop"),i=e("./text").Mode,s=e("./solidity_highlight_rules").SolidityHighlightRules,o=e("./matching_brace_outdent").MatchingBraceOutdent,u=e("../range").Range,a=e("../worker/worker_client").WorkerClient,f=e("./behaviour/cstyle").CstyleBehaviour,l=e("./folding/cstyle").FoldMode,c=function(){this.HighlightRules=s,this.$outdent=new o,this.$behaviour=new f,this.foldingRules=new l};r.inherits(c,i),function(){this.lineCommentStart="//",this.blockComment={start:"/*",end:"*/"},this.getNextLineIndent=function(e,t,n){var r=this.$getIndent(t),i=this.getTokenizer().getLineTokens(t,e),s=i.tokens,o=i.state;if(s.length&&s[s.length-1].type=="comment")return r;if(e=="start"){var u=t.match(/^.*(?:\bcase\b.*\:|[\{\(\[])\s*$/);u&&(r+=n)}else if(e=="doc_comment"){if(o=="start")return"";var u=t.match(/^\s*(\/?)\*/);u&&(u[1]&&(r+=" "),r+="* ")}return r},this.checkOutdent=function(e,t,n){return this.$outdent.checkOutdent(t,n)},this.autoOutdent=function(e,t,n){this.$outdent.autoOutdent(t,n)},this.$id="ace/mode/solidity"}.call(c.prototype),t.Mode=c}) -------------------------------------------------------------------------------- /build_cache/.gitignore: -------------------------------------------------------------------------------- 1 | * 2 | !.gitignore 3 | !README.md 4 | -------------------------------------------------------------------------------- /build_support/astTraversal.js: -------------------------------------------------------------------------------- 1 | 2 | class AstTraversal { 3 | constructor(ast) { 4 | this.ast = ast; 5 | this.stack = []; 6 | this.callbacks = {}; 7 | } 8 | 9 | on(type, callback) { 10 | if (! this.callbacks[type]) { 11 | this.callbacks[type] = []; 12 | } 13 | this.callbacks[type].push(callback); 14 | } 15 | 16 | _applyCallbacks(node) { 17 | for (const callbackId of [node.type, '*']) { 18 | if (this.callbacks[callbackId]) { 19 | for (const cb of this.callbacks[callbackId]) { 20 | const result = cb(node, this.stack, this.ast); 21 | if (false === result) { 22 | return; 23 | } 24 | } 25 | } 26 | } 27 | } 28 | 29 | traverse(ast) { 30 | // if (null === ast) { 31 | // return; 32 | // } 33 | if (Array.isArray(ast)) { 34 | let i = 0; 35 | for (const node of ast) { 36 | this.stack.push({levelType:'listIndex', id:i}); 37 | this.traverse(node); 38 | this.stack.pop(); 39 | i++; 40 | } 41 | return; 42 | } 43 | if ('object' === typeof ast) { 44 | if (!ast || ! ast.type) { // Not a node, i.e. `loc` or `value:{}` or similar. 45 | return; 46 | } 47 | this._applyCallbacks(ast); 48 | this.stack.push({levelType:'nodeType', id:ast.type}); 49 | for (const field of Object.keys(ast)) { 50 | // if ('loc' === field) { 51 | // continue; 52 | // } 53 | this.stack.push({levelType:'fieldName', id:field}); 54 | this.traverse(ast[field]); 55 | this.stack.pop(); 56 | } 57 | this.stack.pop(); 58 | return; 59 | } 60 | } 61 | 62 | start() { 63 | this.traverse(this.ast); 64 | } 65 | 66 | getAst() { 67 | return this.ast; 68 | } 69 | } 70 | 71 | module.exports = AstTraversal; 72 | -------------------------------------------------------------------------------- /build_support/buildForRemixIde.js: -------------------------------------------------------------------------------- 1 | const project = require('../project.js'); 2 | 3 | const aceVersionForRemixIde = 'v1.1.8'; 4 | 5 | function buildForRemixIde() { 6 | project.run('mkdir -p build/remix-ide'); 7 | project.run(`cp build/legacy/${aceVersionForRemixIde}/src-brace/mode-solidity.js build/remix-ide/mode-solidity.js`); 8 | } 9 | 10 | module.exports = buildForRemixIde; 11 | 12 | if (! module.parent) { 13 | buildForRemixIde(); 14 | } 15 | -------------------------------------------------------------------------------- /build_support/buildLegacy.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Re-created ACE build process for older versions <=1.2.3 3 | */ 4 | 5 | const path = require('path'); 6 | 7 | const download = require('download'); 8 | const readFilePromise = require('fs-readfile-promise'); 9 | const solveDependencies = require('dependency-solver').solve; 10 | 11 | const project = require('../project.js'); 12 | const stopBuild = require('./stopBuild.js'); 13 | const localAce = require('./localAceRepository.js'); 14 | const writeFile = require('./writeFile.js'); 15 | const parseRequires = require('./parseRequires.js'); 16 | const normalizeRequires = require('./normalizeRequires.js'); 17 | const ignoreCoreFileRequires = require('./ignoreCoreFileRequires.js'); 18 | const renderCode = require('./renderCode.js'); 19 | const getExportsSuffix = require('./getExportsSuffix.js'); 20 | 21 | // Build for older ACE versions, as far back as the code that was found in the 22 | // version of `mode-solidity.js` which was included with Remix IDE originally. 23 | // (I.e. ACE 1.1.8) 24 | const VERSIONS = [ 25 | // legacy versions 26 | 'v1.1.8', 'v1.1.9', 'v1.2.0', 'v1.2.1', 'v1.2.2', 'v1.2.3', 27 | // overlap with buildWithAce.js as a consistency check. 28 | 'v1.2.4', 'v1.2.5', 'v1.2.6', 'v1.2.7', 'v1.2.8', 'v1.2.9', 'v1.3.0', 29 | 'v1.3.1', 'v1.3.2', 'v1.3.3' 30 | ]; 31 | 32 | async function checkoutFile(fileId, gitTag) { 33 | localAce.createOrRefresh(); 34 | localAce.setVersion(gitTag, false); 35 | return (await readFilePromise(project.dir(`build_cache/ace/lib/${fileId}.js`))).toString('utf8'); 36 | } 37 | 38 | async function downloadFile(fileId, gitTag) { 39 | let url = `https://github.com/ajaxorg/ace/raw/${gitTag}/lib/${fileId}.js`; 40 | return (await download(url)).toString('utf8'); 41 | } 42 | 43 | async function loadFile(fileId, gitTag) { 44 | if ('ace/mode/solidity' == fileId) { 45 | return (await readFilePromise(project.dir('lib/ace/mode/solidity.js'))).toString('utf8'); 46 | } 47 | if ('ace/mode/solidity_highlight_rules' == fileId) { 48 | return (await readFilePromise(project.dir('lib/ace/mode/solidity_highlight_rules.js'))).toString('utf8'); 49 | } 50 | 51 | // return await downloadFile(fileId, gitTag); 52 | return await checkoutFile(fileId, gitTag); 53 | } 54 | 55 | class DependencyCollector { 56 | constructor(version) { 57 | this.version = version; 58 | this.deps = {}; 59 | this.depsIncludingCore = {}; 60 | } 61 | async collect(fileId) { 62 | if (this.deps[fileId]) { 63 | return; 64 | } 65 | let code = await loadFile(fileId, this.version); 66 | let requires; 67 | try { 68 | requires = parseRequires(code); 69 | } 70 | catch (err) { 71 | stopBuild('DependencyCollector parseRequires()', err, fileId, code, 14); 72 | } 73 | requires = normalizeRequires(fileId, requires); 74 | this.depsIncludingCore[fileId] = requires; 75 | this.deps[fileId] = ignoreCoreFileRequires(requires, this.version); 76 | for (let require of this.deps[fileId]) { 77 | await this.collect(require); 78 | } 79 | } 80 | async start(fileId) { 81 | await this.collect(fileId); 82 | } 83 | getDependencies() { 84 | return this.deps; 85 | } 86 | getDependenciesIncludingCore() { 87 | return this.depsIncludingCore; 88 | } 89 | } 90 | 91 | const varieties = [ 92 | { 93 | destination: 'src', 94 | defineNamespace: null, 95 | requireName: 'require' 96 | }, 97 | { 98 | destination: 'src-noconflict', 99 | defineNamespace: 'ace', 100 | requireName: 'require' 101 | }, 102 | { 103 | destination: 'src-brace', 104 | defineNamespace: 'ace', 105 | requireName: 'acequire' 106 | } 107 | ]; 108 | 109 | async function build(language, version) { 110 | let collector = new DependencyCollector(version); 111 | let mainFileId = `ace/mode/${language}`; 112 | await collector.start(mainFileId); 113 | let deps = collector.getDependencies(); 114 | let dependenciesIncludingCore = collector.getDependenciesIncludingCore(); 115 | let orderedFileIds = solveDependencies(deps); 116 | for (let variety of varieties) { 117 | let parts = []; 118 | for (let fileId of orderedFileIds) { 119 | let code = await loadFile(fileId, version); 120 | if (! dependenciesIncludingCore[fileId]) { 121 | stopBuild('buildLegacy() build() deficient dependenciesIncludingCore', language, version, variety, fileId, dependenciesIncludingCore, deps, orderedFileIds, 16); 122 | } 123 | code = renderCode(code, fileId, dependenciesIncludingCore[fileId], variety.defineNamespace, variety.requireName); 124 | parts.push(code); 125 | } 126 | let output = parts.join('\n\n') + '\n'; 127 | output += getExportsSuffix(version, mainFileId, variety.defineNamespace); 128 | let outputFilename = project.dir(`build/legacy/${version}/${variety.destination}/mode-${language}.js`); 129 | await writeFile(outputFilename, output); 130 | } 131 | } 132 | 133 | async function buildLegacy() { 134 | for (version of VERSIONS) { 135 | for (language of ['solidity', 'javascript']) { 136 | await build(language, version); 137 | } 138 | } 139 | } 140 | 141 | module.exports = buildLegacy; 142 | 143 | if (! module.parent) { 144 | buildLegacy(); 145 | } 146 | -------------------------------------------------------------------------------- /build_support/buildWithAce.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Inject solidity.js into ACE build process to package into mode-solidity.js . 3 | */ 4 | 5 | const fs = require('fs'); 6 | const path = require('path'); 7 | const { execSync } = require('child_process'); 8 | 9 | const semver = require('semver'); 10 | 11 | const project = require('../project.js'); 12 | const localAce = require('./localAceRepository.js'); 13 | 14 | // The oldest ACE version which builds on node v8.11.3: 15 | const OLDEST_ACE_VERSION = semver('1.2.4'); 16 | 17 | function loopOverAceVersions(aceVersions) { 18 | for (aceVersion of aceVersions) { 19 | build(aceVersion); 20 | } 21 | } 22 | 23 | function build(aceVersion) { 24 | console.log('#'.repeat(80)); 25 | console.log(`Start building ${aceVersion} .`); 26 | localAce.setVersion(aceVersion, true); 27 | project.run('node tool/add_mode.js Solidity "sol"', 'build_cache/ace'); 28 | project.run('cp lib/ace/mode/solidity* build_cache/ace/lib/ace/mode/'); 29 | project.run('./Makefile.dryice.js normal', 'build_cache/ace'); 30 | for (variety of ['src', 'src-noconflict', 'src-min', 'src-min-noconflict']) { 31 | project.run(`mkdir -p ./build/${aceVersion}/${variety}`); 32 | project.run(`cp ./build_cache/ace/build/${variety}/mode-solidity.js ./build/${aceVersion}/${variety}/`); 33 | project.run(`cp ./build_cache/ace/build/${variety}/mode-javascript.js ./build/${aceVersion}/${variety}/`); // To check for consistency with buildLegacy.js 34 | } 35 | console.log(`Finished building ${aceVersion} .`); 36 | console.log('#'.repeat(80)); 37 | } 38 | 39 | function buildWithAce() { 40 | localAce.createOrRefresh(); 41 | let aceVersions = localAce.getNewVersions(OLDEST_ACE_VERSION); 42 | console.log('ACE versions to build mode-solidity.js for:', aceVersions.join(', ')); 43 | loopOverAceVersions(aceVersions); 44 | } 45 | 46 | module.exports = buildWithAce; 47 | 48 | if (! module.parent) { 49 | buildWithAce(); 50 | } 51 | -------------------------------------------------------------------------------- /build_support/coreFilesByVersion.js: -------------------------------------------------------------------------------- 1 | const download = require('download'); 2 | const writeFilePromise = require('fs-writefile-promise'); 3 | 4 | const VERSIONS = [ 5 | // legacy versions 6 | 'v1.1.8', 'v1.1.9', 'v1.2.0', 'v1.2.1', 'v1.2.2', 'v1.2.3', 7 | // overlap with buildWithAce.js as a consistency check. 8 | 'v1.2.4', 'v1.2.5', 'v1.2.6', 'v1.2.7', 'v1.2.8', 'v1.2.9', 'v1.3.0', 9 | 'v1.3.1', 'v1.3.2', 'v1.3.3' 10 | ]; 11 | 12 | async function downloadCore(gitTag) { 13 | let url = `https://github.com/ajaxorg/ace-builds/raw/${gitTag}/src-noconflict/ace.js`; 14 | // let url = `https://github.com/ajaxorg/ace-builds/raw/${gitTag}/src-noconflict/mode-javascript.js`; 15 | return (await download(url)).toString('utf8'); 16 | } 17 | 18 | function findDefines(code) { 19 | let defines = Object.create(null); 20 | let match; 21 | // ace.define("ace/mode/doc_comment_highlight_rules",["require","exports","module","ace/lib/oop","ace/mode/text_highlight_rules"], function(require, exports, module) { 22 | let defineRe = /ace.define\("((?:\w|\/)+)",\["require","exports","module","((?:\w|\/|",")+)"\], function\(require, exports, module\) \{/g; 23 | while ((match = defineRe.exec(code)) !== null) { 24 | defines[match[1]] = JSON.parse(`["${match[2]}"]`); 25 | } 26 | 27 | // Pseudo-"empty" list of dependencies looks like this: 28 | // ace.define("ace/range",["require","exports","module"], function(require, exports, module) { 29 | defineRe = /ace.define\("((?:\w|\/)+)",\["require","exports","module"\], function\(require, exports, module\) \{/g; 30 | while ((match = defineRe.exec(code)) !== null) { 31 | defines[match[1]] = []; 32 | } 33 | 34 | // Beginning with 1.3.2 the list of dependencies is truly empty. Not even "require","exports","module" anymore. 35 | // ace.define("ace/mode/doc_comment_highlight_rules",[], function(require, exports, module) { 36 | defineRe = /ace.define\("((?:\w|\/)+)",\[\], function\(require, exports, module\) \{/g; 37 | while ((match = defineRe.exec(code)) !== null) { 38 | defines[match[1]] = []; 39 | } 40 | return defines; 41 | } 42 | 43 | async function run() { 44 | let coreFiles = Object.create(null); 45 | for (version of VERSIONS) { 46 | console.log(`Finding coreFiles of version ${version}.`) 47 | coreFiles[version] = findDefines(await downloadCore(version)); 48 | let count = Object.keys(coreFiles[version]).length; 49 | console.log(`Found ${count} coreFiles.`) 50 | } 51 | 52 | let jsonFileContents = JSON.stringify(coreFiles, null, 2); 53 | jsonFileContents += "\n"; // to satisfy `git diff` 54 | await writeFilePromise(__filename + 'on', jsonFileContents); 55 | } 56 | 57 | run(); 58 | -------------------------------------------------------------------------------- /build_support/exampleAst.js: -------------------------------------------------------------------------------- 1 | const recast = require('recast'); 2 | const readFilePromise = require('fs-readfile-promise'); 3 | const writeFilePromise = require('fs-writefile-promise'); 4 | 5 | const project = require('../project.js'); 6 | 7 | async function exampleAst(fileNameStem) { 8 | let code = await readFilePromise(project.dir(`lib/ace/mode/${fileNameStem}.js`)); 9 | let ast = recast.parse(code); 10 | let jsonFileContents = JSON.stringify(ast, null, 2); 11 | jsonFileContents += "\n"; // to satisfy `git diff` 12 | await writeFilePromise(project.dir(`build_cache/${fileNameStem}-ast.json`), jsonFileContents); 13 | } 14 | 15 | exampleAst('solidity'); 16 | exampleAst('solidity_highlight_rules'); 17 | -------------------------------------------------------------------------------- /build_support/getExportsSuffix.js: -------------------------------------------------------------------------------- 1 | const semver = require('semver'); 2 | 3 | function codeTemplate(defineNamespace, fileId, codeExportsTest) { 4 | // The awkward whitespace formatting is to satisfy `git diff`. 5 | return ( 6 | ` (function() { 7 | ${defineNamespace}.require(["${fileId}"], function(m) { 8 | if (typeof module == "object"${codeExportsTest}) { 9 | module.exports = m; 10 | } 11 | }); 12 | })(); 13 | ` 14 | ); 15 | } 16 | 17 | /** 18 | * Add module.exports suffix as in the original ACE build process, >=1.3.2 . 19 | */ 20 | function getExportsSuffix(version, fileId, defineNamespace) { 21 | version = semver.coerce(version); 22 | if (semver.lt(version, semver('1.3.2'))) { 23 | return ''; 24 | } 25 | defineNamespace = defineNamespace ? defineNamespace : 'window'; 26 | codeExportsTest = semver.gte(version, semver('1.3.3')) ? ' && typeof exports == "object" && module' : ''; 27 | let suffix = codeTemplate(defineNamespace, fileId, codeExportsTest); 28 | return suffix; 29 | } 30 | 31 | module.exports = getExportsSuffix; 32 | -------------------------------------------------------------------------------- /build_support/ignoreCoreFileRequires.js: -------------------------------------------------------------------------------- 1 | const coreFilesByVersion = require('./coreFilesByVersion.json'); 2 | 3 | function ignoreCoreFileRequires(requires, version) { 4 | let coreFiles = coreFilesByVersion[version]; 5 | let nonCoreFiles = []; 6 | for (let require of requires) { 7 | if (! coreFiles[require]) 8 | nonCoreFiles.push(require); 9 | } 10 | return nonCoreFiles; 11 | } 12 | 13 | module.exports = ignoreCoreFileRequires; 14 | -------------------------------------------------------------------------------- /build_support/localAceRepository.js: -------------------------------------------------------------------------------- 1 | const fs = require('fs'); 2 | const path = require('path'); 3 | const { execSync } = require('child_process'); 4 | 5 | const semver = require('semver'); 6 | 7 | const project = require('../project.js'); 8 | 9 | function git(subCommand) { 10 | return project.run('git ' + subCommand, 'build_cache/ace'); 11 | } 12 | 13 | let createdDuringThisScriptRun = false; 14 | 15 | function createOrRefresh(force) { 16 | if (createdDuringThisScriptRun && ! force) { 17 | return; 18 | } 19 | try { 20 | fs.accessSync(project.dir('build_cache/ace'), fs.constants.R_OK | fs.constants.W_OK); 21 | git('fetch --all'); 22 | // git('pull --all'); 23 | } catch (err) { 24 | // console.log(err); 25 | project.run('git clone git@github.com:ajaxorg/ace.git ./build_cache/ace'); 26 | } 27 | createdDuringThisScriptRun = true; 28 | } 29 | 30 | function getAllVersions() { 31 | let gitTags = git('tag -l').split('\n').map(x => x.trim()).filter(Boolean); 32 | gitTags = gitTags.filter(gitTag => { 33 | let cleanVersion = semver.coerce(gitTag); 34 | cleanVersion = cleanVersion ? cleanVersion : semver.coerce('0.0.0'); 35 | return ( 36 | (gitTag == 'v' + cleanVersion.toString()) // exclude things like "cloud9" 37 | ); 38 | }); 39 | return gitTags; 40 | } 41 | 42 | function getNewVersions(oldestVersion) { 43 | return ( 44 | getAllVersions() 45 | .filter(gitTag => { 46 | return semver.gte(semver.coerce(gitTag), oldestVersion); 47 | }) 48 | .sort(semver.rcompare) 49 | ); 50 | } 51 | 52 | let lastVersionSetDuringThisScriptRun = null; 53 | 54 | function setVersion(gitTag, install, force) { 55 | if ( 56 | (! force) 57 | && 58 | (gitTag == lastVersionSetDuringThisScriptRun) 59 | ) { 60 | return; 61 | } 62 | project.run('rm -rf ./build/*', 'build_cache/ace'); 63 | project.run('rm -rf ./package-lock.json', 'build_cache/ace'); 64 | project.run('rm -rf ./tool/package-lock.json', 'build_cache/ace'); 65 | git('checkout -- .'); 66 | git('clean -ffd'); 67 | git(`checkout ${gitTag}`); 68 | if (install) { 69 | project.run('npm install', 'build_cache/ace'); 70 | project.run('npm install', 'build_cache/ace/tool'); 71 | } 72 | lastVersionSetDuringThisScriptRun = gitTag; 73 | } 74 | 75 | module.exports = { git, createOrRefresh, getAllVersions, getNewVersions, setVersion }; 76 | -------------------------------------------------------------------------------- /build_support/normalizeRequires.js: -------------------------------------------------------------------------------- 1 | const path = require('path'); 2 | 3 | function normalizeRequires(fileId, requires) { 4 | let dir = path.dirname(fileId); 5 | let normalized = []; 6 | for (let require of requires) { 7 | normalized.push(path.join(dir, require)); 8 | } 9 | return normalized; 10 | } 11 | 12 | module.exports = normalizeRequires; 13 | -------------------------------------------------------------------------------- /build_support/parseRequires.js: -------------------------------------------------------------------------------- 1 | const recast = require('recast'); 2 | const AstTraversal = require('./astTraversal.js'); 3 | 4 | function parseRequires(code) { 5 | let requires = []; 6 | let ast = recast.parse(code); 7 | let traversal = new AstTraversal(ast); 8 | traversal.on("CallExpression", (node, stack, ast) => { 9 | if ( 10 | ('Identifier' == node.callee.type) 11 | && 12 | ('require' == node.callee.name) 13 | && 14 | (1 === node.arguments.length) 15 | && 16 | ('Literal' === node.arguments[0].type) 17 | && 18 | ('string' === typeof node.arguments[0].value) 19 | ) { 20 | requires.push(node.arguments[0].value); 21 | } 22 | }); 23 | traversal.start(); 24 | return requires; 25 | } 26 | 27 | module.exports = parseRequires; 28 | -------------------------------------------------------------------------------- /build_support/renderCode.js: -------------------------------------------------------------------------------- 1 | const recast = require('recast'); 2 | const recastBuilders = recast.types.builders; 3 | 4 | const AstTraversal = require('./astTraversal.js'); 5 | const stopBuild = require('./stopBuild.js'); 6 | 7 | /** 8 | * Remove comments with the same RegExp as in the original ACE build process. 9 | * 10 | * Copied from build_cache/ace/node_modules/architect-build/module-deps.js 11 | * @see https://www.npmjs.com/package/architect-build/v/0.1.0 12 | * @see https://github.com/c9/architect-build/blob/17268dce6559e05548b53143a91a9d83d0e19e40/module-deps.js#L348 13 | */ 14 | function removeLicenceComments(code) { 15 | return code.replace(/(?:(;)|\n|^)\s*\/\*[\d\D]*?\*\/|(\n|^)\s*\/\/.*/g, "$1"); 16 | } 17 | 18 | /** 19 | * Adjust whitespace in AST pretty printer output to satisfy `git diff`. 20 | * 21 | * Until I figured out how to configure the AST pretty printer, we have to make 22 | * do with a RegExp solution. 23 | */ 24 | function fixWhitespaceInDefineCall(code) { 25 | let isDefineCallLineRe = /^(\w+\.)?define\(.*function\(\w+, exports, module\) \{$/g; 26 | let lines = code.split('\n'); 27 | let lineIndex = 0; 28 | for (line of lines) { 29 | if (isDefineCallLineRe.test(line)) { 30 | line = line.replace(/", \["/g, '",["'); 31 | line = line.replace(/", "/g, '","'); 32 | lines[lineIndex] = line; 33 | } 34 | } 35 | return lines.join('\n'); 36 | } 37 | 38 | function renderCode(code, fileId, dependenciesIncludingCore, defineNamespace, requireName) { 39 | requireName = requireName ? requireName : 'require'; 40 | let defineCalleeNode; 41 | if (defineNamespace) { 42 | defineCalleeNode = recastBuilders.memberExpression( 43 | recastBuilders.identifier(defineNamespace), 44 | recastBuilders.identifier('define'), 45 | false 46 | ); 47 | } 48 | let fileIdNode = recastBuilders.literal(fileId); 49 | let singleDepsNodes = []; 50 | for (dep of ['require', 'exports', 'module']) { 51 | singleDepsNodes.push(recastBuilders.literal(dep)); 52 | } 53 | try { 54 | for (dep of dependenciesIncludingCore) { 55 | singleDepsNodes.push(recastBuilders.literal(dep)); 56 | } 57 | } 58 | catch (err) { 59 | stopBuild('renderCode dependenciesIncludingCore', err, fileId, dependenciesIncludingCore, 17); 60 | } 61 | let depsNode = recastBuilders.arrayExpression(singleDepsNodes); 62 | code = removeLicenceComments(code).trim(); 63 | let ast; 64 | try { 65 | ast = recast.parse(code); 66 | } 67 | catch (err) { 68 | stopBuild('renderCode recast.parse()', err, fileId, dependenciesIncludingCore, defineNamespace, requireName, code, 13); 69 | } 70 | let traversal = new AstTraversal(ast); 71 | 72 | // Transform `define()` function call. 73 | traversal.on('CallExpression', (node, stack, ast) => { 74 | if ( 75 | ('Identifier' == node.callee.type) 76 | && 77 | ('define' == node.callee.name) 78 | ) { 79 | if ( 80 | (1 !== node.arguments.length) 81 | || 82 | ('FunctionExpression' !== node.arguments[0].type) 83 | || 84 | (null !== node.arguments[0].id) 85 | || 86 | ('Identifier' !== node.arguments[0].params[0].type) 87 | ) { 88 | stopBuild('AST traversal: Unable to process call to `define()`:', fileId, dependenciesIncludingCore, defineNamespace, requireName, 12); 89 | } 90 | // Rename `require()` function like in https://www.npmjs.com/package/brace 91 | // Here we rename the definition of `require()`. 92 | node.arguments[0].params[0].name = requireName; 93 | 94 | // Add namespace to `define()` function call. 95 | if (defineCalleeNode) { 96 | node.callee = defineCalleeNode; 97 | } 98 | 99 | // Add extra arguments to `define()` function call. 100 | node.arguments.unshift(fileIdNode, depsNode); 101 | } 102 | }); 103 | 104 | // Rename `require()` function like in https://www.npmjs.com/package/brace 105 | // Here we rename all function calls for `require()`. 106 | traversal.on('CallExpression', (node, stack, ast) => { 107 | if ( 108 | ('Identifier' == node.callee.type) 109 | && 110 | ('require' == node.callee.name) 111 | ) { 112 | if ( 113 | (1 !== node.arguments.length) 114 | || 115 | ('Literal' !== node.arguments[0].type) 116 | || 117 | ('string' !== typeof node.arguments[0].value) 118 | ) { 119 | throw Error('Unable to process call to `require()`.'); 120 | } 121 | node.callee.name = requireName; 122 | } 123 | }); 124 | 125 | 126 | traversal.start(); 127 | 128 | // This should only affect printing of modified AST nodes. 129 | let recastPrintOptions = { 130 | wrapColumn: 10 * 1024 // Allow really long lines for `define()` calls. 131 | }; 132 | 133 | let newCode = recast.print(traversal.getAst(), recastPrintOptions).code; 134 | newCode = fixWhitespaceInDefineCall(newCode); 135 | return newCode; 136 | } 137 | 138 | module.exports = renderCode; 139 | -------------------------------------------------------------------------------- /build_support/stopBuild.js: -------------------------------------------------------------------------------- 1 | 2 | 3 | function stopBuild(...reasons) { 4 | console.log('#'.repeat(80)); 5 | let stackHandle = {}; 6 | Error.captureStackTrace(stackHandle, stopBuild); 7 | console.log(stackHandle.stack); 8 | for (let reason of reasons) { 9 | console.log(reason); 10 | } 11 | console.log('#'.repeat(80)); 12 | let lastReason = reasons.pop(); 13 | process.exit(Number.isInteger(lastReason) ? lastReason : 1); 14 | } 15 | 16 | module.exports = stopBuild; 17 | -------------------------------------------------------------------------------- /build_support/writeFile.js: -------------------------------------------------------------------------------- 1 | const path = require('path'); 2 | 3 | const writeFilePromise = require('fs-writefile-promise'); 4 | const mkdirp = require('mkdirp-promise'); 5 | 6 | async function writeFile(name, contents) { 7 | await mkdirp(path.dirname(name)); 8 | await writeFilePromise(name, contents); 9 | } 10 | 11 | module.exports = writeFile; 12 | -------------------------------------------------------------------------------- /lib/ace/mode/solidity.js: -------------------------------------------------------------------------------- 1 | define(function(require, exports, module) { 2 | "use strict"; 3 | 4 | var oop = require("../lib/oop"); 5 | var TextMode = require("./text").Mode; 6 | var SolidityHighlightRules = require("./solidity_highlight_rules").SolidityHighlightRules; 7 | var MatchingBraceOutdent = require("./matching_brace_outdent").MatchingBraceOutdent; 8 | var Range = require("../range").Range; 9 | var WorkerClient = require("../worker/worker_client").WorkerClient; 10 | var CstyleBehaviour = require("./behaviour/cstyle").CstyleBehaviour; 11 | var CStyleFoldMode = require("./folding/cstyle").FoldMode; 12 | 13 | var Mode = function() { 14 | this.HighlightRules = SolidityHighlightRules; 15 | 16 | this.$outdent = new MatchingBraceOutdent(); 17 | this.$behaviour = new CstyleBehaviour(); 18 | this.foldingRules = new CStyleFoldMode(); 19 | }; 20 | oop.inherits(Mode, TextMode); 21 | 22 | (function() { 23 | 24 | this.lineCommentStart = "//"; 25 | this.blockComment = {start: "/*", end: "*/"}; 26 | 27 | this.getNextLineIndent = function(state, line, tab) { 28 | var indent = this.$getIndent(line); 29 | 30 | var tokenizedLine = this.getTokenizer().getLineTokens(line, state); 31 | var tokens = tokenizedLine.tokens; 32 | var endState = tokenizedLine.state; 33 | 34 | if (tokens.length && tokens[tokens.length-1].type == "comment") { 35 | return indent; 36 | } 37 | 38 | if (state == "start") { 39 | var match = line.match(/^.*(?:\bcase\b.*\:|[\{\(\[])\s*$/); 40 | if (match) { 41 | indent += tab; 42 | } 43 | } else if (state == "doc_comment") { 44 | if (endState == "start") { 45 | return ""; 46 | } 47 | var match = line.match(/^\s*(\/?)\*/); 48 | if (match) { 49 | if (match[1]) { 50 | indent += " "; 51 | } 52 | indent += "* "; 53 | } 54 | } 55 | 56 | return indent; 57 | }; 58 | 59 | this.checkOutdent = function(state, line, input) { 60 | return this.$outdent.checkOutdent(line, input); 61 | }; 62 | 63 | this.autoOutdent = function(state, doc, row) { 64 | this.$outdent.autoOutdent(doc, row); 65 | }; 66 | 67 | // this.createWorker = function(session) { 68 | // var worker = new WorkerClient(["ace"], "ace/mode/solidity_worker", "SolidityWorker"); 69 | // worker.attachToDocument(session.getDocument()); 70 | // 71 | // worker.on("jslint", function(results) { 72 | // session.setAnnotations(results.data); 73 | // }); 74 | // 75 | // worker.on("terminate", function() { 76 | // session.clearAnnotations(); 77 | // }); 78 | // 79 | // return worker; 80 | // }; 81 | 82 | this.$id = "ace/mode/solidity"; 83 | }).call(Mode.prototype); 84 | 85 | exports.Mode = Mode; 86 | }); 87 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "ace-mode-solidity", 3 | "version": "0.1.1", 4 | "description": "Ace Edit Mode for Ethereum's Solidity language.", 5 | "browser": "build/remix-ide/mode-solidity.js", 6 | "scripts": { 7 | "test-build": "node ./test_browserify/build.js", 8 | "test-overwrite": "npm run test-build && node ./test_browserify/overwrite-expected-tokenizations.js", 9 | "test-serve": "npm run test-build && node ./test_browserify/serve-editor.js", 10 | "test": "npm run test-build && node ./test_browserify/run.js", 11 | "reports-prep": "npm run test-build && node ./test_browserify/reports-prep.js", 12 | "reports-serve": "node ./test_browserify/reports-serve.js", 13 | "reports": "npm run reports-prep && node ./test_browserify/reports-serve.js" 14 | }, 15 | "repository": { 16 | "type": "git", 17 | "url": "git+https://github.com/raphaelhuefner/ace-mode-solidity.git" 18 | }, 19 | "keywords": [ 20 | "ace", 21 | "edit", 22 | "mode", 23 | "syntax", 24 | "highlighting", 25 | "ethereum", 26 | "solidity" 27 | ], 28 | "author": { 29 | "name": "Raphael Huefner", 30 | "email": "raphaelhuefner@gmail.com", 31 | "url": "https://rh.io" 32 | }, 33 | "license": "MIT", 34 | "bugs": { 35 | "url": "https://github.com/raphaelhuefner/ace-mode-solidity/issues" 36 | }, 37 | "homepage": "https://github.com/raphaelhuefner/ace-mode-solidity#readme", 38 | "dependencies": {}, 39 | "devDependencies": { 40 | "ast-types": "^0.11.5", 41 | "brace": "^0.8.0", 42 | "browserify": "^16.1.0", 43 | "dependency-solver": "^1.0.6", 44 | "download": "^7.1.0", 45 | "enumerate-files": "^2.0.0", 46 | "express": "^4.16.3", 47 | "fs-readfile-promise": "^3.0.1", 48 | "fs-writefile-promise": "^3.0.0", 49 | "mkdirp": "^0.5.1", 50 | "mkdirp-promise": "^5.0.1", 51 | "opn": "^5.3.0", 52 | "puppeteer": "^1.5.0", 53 | "recast": "^0.15.2", 54 | "semver": "^5.5.0", 55 | "tape": "^4.9.1" 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /project.js: -------------------------------------------------------------------------------- 1 | const path = require('path'); 2 | const { execSync } = require('child_process'); 3 | 4 | const PROJECTDIR = __dirname; 5 | 6 | function dir(relativePath) { 7 | return path.join(PROJECTDIR, relativePath); 8 | } 9 | 10 | function run(commandLine, workingDir = '') { 11 | let options = { 12 | encoding: 'utf-8', 13 | cwd: dir(workingDir) 14 | }; 15 | return execSync(commandLine, options); 16 | } 17 | 18 | module.exports = { dir, run }; 19 | -------------------------------------------------------------------------------- /remix-ide: -------------------------------------------------------------------------------- 1 | build/remix-ide/ -------------------------------------------------------------------------------- /test_browserify/.gitignore: -------------------------------------------------------------------------------- 1 | node_modules/ 2 | -------------------------------------------------------------------------------- /test_browserify/build.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | const fs = require('fs'); 3 | const browserify = require('browserify'); 4 | const writeFilePromise = require('fs-writefile-promise'); 5 | const collectSoliditySnippets = require('./collect-solidity-snippets.js'); 6 | 7 | async function writeSoliditySnippets() { 8 | let soliditySnippets = await collectSoliditySnippets(); 9 | await writeFilePromise(__dirname + '/cache/solidity-snippets.js', soliditySnippets); 10 | } 11 | 12 | async function build() { 13 | await writeSoliditySnippets(); 14 | 15 | let browserify_opts = { 16 | debug: true, 17 | bare: true, 18 | basedir: __dirname 19 | } 20 | 21 | browserify(browserify_opts) 22 | .require(require.resolve('./cache/solidity-snippets.js'), { basedir: __dirname }) 23 | .require(require.resolve('../build/remix-ide/mode-solidity.js'), { basedir: __dirname }) 24 | .require(require.resolve('./src/solidity-editor.js'), { entry: true, basedir: __dirname }) 25 | 26 | .bundle() 27 | .pipe(fs.createWriteStream(__dirname + '/cache/bundle.js')); 28 | } 29 | 30 | build(); 31 | -------------------------------------------------------------------------------- /test_browserify/cache/.gitignore: -------------------------------------------------------------------------------- 1 | * 2 | !.gitignore 3 | -------------------------------------------------------------------------------- /test_browserify/collect-solidity-snippets.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | const path = require('path'); 3 | const enumerateFiles = require('enumerate-files'); 4 | const readFilePromise = require('fs-readfile-promise'); 5 | 6 | const DATADIR = __dirname + '/data'; 7 | 8 | 9 | async function solFilesToModuleCode(solFileNames) { 10 | let solCodeCollection = {}; 11 | for (let solFileName of solFileNames) { 12 | let solCode = await readFilePromise(solFileName); 13 | let name = path.basename(solFileName, '.sol'); 14 | solCodeCollection[name] = solCode.toString(); 15 | } 16 | return 'module.exports = ' + JSON.stringify(solCodeCollection, null, 2) + ';'; 17 | } 18 | 19 | async function collectSolCode() { 20 | let files = Array.from(await enumerateFiles(DATADIR)); 21 | let solFileNames = files.filter(file => /\.sol$/.test(file)); 22 | return await solFilesToModuleCode(solFileNames); 23 | } 24 | 25 | module.exports = collectSolCode 26 | -------------------------------------------------------------------------------- /test_browserify/data/Block.json: -------------------------------------------------------------------------------- 1 | [ 2 | [ 3 | { 4 | "type": "comment.line.double-slash", 5 | "value": "// Block = '{' Statement* '}'" 6 | } 7 | ], 8 | [ 9 | { 10 | "type": "paren.lparen", 11 | "value": "{" 12 | }, 13 | { 14 | "type": "paren.rparen", 15 | "value": "}" 16 | } 17 | ], 18 | [], 19 | [ 20 | { 21 | "type": "paren.lparen", 22 | "value": "{" 23 | } 24 | ], 25 | [ 26 | { 27 | "type": "text", 28 | "value": " " 29 | } 30 | ], 31 | [ 32 | { 33 | "type": "paren.rparen", 34 | "value": "}" 35 | } 36 | ], 37 | [], 38 | [ 39 | { 40 | "type": "paren.lparen", 41 | "value": "{" 42 | } 43 | ], 44 | [ 45 | { 46 | "type": "text", 47 | "value": " " 48 | }, 49 | { 50 | "type": "storage.type", 51 | "value": "uint256" 52 | }, 53 | { 54 | "type": "text", 55 | "value": " " 56 | }, 57 | { 58 | "type": "identifier", 59 | "value": "a" 60 | }, 61 | { 62 | "type": "text", 63 | "value": " " 64 | }, 65 | { 66 | "type": "keyword.operator", 67 | "value": "=" 68 | }, 69 | { 70 | "type": "text", 71 | "value": " " 72 | }, 73 | { 74 | "type": "constant.numeric", 75 | "value": "0" 76 | }, 77 | { 78 | "type": "punctuation.operator", 79 | "value": ";" 80 | } 81 | ], 82 | [ 83 | { 84 | "type": "paren.rparen", 85 | "value": "}" 86 | } 87 | ], 88 | [], 89 | [ 90 | { 91 | "type": "paren.lparen", 92 | "value": "{" 93 | } 94 | ], 95 | [ 96 | { 97 | "type": "text", 98 | "value": " " 99 | }, 100 | { 101 | "type": "storage.type", 102 | "value": "uint256" 103 | }, 104 | { 105 | "type": "text", 106 | "value": " " 107 | }, 108 | { 109 | "type": "identifier", 110 | "value": "a" 111 | }, 112 | { 113 | "type": "text", 114 | "value": " " 115 | }, 116 | { 117 | "type": "keyword.operator", 118 | "value": "=" 119 | }, 120 | { 121 | "type": "text", 122 | "value": " " 123 | }, 124 | { 125 | "type": "constant.numeric", 126 | "value": "0" 127 | }, 128 | { 129 | "type": "punctuation.operator", 130 | "value": ";" 131 | } 132 | ], 133 | [ 134 | { 135 | "type": "text", 136 | "value": " " 137 | }, 138 | { 139 | "type": "storage.type", 140 | "value": "uint256" 141 | }, 142 | { 143 | "type": "text", 144 | "value": " " 145 | }, 146 | { 147 | "type": "identifier", 148 | "value": "b" 149 | }, 150 | { 151 | "type": "text", 152 | "value": " " 153 | }, 154 | { 155 | "type": "keyword.operator", 156 | "value": "=" 157 | }, 158 | { 159 | "type": "text", 160 | "value": " " 161 | }, 162 | { 163 | "type": "constant.numeric", 164 | "value": "1" 165 | }, 166 | { 167 | "type": "punctuation.operator", 168 | "value": ";" 169 | } 170 | ], 171 | [ 172 | { 173 | "type": "paren.rparen", 174 | "value": "}" 175 | } 176 | ], 177 | [], 178 | [ 179 | { 180 | "type": "paren.lparen", 181 | "value": "{" 182 | } 183 | ], 184 | [ 185 | { 186 | "type": "text", 187 | "value": " " 188 | }, 189 | { 190 | "type": "storage.type", 191 | "value": "uint256" 192 | }, 193 | { 194 | "type": "text", 195 | "value": " " 196 | }, 197 | { 198 | "type": "identifier", 199 | "value": "a" 200 | }, 201 | { 202 | "type": "text", 203 | "value": " " 204 | }, 205 | { 206 | "type": "keyword.operator", 207 | "value": "=" 208 | }, 209 | { 210 | "type": "text", 211 | "value": " " 212 | }, 213 | { 214 | "type": "constant.numeric", 215 | "value": "0" 216 | }, 217 | { 218 | "type": "punctuation.operator", 219 | "value": ";" 220 | } 221 | ], 222 | [ 223 | { 224 | "type": "text", 225 | "value": " " 226 | }, 227 | { 228 | "type": "storage.type", 229 | "value": "uint256" 230 | }, 231 | { 232 | "type": "text", 233 | "value": " " 234 | }, 235 | { 236 | "type": "identifier", 237 | "value": "b" 238 | }, 239 | { 240 | "type": "text", 241 | "value": " " 242 | }, 243 | { 244 | "type": "keyword.operator", 245 | "value": "=" 246 | }, 247 | { 248 | "type": "text", 249 | "value": " " 250 | }, 251 | { 252 | "type": "constant.numeric", 253 | "value": "1" 254 | }, 255 | { 256 | "type": "punctuation.operator", 257 | "value": ";" 258 | } 259 | ], 260 | [ 261 | { 262 | "type": "text", 263 | "value": " " 264 | }, 265 | { 266 | "type": "storage.type", 267 | "value": "uint256" 268 | }, 269 | { 270 | "type": "text", 271 | "value": " " 272 | }, 273 | { 274 | "type": "identifier", 275 | "value": "c" 276 | }, 277 | { 278 | "type": "text", 279 | "value": " " 280 | }, 281 | { 282 | "type": "keyword.operator", 283 | "value": "=" 284 | }, 285 | { 286 | "type": "text", 287 | "value": " " 288 | }, 289 | { 290 | "type": "constant.numeric", 291 | "value": "2" 292 | }, 293 | { 294 | "type": "punctuation.operator", 295 | "value": ";" 296 | } 297 | ], 298 | [ 299 | { 300 | "type": "paren.rparen", 301 | "value": "}" 302 | } 303 | ], 304 | [] 305 | ] 306 | -------------------------------------------------------------------------------- /test_browserify/data/Block.sol: -------------------------------------------------------------------------------- 1 | // Block = '{' Statement* '}' 2 | {} 3 | 4 | { 5 | 6 | } 7 | 8 | { 9 | uint256 a = 0; 10 | } 11 | 12 | { 13 | uint256 a = 0; 14 | uint256 b = 1; 15 | } 16 | 17 | { 18 | uint256 a = 0; 19 | uint256 b = 1; 20 | uint256 c = 2; 21 | } 22 | -------------------------------------------------------------------------------- /test_browserify/data/Comments.json: -------------------------------------------------------------------------------- 1 | [ 2 | [ 3 | { 4 | "type": "comment.line.double-slash", 5 | "value": "// https://solidity.readthedocs.io/en/develop/layout-of-source-files.html#comments" 6 | } 7 | ], 8 | [], 9 | [ 10 | { 11 | "type": "comment.line.double-slash", 12 | "value": "// Single-line comment" 13 | } 14 | ], 15 | [], 16 | [ 17 | { 18 | "type": "comment.block", 19 | "value": "/* Asterisk comment */" 20 | } 21 | ], 22 | [], 23 | [ 24 | { 25 | "type": "comment.block", 26 | "value": "/*" 27 | } 28 | ], 29 | [ 30 | { 31 | "type": "comment.block", 32 | "value": " * Multi-line comment" 33 | } 34 | ], 35 | [ 36 | { 37 | "type": "comment.block", 38 | "value": " */" 39 | } 40 | ], 41 | [], 42 | [ 43 | { 44 | "type": "comment.line.double-slash", 45 | "value": "// WIP markers:" 46 | } 47 | ], 48 | [ 49 | { 50 | "type": "comment.line.double-slash", 51 | "value": "// " 52 | }, 53 | { 54 | "type": "comment.line.doc.documentation.tag.storage.type", 55 | "value": "TODO" 56 | } 57 | ], 58 | [ 59 | { 60 | "type": "comment.line.double-slash", 61 | "value": "// " 62 | }, 63 | { 64 | "type": "comment.line.doc.documentation.tag.storage.type", 65 | "value": "FIXME" 66 | } 67 | ], 68 | [ 69 | { 70 | "type": "comment.line.double-slash", 71 | "value": "// " 72 | }, 73 | { 74 | "type": "comment.line.doc.documentation.tag.storage.type", 75 | "value": "XXX" 76 | } 77 | ], 78 | [ 79 | { 80 | "type": "comment.line.double-slash", 81 | "value": "// " 82 | }, 83 | { 84 | "type": "comment.line.doc.documentation.tag.storage.type", 85 | "value": "HACK" 86 | } 87 | ], 88 | [], 89 | [ 90 | { 91 | "type": "comment.block", 92 | "value": "/*" 93 | } 94 | ], 95 | [ 96 | { 97 | "type": "comment.block", 98 | "value": " * WIP markers:" 99 | } 100 | ], 101 | [ 102 | { 103 | "type": "comment.block", 104 | "value": " * " 105 | }, 106 | { 107 | "type": "comment.block.doc.documentation.tag.storage.type", 108 | "value": "TODO" 109 | } 110 | ], 111 | [ 112 | { 113 | "type": "comment.block", 114 | "value": " * " 115 | }, 116 | { 117 | "type": "comment.block.doc.documentation.tag.storage.type", 118 | "value": "FIXME" 119 | } 120 | ], 121 | [ 122 | { 123 | "type": "comment.block", 124 | "value": " * " 125 | }, 126 | { 127 | "type": "comment.block.doc.documentation.tag.storage.type", 128 | "value": "XXX" 129 | } 130 | ], 131 | [ 132 | { 133 | "type": "comment.block", 134 | "value": " * " 135 | }, 136 | { 137 | "type": "comment.block.doc.documentation.tag.storage.type", 138 | "value": "HACK" 139 | } 140 | ], 141 | [ 142 | { 143 | "type": "comment.block", 144 | "value": " */" 145 | } 146 | ], 147 | [] 148 | ] 149 | -------------------------------------------------------------------------------- /test_browserify/data/Comments.sol: -------------------------------------------------------------------------------- 1 | // https://solidity.readthedocs.io/en/develop/layout-of-source-files.html#comments 2 | 3 | // Single-line comment 4 | 5 | /* Asterisk comment */ 6 | 7 | /* 8 | * Multi-line comment 9 | */ 10 | 11 | // WIP markers: 12 | // TODO 13 | // FIXME 14 | // XXX 15 | // HACK 16 | 17 | /* 18 | * WIP markers: 19 | * TODO 20 | * FIXME 21 | * XXX 22 | * HACK 23 | */ 24 | -------------------------------------------------------------------------------- /test_browserify/data/ContractDefinition.sol: -------------------------------------------------------------------------------- 1 | // ContractDefinition = ( 'contract' | 'library' | 'interface' ) Identifier 2 | // ( 'is' InheritanceSpecifier (',' InheritanceSpecifier )* )? 3 | // '{' ContractPart* '}' 4 | 5 | contract EmptyOneLiner {} 6 | 7 | // https://en.wikipedia.org/wiki/Indentation_style#Variant:_1TBS_(OTBS) 8 | contract EmptyOneTrueBraceStyle { 9 | } 10 | 11 | // https://en.wikipedia.org/wiki/Indentation_style#Allman_style 12 | contract EmptyAllmanBraceStyle 13 | { 14 | } 15 | 16 | library Alexandria { 17 | } 18 | 19 | interface OECD { 20 | } 21 | 22 | contract Inheriting is Inheritable { 23 | } 24 | 25 | contract MultipleInheritance is Awesome, Multiple, Inheritable { 26 | } 27 | 28 | // (see https://solidity.readthedocs.io/en/develop/contracts.html#libraries ) 29 | // Restrictions for libraries in comparison to contracts: 30 | // - No state variables 31 | // - Cannot inherit nor be inherited 32 | // - Cannot receive Ether 33 | // (These might be lifted at a later point.) 34 | library BetterBeenDecentralized is Alexandria, Ashurbanipal, Aksum { 35 | } 36 | 37 | // constructor (not in grammar.txt) 38 | // But see https://solidity.readthedocs.io/en/develop/contracts.html#constructors 39 | // Also see following inheritance section for base constructors as "modifiers" for 40 | // the current constructor. 41 | contract Constructed { 42 | bytes32 name; 43 | constructor(bytes32 _name) public { 44 | name = _name; 45 | } 46 | } 47 | 48 | // InheritanceSpecifier = UserDefinedTypeName ( '(' Expression ( ',' Expression )* ')' )? 49 | // The above expression(s) ^^ is/are a way to specify arguments for base contructors. 50 | // See https://solidity.readthedocs.io/en/develop/contracts.html#arguments-for-base-constructors 51 | contract Base { 52 | uint x; 53 | constructor(uint _x) public { x = _x; } 54 | } 55 | 56 | contract Derived1 is Base(7) { 57 | constructor(uint _y) public {} 58 | } 59 | 60 | contract Derived2 is Base { 61 | constructor(uint _y) Base(_y * _y) public {} 62 | } 63 | -------------------------------------------------------------------------------- /test_browserify/data/DoWhileStatement.json: -------------------------------------------------------------------------------- 1 | [ 2 | [ 3 | { 4 | "type": "comment.line.double-slash", 5 | "value": "// DoWhileStatement = 'do' Statement 'while' '(' Expression ')'" 6 | } 7 | ], 8 | [ 9 | { 10 | "type": "keyword.control", 11 | "value": "do" 12 | }, 13 | { 14 | "type": "text", 15 | "value": " " 16 | }, 17 | { 18 | "type": "paren.lparen", 19 | "value": "{" 20 | }, 21 | { 22 | "type": "paren.rparen", 23 | "value": "}" 24 | }, 25 | { 26 | "type": "text", 27 | "value": " " 28 | }, 29 | { 30 | "type": "keyword.control", 31 | "value": "while" 32 | }, 33 | { 34 | "type": "text", 35 | "value": " " 36 | }, 37 | { 38 | "type": "paren.lparen", 39 | "value": "(" 40 | }, 41 | { 42 | "type": "constant.language.boolean", 43 | "value": "true" 44 | }, 45 | { 46 | "type": "paren.rparen", 47 | "value": ")" 48 | }, 49 | { 50 | "type": "punctuation.operator", 51 | "value": ";" 52 | } 53 | ], 54 | [ 55 | { 56 | "type": "keyword.control", 57 | "value": "do" 58 | }, 59 | { 60 | "type": "text", 61 | "value": " " 62 | }, 63 | { 64 | "type": "identifier", 65 | "value": "nothing" 66 | }, 67 | { 68 | "type": "paren.lparen", 69 | "value": "(" 70 | }, 71 | { 72 | "type": "paren.rparen", 73 | "value": ")" 74 | }, 75 | { 76 | "type": "punctuation.operator", 77 | "value": ";" 78 | }, 79 | { 80 | "type": "text", 81 | "value": " " 82 | }, 83 | { 84 | "type": "keyword.control", 85 | "value": "while" 86 | }, 87 | { 88 | "type": "text", 89 | "value": " " 90 | }, 91 | { 92 | "type": "paren.lparen", 93 | "value": "(" 94 | }, 95 | { 96 | "type": "constant.language.boolean", 97 | "value": "true" 98 | }, 99 | { 100 | "type": "paren.rparen", 101 | "value": ")" 102 | }, 103 | { 104 | "type": "punctuation.operator", 105 | "value": ";" 106 | } 107 | ], 108 | [ 109 | { 110 | "type": "keyword.control", 111 | "value": "do" 112 | }, 113 | { 114 | "type": "text", 115 | "value": " " 116 | }, 117 | { 118 | "type": "paren.lparen", 119 | "value": "{" 120 | }, 121 | { 122 | "type": "identifier", 123 | "value": "nothing" 124 | }, 125 | { 126 | "type": "paren.lparen", 127 | "value": "(" 128 | }, 129 | { 130 | "type": "paren.rparen", 131 | "value": ")" 132 | }, 133 | { 134 | "type": "punctuation.operator", 135 | "value": ";" 136 | }, 137 | { 138 | "type": "paren.rparen", 139 | "value": "}" 140 | }, 141 | { 142 | "type": "text", 143 | "value": " " 144 | }, 145 | { 146 | "type": "keyword.control", 147 | "value": "while" 148 | }, 149 | { 150 | "type": "text", 151 | "value": " " 152 | }, 153 | { 154 | "type": "paren.lparen", 155 | "value": "(" 156 | }, 157 | { 158 | "type": "constant.language.boolean", 159 | "value": "true" 160 | }, 161 | { 162 | "type": "paren.rparen", 163 | "value": ")" 164 | }, 165 | { 166 | "type": "punctuation.operator", 167 | "value": ";" 168 | } 169 | ], 170 | [] 171 | ] 172 | -------------------------------------------------------------------------------- /test_browserify/data/DoWhileStatement.sol: -------------------------------------------------------------------------------- 1 | // DoWhileStatement = 'do' Statement 'while' '(' Expression ')' 2 | do {} while (true); 3 | do nothing(); while (true); 4 | do {nothing();} while (true); 5 | -------------------------------------------------------------------------------- /test_browserify/data/EnumDefinition.json: -------------------------------------------------------------------------------- 1 | [ 2 | [ 3 | { 4 | "type": "comment.line.double-slash", 5 | "value": "// EnumDefinition = 'enum' Identifier '{' EnumValue? (',' EnumValue)* '}'" 6 | } 7 | ], 8 | [ 9 | { 10 | "type": "comment.line.double-slash", 11 | "value": "// EnumValue = Identifier" 12 | } 13 | ], 14 | [ 15 | { 16 | "type": "storage.type", 17 | "value": "enum" 18 | }, 19 | { 20 | "type": "text", 21 | "value": " " 22 | }, 23 | { 24 | "type": "identifier", 25 | "value": "Eniac" 26 | }, 27 | { 28 | "type": "text", 29 | "value": " " 30 | }, 31 | { 32 | "type": "paren.lparen", 33 | "value": "{" 34 | } 35 | ], 36 | [ 37 | { 38 | "type": "text", 39 | "value": " " 40 | }, 41 | { 42 | "type": "identifier", 43 | "value": "KathleenKayMcNultyMauchlyAntonelli" 44 | }, 45 | { 46 | "type": "punctuation.operator", 47 | "value": "," 48 | } 49 | ], 50 | [ 51 | { 52 | "type": "text", 53 | "value": " " 54 | }, 55 | { 56 | "type": "identifier", 57 | "value": "JeanJenningsBartik" 58 | }, 59 | { 60 | "type": "punctuation.operator", 61 | "value": "," 62 | } 63 | ], 64 | [ 65 | { 66 | "type": "text", 67 | "value": " " 68 | }, 69 | { 70 | "type": "identifier", 71 | "value": "FrancesElizabethBettyHolberton" 72 | }, 73 | { 74 | "type": "punctuation.operator", 75 | "value": "," 76 | } 77 | ], 78 | [ 79 | { 80 | "type": "text", 81 | "value": " " 82 | }, 83 | { 84 | "type": "identifier", 85 | "value": "MarlynWescoffMeltzer" 86 | }, 87 | { 88 | "type": "punctuation.operator", 89 | "value": "," 90 | } 91 | ], 92 | [ 93 | { 94 | "type": "text", 95 | "value": " " 96 | }, 97 | { 98 | "type": "identifier", 99 | "value": "FrancesVBilasSpence" 100 | }, 101 | { 102 | "type": "punctuation.operator", 103 | "value": "," 104 | } 105 | ], 106 | [ 107 | { 108 | "type": "text", 109 | "value": " " 110 | }, 111 | { 112 | "type": "identifier", 113 | "value": "RuthLichtermanTeitelbaum" 114 | } 115 | ], 116 | [ 117 | { 118 | "type": "paren.rparen", 119 | "value": "}" 120 | } 121 | ], 122 | [], 123 | [ 124 | { 125 | "type": "storage.type", 126 | "value": "enum" 127 | }, 128 | { 129 | "type": "text", 130 | "value": " " 131 | }, 132 | { 133 | "type": "identifier", 134 | "value": "Muppets" 135 | }, 136 | { 137 | "type": "text", 138 | "value": " " 139 | }, 140 | { 141 | "type": "paren.lparen", 142 | "value": "{" 143 | } 144 | ], 145 | [ 146 | { 147 | "type": "text", 148 | "value": " " 149 | }, 150 | { 151 | "type": "identifier", 152 | "value": "Kermit" 153 | }, 154 | { 155 | "type": "punctuation.operator", 156 | "value": "," 157 | } 158 | ], 159 | [ 160 | { 161 | "type": "text", 162 | "value": " " 163 | }, 164 | { 165 | "type": "identifier", 166 | "value": "MissPiggy" 167 | }, 168 | { 169 | "type": "punctuation.operator", 170 | "value": "," 171 | } 172 | ], 173 | [ 174 | { 175 | "type": "text", 176 | "value": " " 177 | }, 178 | { 179 | "type": "identifier", 180 | "value": "FozzieBear" 181 | }, 182 | { 183 | "type": "punctuation.operator", 184 | "value": "," 185 | } 186 | ], 187 | [ 188 | { 189 | "type": "text", 190 | "value": " " 191 | }, 192 | { 193 | "type": "identifier", 194 | "value": "Gonzo" 195 | }, 196 | { 197 | "type": "punctuation.operator", 198 | "value": "," 199 | } 200 | ], 201 | [ 202 | { 203 | "type": "text", 204 | "value": " " 205 | }, 206 | { 207 | "type": "identifier", 208 | "value": "Rowlf" 209 | }, 210 | { 211 | "type": "punctuation.operator", 212 | "value": "," 213 | } 214 | ], 215 | [ 216 | { 217 | "type": "text", 218 | "value": " " 219 | }, 220 | { 221 | "type": "identifier", 222 | "value": "Scooter" 223 | }, 224 | { 225 | "type": "punctuation.operator", 226 | "value": "," 227 | } 228 | ], 229 | [ 230 | { 231 | "type": "text", 232 | "value": " " 233 | }, 234 | { 235 | "type": "identifier", 236 | "value": "Pepe" 237 | }, 238 | { 239 | "type": "punctuation.operator", 240 | "value": "," 241 | } 242 | ], 243 | [ 244 | { 245 | "type": "text", 246 | "value": " " 247 | }, 248 | { 249 | "type": "identifier", 250 | "value": "Rizzo" 251 | }, 252 | { 253 | "type": "punctuation.operator", 254 | "value": "," 255 | } 256 | ], 257 | [ 258 | { 259 | "type": "text", 260 | "value": " " 261 | }, 262 | { 263 | "type": "identifier", 264 | "value": "Animal" 265 | }, 266 | { 267 | "type": "punctuation.operator", 268 | "value": "," 269 | } 270 | ], 271 | [ 272 | { 273 | "type": "text", 274 | "value": " " 275 | }, 276 | { 277 | "type": "identifier", 278 | "value": "Walter" 279 | } 280 | ], 281 | [ 282 | { 283 | "type": "paren.rparen", 284 | "value": "}" 285 | } 286 | ], 287 | [] 288 | ] 289 | -------------------------------------------------------------------------------- /test_browserify/data/EnumDefinition.sol: -------------------------------------------------------------------------------- 1 | // EnumDefinition = 'enum' Identifier '{' EnumValue? (',' EnumValue)* '}' 2 | // EnumValue = Identifier 3 | enum Eniac { 4 | KathleenKayMcNultyMauchlyAntonelli, 5 | JeanJenningsBartik, 6 | FrancesElizabethBettyHolberton, 7 | MarlynWescoffMeltzer, 8 | FrancesVBilasSpence, 9 | RuthLichtermanTeitelbaum 10 | } 11 | 12 | enum Muppets { 13 | Kermit, 14 | MissPiggy, 15 | FozzieBear, 16 | Gonzo, 17 | Rowlf, 18 | Scooter, 19 | Pepe, 20 | Rizzo, 21 | Animal, 22 | Walter 23 | } 24 | -------------------------------------------------------------------------------- /test_browserify/data/EventDefinition.json: -------------------------------------------------------------------------------- 1 | [ 2 | [ 3 | { 4 | "type": "comment.line.double-slash", 5 | "value": "// EventDefinition = 'event' Identifier EventParameterList 'anonymous'? ';'" 6 | } 7 | ], 8 | [ 9 | { 10 | "type": "comment.line.double-slash", 11 | "value": "// EventParameterList = '(' ( EventParameter (',' EventParameter )* )? ')'" 12 | } 13 | ], 14 | [ 15 | { 16 | "type": "comment.line.double-slash", 17 | "value": "// EventParameter = TypeName 'indexed'? Identifier?" 18 | } 19 | ], 20 | [ 21 | { 22 | "type": "comment.line.double-slash", 23 | "value": "// EmitStatement = 'emit' FunctionCall" 24 | } 25 | ], 26 | [], 27 | [ 28 | { 29 | "type": "storage.type", 30 | "value": "event" 31 | }, 32 | { 33 | "type": "text", 34 | "value": " " 35 | }, 36 | { 37 | "type": "identifier", 38 | "value": "Eve" 39 | }, 40 | { 41 | "type": "paren.lparen", 42 | "value": "(" 43 | }, 44 | { 45 | "type": "storage.type", 46 | "value": "bool" 47 | }, 48 | { 49 | "type": "punctuation.operator", 50 | "value": "," 51 | }, 52 | { 53 | "type": "text", 54 | "value": " " 55 | }, 56 | { 57 | "type": "storage.type", 58 | "value": "bool" 59 | }, 60 | { 61 | "type": "text", 62 | "value": " " 63 | }, 64 | { 65 | "type": "identifier", 66 | "value": "uneventful" 67 | }, 68 | { 69 | "type": "punctuation.operator", 70 | "value": "," 71 | }, 72 | { 73 | "type": "text", 74 | "value": " " 75 | }, 76 | { 77 | "type": "storage.type", 78 | "value": "bool" 79 | }, 80 | { 81 | "type": "text", 82 | "value": " " 83 | }, 84 | { 85 | "type": "storage.modifier.event", 86 | "value": "indexed" 87 | }, 88 | { 89 | "type": "punctuation.operator", 90 | "value": "," 91 | }, 92 | { 93 | "type": "text", 94 | "value": " " 95 | }, 96 | { 97 | "type": "storage.type", 98 | "value": "bool" 99 | }, 100 | { 101 | "type": "text", 102 | "value": " " 103 | }, 104 | { 105 | "type": "storage.modifier.event", 106 | "value": "indexed" 107 | }, 108 | { 109 | "type": "text", 110 | "value": " " 111 | }, 112 | { 113 | "type": "identifier", 114 | "value": "eventful" 115 | }, 116 | { 117 | "type": "paren.rparen", 118 | "value": ")" 119 | }, 120 | { 121 | "type": "punctuation.operator", 122 | "value": ";" 123 | } 124 | ], 125 | [ 126 | { 127 | "type": "storage.type", 128 | "value": "event" 129 | }, 130 | { 131 | "type": "text", 132 | "value": " " 133 | }, 134 | { 135 | "type": "identifier", 136 | "value": "Eve" 137 | }, 138 | { 139 | "type": "paren.lparen", 140 | "value": "(" 141 | }, 142 | { 143 | "type": "storage.type", 144 | "value": "bool" 145 | }, 146 | { 147 | "type": "punctuation.operator", 148 | "value": "," 149 | }, 150 | { 151 | "type": "text", 152 | "value": " " 153 | }, 154 | { 155 | "type": "storage.type", 156 | "value": "bool" 157 | }, 158 | { 159 | "type": "text", 160 | "value": " " 161 | }, 162 | { 163 | "type": "identifier", 164 | "value": "uneventful" 165 | }, 166 | { 167 | "type": "punctuation.operator", 168 | "value": "," 169 | }, 170 | { 171 | "type": "text", 172 | "value": " " 173 | }, 174 | { 175 | "type": "storage.type", 176 | "value": "bool" 177 | }, 178 | { 179 | "type": "text", 180 | "value": " " 181 | }, 182 | { 183 | "type": "storage.modifier.event", 184 | "value": "indexed" 185 | }, 186 | { 187 | "type": "punctuation.operator", 188 | "value": "," 189 | }, 190 | { 191 | "type": "text", 192 | "value": " " 193 | }, 194 | { 195 | "type": "storage.type", 196 | "value": "bool" 197 | }, 198 | { 199 | "type": "text", 200 | "value": " " 201 | }, 202 | { 203 | "type": "storage.modifier.event", 204 | "value": "indexed" 205 | }, 206 | { 207 | "type": "text", 208 | "value": " " 209 | }, 210 | { 211 | "type": "identifier", 212 | "value": "eventful" 213 | }, 214 | { 215 | "type": "paren.rparen", 216 | "value": ")" 217 | }, 218 | { 219 | "type": "text", 220 | "value": " " 221 | }, 222 | { 223 | "type": "storage.modifier.event", 224 | "value": "anonymous" 225 | }, 226 | { 227 | "type": "punctuation.operator", 228 | "value": ";" 229 | } 230 | ], 231 | [ 232 | { 233 | "type": "storage.type", 234 | "value": "event" 235 | }, 236 | { 237 | "type": "text", 238 | "value": " " 239 | }, 240 | { 241 | "type": "identifier", 242 | "value": "Eve" 243 | }, 244 | { 245 | "type": "paren.lparen", 246 | "value": "(" 247 | }, 248 | { 249 | "type": "storage.type", 250 | "value": "bool" 251 | }, 252 | { 253 | "type": "text", 254 | "value": " " 255 | }, 256 | { 257 | "type": "identifier", 258 | "value": "uneventful" 259 | }, 260 | { 261 | "type": "paren.rparen", 262 | "value": ")" 263 | }, 264 | { 265 | "type": "punctuation.operator", 266 | "value": ";" 267 | } 268 | ], 269 | [ 270 | { 271 | "type": "storage.type", 272 | "value": "event" 273 | }, 274 | { 275 | "type": "text", 276 | "value": " " 277 | }, 278 | { 279 | "type": "identifier", 280 | "value": "Eve" 281 | }, 282 | { 283 | "type": "paren.lparen", 284 | "value": "(" 285 | }, 286 | { 287 | "type": "storage.type", 288 | "value": "bool" 289 | }, 290 | { 291 | "type": "paren.rparen", 292 | "value": ")" 293 | }, 294 | { 295 | "type": "punctuation.operator", 296 | "value": ";" 297 | } 298 | ], 299 | [], 300 | [ 301 | { 302 | "type": "keyword", 303 | "value": "emit" 304 | }, 305 | { 306 | "type": "text", 307 | "value": " " 308 | }, 309 | { 310 | "type": "identifier", 311 | "value": "Eve" 312 | }, 313 | { 314 | "type": "paren.lparen", 315 | "value": "(" 316 | }, 317 | { 318 | "type": "constant.language.boolean", 319 | "value": "true" 320 | }, 321 | { 322 | "type": "paren.rparen", 323 | "value": ")" 324 | }, 325 | { 326 | "type": "punctuation.operator", 327 | "value": ";" 328 | } 329 | ], 330 | [] 331 | ] 332 | -------------------------------------------------------------------------------- /test_browserify/data/EventDefinition.sol: -------------------------------------------------------------------------------- 1 | // EventDefinition = 'event' Identifier EventParameterList 'anonymous'? ';' 2 | // EventParameterList = '(' ( EventParameter (',' EventParameter )* )? ')' 3 | // EventParameter = TypeName 'indexed'? Identifier? 4 | // EmitStatement = 'emit' FunctionCall 5 | 6 | event Eve(bool, bool uneventful, bool indexed, bool indexed eventful); 7 | event Eve(bool, bool uneventful, bool indexed, bool indexed eventful) anonymous; 8 | event Eve(bool uneventful); 9 | event Eve(bool); 10 | 11 | emit Eve(true); 12 | -------------------------------------------------------------------------------- /test_browserify/data/Expression.sol: -------------------------------------------------------------------------------- 1 | // Precedence by order (see github.com/ethereum/solidity/pull/732) 2 | // Expression 3 | // = Expression ('++' | '--') 4 | // | NewExpression 5 | // | IndexAccess 6 | // | MemberAccess 7 | // | FunctionCall 8 | // | '(' Expression ')' 9 | // | ('!' | '~' | 'delete' | '++' | '--' | '+' | '-') Expression 10 | // | Expression '**' Expression 11 | // | Expression ('*' | '/' | '%') Expression 12 | // | Expression ('+' | '-') Expression 13 | // | Expression ('<<' | '>>') Expression 14 | // | Expression '&' Expression 15 | // | Expression '^' Expression 16 | // | Expression '|' Expression 17 | // | Expression ('<' | '>' | '<=' | '>=') Expression 18 | // | Expression ('==' | '!=') Expression 19 | // | Expression '&&' Expression 20 | // | Expression '||' Expression 21 | // | Expression '?' Expression ':' Expression 22 | // | Expression ('=' | '|=' | '^=' | '&=' | '<<=' | '>>=' | '+=' | '-=' | '*=' | '/=' | '%=') Expression 23 | // | PrimaryExpression 24 | // 25 | // PrimaryExpression = BooleanLiteral 26 | // | NumberLiteral 27 | // | HexLiteral 28 | // | StringLiteral 29 | // | TupleExpression 30 | // | Identifier 31 | // | ElementaryTypeNameExpression 32 | // 33 | // ExpressionList = Expression ( ',' Expression )* 34 | // NameValueList = Identifier ':' Expression ( ',' Identifier ':' Expression )* 35 | // 36 | // FunctionCall = Expression '(' FunctionCallArguments ')' 37 | // FunctionCallArguments = '{' NameValueList? '}' 38 | // | ExpressionList? 39 | // 40 | // NewExpression = 'new' TypeName 41 | // MemberAccess = Expression '.' Identifier 42 | // IndexAccess = Expression '[' Expression? ']' 43 | // 44 | // BooleanLiteral = 'true' | 'false' 45 | // NumberLiteral = ( HexNumber | DecimalNumber ) (' ' NumberUnit)? 46 | // NumberUnit = 'wei' | 'szabo' | 'finney' | 'ether' 47 | // | 'seconds' | 'minutes' | 'hours' | 'days' | 'weeks' | 'years' 48 | // HexLiteral = 'hex' ('"' ([0-9a-fA-F]{2})* '"' | '\'' ([0-9a-fA-F]{2})* '\'') 49 | // StringLiteral = '"' ([^"\r\n\\] | '\\' .)* '"' 50 | // Identifier = [a-zA-Z_$] [a-zA-Z_$0-9]* 51 | // 52 | // HexNumber = '0x' [0-9a-fA-F]+ 53 | // DecimalNumber = [0-9]+ ( '.' [0-9]* )? ( [eE] [0-9]+ )? 54 | // 55 | // TupleExpression = '(' ( Expression? ( ',' Expression? )* )? ')' 56 | // | '[' ( Expression ( ',' Expression )* )? ']' 57 | 58 | // Expression ('++' | '--') 59 | int256 x = 0; 60 | x++; 61 | x ++; 62 | x--; 63 | x --; 64 | 65 | // NewExpression 66 | CustomContract customContract = new CustomContract(); 67 | 68 | // IndexAccess 69 | uint256[] amounts; 70 | amounts[0] = 17; 71 | uint256 a = 1; 72 | amounts[a] = amounts[0]; 73 | 74 | // MemberAccess 75 | customContract.customColor = "red"; 76 | customContract.customize(); 77 | string color = customContract.customColor; 78 | 79 | // FunctionCall 80 | // FunctionCall = Expression '(' FunctionCallArguments ')' 81 | // FunctionCallArguments = '{' NameValueList? '}' 82 | // | ExpressionList? 83 | // NameValueList = Identifier ':' Expression ( ',' Identifier ':' Expression )* 84 | uint256 result = customContract.customize(); 85 | uint256 result = customContract.customize(1, 2, 3); 86 | uint256 result = customContract.customize({a:1, b:2, c:3}); 87 | 88 | doit(); 89 | doit(1, 2, 3); 90 | doit({a:1, b:2, c:3}); 91 | 92 | doit (); 93 | doit (1, 2, 3); 94 | doit ({a:1, b:2, c:3}); 95 | 96 | // '(' Expression ')' 97 | (myInt); 98 | (1); 99 | 100 | // ('!' | '~' | 'delete' | '++' | '--' | '+' | '-') Expression 101 | !a; ! a; 102 | ~a; ~ a; 103 | delete a; 104 | ++a; ++ a; 105 | --a; -- a; 106 | +a; + a; 107 | -a; - a; 108 | 109 | // Expression '**' Expression 110 | uint256 x = a ** b; 111 | 112 | // Expression ('*' | '/' | '%') Expression 113 | uint256 x = a * b; 114 | uint256 y = a / b; 115 | uint256 z = a % b; 116 | 117 | // Expression ('+' | '-') Expression 118 | uint256 x = a + b; 119 | uint256 y = a - b; 120 | 121 | // Expression ('<<' | '>>') Expression 122 | uint256 x = a << b; 123 | uint256 y = a >> b; 124 | 125 | // Expression '&' Expression 126 | uint256 x = a & b; 127 | 128 | // Expression '^' Expression 129 | uint256 x = a ^ b; 130 | 131 | // Expression '|' Expression 132 | uint256 x = a | b; 133 | 134 | // Expression ('<' | '>' | '<=' | '>=') Expression 135 | bool lt = a < b; 136 | bool gt = a > b; 137 | bool le = a <= b; 138 | bool ge = a >= b; 139 | 140 | // Expression ('==' | '!=') Expression 141 | bool eq = a == b; 142 | bool ne = a != b; 143 | 144 | // Expression '&&' Expression 145 | bool and = a && b; 146 | 147 | // Expression '||' Expression 148 | bool or = a || b; 149 | 150 | // Expression '?' Expression ':' Expression 151 | string outcome = conditional > 10 ? "yes" : "no"; 152 | 153 | // Expression ('=' | '|=' | '^=' | '&=' | '<<=' | '>>=' | '+=' | '-=' | '*=' | '/=' | '%=') Expression 154 | struct KitchenSink { 155 | uint32 color; 156 | uint256 volume; 157 | } 158 | KitchenSink k; 159 | k.color = 0x00000000; 160 | k.color |= 0xff000000; 161 | k.color ^= 0x0f0f0f0f; 162 | k.color &= 0xffff0000; 163 | v.volume = 25; 164 | v.volume <<= 2; 165 | v.volume >>= 2; 166 | v.volume += 2; 167 | v.volume -= 2; 168 | v.volume *= 2; 169 | v.volume /= 2; 170 | v.volume %= 2; 171 | 172 | // PrimaryExpression = BooleanLiteral 173 | // | NumberLiteral 174 | // | HexLiteral 175 | // | StringLiteral 176 | // | TupleExpression 177 | // | Identifier 178 | // | ElementaryTypeNameExpression 179 | 180 | 181 | 182 | // BooleanLiteral = 'true' | 'false' 183 | bool truth = true; 184 | bool truth = false; 185 | 186 | // NumberLiteral = ( HexNumber | DecimalNumber ) (' ' NumberUnit)? 187 | // HexNumber = '0x' [0-9a-fA-F]+ 188 | // DecimalNumber = [0-9]+ ( '.' [0-9]* )? ( [eE] [0-9]+ )? 189 | // NumberUnit = 'wei' | 'szabo' | 'finney' | 'ether' 190 | // | 'seconds' | 'minutes' | 'hours' | 'days' | 'weeks' | 'years' 191 | uint256 number = 0x123abcDEF wei; 192 | uint256 number = 123456 szabo; 193 | uint256 number = 123456 finney; 194 | uint256 number = 123456 ether; 195 | uint256 time = 60 seconds; 196 | uint256 time = 60 minutes; 197 | uint256 time = 60 hours; 198 | uint256 time = 60 days; 199 | uint256 time = 60 weeks; 200 | uint256 time = 60 years; 201 | 202 | ufixed128x80 fractional = 123.456; 203 | ufixed128x80 fractional = -123.456; 204 | ufixed128x80 fractional = 123.456e12; 205 | ufixed128x80 fractional = -123.456e12; 206 | ufixed128x80 fractional = 123.456E12; 207 | ufixed128x80 fractional = -123.456E12; 208 | 209 | // grammar.txt is missing negative exponents (for really small numbers). 210 | ufixed128x80 fractional = 1.456e-12; 211 | ufixed128x80 fractional = -1.456e-12; 212 | ufixed128x80 fractional = 1.456E-12; 213 | ufixed128x80 fractional = -1.456E-12; 214 | 215 | // HexLiteral = 'hex' ('"' ([0-9a-fA-F]{2})* '"' | '\'' ([0-9a-fA-F]{2})* '\'') 216 | bytes[] hexer = hex""; 217 | bytes[] hexer = hex"0123456789abcdef0123456789ABCDEF"; 218 | bytes[] hexer = hex''; 219 | bytes[] hexer = hex'0123456789abcdef0123456789ABCDEF'; 220 | 221 | // StringLiteral = '"' ([^"\r\n\\] | '\\' .)* '"' 222 | string talker = ""; 223 | string talker = "Hello!"; 224 | string talker = "Hello \x26\x03!"; 225 | string talker = "Hello \u2603!"; 226 | string talker = "I said \"Hello!\", did you hear it?"; 227 | string talker = "Look ma, \ 228 | multi-line strings! Just escape \ 229 | the newline with a back-slash."; 230 | 231 | // https://solidity.readthedocs.io/en/develop/types.html#string-literals 232 | // ^^ says both single-quoted and double-quoted string literals, even if 233 | // grammar.txt has only double-quoted. 234 | string greet = ''; 235 | string greet = 'Hello World!'; 236 | string greet = 'Hello \x26\x03!'; 237 | string greet = 'Hello \u2603!'; 238 | string greet = 'Hello \'World\'!'; 239 | string greet = 'Hello \ 240 | World!'; 241 | 242 | // Identifier = [a-zA-Z_$] [a-zA-Z_$0-9]* 243 | uint a = 0; 244 | uint A = 0; 245 | // "_" is be a legal identifier outside of modifiers. Keyword syntax 246 | // highlighting triggers nevertheless, to alert user of special meaning and 247 | // potential confusion. 248 | uint _ = 0; 249 | uint $ = 0; 250 | uint a0b_$1c = 0; 251 | uint A0b_$1c = 0; 252 | uint _0b_$1c = 0; 253 | uint $0b_$1c = 0; 254 | 255 | // TupleExpression = '(' ( Expression? ( ',' Expression? )* )? ')' 256 | // | '[' ( Expression ( ',' Expression )* )? ']' 257 | // The "[]" bracket notation is not a tuple but an array literal. See below. 258 | uint256 a = 0; 259 | uint256 b = 0; 260 | uint256 c = 0; 261 | (a, b, c) = (1, 1, 1); 262 | 263 | // Array Literal (not in grammar.txt) 264 | uint256[3] memory b = [uint256(1), 2, 3]; 265 | 266 | // Explicit Type Cast (not in grammar.txt AFAICT) 267 | uint8 a = 1; 268 | uint256 b = uint256(a); 269 | 270 | address o = address(otherContract); 271 | -------------------------------------------------------------------------------- /test_browserify/data/ForStatement.sol: -------------------------------------------------------------------------------- 1 | // ForStatement = 'for' '(' (SimpleStatement)? ';' (Expression)? ';' (ExpressionStatement)? ')' Statement 2 | // Continue = 'continue' 3 | // Break = 'break' 4 | 5 | for (;;) {} 6 | for (uint256 i = 0;;) {} 7 | for (uint256 i = 0; i < 10;) {} 8 | for (uint256 i = 0; i < 10; i++) {} 9 | 10 | uint256 o = 0; 11 | for (uint256 i = 0; i < 10; i++) { 12 | if (i % 2) { 13 | continue; 14 | } 15 | o += i; 16 | if (o > 40) { 17 | break; 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /test_browserify/data/FunctionArguments.sol: -------------------------------------------------------------------------------- 1 | pragma solidity ^0.4.24; 2 | 3 | contract NestedParenthesesInFunctionArguments { 4 | mapping(uint256 => address) internal contrived; 5 | 6 | function difficultSyntaxHighlight( 7 | function(mapping(uint256 => address), bool) internal returns(bool) callbackParam, 8 | bool simpleParam 9 | ) internal returns(bool) { 10 | return callbackParam(contrived, simpleParam); 11 | } 12 | } 13 | 14 | contract FixedNumberFunctionArguments { 15 | function fixedNumberSyntaxHighlight(fixed136x63 param1, ufixed216x77 param2) internal returns(bool) { 16 | return false; 17 | } 18 | } 19 | 20 | library Somewhere { 21 | struct Great { 22 | int256 lat; 23 | int256 lon; 24 | string name; 25 | } 26 | } 27 | 28 | contract UserDefinedTypeNameFunctionArguments { 29 | struct Home { 30 | uint8 roomId; 31 | string name; 32 | } 33 | 34 | function userDefinedTypeNameSyntaxHighlight(Somewhere.Great memory vivid, Home storage trip) internal pure returns(bool) { 35 | return true; 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /test_browserify/data/FunctionDefinition.sol: -------------------------------------------------------------------------------- 1 | // FunctionDefinition = 'function' Identifier? ParameterList 2 | // ( ModifierInvocation | StateMutability | 'external' | 'public' | 'internal' | 'private' )* 3 | // ( 'returns' ParameterList )? ( ';' | Block ) 4 | // Return = 'return' Expression? 5 | // Throw = 'throw' 6 | 7 | // Order: ModifierInvocation StateMutability Visibility 8 | function f(uint256 param) modding(param) pure external returns(uint256) {return 2 * param;} 9 | function f(uint256 param) modding(param) constant external returns(uint256) {return 2 * param;} 10 | function f(uint256 param) modding(param) view external returns(uint256) {return 2 * param;} 11 | function f(uint256 param) modding(param) payable external returns(uint256) {return 2 * param;} 12 | 13 | function f(uint256 param) modding(param) pure public returns(uint256) {return 2 * param;} 14 | function f(uint256 param) modding(param) constant public returns(uint256) {return 2 * param;} 15 | function f(uint256 param) modding(param) view public returns(uint256) {return 2 * param;} 16 | function f(uint256 param) modding(param) payable public returns(uint256) {return 2 * param;} 17 | 18 | function f(uint256 param) modding(param) pure internal returns(uint256) {return 2 * param;} 19 | function f(uint256 param) modding(param) constant internal returns(uint256) {return 2 * param;} 20 | function f(uint256 param) modding(param) view internal returns(uint256) {return 2 * param;} 21 | function f(uint256 param) modding(param) payable internal returns(uint256) {return 2 * param;} 22 | 23 | function f(uint256 param) modding(param) pure private returns(uint256) {return 2 * param;} 24 | function f(uint256 param) modding(param) constant private returns(uint256) {return 2 * param;} 25 | function f(uint256 param) modding(param) view private returns(uint256) {return 2 * param;} 26 | function f(uint256 param) modding(param) payable private returns(uint256) {return 2 * param;} 27 | 28 | 29 | // Order: StateMutability Visibility ModifierInvocation 30 | function f(uint256 param) pure external modding(param) returns(uint256) {return 2 * param;} 31 | function f(uint256 param) constant external modding(param) returns(uint256) {return 2 * param;} 32 | function f(uint256 param) view external modding(param) returns(uint256) {return 2 * param;} 33 | function f(uint256 param) payable external modding(param) returns(uint256) {return 2 * param;} 34 | 35 | function f(uint256 param) pure public modding(param) returns(uint256) {return 2 * param;} 36 | function f(uint256 param) constant public modding(param) returns(uint256) {return 2 * param;} 37 | function f(uint256 param) view public modding(param) returns(uint256) {return 2 * param;} 38 | function f(uint256 param) payable public modding(param) returns(uint256) {return 2 * param;} 39 | 40 | function f(uint256 param) pure internal modding(param) returns(uint256) {return 2 * param;} 41 | function f(uint256 param) constant internal modding(param) returns(uint256) {return 2 * param;} 42 | function f(uint256 param) view internal modding(param) returns(uint256) {return 2 * param;} 43 | function f(uint256 param) payable internal modding(param) returns(uint256) {return 2 * param;} 44 | 45 | function f(uint256 param) pure private modding(param) returns(uint256) {return 2 * param;} 46 | function f(uint256 param) constant private modding(param) returns(uint256) {return 2 * param;} 47 | function f(uint256 param) view private modding(param) returns(uint256) {return 2 * param;} 48 | function f(uint256 param) payable private modding(param) returns(uint256) {return 2 * param;} 49 | 50 | 51 | // Order: Visibility StateMutability ModifierInvocation 52 | function f(uint256 param) external pure modding(param) returns(uint256) {return 2 * param;} 53 | function f(uint256 param) external constant modding(param) returns(uint256) {return 2 * param;} 54 | function f(uint256 param) external view modding(param) returns(uint256) {return 2 * param;} 55 | function f(uint256 param) external payable modding(param) returns(uint256) {return 2 * param;} 56 | 57 | function f(uint256 param) public pure modding(param) returns(uint256) {return 2 * param;} 58 | function f(uint256 param) public constant modding(param) returns(uint256) {return 2 * param;} 59 | function f(uint256 param) public view modding(param) returns(uint256) {return 2 * param;} 60 | function f(uint256 param) public payable modding(param) returns(uint256) {return 2 * param;} 61 | 62 | function f(uint256 param) internal pure modding(param) returns(uint256) {return 2 * param;} 63 | function f(uint256 param) internal constant modding(param) returns(uint256) {return 2 * param;} 64 | function f(uint256 param) internal view modding(param) returns(uint256) {return 2 * param;} 65 | function f(uint256 param) internal payable modding(param) returns(uint256) {return 2 * param;} 66 | 67 | function f(uint256 param) private pure modding(param) returns(uint256) {return 2 * param;} 68 | function f(uint256 param) private constant modding(param) returns(uint256) {return 2 * param;} 69 | function f(uint256 param) private view modding(param) returns(uint256) {return 2 * param;} 70 | function f(uint256 param) private payable modding(param) returns(uint256) {return 2 * param;} 71 | 72 | 73 | // Leave off some/all optional parts. 74 | function (uint256 param) {} 75 | function g(uint256 param); 76 | function g(MyStruct memory param) returns(MyOtherStruct memory); 77 | function g(MyStruct storage param) returns(MyOtherStruct storage); 78 | function g(MyStruct calldata param); 79 | function g(uint256 param) returns(bool, uint256, string); 80 | function g(uint256 param) private returns(bool, uint256, string) {} 81 | function g(uint256 param) public modding(param, 17) returns(bool, uint256, string) {} 82 | function g(uint256 param) private modding(123456, param, 17) returns(bool, uint256, string) {} 83 | 84 | function g(uint256 param) private modding(123456, param, 17) { 85 | // NOTE: From version 0.4.13 the throw keyword is deprecated and will be phased out in the future. 86 | if (param < 17000) { 87 | throw; 88 | } 89 | return; 90 | } 91 | 92 | function g() public modding(123456, 13, 17) returns(bool) { 93 | return false; 94 | } 95 | 96 | function g() public moddingWithoutParam returns(bool, uint256, string) { 97 | return (true, 17, "Hello World!"); 98 | } 99 | -------------------------------------------------------------------------------- /test_browserify/data/GlobalFunctions.sol: -------------------------------------------------------------------------------- 1 | // https://solidity.readthedocs.io/en/develop/units-and-global-variables.html 2 | // https://solidity.readthedocs.io/en/develop/miscellaneous.html#global-variables 3 | 4 | contract GlobalFunctions { 5 | function h(uint256 param) payable external { 6 | bytes memory encoded1 = abi.encode("Hello", "World!"); // ABI-encodes the given arguments 7 | bytes memory encoded2 = abi.encodePacked("Hello", "World!"); // Performes packed encoding of the given arguments 8 | bytes memory encoded3 = abi.encodeWithSelector(0x12345678, "Hello", "World!"); // ABI-encodes the given arguments starting from the second and prepends the given four-byte selector 9 | bytes memory encoded4 = abi.encodeWithSignature("m(string,string)", "Hello", "World!"); // Equivalent to abi.encodeWithSelector(bytes4(keccak256(bytes(signature)), ...) 10 | bytes32 b1hash = block.blockhash(12); // hash of the given block - only works for 256 most recent, excluding current, blocks - deprecated in version 0.4.22 and replaced by blockhash(uint blockNumber). 11 | uint256 runway = gasleft(); // remaining gas 12 | assert(param < 10); // abort execution and revert state changes if condition is false (use for internal error) 13 | require(param < 10); // abort execution and revert state changes if condition is false (use for malformed input or error in external component) 14 | require(param < 10, "Value of `i` is too big!"); // abort execution and revert state changes if condition is false (use for malformed input or error in external component). Also provide error message. 15 | revert(); // abort execution and revert state changes 16 | revert("Better not!"); // abort execution and revert state changes providing an explanatory string 17 | bytes32 b2hash = blockhash(12); // hash of the given block - only works for 256 most recent blocks 18 | bytes32 khash = keccak256(hex'0123456789'); // compute the Ethereum-SHA-3 (Keccak-256) hash of the input 19 | bytes32 s3hash = sha3(hex'0123456789'); // a deprecated alias to keccak256 20 | bytes32 s256hash = sha256(hex'0123456789'); // compute the SHA-256 hash of the input 21 | bytes20 rhash = ripemd160(hex'0123456789'); // compute the RIPEMD-160 hash of the input 22 | } 23 | 24 | function i(uint256 param) payable external { 25 | // All I learned about `ecrecover()` is that people have difficulties to learn about `ecrecover()`. 26 | // Fortunately, I don't need to understand it yet, only to make it's syntax highlighting work: 27 | bytes32 b32 = hex'0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef'; 28 | address addy = ecrecover(b32, 0xff, b32, b32); // recover address associated with the public key from elliptic curve signature, return zero on error 29 | 30 | uint256 sum = addmod(1, 2, 3); // compute (x + y) % k where the addition is performed with arbitrary precision and does not wrap around at 2**256. Assert that k != 0 starting from version 0.5.0. 31 | uint256 prod = mulmod(1, 2, 3); // compute (x * y) % k where the multiplication is performed with arbitrary precision and does not wrap around at 2**256. Assert that k != 0 starting from version 0.5.0. 32 | selfdestruct(addy); // destroy the current contract, sending its funds to the given address 33 | suicide(addy); // a deprecated alias to selfdestruct 34 | bool success1 = addy.call(hex'01234567'); // issue low-level CALL with the given payload, returns false on failure, forwards all available gas, adjustable 35 | bool success2 = addy.callcode(hex'01234567'); // issue low-level CALLCODE with the given payload, returns false on failure, forwards all available gas, adjustable 36 | bool success3 = addy.delegatecall(hex'01234567'); // issue low-level DELEGATECALL with the given payload, returns false on failure, forwards all available gas, adjustable 37 | bool success4 = addy.send(1337); // send given amount of Wei to Address, returns false on failure 38 | addy.transfer(1337); // send given amount of Wei to Address, throws on failure 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /test_browserify/data/GlobalVariables.sol: -------------------------------------------------------------------------------- 1 | // https://solidity.readthedocs.io/en/develop/units-and-global-variables.html 2 | // https://solidity.readthedocs.io/en/develop/miscellaneous.html#global-variables 3 | 4 | contract GlobalVariables { 5 | function j(uint256 param) payable external { 6 | address addy = block.coinbase; // current block miner’s address 7 | uint256 hardship = block.difficulty; // current block difficulty 8 | uint256 tankVolume = block.gaslimit; // current block gaslimit 9 | uint256 houseNumber = block.number; // current block number 10 | uint256 nowish = block.timestamp; // current block timestamp 11 | bytes memory whatToDo = msg.data; // complete calldata 12 | uint256 runway = msg.gas; // remaining gas - deprecated in version 0.4.21 and to be replaced by gasleft() 13 | address boss = msg.sender; // sender of the message (current call) 14 | uint256 worth = msg.value; // number of wei sent with the message 15 | uint256 betterThanNever = now; // current block timestamp (alias for block.timestamp) 16 | uint256 fuel = tx.gasprice; // gas price of the transaction 17 | address bigWig = tx.origin; // sender of the transaction (full call chain) 18 | this.j(17); // the current contract, explicitly convertible to address 19 | super.j(17); // the contract one level higher in the inheritance hierarchy 20 | uint256 addyPurse = addy.balance; // balance of the Address in Wei 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /test_browserify/data/IfStatement.json: -------------------------------------------------------------------------------- 1 | [ 2 | [ 3 | { 4 | "type": "comment.line.double-slash", 5 | "value": "// IfStatement = 'if' '(' Expression ')' Statement ( 'else' Statement )?" 6 | } 7 | ], 8 | [ 9 | { 10 | "type": "keyword.control", 11 | "value": "if" 12 | }, 13 | { 14 | "type": "text", 15 | "value": " " 16 | }, 17 | { 18 | "type": "paren.lparen", 19 | "value": "(" 20 | }, 21 | { 22 | "type": "constant.language.boolean", 23 | "value": "true" 24 | }, 25 | { 26 | "type": "paren.rparen", 27 | "value": ")" 28 | }, 29 | { 30 | "type": "text", 31 | "value": " " 32 | }, 33 | { 34 | "type": "keyword.control", 35 | "value": "return" 36 | }, 37 | { 38 | "type": "text", 39 | "value": " " 40 | }, 41 | { 42 | "type": "constant.language.boolean", 43 | "value": "false" 44 | }, 45 | { 46 | "type": "punctuation.operator", 47 | "value": ";" 48 | } 49 | ], 50 | [ 51 | { 52 | "type": "keyword.control", 53 | "value": "if" 54 | }, 55 | { 56 | "type": "text", 57 | "value": " " 58 | }, 59 | { 60 | "type": "paren.lparen", 61 | "value": "(" 62 | }, 63 | { 64 | "type": "constant.language.boolean", 65 | "value": "true" 66 | }, 67 | { 68 | "type": "paren.rparen", 69 | "value": ")" 70 | }, 71 | { 72 | "type": "text", 73 | "value": " " 74 | }, 75 | { 76 | "type": "keyword.control", 77 | "value": "return" 78 | }, 79 | { 80 | "type": "text", 81 | "value": " " 82 | }, 83 | { 84 | "type": "constant.language.boolean", 85 | "value": "false" 86 | }, 87 | { 88 | "type": "punctuation.operator", 89 | "value": ";" 90 | }, 91 | { 92 | "type": "text", 93 | "value": " " 94 | }, 95 | { 96 | "type": "keyword.control", 97 | "value": "else" 98 | }, 99 | { 100 | "type": "text", 101 | "value": " " 102 | }, 103 | { 104 | "type": "keyword.control", 105 | "value": "return" 106 | }, 107 | { 108 | "type": "text", 109 | "value": " " 110 | }, 111 | { 112 | "type": "constant.language.boolean", 113 | "value": "true" 114 | }, 115 | { 116 | "type": "punctuation.operator", 117 | "value": ";" 118 | } 119 | ], 120 | [], 121 | [ 122 | { 123 | "type": "keyword.control", 124 | "value": "if" 125 | }, 126 | { 127 | "type": "text", 128 | "value": " " 129 | }, 130 | { 131 | "type": "paren.lparen", 132 | "value": "(" 133 | }, 134 | { 135 | "type": "constant.language.boolean", 136 | "value": "true" 137 | }, 138 | { 139 | "type": "paren.rparen", 140 | "value": ")" 141 | }, 142 | { 143 | "type": "text", 144 | "value": " " 145 | }, 146 | { 147 | "type": "paren.lparen", 148 | "value": "{" 149 | }, 150 | { 151 | "type": "keyword.control", 152 | "value": "return" 153 | }, 154 | { 155 | "type": "text", 156 | "value": " " 157 | }, 158 | { 159 | "type": "constant.language.boolean", 160 | "value": "false" 161 | }, 162 | { 163 | "type": "punctuation.operator", 164 | "value": ";" 165 | }, 166 | { 167 | "type": "paren.rparen", 168 | "value": "}" 169 | } 170 | ], 171 | [ 172 | { 173 | "type": "keyword.control", 174 | "value": "if" 175 | }, 176 | { 177 | "type": "text", 178 | "value": " " 179 | }, 180 | { 181 | "type": "paren.lparen", 182 | "value": "(" 183 | }, 184 | { 185 | "type": "constant.language.boolean", 186 | "value": "true" 187 | }, 188 | { 189 | "type": "paren.rparen", 190 | "value": ")" 191 | }, 192 | { 193 | "type": "text", 194 | "value": " " 195 | }, 196 | { 197 | "type": "paren.lparen", 198 | "value": "{" 199 | }, 200 | { 201 | "type": "keyword.control", 202 | "value": "return" 203 | }, 204 | { 205 | "type": "text", 206 | "value": " " 207 | }, 208 | { 209 | "type": "constant.language.boolean", 210 | "value": "false" 211 | }, 212 | { 213 | "type": "punctuation.operator", 214 | "value": ";" 215 | }, 216 | { 217 | "type": "paren.rparen", 218 | "value": "}" 219 | }, 220 | { 221 | "type": "text", 222 | "value": " " 223 | }, 224 | { 225 | "type": "keyword.control", 226 | "value": "else" 227 | }, 228 | { 229 | "type": "text", 230 | "value": " " 231 | }, 232 | { 233 | "type": "paren.lparen", 234 | "value": "{" 235 | }, 236 | { 237 | "type": "keyword.control", 238 | "value": "return" 239 | }, 240 | { 241 | "type": "text", 242 | "value": " " 243 | }, 244 | { 245 | "type": "constant.language.boolean", 246 | "value": "true" 247 | }, 248 | { 249 | "type": "punctuation.operator", 250 | "value": ";" 251 | }, 252 | { 253 | "type": "paren.rparen", 254 | "value": "}" 255 | } 256 | ], 257 | [] 258 | ] 259 | -------------------------------------------------------------------------------- /test_browserify/data/IfStatement.sol: -------------------------------------------------------------------------------- 1 | // IfStatement = 'if' '(' Expression ')' Statement ( 'else' Statement )? 2 | if (true) return false; 3 | if (true) return false; else return true; 4 | 5 | if (true) {return false;} 6 | if (true) {return false;} else {return true;} 7 | -------------------------------------------------------------------------------- /test_browserify/data/ImportDirective.sol: -------------------------------------------------------------------------------- 1 | // ImportDirective = 'import' StringLiteral ('as' Identifier)? ';' 2 | // | 'import' ('*' | Identifier) ('as' Identifier)? 'from' StringLiteral ';' 3 | // | 'import' '{' Identifier ('as' Identifier)? ( ',' Identifier ('as' Identifier)? )* '}' 'from' StringLiteral ';' 4 | 5 | import "./other.sol"; 6 | import "./other.sol" as other; 7 | import * from "./other.sol"; 8 | import other from "./other.sol"; 9 | import * as other from "./other.sol"; 10 | import other as something from "./other.sol"; 11 | import {other} from "./other.sol"; 12 | import {other as something} from "./other.sol"; 13 | import {other, something} from "./other.sol"; 14 | import {other as something, more} from "./other.sol"; 15 | import {other as something, more as something_else} from "./other.sol"; 16 | import {other as something, more, even_more as completely_different} from "./other.sol"; 17 | import {other as something, more as something_else, even_more as completely_different} from "./other.sol"; 18 | -------------------------------------------------------------------------------- /test_browserify/data/ModifierDefinition.json: -------------------------------------------------------------------------------- 1 | [ 2 | [ 3 | { 4 | "type": "comment.line.double-slash", 5 | "value": "// ModifierDefinition = 'modifier' Identifier ParameterList? Block" 6 | } 7 | ], 8 | [ 9 | { 10 | "type": "comment.line.double-slash", 11 | "value": "// PlaceholderStatement = '_'" 12 | } 13 | ], 14 | [ 15 | { 16 | "type": "storage.type", 17 | "value": "modifier" 18 | }, 19 | { 20 | "type": "text", 21 | "value": " " 22 | }, 23 | { 24 | "type": "identifier", 25 | "value": "costs" 26 | }, 27 | { 28 | "type": "paren.lparen", 29 | "value": "(" 30 | }, 31 | { 32 | "type": "storage.type", 33 | "value": "uint" 34 | }, 35 | { 36 | "type": "text", 37 | "value": " " 38 | }, 39 | { 40 | "type": "identifier", 41 | "value": "price" 42 | }, 43 | { 44 | "type": "paren.rparen", 45 | "value": ")" 46 | }, 47 | { 48 | "type": "text", 49 | "value": " " 50 | }, 51 | { 52 | "type": "paren.lparen", 53 | "value": "{" 54 | } 55 | ], 56 | [ 57 | { 58 | "type": "text", 59 | "value": " " 60 | }, 61 | { 62 | "type": "keyword.control", 63 | "value": "if" 64 | }, 65 | { 66 | "type": "text", 67 | "value": " " 68 | }, 69 | { 70 | "type": "paren.lparen", 71 | "value": "(" 72 | }, 73 | { 74 | "type": "support.variable", 75 | "value": "msg.value" 76 | }, 77 | { 78 | "type": "text", 79 | "value": " " 80 | }, 81 | { 82 | "type": "keyword.operator", 83 | "value": ">=" 84 | }, 85 | { 86 | "type": "text", 87 | "value": " " 88 | }, 89 | { 90 | "type": "identifier", 91 | "value": "price" 92 | }, 93 | { 94 | "type": "paren.rparen", 95 | "value": ")" 96 | }, 97 | { 98 | "type": "text", 99 | "value": " " 100 | }, 101 | { 102 | "type": "paren.lparen", 103 | "value": "{" 104 | } 105 | ], 106 | [ 107 | { 108 | "type": "text", 109 | "value": " " 110 | }, 111 | { 112 | "type": "keyword.control", 113 | "value": "_" 114 | }, 115 | { 116 | "type": "punctuation.operator", 117 | "value": ";" 118 | } 119 | ], 120 | [ 121 | { 122 | "type": "text", 123 | "value": " " 124 | }, 125 | { 126 | "type": "paren.rparen", 127 | "value": "}" 128 | } 129 | ], 130 | [ 131 | { 132 | "type": "paren.rparen", 133 | "value": "}" 134 | } 135 | ], 136 | [], 137 | [ 138 | { 139 | "type": "storage.type", 140 | "value": "modifier" 141 | }, 142 | { 143 | "type": "text", 144 | "value": " " 145 | }, 146 | { 147 | "type": "identifier", 148 | "value": "notSoDifferent" 149 | }, 150 | { 151 | "type": "text", 152 | "value": " " 153 | }, 154 | { 155 | "type": "paren.lparen", 156 | "value": "{" 157 | } 158 | ], 159 | [ 160 | { 161 | "type": "text", 162 | "value": " " 163 | }, 164 | { 165 | "type": "keyword.control", 166 | "value": "_" 167 | }, 168 | { 169 | "type": "punctuation.operator", 170 | "value": ";" 171 | } 172 | ], 173 | [ 174 | { 175 | "type": "paren.rparen", 176 | "value": "}" 177 | } 178 | ], 179 | [] 180 | ] 181 | -------------------------------------------------------------------------------- /test_browserify/data/ModifierDefinition.sol: -------------------------------------------------------------------------------- 1 | // ModifierDefinition = 'modifier' Identifier ParameterList? Block 2 | // PlaceholderStatement = '_' 3 | modifier costs(uint price) { 4 | if (msg.value >= price) { 5 | _; 6 | } 7 | } 8 | 9 | modifier notSoDifferent { 10 | _; 11 | } 12 | -------------------------------------------------------------------------------- /test_browserify/data/NatSpec.sol: -------------------------------------------------------------------------------- 1 | // https://solidity.readthedocs.io/en/develop/layout-of-source-files.html#comments 2 | 3 | // Double-Asterisk doc comments 4 | 5 | /** @title Shape calculator. */ 6 | contract ShapeCalculator { 7 | /** @dev Calculates a rectangle's surface and perimeter. 8 | * @param w Width of the rectangle. 9 | * @param h Height of the rectangle. 10 | * @return s The calculated surface. 11 | * @return p The calculated perimeter. 12 | */ 13 | function rectangle(uint w, uint h) returns (uint s, uint p) { 14 | s = w * h; 15 | p = 2 * (w + h); 16 | } 17 | } 18 | 19 | // Triple-Slash doc comments 20 | 21 | /// @title Shape calculator. 22 | contract ShapeCalculator2 { 23 | /// @dev Calculates a rectangle's surface and perimeter. 24 | /// @param w Width of the rectangle. 25 | /// @param h Height of the rectangle. 26 | /// @return s The calculated surface. 27 | /// @return p The calculated perimeter. 28 | function rectangle(uint w, uint h) returns (uint s, uint p) { 29 | s = w * h; 30 | p = 2 * (w + h); 31 | } 32 | } 33 | 34 | // https://github.com/ethereum/wiki/wiki/Ethereum-Natural-Specification-Format 35 | 36 | /// @title A simulator for Bugs Bunny, the most famous Rabbit 37 | /// @author Warned Bros 38 | /// @notice You can use this contract for only the most basic simulation 39 | /// @dev All function calls are currently implement without side effects 40 | contract BugsBunny { 41 | /// @author Bob Clampett 42 | /// @notice Determine if Bugs will accept `(_food)` to eat 43 | /// @dev String comparison may be inefficient 44 | /// @param _food The name of a food to evaluate (English) 45 | /// @return true if Bugs will eat it, false otherwise 46 | function doesEat(string _food) external pure returns (bool) { 47 | return keccak256(_food) == keccak256("carrot"); 48 | } 49 | } 50 | 51 | // https://github.com/ethereum/wiki/wiki/Ethereum-Natural-Specification-Format#dynamic-expressions 52 | 53 | /// @author email.address@not-highlighted.com 54 | contract ShowcaseDynamicComments { 55 | /// @notice Send `(valueInmGAV / 1000).fixed(0,3)` GAV from the account of 56 | /// `message.caller.address()` to an account accessible only by `to.address()` 57 | function send(address to, uint256 valueInmGAV) { 58 | } 59 | } 60 | 61 | // The following simple comments should not have NatSpec highlighting: 62 | 63 | // @title A simulator for Bugs Bunny, the most famous Rabbit 64 | // @author Warned Bros 65 | // @notice You can use this contract for only the most basic simulation 66 | // @dev All function calls are currently implement without side effects 67 | // @param _food The name of a food to evaluate (English) 68 | // @return true if Bugs will eat it, false otherwise 69 | 70 | /* 71 | * @title A simulator for Bugs Bunny, the most famous Rabbit 72 | * @author Warned Bros 73 | * @notice You can use this contract for only the most basic simulation 74 | * @dev All function calls are currently implement without side effects 75 | * @param _food The name of a food to evaluate (English) 76 | * @return true if Bugs will eat it, false otherwise 77 | */ 78 | -------------------------------------------------------------------------------- /test_browserify/data/PragmaDirective.json: -------------------------------------------------------------------------------- 1 | [ 2 | [ 3 | { 4 | "type": "comment.line.double-slash", 5 | "value": "// Pragma actually parses anything up to the trailing ';' to be fully forward-compatible." 6 | } 7 | ], 8 | [ 9 | { 10 | "type": "comment.line.double-slash", 11 | "value": "// PragmaDirective = 'pragma' Identifier ([^;]+) ';'" 12 | } 13 | ], 14 | [], 15 | [ 16 | { 17 | "type": "keyword", 18 | "value": "pragma" 19 | }, 20 | { 21 | "type": "text", 22 | "value": " " 23 | }, 24 | { 25 | "type": "keyword", 26 | "value": "solidity" 27 | }, 28 | { 29 | "type": "text", 30 | "value": " " 31 | }, 32 | { 33 | "type": "constant.other", 34 | "value": "^0.4.24" 35 | }, 36 | { 37 | "type": "punctuation.operator", 38 | "value": ";" 39 | } 40 | ], 41 | [ 42 | { 43 | "type": "keyword", 44 | "value": "pragma" 45 | }, 46 | { 47 | "type": "text", 48 | "value": " " 49 | }, 50 | { 51 | "type": "keyword", 52 | "value": "experimental" 53 | }, 54 | { 55 | "type": "text", 56 | "value": " " 57 | }, 58 | { 59 | "type": "constant.other", 60 | "value": "\"v0.5.0\"" 61 | }, 62 | { 63 | "type": "punctuation.operator", 64 | "value": ";" 65 | } 66 | ], 67 | [] 68 | ] 69 | -------------------------------------------------------------------------------- /test_browserify/data/PragmaDirective.sol: -------------------------------------------------------------------------------- 1 | // Pragma actually parses anything up to the trailing ';' to be fully forward-compatible. 2 | // PragmaDirective = 'pragma' Identifier ([^;]+) ';' 3 | 4 | pragma solidity ^0.4.24; 5 | pragma experimental "v0.5.0"; 6 | -------------------------------------------------------------------------------- /test_browserify/data/ReservedKeywords.json: -------------------------------------------------------------------------------- 1 | [ 2 | [ 3 | { 4 | "type": "comment.line.double-slash", 5 | "value": "// see https://solidity.readthedocs.io/en/develop/miscellaneous.html#reserved-keywords" 6 | } 7 | ], 8 | [], 9 | [ 10 | { 11 | "type": "keyword.other.reserved", 12 | "value": "abstract" 13 | } 14 | ], 15 | [ 16 | { 17 | "type": "keyword.other.reserved", 18 | "value": "after" 19 | } 20 | ], 21 | [ 22 | { 23 | "type": "keyword.other.reserved", 24 | "value": "alias" 25 | } 26 | ], 27 | [ 28 | { 29 | "type": "keyword.other.reserved", 30 | "value": "apply" 31 | } 32 | ], 33 | [ 34 | { 35 | "type": "keyword.other.reserved", 36 | "value": "auto" 37 | } 38 | ], 39 | [ 40 | { 41 | "type": "keyword.other.reserved", 42 | "value": "case" 43 | } 44 | ], 45 | [ 46 | { 47 | "type": "keyword.other.reserved", 48 | "value": "catch" 49 | } 50 | ], 51 | [ 52 | { 53 | "type": "keyword.other.reserved", 54 | "value": "copyof" 55 | } 56 | ], 57 | [ 58 | { 59 | "type": "keyword.other.reserved", 60 | "value": "default" 61 | } 62 | ], 63 | [ 64 | { 65 | "type": "keyword.other.reserved", 66 | "value": "define" 67 | } 68 | ], 69 | [ 70 | { 71 | "type": "keyword.other.reserved", 72 | "value": "final" 73 | } 74 | ], 75 | [ 76 | { 77 | "type": "keyword.other.reserved", 78 | "value": "immutable" 79 | } 80 | ], 81 | [ 82 | { 83 | "type": "keyword.other.reserved", 84 | "value": "implements" 85 | } 86 | ], 87 | [ 88 | { 89 | "type": "keyword.other.reserved", 90 | "value": "in" 91 | } 92 | ], 93 | [ 94 | { 95 | "type": "keyword.other.reserved", 96 | "value": "inline" 97 | } 98 | ], 99 | [ 100 | { 101 | "type": "keyword.other.reserved", 102 | "value": "let" 103 | } 104 | ], 105 | [ 106 | { 107 | "type": "keyword.other.reserved", 108 | "value": "macro" 109 | } 110 | ], 111 | [ 112 | { 113 | "type": "keyword.other.reserved", 114 | "value": "match" 115 | } 116 | ], 117 | [ 118 | { 119 | "type": "keyword.other.reserved", 120 | "value": "mutable" 121 | } 122 | ], 123 | [ 124 | { 125 | "type": "keyword.other.reserved", 126 | "value": "null" 127 | } 128 | ], 129 | [ 130 | { 131 | "type": "keyword.other.reserved", 132 | "value": "of" 133 | } 134 | ], 135 | [ 136 | { 137 | "type": "keyword.other.reserved", 138 | "value": "override" 139 | } 140 | ], 141 | [ 142 | { 143 | "type": "keyword.other.reserved", 144 | "value": "partial" 145 | } 146 | ], 147 | [ 148 | { 149 | "type": "keyword.other.reserved", 150 | "value": "promise" 151 | } 152 | ], 153 | [ 154 | { 155 | "type": "keyword.other.reserved", 156 | "value": "reference" 157 | } 158 | ], 159 | [ 160 | { 161 | "type": "keyword.other.reserved", 162 | "value": "relocatable" 163 | } 164 | ], 165 | [ 166 | { 167 | "type": "keyword.other.reserved", 168 | "value": "sealed" 169 | } 170 | ], 171 | [ 172 | { 173 | "type": "keyword.other.reserved", 174 | "value": "sizeof" 175 | } 176 | ], 177 | [ 178 | { 179 | "type": "keyword.other.reserved", 180 | "value": "static" 181 | } 182 | ], 183 | [ 184 | { 185 | "type": "keyword.other.reserved", 186 | "value": "supports" 187 | } 188 | ], 189 | [ 190 | { 191 | "type": "keyword.other.reserved", 192 | "value": "switch" 193 | } 194 | ], 195 | [ 196 | { 197 | "type": "keyword.other.reserved", 198 | "value": "try" 199 | } 200 | ], 201 | [ 202 | { 203 | "type": "keyword.other.reserved", 204 | "value": "type" 205 | } 206 | ], 207 | [ 208 | { 209 | "type": "keyword.other.reserved", 210 | "value": "typedef" 211 | } 212 | ], 213 | [ 214 | { 215 | "type": "keyword.other.reserved", 216 | "value": "typeof" 217 | } 218 | ], 219 | [ 220 | { 221 | "type": "keyword.other.reserved", 222 | "value": "unchecked" 223 | } 224 | ] 225 | ] 226 | -------------------------------------------------------------------------------- /test_browserify/data/ReservedKeywords.sol: -------------------------------------------------------------------------------- 1 | // see https://solidity.readthedocs.io/en/develop/miscellaneous.html#reserved-keywords 2 | 3 | abstract 4 | after 5 | alias 6 | apply 7 | auto 8 | case 9 | catch 10 | copyof 11 | default 12 | define 13 | final 14 | immutable 15 | implements 16 | in 17 | inline 18 | let 19 | macro 20 | match 21 | mutable 22 | null 23 | of 24 | override 25 | partial 26 | promise 27 | reference 28 | relocatable 29 | sealed 30 | sizeof 31 | static 32 | supports 33 | switch 34 | try 35 | type 36 | typedef 37 | typeof 38 | unchecked -------------------------------------------------------------------------------- /test_browserify/data/StateVariableDeclaration.sol: -------------------------------------------------------------------------------- 1 | // StateVariableDeclaration = TypeName ( 'public' | 'internal' | 'private' | 'constant' )* Identifier ('=' Expression)? ';' 2 | string public publicExample = "publicExample"; 3 | string internal internalExample = "internalExample"; 4 | string private privateExample = "privateExample"; 5 | string public constant publicConstantExample = "publicConstantExample"; 6 | string internal constant internalConstantExample = "internalConstantExample"; 7 | string private constant privateConstantExample = "privateConstantExample"; 8 | string constant public constantPublicExample = "constantPublicExample"; 9 | string constant internal constantInternalExample = "constantInternalExample"; 10 | string constant private constantPrivateExample = "constantPrivateExample"; 11 | string public publicExampleDefaultValue; 12 | string internal internalExampleDefaultValue; 13 | string private privateExampleDefaultValue; 14 | 15 | 16 | -------------------------------------------------------------------------------- /test_browserify/data/StructDefinition.json: -------------------------------------------------------------------------------- 1 | [ 2 | [ 3 | { 4 | "type": "comment.line.double-slash", 5 | "value": "// StructDefinition = 'struct' Identifier '{'" 6 | } 7 | ], 8 | [ 9 | { 10 | "type": "comment.line.double-slash", 11 | "value": "// ( VariableDeclaration ';' (VariableDeclaration ';')* ) '}'" 12 | } 13 | ], 14 | [ 15 | { 16 | "type": "storage.type", 17 | "value": "struct" 18 | }, 19 | { 20 | "type": "text", 21 | "value": " " 22 | }, 23 | { 24 | "type": "identifier", 25 | "value": "Structure" 26 | }, 27 | { 28 | "type": "text", 29 | "value": " " 30 | }, 31 | { 32 | "type": "paren.lparen", 33 | "value": "{" 34 | } 35 | ], 36 | [ 37 | { 38 | "type": "text", 39 | "value": " " 40 | }, 41 | { 42 | "type": "storage.type", 43 | "value": "address" 44 | }, 45 | { 46 | "type": "text", 47 | "value": " " 48 | }, 49 | { 50 | "type": "identifier", 51 | "value": "architect" 52 | }, 53 | { 54 | "type": "punctuation.operator", 55 | "value": ";" 56 | } 57 | ], 58 | [ 59 | { 60 | "type": "text", 61 | "value": " " 62 | }, 63 | { 64 | "type": "storage.type", 65 | "value": "uint256" 66 | }, 67 | { 68 | "type": "text", 69 | "value": " " 70 | }, 71 | { 72 | "type": "identifier", 73 | "value": "maxLoad" 74 | }, 75 | { 76 | "type": "punctuation.operator", 77 | "value": ";" 78 | } 79 | ], 80 | [ 81 | { 82 | "type": "paren.rparen", 83 | "value": "}" 84 | } 85 | ], 86 | [], 87 | [ 88 | { 89 | "type": "storage.type", 90 | "value": "struct" 91 | }, 92 | { 93 | "type": "text", 94 | "value": " " 95 | }, 96 | { 97 | "type": "identifier", 98 | "value": "Town" 99 | }, 100 | { 101 | "type": "text", 102 | "value": " " 103 | }, 104 | { 105 | "type": "paren.lparen", 106 | "value": "{" 107 | } 108 | ], 109 | [ 110 | { 111 | "type": "text", 112 | "value": " " 113 | }, 114 | { 115 | "type": "storage.type.array.dynamic", 116 | "value": "string" 117 | }, 118 | { 119 | "type": "text", 120 | "value": " " 121 | }, 122 | { 123 | "type": "identifier", 124 | "value": "name" 125 | }, 126 | { 127 | "type": "punctuation.operator", 128 | "value": ";" 129 | } 130 | ], 131 | [ 132 | { 133 | "type": "text", 134 | "value": " " 135 | }, 136 | { 137 | "type": "storage.type", 138 | "value": "mapping" 139 | }, 140 | { 141 | "type": "text", 142 | "value": " " 143 | }, 144 | { 145 | "type": "paren.lparen", 146 | "value": "(" 147 | }, 148 | { 149 | "type": "storage.type", 150 | "value": "address" 151 | }, 152 | { 153 | "type": "text", 154 | "value": " " 155 | }, 156 | { 157 | "type": "keyword.operator", 158 | "value": "=>" 159 | }, 160 | { 161 | "type": "text", 162 | "value": " " 163 | }, 164 | { 165 | "type": "identifier", 166 | "value": "Structure" 167 | }, 168 | { 169 | "type": "paren.rparen", 170 | "value": ")" 171 | }, 172 | { 173 | "type": "text", 174 | "value": " " 175 | }, 176 | { 177 | "type": "identifier", 178 | "value": "buildings" 179 | }, 180 | { 181 | "type": "punctuation.operator", 182 | "value": ";" 183 | } 184 | ], 185 | [ 186 | { 187 | "type": "paren.rparen", 188 | "value": "}" 189 | } 190 | ], 191 | [] 192 | ] 193 | -------------------------------------------------------------------------------- /test_browserify/data/StructDefinition.sol: -------------------------------------------------------------------------------- 1 | // StructDefinition = 'struct' Identifier '{' 2 | // ( VariableDeclaration ';' (VariableDeclaration ';')* ) '}' 3 | struct Structure { 4 | address architect; 5 | uint256 maxLoad; 6 | } 7 | 8 | struct Town { 9 | string name; 10 | mapping (address => Structure) buildings; 11 | } 12 | -------------------------------------------------------------------------------- /test_browserify/data/UsingForDeclaration.json: -------------------------------------------------------------------------------- 1 | [ 2 | [ 3 | { 4 | "type": "comment.line.double-slash", 5 | "value": "// UsingForDeclaration = 'using' Identifier 'for' ('*' | TypeName) ';'" 6 | } 7 | ], 8 | [ 9 | { 10 | "type": "keyword", 11 | "value": "using" 12 | }, 13 | { 14 | "type": "text", 15 | "value": " " 16 | }, 17 | { 18 | "type": "identifier", 19 | "value": "VersatileLibrary" 20 | }, 21 | { 22 | "type": "text", 23 | "value": " " 24 | }, 25 | { 26 | "type": "keyword", 27 | "value": "for" 28 | }, 29 | { 30 | "type": "text", 31 | "value": " " 32 | }, 33 | { 34 | "type": "identifier", 35 | "value": "SomeThing" 36 | }, 37 | { 38 | "type": "punctuation.operator", 39 | "value": ";" 40 | } 41 | ], 42 | [ 43 | { 44 | "type": "keyword", 45 | "value": "using" 46 | }, 47 | { 48 | "type": "text", 49 | "value": " " 50 | }, 51 | { 52 | "type": "identifier", 53 | "value": "Globality" 54 | }, 55 | { 56 | "type": "text", 57 | "value": " " 58 | }, 59 | { 60 | "type": "keyword", 61 | "value": "for" 62 | }, 63 | { 64 | "type": "text", 65 | "value": " " 66 | }, 67 | { 68 | "type": "identifier", 69 | "value": "*" 70 | }, 71 | { 72 | "type": "punctuation.operator", 73 | "value": ";" 74 | } 75 | ], 76 | [] 77 | ] 78 | -------------------------------------------------------------------------------- /test_browserify/data/UsingForDeclaration.sol: -------------------------------------------------------------------------------- 1 | // UsingForDeclaration = 'using' Identifier 'for' ('*' | TypeName) ';' 2 | using VersatileLibrary for SomeThing; 3 | using Globality for *; 4 | -------------------------------------------------------------------------------- /test_browserify/data/VariableDefinition.sol: -------------------------------------------------------------------------------- 1 | // VariableDefinition = ('var' IdentifierList | VariableDeclaration | '(' VariableDeclaration? (',' VariableDeclaration? )* ')' ) ( '=' Expression )? 2 | // 3 | // semantic restriction: mappings and structs (recursively) containing mappings 4 | // are not allowed in argument lists 5 | // VariableDeclaration = TypeName StorageLocation? Identifier 6 | // TypeName = ElementaryTypeName 7 | // | UserDefinedTypeName 8 | // | Mapping 9 | // | ArrayTypeName 10 | // | FunctionTypeName 11 | // StorageLocation = 'memory' | 'storage' | 'calldata' 12 | // Mapping = 'mapping' '(' ElementaryTypeName '=>' TypeName ')' 13 | 14 | // Warning: Use of the "var" keyword is deprecated. 15 | // TypeError: Assignment necessary for type detection. 16 | var (abc, def, ghi) = (0, 0, 0); 17 | var xyz = 1000; 18 | 19 | // StorageLocation 20 | uint256 memory x; 21 | uint256 storage x; 22 | uint256 calldata x; 23 | 24 | // ElementaryTypeName 25 | address owner = 0x0123456789abcdef0123456789ABCDEF01234567; 26 | bool truth = true; 27 | bool (truth, untruth) = (true, false); 28 | string greet = "Hello World!"; 29 | var xyz = 1000; 30 | 31 | int x = 0; 32 | int8 x = 0; 33 | int16 x = 0; 34 | int24 x = 0; 35 | int32 x = 0; 36 | int40 x = 0; 37 | int48 x = 0; 38 | int56 x = 0; 39 | int64 x = 0; 40 | int72 x = 0; 41 | int80 x = 0; 42 | int88 x = 0; 43 | int96 x = 0; 44 | int104 x = 0; 45 | int112 x = 0; 46 | int120 x = 0; 47 | int128 x = 0; 48 | int136 x = 0; 49 | int144 x = 0; 50 | int152 x = 0; 51 | int160 x = 0; 52 | int168 x = 0; 53 | int176 x = 0; 54 | int184 x = 0; 55 | int192 x = 0; 56 | int200 x = 0; 57 | int208 x = 0; 58 | int216 x = 0; 59 | int224 x = 0; 60 | int232 x = 0; 61 | int240 x = 0; 62 | int248 x = 0; 63 | int256 x = 0; 64 | 65 | uint x = 0; 66 | uint8 x = 0; 67 | uint16 x = 0; 68 | uint24 x = 0; 69 | uint32 x = 0; 70 | uint40 x = 0; 71 | uint48 x = 0; 72 | uint56 x = 0; 73 | uint64 x = 0; 74 | uint72 x = 0; 75 | uint80 x = 0; 76 | uint88 x = 0; 77 | uint96 x = 0; 78 | uint104 x = 0; 79 | uint112 x = 0; 80 | uint120 x = 0; 81 | uint128 x = 0; 82 | uint136 x = 0; 83 | uint144 x = 0; 84 | uint152 x = 0; 85 | uint160 x = 0; 86 | uint168 x = 0; 87 | uint176 x = 0; 88 | uint184 x = 0; 89 | uint192 x = 0; 90 | uint200 x = 0; 91 | uint208 x = 0; 92 | uint216 x = 0; 93 | uint224 x = 0; 94 | uint232 x = 0; 95 | uint240 x = 0; 96 | uint248 x = 0; 97 | uint256 x = 0; 98 | 99 | byte x = 0; 100 | bytes x = 0; 101 | bytes1 x = 0; 102 | bytes2 x = 0; 103 | bytes3 x = 0; 104 | bytes4 x = 0; 105 | bytes5 x = 0; 106 | bytes6 x = 0; 107 | bytes7 x = 0; 108 | bytes8 x = 0; 109 | bytes9 x = 0; 110 | bytes10 x = 0; 111 | bytes11 x = 0; 112 | bytes12 x = 0; 113 | bytes13 x = 0; 114 | bytes14 x = 0; 115 | bytes15 x = 0; 116 | bytes16 x = 0; 117 | bytes17 x = 0; 118 | bytes18 x = 0; 119 | bytes19 x = 0; 120 | bytes20 x = 0; 121 | bytes21 x = 0; 122 | bytes22 x = 0; 123 | bytes23 x = 0; 124 | bytes24 x = 0; 125 | bytes25 x = 0; 126 | bytes26 x = 0; 127 | bytes27 x = 0; 128 | bytes28 x = 0; 129 | bytes29 x = 0; 130 | bytes30 x = 0; 131 | bytes31 x = 0; 132 | bytes32 x = 0; 133 | 134 | fixed x = 0.0; 135 | fixed8x4 x = 0.0; 136 | fixed16x12 x = 0.0; 137 | fixed24x18 x = 0.0; 138 | fixed32x18 x = 0.0; 139 | fixed40x18 x = 0.0; 140 | fixed48x18 x = 0.0; 141 | fixed56x18 x = 0.0; 142 | fixed64x18 x = 0.0; 143 | fixed72x18 x = 0.0; 144 | fixed80x80 x = 0.0; 145 | fixed88x80 x = 0.0; 146 | fixed96x80 x = 0.0; 147 | fixed104x80 x = 0.0; 148 | fixed112x80 x = 0.0; 149 | fixed120x80 x = 0.0; 150 | fixed128x80 x = 0.0; 151 | fixed136x80 x = 0.0; 152 | fixed144x80 x = 0.0; 153 | fixed152x80 x = 0.0; 154 | fixed160x80 x = 0.0; 155 | fixed168x80 x = 0.0; 156 | fixed176x80 x = 0.0; 157 | fixed184x80 x = 0.0; 158 | fixed192x80 x = 0.0; 159 | fixed200x80 x = 0.0; 160 | fixed208x80 x = 0.0; 161 | fixed216x80 x = 0.0; 162 | fixed224x80 x = 0.0; 163 | fixed232x80 x = 0.0; 164 | fixed240x80 x = 0.0; 165 | fixed248x80 x = 0.0; 166 | fixed256x80 x = 0.0; 167 | 168 | ufixed x = 0.0; 169 | ufixed8x4 x = 0.0; 170 | ufixed16x12 x = 0.0; 171 | ufixed24x18 x = 0.0; 172 | ufixed32x18 x = 0.0; 173 | ufixed40x18 x = 0.0; 174 | ufixed48x18 x = 0.0; 175 | ufixed56x18 x = 0.0; 176 | ufixed64x18 x = 0.0; 177 | ufixed72x18 x = 0.0; 178 | ufixed80x80 x = 0.0; 179 | ufixed88x80 x = 0.0; 180 | ufixed96x80 x = 0.0; 181 | ufixed104x80 x = 0.0; 182 | ufixed112x80 x = 0.0; 183 | ufixed120x80 x = 0.0; 184 | ufixed128x80 x = 0.0; 185 | ufixed136x80 x = 0.0; 186 | ufixed144x80 x = 0.0; 187 | ufixed152x80 x = 0.0; 188 | ufixed160x80 x = 0.0; 189 | ufixed168x80 x = 0.0; 190 | ufixed176x80 x = 0.0; 191 | ufixed184x80 x = 0.0; 192 | ufixed192x80 x = 0.0; 193 | ufixed200x80 x = 0.0; 194 | ufixed208x80 x = 0.0; 195 | ufixed216x80 x = 0.0; 196 | ufixed224x80 x = 0.0; 197 | ufixed232x80 x = 0.0; 198 | ufixed240x80 x = 0.0; 199 | ufixed248x80 x = 0.0; 200 | ufixed256x80 x = 0.0; 201 | 202 | // UserDefinedTypeName 203 | Abc.def.ghi jkl = 13; 204 | 205 | // Mapping 206 | mapping (address => uint256) accounts; 207 | 208 | // ArrayTypeName 209 | uint256[] amounts; 210 | uint256[7] lessAmounts; 211 | 212 | // FunctionTypeName 213 | // 'function' FunctionTypeParameterList ( 'internal' | 'external' | StateMutability )* 214 | // ( 'returns' FunctionTypeParameterList )? 215 | function (uint256, string) internal pure returns(uint256, bool) myDecision; 216 | function (uint256, string) internal pure myAction; 217 | 218 | // Destructuring Assignments 219 | (uint256 x, bool b, uint256 y) = f(); 220 | (, bool b, uint256 y) = f(); 221 | (uint256 x,, uint256 y) = f(); 222 | -------------------------------------------------------------------------------- /test_browserify/data/WhileStatement.json: -------------------------------------------------------------------------------- 1 | [ 2 | [ 3 | { 4 | "type": "comment.line.double-slash", 5 | "value": "// WhileStatement = 'while' '(' Expression ')' Statement" 6 | } 7 | ], 8 | [ 9 | { 10 | "type": "keyword.control", 11 | "value": "while" 12 | }, 13 | { 14 | "type": "text", 15 | "value": " " 16 | }, 17 | { 18 | "type": "paren.lparen", 19 | "value": "(" 20 | }, 21 | { 22 | "type": "constant.language.boolean", 23 | "value": "true" 24 | }, 25 | { 26 | "type": "paren.rparen", 27 | "value": ")" 28 | }, 29 | { 30 | "type": "text", 31 | "value": " " 32 | }, 33 | { 34 | "type": "identifier", 35 | "value": "f" 36 | }, 37 | { 38 | "type": "paren.lparen", 39 | "value": "(" 40 | }, 41 | { 42 | "type": "paren.rparen", 43 | "value": ")" 44 | }, 45 | { 46 | "type": "punctuation.operator", 47 | "value": ";" 48 | } 49 | ], 50 | [ 51 | { 52 | "type": "keyword.control", 53 | "value": "while" 54 | }, 55 | { 56 | "type": "text", 57 | "value": " " 58 | }, 59 | { 60 | "type": "paren.lparen", 61 | "value": "(" 62 | }, 63 | { 64 | "type": "constant.language.boolean", 65 | "value": "true" 66 | }, 67 | { 68 | "type": "paren.rparen", 69 | "value": ")" 70 | }, 71 | { 72 | "type": "text", 73 | "value": " " 74 | }, 75 | { 76 | "type": "paren.lparen", 77 | "value": "{" 78 | }, 79 | { 80 | "type": "identifier", 81 | "value": "f" 82 | }, 83 | { 84 | "type": "paren.lparen", 85 | "value": "(" 86 | }, 87 | { 88 | "type": "paren.rparen", 89 | "value": ")" 90 | }, 91 | { 92 | "type": "punctuation.operator", 93 | "value": ";" 94 | }, 95 | { 96 | "type": "paren.rparen", 97 | "value": "}" 98 | } 99 | ], 100 | [] 101 | ] 102 | -------------------------------------------------------------------------------- /test_browserify/data/WhileStatement.sol: -------------------------------------------------------------------------------- 1 | // WhileStatement = 'while' '(' Expression ')' Statement 2 | while (true) f(); 3 | while (true) {f();} 4 | -------------------------------------------------------------------------------- /test_browserify/gather-tokenizations.js: -------------------------------------------------------------------------------- 1 | const puppeteer = require('puppeteer'); 2 | const express = require('express'); 3 | 4 | module.exports = function gatherTokenizations() { 5 | return new Promise((gatherResolve, gatherReject) => { 6 | const server = express() 7 | .use(express.static(__dirname + '/public/')) 8 | .listen(3000, async () => { 9 | const browser = await puppeteer.launch({args: ['--no-sandbox']}); 10 | const page = await browser.newPage(); 11 | 12 | const outputPromise = new Promise((outputResolve, outputReject) => { 13 | page.on('console', async msg => { 14 | if ( 15 | (2 == msg.args().length) 16 | && 17 | ('tokenization' == await msg.args()[0].jsonValue()) 18 | ) { 19 | let tokenizationJSON = await msg.args()[1].jsonValue(); 20 | outputResolve(JSON.parse(tokenizationJSON)); 21 | } 22 | }); 23 | }); 24 | 25 | await page.goto('http://localhost:3000/index.html', {waitUntil: 'networkidle0'}); 26 | 27 | let tokenization = await outputPromise; 28 | 29 | await browser.close(); 30 | server.close(); 31 | gatherResolve(tokenization); 32 | }); 33 | }); 34 | } 35 | -------------------------------------------------------------------------------- /test_browserify/overwrite-expected-tokenizations.js: -------------------------------------------------------------------------------- 1 | const gatherTokenizations = require('./gather-tokenizations.js'); 2 | const writeFilePromise = require('fs-writefile-promise'); 3 | 4 | const DATADIR = __dirname + '/data'; 5 | 6 | async function overwrite() { 7 | const tokenizations = await gatherTokenizations(); 8 | Object.keys(tokenizations).forEach(async function (key) { 9 | let jsonFileName = `${DATADIR}/${key}.json`; 10 | let jsonFileContents = JSON.stringify(tokenizations[key], null, 2); 11 | jsonFileContents += "\n"; // to satisfy `git diff` 12 | await writeFilePromise(jsonFileName, jsonFileContents); 13 | }); 14 | } 15 | 16 | overwrite(); 17 | -------------------------------------------------------------------------------- /test_browserify/public/bundle.js: -------------------------------------------------------------------------------- 1 | ../cache/bundle.js -------------------------------------------------------------------------------- /test_browserify/public/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/raphaelhuefner/ace-mode-solidity/010993c0b32760b446461f26a5075a990ae9b29d/test_browserify/public/favicon.ico -------------------------------------------------------------------------------- /test_browserify/public/index.css: -------------------------------------------------------------------------------- 1 | #editor { 2 | position: absolute; 3 | top: 0; 4 | bottom: 0; 5 | left: 0; 6 | right: 0; 7 | } 8 | -------------------------------------------------------------------------------- /test_browserify/public/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Solidity with brace example 6 | 7 | 8 | 9 | 10 |
11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /test_browserify/reports-prep.js: -------------------------------------------------------------------------------- 1 | const gatherTokenizations = require('./gather-tokenizations.js'); 2 | const readFilePromise = require('fs-readfile-promise'); 3 | const writeFilePromise = require('fs-writefile-promise'); 4 | 5 | const DATADIR = __dirname + '/data'; 6 | const CACHEDIR = __dirname + '/cache'; 7 | 8 | async function writeNewTokenizations() { 9 | const tokenizations = await gatherTokenizations(); 10 | let cacheFileContents = JSON.stringify(tokenizations, null, 2); 11 | cacheFileContents += "\n"; // to satisfy `git diff` 12 | await writeFilePromise(`${CACHEDIR}/new-tokenizations.json`, cacheFileContents); 13 | return Object.keys(tokenizations); 14 | } 15 | 16 | async function writeOldTokenizations(keys) { 17 | let tokenizations = {}; 18 | for (key of keys) { 19 | let expectedTokenizationFileName = `${DATADIR}/${key}.json`; 20 | let expectedTokenization = JSON.parse(await readFilePromise(expectedTokenizationFileName)); 21 | tokenizations[key] = expectedTokenization; 22 | } 23 | let cacheFileContents = JSON.stringify(tokenizations, null, 2); 24 | cacheFileContents += "\n"; // to satisfy `git diff` 25 | await writeFilePromise(`${CACHEDIR}/old-tokenizations.json`, cacheFileContents); 26 | } 27 | 28 | async function prep() { 29 | let keys = await writeNewTokenizations(); 30 | await writeOldTokenizations(keys); 31 | } 32 | 33 | prep(); 34 | -------------------------------------------------------------------------------- /test_browserify/reports-serve.js: -------------------------------------------------------------------------------- 1 | const express = require('express'); 2 | const opn = require('opn'); 3 | 4 | const server = express() 5 | .use(express.static(__dirname + '/reports/')) 6 | .listen(3000, async () => { 7 | opn('http://localhost:3000/index.html'); 8 | }); 9 | 10 | // server.close(); 11 | -------------------------------------------------------------------------------- /test_browserify/reports/by-string-value.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Tokenization Reports for Solidity in ACE 6 | 7 | 8 | 9 | 10 |

Tokens by string value

11 |
12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /test_browserify/reports/by-string-value.js: -------------------------------------------------------------------------------- 1 | class Stats { 2 | constructor() { 3 | this.buckets = new Map(); 4 | } 5 | 6 | collect(dataSetId, tokenizations) { 7 | for (let snippetId of Object.keys(tokenizations)) { 8 | this.visitTokenization(dataSetId, snippetId, tokenizations[snippetId]) 9 | } 10 | } 11 | 12 | visitTokenization(dataSetId, snippetId, tokenization) { 13 | tokenization.forEach((line, lineIndex) => this.visitLine(line, lineIndex, snippetId, dataSetId)); 14 | } 15 | 16 | visitLine(line, lineIndex, snippetId, dataSetId) { 17 | line.forEach((token, tokenIndex) => this.visitToken(token, tokenIndex, lineIndex, snippetId, dataSetId)); 18 | } 19 | 20 | visitToken(token, tokenIndex, lineIndex, snippetId, dataSetId) { 21 | let {value, type} = token; 22 | this.addToBucket([value, type, dataSetId, snippetId], {lineIndex, tokenIndex}); 23 | } 24 | 25 | addToBucket(coordinates, value) { 26 | let buckets = this.buckets; 27 | for (let [dimension, coordinate] of coordinates.entries()) { 28 | let isLastDimension = (dimension == (coordinates.length - 1)); 29 | if (! buckets.has(coordinate)) { 30 | buckets.set(coordinate, isLastDimension ? [] : new Map()); 31 | } 32 | buckets = buckets.get(coordinate); 33 | if (isLastDimension) { 34 | buckets.push(value); 35 | } 36 | } 37 | } 38 | 39 | get summary() { 40 | return this.buckets; 41 | } 42 | } 43 | 44 | 45 | class Sorter { 46 | sort(summary) { 47 | let order = []; 48 | let ordered = new Map(); 49 | for (let [value, types] of summary) { 50 | order.push({value, total:types.size}); 51 | } 52 | order.sort((a, b) => { 53 | // sort `total` DESC 54 | if (a.total < b.total) return /*-1*/ 1; 55 | if (a.total > b.total) return /* 1*/ -1; 56 | 57 | // sort `value` ASC 58 | if (a.value < b.value) return -1; 59 | if (a.value > b.value) return 1; 60 | 61 | return 0; 62 | }); 63 | for (let {value, total} of order) { 64 | ordered.set(value, summary.get(value)); 65 | } 66 | return ordered; 67 | } 68 | } 69 | 70 | 71 | class Stylist { 72 | constructor(summary) { 73 | this.summary = summary; 74 | this.lines = []; 75 | } 76 | 77 | print(...stuff) { 78 | this.lines = this.lines.concat(stuff); 79 | } 80 | 81 | styleTypes(types) { 82 | this.print(` (`); 83 | let types_list = []; 84 | for (let [type, dataSets] of types) { 85 | let dataSetClass = Array.from(dataSets.keys()).sort().join('-'); 86 | types_list.push(`${type}`); 87 | } 88 | this.print(types_list.join(', ')); 89 | this.print(`)`); 90 | } 91 | 92 | style() { 93 | this.print(`
    `); 94 | for (let [value, types] of this.summary) { 95 | let num_types = types.size; 96 | this.print(`
  • `); 97 | this.print(`${num_types}x`); 98 | this.print(` "${value}"`); 99 | this.styleTypes(types); 100 | this.print(`
  • `); 101 | } 102 | this.print(`
`); 103 | } 104 | 105 | get output() { 106 | return this.lines.join("\n"); 107 | } 108 | } 109 | 110 | async function run() { 111 | const stats = new Stats(); 112 | for (dataSetId of ['old', 'new']) { 113 | let tokenizations = await fetch(`./${dataSetId}-tokenizations.json`).then(res => res.json()); 114 | stats.collect(dataSetId, tokenizations); 115 | } 116 | const sorter = new Sorter(); 117 | let sorted = sorter.sort(stats.summary); 118 | // console.log(sorted); 119 | 120 | const stylist = new Stylist(sorted); 121 | stylist.style(); 122 | document.getElementById('report').innerHTML = stylist.output; 123 | } 124 | 125 | run(); 126 | -------------------------------------------------------------------------------- /test_browserify/reports/diff-summary.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Tokenization Reports for Solidity in ACE 6 | 7 | 8 | 9 | 10 |

Diff Summary

11 |
12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /test_browserify/reports/diff-summary.js: -------------------------------------------------------------------------------- 1 | class Stats { 2 | constructor() { 3 | this.filesWithDifferentLineCount = new Map(); 4 | this.linesWithDifferentTokenCount = new Map(); 5 | this.tokensWithDifferentStringValue = new Map(); 6 | this.buckets = new Map(); 7 | } 8 | 9 | _getBucketId(tokenizedValue, oldToken, newToken) { 10 | return [tokenizedValue, oldToken, newToken].join('#'); 11 | } 12 | 13 | _collectDifferentLineCount(fileName, oldTokenization, newTokenization) { 14 | if (oldTokenization.length != newTokenization.length) { 15 | let stats = { 16 | before: oldTokenization.length, 17 | after: newTokenization.length 18 | } 19 | this.filesWithDifferentLineCount.set(fileName, stats); 20 | return true; 21 | } 22 | return false; 23 | } 24 | 25 | _collectDifferentTokenCount(fileName, lineIndex, oldTokens, newTokens) { 26 | if (oldTokens.length != newTokens.length) { 27 | let lineId = `${fileName}.sol@${lineIndex + 1}`; 28 | let stats = { 29 | before: oldTokens.length, 30 | after: newTokens.length 31 | } 32 | this.linesWithDifferentTokenCount.set(lineId, stats); 33 | return true; 34 | } 35 | return false; 36 | } 37 | 38 | _collectDifferentTokenStringValue(fileName, lineIndex, tokenIndex, charPos, oldToken, newToken) { 39 | if (oldToken.value != newToken.value) { 40 | let posId = `${fileName}.sol@${lineIndex + 1}:${charPos + 1}`; 41 | let stats = { 42 | before: oldToken.value, 43 | after: newToken.value 44 | } 45 | this.tokensWithDifferentStringValue.set(posId, stats); 46 | return true; 47 | } 48 | return false; 49 | } 50 | 51 | _visitEachToken(fileName, lineIndex, tokenIndex, charPos, oldToken, newToken) { 52 | if (this._collectDifferentTokenStringValue(fileName, lineIndex, tokenIndex, charPos, oldToken, newToken)) return; 53 | if (oldToken.type == newToken.type) return; 54 | let bucketId = this._getBucketId(oldToken.value, oldToken.type, newToken.type); 55 | if (! this.buckets.has(bucketId)) { 56 | let init = { 57 | value: oldToken.value, 58 | before: oldToken.type, 59 | after: newToken.type, 60 | total: 0, 61 | files: new Set() 62 | }; 63 | this.buckets.set(bucketId, init); 64 | } 65 | let stat = this.buckets.get(bucketId); 66 | stat.total++; 67 | stat.files.add(fileName); 68 | this.buckets.set(bucketId, stat); 69 | } 70 | 71 | _visitEachLine(fileName, oldTokenization, newTokenization) { 72 | oldTokenization.forEach((oldTokens, lineIndex) => { 73 | let newTokens = newTokenization[lineIndex]; 74 | if (this._collectDifferentTokenCount(fileName, lineIndex, oldTokens, newTokens)) return; 75 | let charPos = 1; 76 | oldTokens.forEach((oldToken, tokenIndex) => { 77 | let newToken = newTokens[tokenIndex]; 78 | this._visitEachToken(fileName, lineIndex, tokenIndex, charPos, oldToken, newToken); 79 | charPos += oldToken.value.length; 80 | }); 81 | }); 82 | } 83 | 84 | gather(fileName, oldTokenization, newTokenization) { 85 | if (this._collectDifferentLineCount(fileName, oldTokenization, newTokenization)) return; 86 | this._visitEachLine(fileName, oldTokenization, newTokenization); 87 | } 88 | 89 | get summary() { 90 | return { 91 | filesWithDifferentLineCount: this.filesWithDifferentLineCount, 92 | linesWithDifferentTokenCount: this.linesWithDifferentTokenCount, 93 | tokensWithDifferentStringValue: this.tokensWithDifferentStringValue, 94 | buckets: this.buckets 95 | }; 96 | } 97 | } 98 | 99 | 100 | class Stylist { 101 | constructor(summary) { 102 | this.summary = summary; 103 | this.lines = []; 104 | } 105 | 106 | print(...stuff) { 107 | this.lines = this.lines.concat(stuff); 108 | } 109 | 110 | _printLabel(input) { 111 | let label = input.replace(/([a-z])([A-Z])/g, '$1 $2').toUpperCase(); 112 | this.print(`

${label}

`); 113 | } 114 | 115 | style() { 116 | for (let statType of ['filesWithDifferentLineCount', 'linesWithDifferentTokenCount', 'tokensWithDifferentStringValue']) { 117 | let stats = this.summary[statType]; 118 | if (0 == stats.size) continue; 119 | this._printLabel(statType); 120 | this.print(`
    `); 121 | for (let [id, {before, after}] of stats) { 122 | this.print(`
  • `); 123 | this.print(`${id}: ${before}${after}`); 124 | this.print(`
  • `); 125 | } 126 | this.print(`
`); 127 | this.print(`
`); 128 | } 129 | 130 | if (0 == this.summary.buckets.size) return; 131 | let sortableBuckets = []; 132 | for (let [bucketId, stat] of this.summary.buckets) { 133 | sortableBuckets.push(stat); 134 | } 135 | sortableBuckets.sort((a, b) => { 136 | if (a.before < b.before) return -1; 137 | if (a.before > b.before) return 1; 138 | 139 | if (a.after < b.after) return -1; 140 | if (a.after > b.after) return 1; 141 | 142 | if (a.total < b.total) return /*-1; // ASC*/ 1; // DESC 143 | if (a.total > b.total) return /* 1; // ASC*/ -1; // DESC 144 | 145 | if (a.value < b.value) return -1; 146 | if (a.value > b.value) return 1; 147 | 148 | return 0; 149 | }); 150 | this._printLabel('Changed Tokenizations'); 151 | this.print(`
    `); 152 | for (let {value, before, after, total, files} of sortableBuckets) { 153 | let fileList = Array.from(files.values()).join(', '); 154 | this.print(`
  • `); 155 | this.print(`${before}${after} n=${total}, "${value}", [${fileList}]`); 156 | this.print(`
  • `); 157 | } 158 | this.print(`
`); 159 | this.print(`
`); 160 | } 161 | 162 | get output() { 163 | return this.lines.join("\n"); 164 | } 165 | } 166 | 167 | async function run() { 168 | const stats = new Stats(); 169 | const tokenizations = {}; 170 | for (dataSetId of ['old', 'new']) { 171 | tokenizations[dataSetId] = await fetch(`./${dataSetId}-tokenizations.json`).then(res => res.json()); 172 | } 173 | for (let key of Object.keys(tokenizations['new'])) { 174 | stats.gather(key, tokenizations['old'][key], tokenizations['new'][key]); 175 | } 176 | 177 | const stylist = new Stylist(stats.summary); 178 | stylist.style(); 179 | document.getElementById('report').innerHTML = stylist.output; 180 | } 181 | 182 | run(); 183 | -------------------------------------------------------------------------------- /test_browserify/reports/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Tokenization Reports for Solidity in ACE 6 | 7 | 8 | 9 | 10 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /test_browserify/reports/new-tokenizations.json: -------------------------------------------------------------------------------- 1 | ../cache/new-tokenizations.json -------------------------------------------------------------------------------- /test_browserify/reports/old-tokenizations.json: -------------------------------------------------------------------------------- 1 | ../cache/old-tokenizations.json -------------------------------------------------------------------------------- /test_browserify/reports/style.css: -------------------------------------------------------------------------------- 1 | li { 2 | line-height: 200%; 3 | } 4 | 5 | li code { 6 | display:inline; 7 | } 8 | 9 | /* by-string-value.html */ 10 | span.type { 11 | padding: 1px; 12 | border-radius: 5px; 13 | border: 1px solid #999999; 14 | background-color: #cccccc; 15 | } 16 | 17 | span.type.new-old { 18 | border: 1px solid #6666ff; 19 | background-color: #ddddff; 20 | } 21 | 22 | span.type.old { 23 | border: 1px solid #ff0000; 24 | background-color: #ffcccc; 25 | } 26 | 27 | span.type.new { 28 | border:1px solid #00ff00; 29 | background-color: #ccffcc; 30 | } 31 | 32 | 33 | /* diff-summary.html */ 34 | span.neutral { 35 | padding: 1px; 36 | border-radius: 5px; 37 | border: 1px solid #6666ff; 38 | background-color: #ddddff; 39 | } 40 | 41 | span.before { 42 | padding: 1px; 43 | border-radius: 5px; 44 | border: 1px solid #ff0000; 45 | background-color: #ffcccc; 46 | } 47 | 48 | span.after { 49 | padding: 1px; 50 | border-radius: 5px; 51 | border: 1px solid #00ff00; 52 | background-color: #ccffcc; 53 | } 54 | -------------------------------------------------------------------------------- /test_browserify/run.js: -------------------------------------------------------------------------------- 1 | const gatherTokenizations = require('./gather-tokenizations.js'); 2 | const readFilePromise = require('fs-readfile-promise'); 3 | const test = require('tape'); 4 | 5 | const DATADIR = __dirname + '/data'; 6 | 7 | async function runTests() { 8 | const tokenizations = await gatherTokenizations(); 9 | Object.keys(tokenizations).forEach(async key => { 10 | let actualTokenization = tokenizations[key]; 11 | let expectedTokenizationFileName = `${DATADIR}/${key}.json`; 12 | let expectedTokenization = JSON.parse(await readFilePromise(expectedTokenizationFileName)); 13 | test(`Testing Solidity code snippet "${key}.sol".`, t => { 14 | t.plan(1); 15 | t.deepEqual(actualTokenization, expectedTokenization); 16 | }); 17 | }); 18 | } 19 | 20 | runTests(); 21 | -------------------------------------------------------------------------------- /test_browserify/serve-editor.js: -------------------------------------------------------------------------------- 1 | const express = require('express'); 2 | const opn = require('opn'); 3 | 4 | const server = express() 5 | .use(express.static(__dirname + '/public/')) 6 | .listen(3000, async () => { 7 | opn('http://localhost:3000/index.html?do_not_run_tokenization=true'); 8 | }); 9 | 10 | // server.close(); 11 | -------------------------------------------------------------------------------- /test_browserify/src/solidity-editor.js: -------------------------------------------------------------------------------- 1 | var ace = require('brace'); 2 | require('../../build/remix-ide/mode-solidity.js'); 3 | var soliditySnippets = require('../cache/solidity-snippets.js'); 4 | 5 | var editor = ace.edit('editor'); 6 | editor.getSession().setMode('ace/mode/solidity'); 7 | 8 | function getTokenization(editor, soliditySnippets) { 9 | var tokenization = {}; 10 | Object.keys(soliditySnippets).forEach(function (key) { 11 | editor.setValue(soliditySnippets[key]); 12 | editor.clearSelection(); 13 | var l = editor.getSession().getLength(); 14 | var tokens = []; 15 | for (var i = 0; i < l; i++) { 16 | tokens.push(editor.getSession().getTokens(i)); 17 | } 18 | tokenization[key] = tokens; 19 | }); 20 | return tokenization; 21 | } 22 | 23 | function logTokenization(tokenization) { 24 | console.log('tokenization', JSON.stringify(tokenization, null, 2)) 25 | } 26 | 27 | function shouldRunTokenization() { 28 | return ( 29 | ! document.location.search 30 | || 31 | (-1 == document.location.search.indexOf("do_not_run_tokenization=true")) 32 | ); 33 | } 34 | 35 | if (shouldRunTokenization()) { 36 | logTokenization(getTokenization(editor, soliditySnippets)); 37 | } 38 | --------------------------------------------------------------------------------