Skip to content

Instantly share code, notes, and snippets.

@davidhq
Last active January 15, 2019 02:26
Show Gist options
  • Save davidhq/811662ede7c304e146ed73c9e8e27259 to your computer and use it in GitHub Desktop.
Save davidhq/811662ede7c304e146ed73c9e8e27259 to your computer and use it in GitHub Desktop.
# Function
function:
- match: \b(function)\s+({{identifier}})
captures:
1: storage.type.function
2: entity.name.function
push:
- function-body
- returns-declaration
- modifiers
- argument-list
- match: \b(function)(\(\s*\))
captures:
1: keyword.control
2: scope
push:
- function-body
- returns-declaration
- modifiers
constructor:
- match: \b(constructor)
scope: entity.name.function.sol
push:
- function-body
- modifiers
- argument-list
argument-list:
- match: \(
push: argument_or_pop
- match: ','
push: argument_or_pop
- match: \)
pop: true
argument_or_pop:
- include: argument
- include: else-pop
argument:
- match: '({{type_or_array}})\s+({{attribute}})\s+({{identifier}})'
captures:
1: constant.language
2: storage.modifier
3: variable.parameter.function
pop: true
- match: '({{type_or_array}})\s+({{identifier}})'
captures:
1: constant.language
2: variable.parameter.function
pop: true
- match: '({{identifier}})\s+({{identifier}})'
captures:
1: source
2: variable.parameter.function
pop: true
modifiers:
- match: '{{func_modifier}}'
scope: storage.modifier
push: modifiers
- include: else-pop
returns-declaration:
- match: returns
scope: keyword.control
push: returns-declaration-arguments
- include: else-pop
returns-declaration-arguments:
- match: \(
push: argument-or-type
- match: ','
push: argument-or-type
- match: \)
pop: true
argument-or-type:
- include: argument
- match: '{{type_or_array}}'
scope: constant.language
pop: true
function-body:
- match: '\{'
scope: punctuation.section.block.begin.sol
set: function-body-contents
- include: else-pop
function-body-contents:
- match: '\}'
scope: punctuation.section.block.end.js
pop: true
- include: declaration
...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment