Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 16 additions & 4 deletions lexers/embedded/solidity.xml
Original file line number Diff line number Diff line change
Expand Up @@ -157,8 +157,20 @@
<rule pattern="(continue|returns|storage|memory|delete|return|throw|break|catch|while|else|from|new|try|for|if|is|as|do|in|_)\b">
<token type="Keyword"/>
</rule>
<rule pattern="assembly\b">
<token type="Keyword"/>
<rule pattern="(assembly)(\s+\()(.+)(\)\s+{)">
<bygroups>
<token type="Keyword"/>
<token type="Text"/>
<token type="LiteralString"/>
<token type="Text"/>
</bygroups>
<push state="assembly"/>
</rule>
<rule pattern="(assembly)(\s+{)">
<bygroups>
<token type="Keyword"/>
<token type="Text"/>
</bygroups>
<push state="assembly"/>
</rule>
<rule pattern="(contract|interface|enum|event|struct)(\s+)([a-zA-Z_]\w*)">
Expand Down Expand Up @@ -235,7 +247,7 @@
<token type="Punctuation"/>
<pop depth="1"/>
</rule>
<rule pattern="[(),]">
<rule pattern="[(),.]">
<token type="Punctuation"/>
</rule>
<rule pattern=":=|=:">
Expand Down Expand Up @@ -276,4 +288,4 @@
</rule>
</state>
</rules>
</lexer>
</lexer>
8 changes: 8 additions & 0 deletions lexers/testdata/solidity.actual
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,14 @@ contract ReactExample {
you_awesome = "You're awesome";
}

function AssemblyExample() public {
assembly {
let o := sload(0)
call(gas(), o, 5, 0, 0, 0, 0)
}
require(success, "Failed to send ETH");
}

function kill() public {
require(msg.sender==owner);
selfdestruct(owner);
Expand Down
57 changes: 57 additions & 0 deletions lexers/testdata/solidity.expected
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,63 @@
{"type":"Text","value":"\n \n "},
{"type":"KeywordDeclaration","value":"function"},
{"type":"Text","value":" "},
{"type":"NameFunction","value":"AssemblyExample"},
{"type":"Punctuation","value":"()"},
{"type":"Text","value":" "},
{"type":"Keyword","value":"public"},
{"type":"Text","value":" "},
{"type":"Punctuation","value":"{"},
{"type":"Text","value":"\n "},
{"type":"Keyword","value":"assembly"},
{"type":"Text","value":" {\n "},
{"type":"OperatorWord","value":"let"},
{"type":"Text","value":" "},
{"type":"NameVariable","value":"o"},
{"type":"Text","value":" "},
{"type":"Operator","value":":="},
{"type":"Text","value":" "},
{"type":"NameFunction","value":"sload"},
{"type":"Punctuation","value":"("},
{"type":"LiteralNumberInteger","value":"0"},
{"type":"Punctuation","value":")"},
{"type":"Text","value":"\n "},
{"type":"NameFunction","value":"call"},
{"type":"Punctuation","value":"("},
{"type":"NameFunction","value":"gas"},
{"type":"Punctuation","value":"(),"},
{"type":"Text","value":" "},
{"type":"Name","value":"o"},
{"type":"Punctuation","value":","},
{"type":"Text","value":" "},
{"type":"LiteralNumberInteger","value":"5"},
{"type":"Punctuation","value":","},
{"type":"Text","value":" "},
{"type":"LiteralNumberInteger","value":"0"},
{"type":"Punctuation","value":","},
{"type":"Text","value":" "},
{"type":"LiteralNumberInteger","value":"0"},
{"type":"Punctuation","value":","},
{"type":"Text","value":" "},
{"type":"LiteralNumberInteger","value":"0"},
{"type":"Punctuation","value":","},
{"type":"Text","value":" "},
{"type":"LiteralNumberInteger","value":"0"},
{"type":"Punctuation","value":")"},
{"type":"Text","value":"\n "},
{"type":"Punctuation","value":"}"},
{"type":"Text","value":"\n "},
{"type":"NameBuiltin","value":"require"},
{"type":"Punctuation","value":"("},
{"type":"Name","value":"success"},
{"type":"Punctuation","value":","},
{"type":"Text","value":" "},
{"type":"LiteralString","value":"\"Failed to send ETH\""},
{"type":"Punctuation","value":");"},
{"type":"Text","value":"\n "},
{"type":"Punctuation","value":"}"},
{"type":"Text","value":"\n \n "},
{"type":"KeywordDeclaration","value":"function"},
{"type":"Text","value":" "},
{"type":"NameFunction","value":"kill"},
{"type":"Punctuation","value":"()"},
{"type":"Text","value":" "},
Expand Down
Loading