-
Notifications
You must be signed in to change notification settings - Fork 42
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
726 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,192 @@ | ||
# [PackageDev] target_format: plist, ext: tmLanguage | ||
--- | ||
name: Yul | ||
scopeName: source.yul | ||
fileTypes: [yul, yulp] | ||
uuid: ad87d2cd-8575-4afe-984e-9421a3788913 | ||
|
||
|
||
patterns: | ||
- match: \/\/.* | ||
name: comment | ||
comment: Comments | ||
- begin: (\/\*) | ||
end: (\*\/) | ||
name: comment | ||
comment: Multiline comments | ||
- match: \b(event|enum)\s+([A-Za-z_]\w*)\b | ||
name: keyword | ||
captures: | ||
'2': {name: entity.name.function} | ||
comment: Events | ||
|
||
# we need this because of multiline! | ||
- name: scope | ||
#contentName: string.other.ssraw | ||
begin: \b(object)\s+(\"[A-Za-z_]\w*\")(?:\s+(is)\s+)? | ||
beginCaptures: | ||
'1': {name: keyword} | ||
'2': {name: string.quoted} | ||
'3': {name: keyword} | ||
end: \{ | ||
patterns: | ||
#- include: $self | ||
- name: string.quoted | ||
match: '\"[A-Za-z_]\w*\"' | ||
# contract Derived1 is Base(7) { | ||
- include: "#numbers" | ||
|
||
# - match: \b(contract|interface|library)\s+([A-Za-z_]\w*)(?:\s+(is)\s+((?:[A-Za-z_]\w*\,?\s*)*))?\b | ||
# name: keyword | ||
# captures: | ||
# '1': {name: keyword} | ||
# '2': {name: entity.name.function} | ||
# '3': {name: keyword} | ||
# '4': {name: entity.name.function} | ||
# comment: Structures, function, event definitions | ||
- match: \b(constructor|error|using|struct|type|modifier|fallback)(\s+[A-Za-z_]\w*)?\b | ||
name: keyword | ||
captures: | ||
'2': {name: entity.name.function} | ||
comment: Structures, function, event definitions | ||
- match: \b(function)(\s+[A-Za-z_]\w*)?\b | ||
name: keyword | ||
captures: | ||
'2': {name: entity.name.function} | ||
comment: Structures, function, event definitions | ||
# - match: \.(length|selector)\b | ||
- match: \.(selector)\b | ||
captures: | ||
'1': {name: markup.italic} | ||
comment: Special treatment for length and .selector | ||
- match: \bthis\b | ||
name: markup.italic | ||
comment: this | ||
- match: \bsuper\b | ||
name: markup.italic | ||
comment: Special treatment for "super" | ||
- match: \b(address(?:\s+payable)?|string|bytes?\d*|int\d*|uint\d*|bool|u?fixed\d+x\d+)\s*(?:\[(\d*)\])?\s*(?:\[(\d*)\])?\s*(?:(indexed|memory|storage|calldata|payable|immutable)?\s*(\b[A-Za-z_]\w*)?\s*)?(?=[,\)\n]) | ||
captures: | ||
'1': {name: constant.language} | ||
'2': {name: constant.numeric} | ||
'3': {name: constant.numeric} | ||
'4': {name: keyword} | ||
'5': {name: variable.parameter} # variable.parameter | ||
comment: Built-in types function arguments | ||
- match: \b(?:(indexed|memory|storage|calldata|payable|immutable)\s*(\b[A-Za-z_]\w*)?\s*)(?=[,\)\n]) | ||
captures: | ||
'1': {name: keyword} | ||
'2': {name: variable.parameter} # variable.parameter | ||
comment: Other types function arguments, like structs... but can only detect them if they have a modifier, example -- function witness(instance memory w, instance memory a, instance memory a1, instance memory a1_odd, uint k) | ||
- match: \b(true|false)\b | ||
name: constant.language | ||
comment: True and false keywords | ||
- match: \b(address(?:\s*payable)?|string|bytes?\d*|int\d*|uint\d*|bool|u?fixed\d+x\d+)\b(?:(?:\s*\[(\d*)\])?(?:\s*\[(\d*)\])?(?:\s*\[(\d*)\])?\s*((?:private\s|public\s|internal\s|external\s|constant\s|immutable\s|memory\s|storage\s)*)\s*(?:[A-Za-z_]\w*)\s*(\=))? | ||
captures: | ||
'1': {name: constant.language} | ||
'2': {name: constant.numeric} | ||
'3': {name: constant.numeric} | ||
'4': {name: constant.numeric} | ||
'5': {name: keyword} | ||
'6': {name: keyword} | ||
comment: Variable definitions - bytes data; | uint x = uint(y); BUT also just appearances of basic types anywhere... good example -- "using SafeMath for uint256;" | ||
- match: \b(payable)\s*\( | ||
captures: | ||
'1': {name: constant.language} | ||
comment: Type conversion payable(...) | ||
- match: \b(from)\s*(?=[\'\"]) | ||
captures: | ||
'1': {name: keyword} | ||
comment: import ... from | ||
- match: \b(?:[A-Za-z_]\w*)\s+(as)\s+(?:[A-Za-z_]\w*) | ||
captures: | ||
'1': {name: keyword} | ||
comment: import {Unauthorized, add as func, Point} from "./Foo.sol"; | ||
- match: \b(global); # using {plusOne, minusOne} for RestrictedNumber global; | ||
captures: | ||
'1': {name: keyword} | ||
comment: import ... from | ||
- match: \b(var|solidity|constant|pragma\s*(?:experimental|abicoder)?|code|data|hex|import|const|mstruct|mapping|payable|storage|memory|calldata|if|else|for|while|do|break|continue|returns?|try|catch|private|public|pure|view|internal|immutable|external|virtual|override|abstract|suicide|emit|is|throw|revert|assert|require|receive|delete)\b | ||
name: keyword | ||
comment: Langauge keywords | ||
- include: "#numbers" | ||
- match: \b(0[xX][a-fA-F0-9]+)\b | ||
name: constant.numeric | ||
comment: Hexadecimal | ||
- match: (=|:=|!|>|<|\||&|\?|\^|~|\*|\+|\-|\/|\%) | ||
name: keyword.operator | ||
comment: Operators | ||
- match: (\bhex\b|\bunicode\b) | ||
name: markup.italic | ||
comment: Operators | ||
- match: \s\:\s | ||
name: keyword.operator | ||
comment: Ternary colon | ||
- match: \bnow\b | ||
name: support.type | ||
comment: Now - it was removed in solidity 0.4 but we still include it because some old contracts use it | ||
- match: \b_; | ||
name: keyword | ||
comment: modifier placeholder statement | ||
#One novel construct found in Solidity is the placeholder statement _;. It may | ||
#appear only in function modifiers, where it denotes the point of entry into the | ||
#next modifier or the function body. | ||
- match: \b(msg|block|tx)\.([A-Za-z_]\w*)\b | ||
captures: | ||
'1': {name: support.type} | ||
'2': {name: support.type} | ||
comment: msg and block special usage | ||
- match: \b(abi)\.([A-Za-z_]\w*)\b | ||
name: support.type | ||
comment: abi functions | ||
#we don't do this anymore, esp since we cannot distinguish between assembly and normal function.. and | ||
# don't want addmod etc. to be italic in assembly since it's a normal opcode, should be the same as other opcodes | ||
# - match: \b(addmod|mulmod|keccak256|sha256|sha3|ripemd160|ecrecover)\s*\( | ||
- match: \b(blockhash|gasleft)\s*\( | ||
captures: | ||
'1': {name: support.type} | ||
comment: Function call - some special built-in functions | ||
# - match: \.(call|delegatecall|staticcall)\s*[\(\{] | ||
# captures: | ||
# '1': {name: markup.italic} | ||
# comment: Function call - smart contract calls, also special params call{...}() | ||
- match: \b([A-Za-z_]\w*)(?:\s*\[(\d*)\]\s*)?(?:\s*\[(\d*)\]\s*)?\( | ||
captures: | ||
'1': {name: entity.name.function} | ||
'2': {name: constant.numeric} | ||
'3': {name: constant.numeric} | ||
comment: Function call, also for example - info.factories = new Factory[](factoryAddresses.length); | ||
- match: (?:\.|(new\s+))([A-Za-z_]\w*)\{ | ||
captures: | ||
'1': {name: keyword} | ||
'2': {name: entity.name.function} | ||
comment: Special parameters IWETH(wavaxTokenAddress).deposit{ ... }(); ... new UniswapV3Pool{...}() https://docs.soliditylang.org/en/v0.8.11/control-structures.html#external-function-calls , https://docs.soliditylang.org/en/v0.8.11/control-structures.html#creating-contracts-via-new | ||
- match: \b(wei|gwei|ether|seconds|minutes|hours|days|weeks)\b | ||
captures: | ||
'1': {name: support.type} | ||
comment: Ether and time units | ||
- match: \bnew\b | ||
name: keyword | ||
comment: New | ||
- match: \banonymous\b | ||
name: keyword | ||
comment: Event | ||
- match: \bunchecked\b | ||
name: keyword | ||
comment: Unchecked | ||
- match: \b(assembly|switch|let|case|default)\b | ||
name: keyword | ||
comment: Assembly stuff | ||
- match: ([\"].*?[\"]) | ||
name: string.quoted | ||
comment: Strings | ||
- match: ([\'].*?[\']) | ||
name: string.quoted | ||
comment: Strings | ||
|
||
repository: | ||
numbers: | ||
patterns: | ||
- match: \b(?:[+-]?\.?\d[\d_eE]*)(?:\.\d+[\deE]*)?\b | ||
name: constant.numeric | ||
comment: Numbers, possibly with scientific notation |
Oops, something went wrong.