mirror of
https://github.com/alecthomas/chroma.git
synced 2025-03-17 20:58:08 +02:00
Add Solidity lexer
This commit is contained in:
parent
38cc9bdc19
commit
5964ce913c
109
lexers/solidity.go
Normal file
109
lexers/solidity.go
Normal file
File diff suppressed because one or more lines are too long
20
lexers/testdata/solidity.actual
vendored
Normal file
20
lexers/testdata/solidity.actual
vendored
Normal file
@ -0,0 +1,20 @@
|
||||
pragma solidity ^0.4.11;
|
||||
|
||||
contract ReactExample {
|
||||
address private owner;
|
||||
string public you_awesome;
|
||||
|
||||
function ReactExample() public {
|
||||
owner = msg.sender;
|
||||
you_awesome = "You're awesome";
|
||||
}
|
||||
|
||||
function kill() public {
|
||||
require(msg.sender==owner);
|
||||
selfdestruct(owner);
|
||||
}
|
||||
|
||||
function () public payable {
|
||||
revert ();
|
||||
}
|
||||
}
|
102
lexers/testdata/solidity.expected
vendored
Normal file
102
lexers/testdata/solidity.expected
vendored
Normal file
@ -0,0 +1,102 @@
|
||||
[
|
||||
{"type":"KeywordReserved","value":"pragma solidity"},
|
||||
{"type":"Text","value":" "},
|
||||
{"type":"Operator","value":"^"},
|
||||
{"type":"LiteralNumberInteger","value":"0"},
|
||||
{"type":"Punctuation","value":"."},
|
||||
{"type":"LiteralNumberInteger","value":"4"},
|
||||
{"type":"Punctuation","value":"."},
|
||||
{"type":"LiteralNumberInteger","value":"11"},
|
||||
{"type":"Punctuation","value":";"},
|
||||
{"type":"Text","value":"\n\n"},
|
||||
{"type":"KeywordDeclaration","value":"contract"},
|
||||
{"type":"Text","value":" "},
|
||||
{"type":"Name","value":"ReactExample"},
|
||||
{"type":"Text","value":" "},
|
||||
{"type":"Punctuation","value":"{"},
|
||||
{"type":"Text","value":"\n "},
|
||||
{"type":"KeywordType","value":"address"},
|
||||
{"type":"Text","value":" "},
|
||||
{"type":"KeywordReserved","value":"private"},
|
||||
{"type":"Text","value":" "},
|
||||
{"type":"Name","value":"owner"},
|
||||
{"type":"Punctuation","value":";"},
|
||||
{"type":"Text","value":"\n "},
|
||||
{"type":"KeywordType","value":"string"},
|
||||
{"type":"Text","value":" "},
|
||||
{"type":"KeywordReserved","value":"public"},
|
||||
{"type":"Text","value":" "},
|
||||
{"type":"Name","value":"you_awesome"},
|
||||
{"type":"Punctuation","value":";"},
|
||||
{"type":"Text","value":"\n \n "},
|
||||
{"type":"KeywordDeclaration","value":"function"},
|
||||
{"type":"Text","value":" "},
|
||||
{"type":"Name","value":"ReactExample"},
|
||||
{"type":"Punctuation","value":"()"},
|
||||
{"type":"Text","value":" "},
|
||||
{"type":"KeywordReserved","value":"public"},
|
||||
{"type":"Text","value":" "},
|
||||
{"type":"Punctuation","value":"{"},
|
||||
{"type":"Text","value":"\n "},
|
||||
{"type":"Name","value":"owner"},
|
||||
{"type":"Text","value":" "},
|
||||
{"type":"Operator","value":"="},
|
||||
{"type":"Text","value":" "},
|
||||
{"type":"NameBuiltin","value":"msg"},
|
||||
{"type":"Punctuation","value":"."},
|
||||
{"type":"NameBuiltin","value":"sender"},
|
||||
{"type":"Punctuation","value":";"},
|
||||
{"type":"Text","value":"\n "},
|
||||
{"type":"Name","value":"you_awesome"},
|
||||
{"type":"Text","value":" "},
|
||||
{"type":"Operator","value":"="},
|
||||
{"type":"Text","value":" "},
|
||||
{"type":"LiteralString","value":"\"You're awesome\""},
|
||||
{"type":"Punctuation","value":";"},
|
||||
{"type":"Text","value":"\n "},
|
||||
{"type":"Punctuation","value":"}"},
|
||||
{"type":"Text","value":"\n \n "},
|
||||
{"type":"KeywordDeclaration","value":"function"},
|
||||
{"type":"Text","value":" "},
|
||||
{"type":"Name","value":"kill"},
|
||||
{"type":"Punctuation","value":"()"},
|
||||
{"type":"Text","value":" "},
|
||||
{"type":"KeywordReserved","value":"public"},
|
||||
{"type":"Text","value":" "},
|
||||
{"type":"Punctuation","value":"{"},
|
||||
{"type":"Text","value":"\n "},
|
||||
{"type":"NameBuiltin","value":"require"},
|
||||
{"type":"Punctuation","value":"("},
|
||||
{"type":"NameBuiltin","value":"msg"},
|
||||
{"type":"Punctuation","value":"."},
|
||||
{"type":"NameBuiltin","value":"sender"},
|
||||
{"type":"Operator","value":"=="},
|
||||
{"type":"Name","value":"owner"},
|
||||
{"type":"Punctuation","value":");"},
|
||||
{"type":"Text","value":"\n "},
|
||||
{"type":"NameBuiltin","value":"selfdestruct"},
|
||||
{"type":"Punctuation","value":"("},
|
||||
{"type":"Name","value":"owner"},
|
||||
{"type":"Punctuation","value":");"},
|
||||
{"type":"Text","value":"\n "},
|
||||
{"type":"Punctuation","value":"}"},
|
||||
{"type":"Text","value":"\n \n "},
|
||||
{"type":"KeywordDeclaration","value":"function"},
|
||||
{"type":"Text","value":" "},
|
||||
{"type":"Punctuation","value":"()"},
|
||||
{"type":"Text","value":" "},
|
||||
{"type":"KeywordReserved","value":"public"},
|
||||
{"type":"Text","value":" "},
|
||||
{"type":"KeywordReserved","value":"payable"},
|
||||
{"type":"Text","value":" "},
|
||||
{"type":"Punctuation","value":"{"},
|
||||
{"type":"Text","value":"\n "},
|
||||
{"type":"NameBuiltin","value":"revert"},
|
||||
{"type":"Text","value":" "},
|
||||
{"type":"Punctuation","value":"();"},
|
||||
{"type":"Text","value":"\n "},
|
||||
{"type":"Punctuation","value":"}"},
|
||||
{"type":"Text","value":"\n"},
|
||||
{"type":"Punctuation","value":"}"},
|
||||
{"type":"Text","value":"\n"}
|
||||
]
|
Loading…
x
Reference in New Issue
Block a user