Added support for Solidity (#2031)

This adds support for the Solidity language.

https://solidity.readthedocs.io/en/v0.4.23/
This commit is contained in:
Michael Schmidt 2019-09-02 20:29:26 +02:00 committed by GitHub
parent fb618331cc
commit cc2cf3f7bb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
17 changed files with 646 additions and 3 deletions

File diff suppressed because one or more lines are too long

View File

@ -865,6 +865,11 @@
"require": "markup-templating",
"owner": "Golmote"
},
"solidity": {
"title": "Solidity (Ethereum)",
"require": "clike",
"owner": "glachaud"
},
"soy": {
"title": "Soy (Closure Template)",
"require": "markup-templating",

View File

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

1
components/prism-solidity.min.js vendored Normal file
View File

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

View File

@ -0,0 +1,151 @@
<h2>Full example</h2>
<pre><code>pragma solidity >=0.4.22 &lt;0.7.0;
/// @title Voting with delegation.
contract Ballot {
// This declares a new complex type which will
// be used for variables later.
// It will represent a single voter.
struct Voter {
uint weight; // weight is accumulated by delegation
bool voted; // if true, that person already voted
address delegate; // person delegated to
uint vote; // index of the voted proposal
}
// This is a type for a single proposal.
struct Proposal {
bytes32 name; // short name (up to 32 bytes)
uint voteCount; // number of accumulated votes
}
address public chairperson;
// This declares a state variable that
// stores a `Voter` struct for each possible address.
mapping(address => Voter) public voters;
// A dynamically-sized array of `Proposal` structs.
Proposal[] public proposals;
/// Create a new ballot to choose one of `proposalNames`.
constructor(bytes32[] memory proposalNames) public {
chairperson = msg.sender;
voters[chairperson].weight = 1;
// For each of the provided proposal names,
// create a new proposal object and add it
// to the end of the array.
for (uint i = 0; i &lt; proposalNames.length; i++) {
// `Proposal({...})` creates a temporary
// Proposal object and `proposals.push(...)`
// appends it to the end of `proposals`.
proposals.push(Proposal({
name: proposalNames[i],
voteCount: 0
}));
}
}
// Give `voter` the right to vote on this ballot.
// May only be called by `chairperson`.
function giveRightToVote(address voter) public {
// If the first argument of `require` evaluates
// to `false`, execution terminates and all
// changes to the state and to Ether balances
// are reverted.
// This used to consume all gas in old EVM versions, but
// not anymore.
// It is often a good idea to use `require` to check if
// functions are called correctly.
// As a second argument, you can also provide an
// explanation about what went wrong.
require(
msg.sender == chairperson,
"Only chairperson can give right to vote."
);
require(
!voters[voter].voted,
"The voter already voted."
);
require(voters[voter].weight == 0);
voters[voter].weight = 1;
}
/// Delegate your vote to the voter `to`.
function delegate(address to) public {
// assigns reference
Voter storage sender = voters[msg.sender];
require(!sender.voted, "You already voted.");
require(to != msg.sender, "Self-delegation is disallowed.");
// Forward the delegation as long as
// `to` also delegated.
// In general, such loops are very dangerous,
// because if they run too long, they might
// need more gas than is available in a block.
// In this case, the delegation will not be executed,
// but in other situations, such loops might
// cause a contract to get "stuck" completely.
while (voters[to].delegate != address(0)) {
to = voters[to].delegate;
// We found a loop in the delegation, not allowed.
require(to != msg.sender, "Found loop in delegation.");
}
// Since `sender` is a reference, this
// modifies `voters[msg.sender].voted`
sender.voted = true;
sender.delegate = to;
Voter storage delegate_ = voters[to];
if (delegate_.voted) {
// If the delegate already voted,
// directly add to the number of votes
proposals[delegate_.vote].voteCount += sender.weight;
} else {
// If the delegate did not vote yet,
// add to her weight.
delegate_.weight += sender.weight;
}
}
/// Give your vote (including votes delegated to you)
/// to proposal `proposals[proposal].name`.
function vote(uint proposal) public {
Voter storage sender = voters[msg.sender];
require(sender.weight != 0, "Has no right to vote");
require(!sender.voted, "Already voted.");
sender.voted = true;
sender.vote = proposal;
// If `proposal` is out of the range of the array,
// this will throw automatically and revert all
// changes.
proposals[proposal].voteCount += sender.weight;
}
/// @dev Computes the winning proposal taking all
/// previous votes into account.
function winningProposal() public view
returns (uint winningProposal_)
{
uint winningVoteCount = 0;
for (uint p = 0; p &lt; proposals.length; p++) {
if (proposals[p].voteCount > winningVoteCount) {
winningVoteCount = proposals[p].voteCount;
winningProposal_ = p;
}
}
}
// Calls winningProposal() function to get the index
// of the winner contained in the proposals array and then
// returns the name of the winner
function winnerName() public view
returns (bytes32 winnerName_)
{
winnerName_ = proposals[winningProposal()].name;
}
}</code></pre>

View File

@ -98,6 +98,7 @@
"scala": "java",
"shell-session": "bash",
"smarty": "markup-templating",
"solidity": "clike",
"soy": "markup-templating",
"swift": "clike",
"tap": "yaml",

View File

@ -1 +1 @@
!function(){if("undefined"!=typeof self&&self.Prism&&self.document&&document.createElement){var c={javascript:"clike",actionscript:"javascript",arduino:"cpp",aspnet:["markup","csharp"],bison:"c",c:"clike",csharp:"clike",cpp:"c",coffeescript:"javascript",crystal:"ruby","css-extras":"css",d:"clike",dart:"clike",django:"markup-templating",ejs:["javascript","markup-templating"],erb:["ruby","markup-templating"],fsharp:"clike","firestore-security-rules":"clike",flow:"javascript",glsl:"clike",gml:"clike",go:"clike",groovy:"clike",haml:"ruby",handlebars:"markup-templating",haxe:"clike",java:"clike",javadoc:["markup","java","javadoclike"],jolie:"clike",jsdoc:["javascript","javadoclike"],"js-extras":"javascript","js-templates":"javascript",jsonp:"json",json5:"json",kotlin:"clike",less:"css",lilypond:"scheme",markdown:"markup","markup-templating":"markup",n4js:"javascript",nginx:"clike",objectivec:"c",opencl:"cpp",parser:"markup",php:["clike","markup-templating"],phpdoc:["php","javadoclike"],"php-extras":"php",plsql:"sql",processing:"clike",protobuf:"clike",pug:["markup","javascript"],qore:"clike",jsx:["markup","javascript"],tsx:["jsx","typescript"],reason:"clike",ruby:"clike",sas:"sql",sass:"css",scss:"css",scala:"java","shell-session":"bash",smarty:"markup-templating",soy:"markup-templating",swift:"clike",tap:"yaml",textile:"markup",tt2:["clike","markup-templating"],twig:"markup",typescript:"javascript","t4-cs":["t4-templating","csharp"],"t4-vb":["t4-templating","visual-basic"],vala:"clike",vbnet:"basic",velocity:"markup",wiki:"markup",xeora:"markup",xquery:"markup"},l={html:"markup",xml:"markup",svg:"markup",mathml:"markup",js:"javascript",adoc:"asciidoc",shell:"bash",rbnf:"bnf",cs:"csharp",dotnet:"csharp",coffee:"coffeescript",jinja2:"django","dns-zone":"dns-zone-file",dockerfile:"docker",gamemakerlanguage:"gml",hs:"haskell",tex:"latex",context:"latex",ly:"lilypond",emacs:"lisp",elisp:"lisp","emacs-lisp":"lisp",md:"markdown",n4jsd:"n4js",objectpascal:"pascal",px:"pcaxis",py:"python",rb:"ruby",trig:"turtle",ts:"typescript",t4:"t4-cs",vb:"visual-basic",xeoracube:"xeora",yml:"yaml"},n={},e=document.getElementsByTagName("script"),a=e[e.length-1],t="components/",s=/\bplugins\/autoloader\/prism-autoloader\.(?:min\.)js$/i,i=/[\w-]+\.(?:min\.)js$/i;if(a.hasAttribute("data-autoloader-path"))t=a.getAttribute("data-autoloader-path").trim().replace(/\/?$/,"/");else{var r=a.src;s.test(r)?t=r.replace(s,"components/"):i.test(r)&&(t=r.replace(i,"components/"))}var p=Prism.plugins.autoloader={languages_path:t,use_minified:!0,loadLanguages:o};Prism.hooks.add("complete",function(e){e.element&&e.language&&!e.grammar&&"none"!==e.language&&function(e,a){e in l&&(e=l[e]);var t=a.getAttribute("data-dependencies"),s=a.parentElement;!t&&s&&"pre"===s.tagName.toLowerCase()&&(t=s.getAttribute("data-dependencies")),o(t=t?t.split(/\s*,\s*/g):[],function(){m(e,function(){Prism.highlightElement(a)})})}(e.language,e.element)})}function o(e,a,t){"string"==typeof e&&(e=[e]);var s=e.length,i=0,r=!1;function c(){r||++i===s&&a&&a(e)}0!==s?e.forEach(function(e){m(e,c,function(){r||(r=!0,t&&t(e))})}):a&&setTimeout(a,0)}function m(a,t,s){var i=0<=a.indexOf("!");a=a.replace("!",""),a=l[a]||a;var e=function(){var e=n[a];if(e||(e=n[a]={callbacks:[]}),e.callbacks.push({success:t,error:s}),!i&&Prism.languages[a])u(a,"success");else if(!i&&e.error)u(a,"error");else if(i||!e.loading){e.loading=!0,function(e,a,t){var s=document.createElement("script");s.src=e,s.async=!0,s.onload=function(){document.body.removeChild(s),a&&a()},s.onerror=function(){document.body.removeChild(s),t&&t()},document.body.appendChild(s)}(function(e){return p.languages_path+"prism-"+e+(p.use_minified?".min":"")+".js"}(a),function(){e.loading=!1,u(a,"success")},function(){e.loading=!1,e.error=!0,u(a,"error")})}},r=c[a];r&&r.length?o(r,e,s):e()}function u(e,a){if(n[e]){for(var t=n[e].callbacks,s=0,i=t.length;s<i;s++){var r=t[s][a];r&&setTimeout(r,0)}t.length=0}}}();
!function(){if("undefined"!=typeof self&&self.Prism&&self.document&&document.createElement){var c={javascript:"clike",actionscript:"javascript",arduino:"cpp",aspnet:["markup","csharp"],bison:"c",c:"clike",csharp:"clike",cpp:"c",coffeescript:"javascript",crystal:"ruby","css-extras":"css",d:"clike",dart:"clike",django:"markup-templating",ejs:["javascript","markup-templating"],erb:["ruby","markup-templating"],fsharp:"clike","firestore-security-rules":"clike",flow:"javascript",glsl:"clike",gml:"clike",go:"clike",groovy:"clike",haml:"ruby",handlebars:"markup-templating",haxe:"clike",java:"clike",javadoc:["markup","java","javadoclike"],jolie:"clike",jsdoc:["javascript","javadoclike"],"js-extras":"javascript","js-templates":"javascript",jsonp:"json",json5:"json",kotlin:"clike",less:"css",lilypond:"scheme",markdown:"markup","markup-templating":"markup",n4js:"javascript",nginx:"clike",objectivec:"c",opencl:"cpp",parser:"markup",php:["clike","markup-templating"],phpdoc:["php","javadoclike"],"php-extras":"php",plsql:"sql",processing:"clike",protobuf:"clike",pug:["markup","javascript"],qore:"clike",jsx:["markup","javascript"],tsx:["jsx","typescript"],reason:"clike",ruby:"clike",sas:"sql",sass:"css",scss:"css",scala:"java","shell-session":"bash",smarty:"markup-templating",solidity:"clike",soy:"markup-templating",swift:"clike",tap:"yaml",textile:"markup",tt2:["clike","markup-templating"],twig:"markup",typescript:"javascript","t4-cs":["t4-templating","csharp"],"t4-vb":["t4-templating","visual-basic"],vala:"clike",vbnet:"basic",velocity:"markup",wiki:"markup",xeora:"markup",xquery:"markup"},l={html:"markup",xml:"markup",svg:"markup",mathml:"markup",js:"javascript",adoc:"asciidoc",shell:"bash",rbnf:"bnf",cs:"csharp",dotnet:"csharp",coffee:"coffeescript",jinja2:"django","dns-zone":"dns-zone-file",dockerfile:"docker",gamemakerlanguage:"gml",hs:"haskell",tex:"latex",context:"latex",ly:"lilypond",emacs:"lisp",elisp:"lisp","emacs-lisp":"lisp",md:"markdown",n4jsd:"n4js",objectpascal:"pascal",px:"pcaxis",py:"python",rb:"ruby",trig:"turtle",ts:"typescript",t4:"t4-cs",vb:"visual-basic",xeoracube:"xeora",yml:"yaml"},n={},e=document.getElementsByTagName("script"),a=e[e.length-1],t="components/",s=/\bplugins\/autoloader\/prism-autoloader\.(?:min\.)js$/i,i=/[\w-]+\.(?:min\.)js$/i;if(a.hasAttribute("data-autoloader-path"))t=a.getAttribute("data-autoloader-path").trim().replace(/\/?$/,"/");else{var r=a.src;s.test(r)?t=r.replace(s,"components/"):i.test(r)&&(t=r.replace(i,"components/"))}var p=Prism.plugins.autoloader={languages_path:t,use_minified:!0,loadLanguages:o};Prism.hooks.add("complete",function(e){e.element&&e.language&&!e.grammar&&"none"!==e.language&&function(e,a){e in l&&(e=l[e]);var t=a.getAttribute("data-dependencies"),s=a.parentElement;!t&&s&&"pre"===s.tagName.toLowerCase()&&(t=s.getAttribute("data-dependencies")),o(t=t?t.split(/\s*,\s*/g):[],function(){m(e,function(){Prism.highlightElement(a)})})}(e.language,e.element)})}function o(e,a,t){"string"==typeof e&&(e=[e]);var s=e.length,i=0,r=!1;function c(){r||++i===s&&a&&a(e)}0!==s?e.forEach(function(e){m(e,c,function(){r||(r=!0,t&&t(e))})}):a&&setTimeout(a,0)}function m(a,t,s){var i=0<=a.indexOf("!");a=a.replace("!",""),a=l[a]||a;var e=function(){var e=n[a];if(e||(e=n[a]={callbacks:[]}),e.callbacks.push({success:t,error:s}),!i&&Prism.languages[a])u(a,"success");else if(!i&&e.error)u(a,"error");else if(i||!e.loading){e.loading=!0,function(e,a,t){var s=document.createElement("script");s.src=e,s.async=!0,s.onload=function(){document.body.removeChild(s),a&&a()},s.onerror=function(){document.body.removeChild(s),t&&t()},document.body.appendChild(s)}(function(e){return p.languages_path+"prism-"+e+(p.use_minified?".min":"")+".js"}(a),function(){e.loading=!1,u(a,"success")},function(){e.loading=!1,e.error=!0,u(a,"error")})}},r=c[a];r&&r.length?o(r,e,s):e()}function u(e,a){if(n[e]){for(var t=n[e].callbacks,s=0,i=t.length;s<i;s++){var r=t[s][a];r&&setTimeout(r,0)}t.length=0}}}();

View File

@ -123,6 +123,7 @@
"sass": "Sass (Sass)",
"scss": "Sass (Scss)",
"shell-session": "Shell session",
"solidity": "Solidity (Ethereum)",
"soy": "Soy (Closure Template)",
"splunk-spl": "Splunk SPL",
"sql": "SQL",

View File

@ -1 +1 @@
!function(){if("undefined"!=typeof self&&self.Prism&&self.document)if(Prism.plugins.toolbar){var i={html:"HTML",xml:"XML",svg:"SVG",mathml:"MathML",css:"CSS",clike:"C-like",js:"JavaScript",abap:"ABAP",abnf:"Augmented BackusNaur form",apacheconf:"Apache Configuration",apl:"APL",aql:"AQL",arff:"ARFF",asciidoc:"AsciiDoc",adoc:"AsciiDoc",asm6502:"6502 Assembly",aspnet:"ASP.NET (C#)",autohotkey:"AutoHotkey",autoit:"AutoIt",shell:"Bash",basic:"BASIC",bnf:"BackusNaur form",rbnf:"Routing BackusNaur form",csharp:"C#",cs:"C#",dotnet:"C#",cpp:"C++",cil:"CIL",coffee:"CoffeeScript",cmake:"CMake",csp:"Content-Security-Policy","css-extras":"CSS Extras",django:"Django/Jinja2",jinja2:"Django/Jinja2","dns-zone-file":"DNS zone file","dns-zone":"DNS zone file",dockerfile:"Docker",ebnf:"Extended BackusNaur form",ejs:"EJS",erb:"ERB",fsharp:"F#","firestore-security-rules":"Firestore security rules",gcode:"G-code",gdscript:"GDScript",gedcom:"GEDCOM",glsl:"GLSL",gml:"GameMaker Language",gamemakerlanguage:"GameMaker Language",graphql:"GraphQL",hs:"Haskell",hcl:"HCL",http:"HTTP",hpkp:"HTTP Public-Key-Pins",hsts:"HTTP Strict-Transport-Security",ichigojam:"IchigoJam",inform7:"Inform 7",javadoc:"JavaDoc",javadoclike:"JavaDoc-like",javastacktrace:"Java stack trace",jq:"JQ",jsdoc:"JSDoc","js-extras":"JS Extras","js-templates":"JS Templates",json:"JSON",jsonp:"JSONP",json5:"JSON5",latex:"LaTeX",tex:"TeX",context:"ConTeXt",lilypond:"LilyPond",ly:"LilyPond",emacs:"Lisp",elisp:"Lisp","emacs-lisp":"Lisp",lolcode:"LOLCODE",md:"Markdown","markup-templating":"Markup templating",matlab:"MATLAB",mel:"MEL",n1ql:"N1QL",n4js:"N4JS",n4jsd:"N4JS","nand2tetris-hdl":"Nand To Tetris HDL",nasm:"NASM",nginx:"nginx",nsis:"NSIS",objectivec:"Objective-C",ocaml:"OCaml",opencl:"OpenCL",parigp:"PARI/GP",objectpascal:"Object Pascal",pcaxis:"PC-Axis",px:"PC-Axis",php:"PHP",phpdoc:"PHPDoc","php-extras":"PHP Extras",plsql:"PL/SQL",powershell:"PowerShell",properties:".properties",protobuf:"Protocol Buffers",py:"Python",q:"Q (kdb+ database)",jsx:"React JSX",tsx:"React TSX",renpy:"Ren'py",rest:"reST (reStructuredText)",rb:"Ruby",sas:"SAS",sass:"Sass (Sass)",scss:"Sass (Scss)","shell-session":"Shell session",soy:"Soy (Closure Template)","splunk-spl":"Splunk SPL",sql:"SQL",tap:"TAP",toml:"TOML",tt2:"Template Toolkit 2",trig:"TriG",ts:"TypeScript","t4-cs":"T4 Text Templates (C#)",t4:"T4 Text Templates (C#)","t4-vb":"T4 Text Templates (VB)","t4-templating":"T4 templating",vbnet:"VB.Net",vhdl:"VHDL",vim:"vim","visual-basic":"Visual Basic",vb:"Visual Basic",wasm:"WebAssembly",wiki:"Wiki markup",xeoracube:"XeoraCube",xojo:"Xojo (REALbasic)",xquery:"XQuery",yaml:"YAML",yml:"YAML"};Prism.plugins.toolbar.registerButton("show-language",function(e){var a=e.element.parentNode;if(a&&/pre/i.test(a.nodeName)){var s,t=a.getAttribute("data-language")||i[e.language]||((s=e.language)?(s.substring(0,1).toUpperCase()+s.substring(1)).replace(/s(?=cript)/,"S"):s);if(t){var o=document.createElement("span");return o.textContent=t,o}}})}else console.warn("Show Languages plugin loaded before Toolbar plugin.")}();
!function(){if("undefined"!=typeof self&&self.Prism&&self.document)if(Prism.plugins.toolbar){var i={html:"HTML",xml:"XML",svg:"SVG",mathml:"MathML",css:"CSS",clike:"C-like",js:"JavaScript",abap:"ABAP",abnf:"Augmented BackusNaur form",apacheconf:"Apache Configuration",apl:"APL",aql:"AQL",arff:"ARFF",asciidoc:"AsciiDoc",adoc:"AsciiDoc",asm6502:"6502 Assembly",aspnet:"ASP.NET (C#)",autohotkey:"AutoHotkey",autoit:"AutoIt",shell:"Bash",basic:"BASIC",bnf:"BackusNaur form",rbnf:"Routing BackusNaur form",csharp:"C#",cs:"C#",dotnet:"C#",cpp:"C++",cil:"CIL",coffee:"CoffeeScript",cmake:"CMake",csp:"Content-Security-Policy","css-extras":"CSS Extras",django:"Django/Jinja2",jinja2:"Django/Jinja2","dns-zone-file":"DNS zone file","dns-zone":"DNS zone file",dockerfile:"Docker",ebnf:"Extended BackusNaur form",ejs:"EJS",erb:"ERB",fsharp:"F#","firestore-security-rules":"Firestore security rules",gcode:"G-code",gdscript:"GDScript",gedcom:"GEDCOM",glsl:"GLSL",gml:"GameMaker Language",gamemakerlanguage:"GameMaker Language",graphql:"GraphQL",hs:"Haskell",hcl:"HCL",http:"HTTP",hpkp:"HTTP Public-Key-Pins",hsts:"HTTP Strict-Transport-Security",ichigojam:"IchigoJam",inform7:"Inform 7",javadoc:"JavaDoc",javadoclike:"JavaDoc-like",javastacktrace:"Java stack trace",jq:"JQ",jsdoc:"JSDoc","js-extras":"JS Extras","js-templates":"JS Templates",json:"JSON",jsonp:"JSONP",json5:"JSON5",latex:"LaTeX",tex:"TeX",context:"ConTeXt",lilypond:"LilyPond",ly:"LilyPond",emacs:"Lisp",elisp:"Lisp","emacs-lisp":"Lisp",lolcode:"LOLCODE",md:"Markdown","markup-templating":"Markup templating",matlab:"MATLAB",mel:"MEL",n1ql:"N1QL",n4js:"N4JS",n4jsd:"N4JS","nand2tetris-hdl":"Nand To Tetris HDL",nasm:"NASM",nginx:"nginx",nsis:"NSIS",objectivec:"Objective-C",ocaml:"OCaml",opencl:"OpenCL",parigp:"PARI/GP",objectpascal:"Object Pascal",pcaxis:"PC-Axis",px:"PC-Axis",php:"PHP",phpdoc:"PHPDoc","php-extras":"PHP Extras",plsql:"PL/SQL",powershell:"PowerShell",properties:".properties",protobuf:"Protocol Buffers",py:"Python",q:"Q (kdb+ database)",jsx:"React JSX",tsx:"React TSX",renpy:"Ren'py",rest:"reST (reStructuredText)",rb:"Ruby",sas:"SAS",sass:"Sass (Sass)",scss:"Sass (Scss)","shell-session":"Shell session",solidity:"Solidity (Ethereum)",soy:"Soy (Closure Template)","splunk-spl":"Splunk SPL",sql:"SQL",tap:"TAP",toml:"TOML",tt2:"Template Toolkit 2",trig:"TriG",ts:"TypeScript","t4-cs":"T4 Text Templates (C#)",t4:"T4 Text Templates (C#)","t4-vb":"T4 Text Templates (VB)","t4-templating":"T4 templating",vbnet:"VB.Net",vhdl:"VHDL",vim:"vim","visual-basic":"Visual Basic",vb:"Visual Basic",wasm:"WebAssembly",wiki:"Wiki markup",xeoracube:"XeoraCube",xojo:"Xojo (REALbasic)",xquery:"XQuery",yaml:"YAML",yml:"YAML"};Prism.plugins.toolbar.registerButton("show-language",function(e){var a=e.element.parentNode;if(a&&/pre/i.test(a.nodeName)){var s,t=a.getAttribute("data-language")||i[e.language]||((s=e.language)?(s.substring(0,1).toUpperCase()+s.substring(1)).replace(/s(?=cript)/,"S"):s);if(t){var o=document.createElement("span");return o.textContent=t,o}}})}else console.warn("Show Languages plugin loaded before Toolbar plugin.")}();

View File

@ -0,0 +1,126 @@
address
bool
string
byte
bytes
int
uint
bytes1 bytes2 bytes3 bytes4 bytes5 bytes6 bytes7 bytes8 bytes9 bytes10 bytes11 bytes12 bytes13 bytes14 bytes15 bytes16 bytes17 bytes18 bytes19 bytes20 bytes21 bytes22 bytes23 bytes24 bytes25 bytes26 bytes27 bytes28 bytes29 bytes30 bytes31 bytes32
int8 int16 int24 int32 int40 int48 int56 int64 int72 int80 int88 int96 int104 int112 int120 int128 int136 int144 int152 int160 int168 int176 int184 int192 int200 int208 int216 int224 int232 int240 int248 int256
uint8 uint16 uint24 uint32 uint40 uint48 uint56 uint64 uint72 uint80 uint88 uint96 uint104 uint112 uint120 uint128 uint136 uint144 uint152 uint160 uint168 uint176 uint184 uint192 uint200 uint208 uint216 uint224 uint232 uint240 uint248 uint256
----------------------------------------------------
[
["builtin", "address"],
["builtin", "bool"],
["builtin", "string"],
["builtin", "byte"],
["builtin", "bytes"],
["builtin", "int"],
["builtin", "uint"],
["builtin", "bytes1"],
["builtin", "bytes2"],
["builtin", "bytes3"],
["builtin", "bytes4"],
["builtin", "bytes5"],
["builtin", "bytes6"],
["builtin", "bytes7"],
["builtin", "bytes8"],
["builtin", "bytes9"],
["builtin", "bytes10"],
["builtin", "bytes11"],
["builtin", "bytes12"],
["builtin", "bytes13"],
["builtin", "bytes14"],
["builtin", "bytes15"],
["builtin", "bytes16"],
["builtin", "bytes17"],
["builtin", "bytes18"],
["builtin", "bytes19"],
["builtin", "bytes20"],
["builtin", "bytes21"],
["builtin", "bytes22"],
["builtin", "bytes23"],
["builtin", "bytes24"],
["builtin", "bytes25"],
["builtin", "bytes26"],
["builtin", "bytes27"],
["builtin", "bytes28"],
["builtin", "bytes29"],
["builtin", "bytes30"],
["builtin", "bytes31"],
["builtin", "bytes32"],
["builtin", "int8"],
["builtin", "int16"],
["builtin", "int24"],
["builtin", "int32"],
["builtin", "int40"],
["builtin", "int48"],
["builtin", "int56"],
["builtin", "int64"],
["builtin", "int72"],
["builtin", "int80"],
["builtin", "int88"],
["builtin", "int96"],
["builtin", "int104"],
["builtin", "int112"],
["builtin", "int120"],
["builtin", "int128"],
["builtin", "int136"],
["builtin", "int144"],
["builtin", "int152"],
["builtin", "int160"],
["builtin", "int168"],
["builtin", "int176"],
["builtin", "int184"],
["builtin", "int192"],
["builtin", "int200"],
["builtin", "int208"],
["builtin", "int216"],
["builtin", "int224"],
["builtin", "int232"],
["builtin", "int240"],
["builtin", "int248"],
["builtin", "int256"],
["builtin", "uint8"],
["builtin", "uint16"],
["builtin", "uint24"],
["builtin", "uint32"],
["builtin", "uint40"],
["builtin", "uint48"],
["builtin", "uint56"],
["builtin", "uint64"],
["builtin", "uint72"],
["builtin", "uint80"],
["builtin", "uint88"],
["builtin", "uint96"],
["builtin", "uint104"],
["builtin", "uint112"],
["builtin", "uint120"],
["builtin", "uint128"],
["builtin", "uint136"],
["builtin", "uint144"],
["builtin", "uint152"],
["builtin", "uint160"],
["builtin", "uint168"],
["builtin", "uint176"],
["builtin", "uint184"],
["builtin", "uint192"],
["builtin", "uint200"],
["builtin", "uint208"],
["builtin", "uint216"],
["builtin", "uint224"],
["builtin", "uint232"],
["builtin", "uint240"],
["builtin", "uint248"],
["builtin", "uint256"]
]
----------------------------------------------------
Checks for builtin types.

View File

@ -0,0 +1,65 @@
contract Foo {}
contract Foo is Bar {}
enum Foo { X, Y, Z }
interface Foo {}
library Foo {}
new Foo();
struct Foo {}
using Foo for bar;
----------------------------------------------------
[
["keyword", "contract"],
["class-name", "Foo"],
["punctuation", "{"],
["punctuation", "}"],
["keyword", "contract"],
["class-name", "Foo"],
["keyword", "is"],
" Bar ",
["punctuation", "{"],
["punctuation", "}"],
["keyword", "enum"],
["class-name", "Foo"],
["punctuation", "{"],
" X",
["punctuation", ","],
" Y",
["punctuation", ","],
" Z ",
["punctuation", "}"],
["keyword", "interface"],
["class-name", "Foo"],
["punctuation", "{"],
["punctuation", "}"],
["keyword", "library"],
["class-name", "Foo"],
["punctuation", "{"],
["punctuation", "}"],
["keyword", "new"],
["class-name", "Foo"],
["punctuation", "("],
["punctuation", ")"],
["punctuation", ";"],
["keyword", "struct"],
["class-name", "Foo"],
["punctuation", "{"],
["punctuation", "}"],
["keyword", "using"],
["class-name", "Foo"],
["keyword", "for"],
" bar",
["punctuation", ";"]
]
----------------------------------------------------
Checks for class names.

View File

@ -0,0 +1,15 @@
// foo
/*
bar
*/
----------------------------------------------------
[
["comment", "// foo"],
["comment", "/*\nbar\n*/"]
]
----------------------------------------------------
Checks for comments.

View File

@ -0,0 +1,128 @@
_
anonymous
as
assembly
assert
break
calldata
case
constant
constructor
continue
contract;
default
delete
do
else
emit
enum;
event
external
for
from
function
if
import
indexed
inherited
interface;
internal
is
let
library;
mapping
memory
modifier
new;
payable
pragma
private
public
pure
require
return
returns
revert
selfdestruct
solidity
storage
struct;
suicide
switch
this
throw
using;
view
while
----------------------------------------------------
[
["keyword", "_"],
["keyword", "anonymous"],
["keyword", "as"],
["keyword", "assembly"],
["keyword", "assert"],
["keyword", "break"],
["keyword", "calldata"],
["keyword", "case"],
["keyword", "constant"],
["keyword", "constructor"],
["keyword", "continue"],
["keyword", "contract"],
["punctuation", ";"],
["keyword", "default"],
["keyword", "delete"],
["keyword", "do"],
["keyword", "else"],
["keyword", "emit"],
["keyword", "enum"],
["punctuation", ";"],
["keyword", "event"],
["keyword", "external"],
["keyword", "for"],
["keyword", "from"],
["keyword", "function"],
["keyword", "if"],
["keyword", "import"],
["keyword", "indexed"],
["keyword", "inherited"],
["keyword", "interface"],
["punctuation", ";"],
["keyword", "internal"],
["keyword", "is"],
["keyword", "let"],
["keyword", "library"],
["punctuation", ";"],
["keyword", "mapping"],
["keyword", "memory"],
["keyword", "modifier"],
["keyword", "new"],
["punctuation", ";"],
["keyword", "payable"],
["keyword", "pragma"],
["keyword", "private"],
["keyword", "public"],
["keyword", "pure"],
["keyword", "require"],
["keyword", "return"],
["keyword", "returns"],
["keyword", "revert"],
["keyword", "selfdestruct"],
["keyword", "solidity"],
["keyword", "storage"],
["keyword", "struct"],
["punctuation", ";"],
["keyword", "suicide"],
["keyword", "switch"],
["keyword", "this"],
["keyword", "throw"],
["keyword", "using"],
["punctuation", ";"],
["keyword", "view"],
["keyword", "while"]
]
----------------------------------------------------
Checks for keywords.

View File

@ -0,0 +1,68 @@
+ - * / %
+= -= *= /= %=
^ & | ~
^= &= |=
>> << >>= <<=
&& || !
=
>= <= > < != ==
=> -> := =:
?
----------------------------------------------------
[
["operator", "+"],
["operator", "-"],
["operator", "*"],
["operator", "/"],
["operator", "%"],
["operator", "+="],
["operator", "-="],
["operator", "*="],
["operator", "/="],
["operator", "%="],
["operator", "^"],
["operator", "&"],
["operator", "|"],
["operator", "~"],
["operator", "^="],
["operator", "&="],
["operator", "|="],
["operator", ">>"],
["operator", "<<"],
["operator", ">>="],
["operator", "<<="],
["operator", "&&"],
["operator", "||"],
["operator", "!"],
["operator", "="],
["operator", ">="],
["operator", "<="],
["operator", ">"],
["operator", "<"],
["operator", "!="],
["operator", "=="],
["operator", "=>"],
["operator", "->"],
["operator", ":="],
["operator", "=:"],
["operator", "?"]
]
----------------------------------------------------
Checks for operators.

View File

@ -0,0 +1,21 @@
() [] {}
. : , ;
----------------------------------------------------
[
["punctuation", "("],
["punctuation", ")"],
["punctuation", "["],
["punctuation", "]"],
["punctuation", "{"],
["punctuation", "}"],
["punctuation", "."],
["punctuation", ":"],
["punctuation", ","],
["punctuation", ";"]
]
----------------------------------------------------
Checks for punctuation.

View File

@ -0,0 +1,17 @@
"foo\"\'"
'bar\'\"'
"\n\"\'\\abc\
def"
----------------------------------------------------
[
["string", "\"foo\\\"\\'\""],
["string", "'bar\\'\\\"'"],
["string", "\"\\n\\\"\\'\\\\abc\\\ndef\""]
]
----------------------------------------------------
Checks for strings.

View File

@ -0,0 +1,24 @@
pragma solidity >=0.4.0 <0.7.0;
pragma solidity ^0.5.0;
----------------------------------------------------
[
["keyword", "pragma"],
["keyword", "solidity"],
["operator", ">="],
["version", "0.4.0"],
["operator", "<"],
["version", "0.7.0"],
["punctuation", ";"],
["keyword", "pragma"],
["keyword", "solidity"],
["operator", "^"],
["version", "0.5.0"],
["punctuation", ";"]
]
----------------------------------------------------
Checks for version literals.