adjust publisher, update README
This commit is contained in:
parent
aff5b51771
commit
7db4412b97
10 changed files with 1058 additions and 0 deletions
4
zokrates_parser/src/textmate/.vscodeignore
Normal file
4
zokrates_parser/src/textmate/.vscodeignore
Normal file
|
@ -0,0 +1,4 @@
|
|||
.vscode/**
|
||||
.vscode-test/**
|
||||
.gitignore
|
||||
vsc-extension-quickstart.md
|
9
zokrates_parser/src/textmate/CHANGELOG.md
Normal file
9
zokrates_parser/src/textmate/CHANGELOG.md
Normal file
|
@ -0,0 +1,9 @@
|
|||
# Change Log
|
||||
|
||||
All notable changes to the "zokrates" extension will be documented in this file.
|
||||
|
||||
Check [Keep a Changelog](http://keepachangelog.com/) for recommendations on how to structure this file.
|
||||
|
||||
## [Unreleased]
|
||||
|
||||
- Initial release
|
3
zokrates_parser/src/textmate/README.md
Normal file
3
zokrates_parser/src/textmate/README.md
Normal file
|
@ -0,0 +1,3 @@
|
|||
# ZoKrates Syntax Highlighter
|
||||
|
||||
This is a Textmate syntax highlighter for the [ZoKrates language](https://zokrates.github.io).
|
28
zokrates_parser/src/textmate/language-configuration.json
Normal file
28
zokrates_parser/src/textmate/language-configuration.json
Normal file
|
@ -0,0 +1,28 @@
|
|||
{
|
||||
"comments": {
|
||||
// symbol used for single line comment. Remove this entry if your language does not support line comments
|
||||
"lineComment": "//",
|
||||
// symbols used for start and end a block comment. Remove this entry if your language does not support block comments
|
||||
"blockComment": [ "/*", "*/" ]
|
||||
},
|
||||
// symbols used as brackets
|
||||
"brackets": [
|
||||
["{", "}"],
|
||||
["[", "]"],
|
||||
["(", ")"]
|
||||
],
|
||||
// symbols that are auto closed when typing
|
||||
"autoClosingPairs": [
|
||||
["{", "}"],
|
||||
["[", "]"],
|
||||
["(", ")"],
|
||||
["\"", "\""],
|
||||
],
|
||||
// symbols that can be used to surround a selection
|
||||
"surroundingPairs": [
|
||||
["{", "}"],
|
||||
["[", "]"],
|
||||
["(", ")"],
|
||||
["\"", "\""],
|
||||
]
|
||||
}
|
27
zokrates_parser/src/textmate/package.json
Normal file
27
zokrates_parser/src/textmate/package.json
Normal file
|
@ -0,0 +1,27 @@
|
|||
{
|
||||
"name": "zokrates",
|
||||
"displayName": "zokrates",
|
||||
"description": "Syntax highlighting for the ZoKrates language",
|
||||
"publisher": "zokrates",
|
||||
"repository": "https://github.com/ZoKrates/ZoKrates",
|
||||
"version": "0.0.1",
|
||||
"engines": {
|
||||
"vscode": "^1.53.0"
|
||||
},
|
||||
"categories": [
|
||||
"Programming Languages"
|
||||
],
|
||||
"contributes": {
|
||||
"languages": [{
|
||||
"id": "zokrates",
|
||||
"aliases": ["ZoKrates", "zokrates"],
|
||||
"extensions": [".zok"],
|
||||
"configuration": "./language-configuration.json"
|
||||
}],
|
||||
"grammars": [{
|
||||
"language": "zokrates",
|
||||
"scopeName": "source.zok",
|
||||
"path": "./syntaxes/zokrates.tmLanguage.json"
|
||||
}]
|
||||
}
|
||||
}
|
600
zokrates_parser/src/textmate/syntaxes/zokrates.tmLanguage.json
Normal file
600
zokrates_parser/src/textmate/syntaxes/zokrates.tmLanguage.json
Normal file
|
@ -0,0 +1,600 @@
|
|||
{
|
||||
"$schema": "https://raw.githubusercontent.com/martinring/tmlanguage/master/tmlanguage.json",
|
||||
"name": "ZoKrates",
|
||||
"fileTypes": [
|
||||
"zok"
|
||||
],
|
||||
"scopeName": "source.zok",
|
||||
"patterns": [
|
||||
{
|
||||
"comment": "attributes",
|
||||
"name": "meta.attribute.zokrates",
|
||||
"begin": "(#)(\\!?)(\\[)",
|
||||
"beginCaptures": {
|
||||
"1": {
|
||||
"name": "punctuation.definition.attribute.zokrates"
|
||||
},
|
||||
"2": {
|
||||
"name": "keyword.operator.attribute.inner.zokrates"
|
||||
},
|
||||
"3": {
|
||||
"name": "punctuation.brackets.attribute.zokrates"
|
||||
}
|
||||
},
|
||||
"end": "\\]",
|
||||
"endCaptures": {
|
||||
"0": {
|
||||
"name": "punctuation.brackets.attribute.zokrates"
|
||||
}
|
||||
},
|
||||
"patterns": [
|
||||
{
|
||||
"include": "#block-comments"
|
||||
},
|
||||
{
|
||||
"include": "#comments"
|
||||
},
|
||||
{
|
||||
"include": "#keywords"
|
||||
},
|
||||
{
|
||||
"include": "#lifetimes"
|
||||
},
|
||||
{
|
||||
"include": "#punctuation"
|
||||
},
|
||||
{
|
||||
"include": "#strings"
|
||||
},
|
||||
{
|
||||
"include": "#gtypes"
|
||||
},
|
||||
{
|
||||
"include": "#types"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"include": "#block-comments"
|
||||
},
|
||||
{
|
||||
"include": "#comments"
|
||||
},
|
||||
{
|
||||
"include": "#constants"
|
||||
},
|
||||
{
|
||||
"include": "#functions"
|
||||
},
|
||||
{
|
||||
"include": "#types"
|
||||
},
|
||||
{
|
||||
"include": "#keywords"
|
||||
},
|
||||
{
|
||||
"include": "#punctuation"
|
||||
},
|
||||
{
|
||||
"include": "#strings"
|
||||
},
|
||||
{
|
||||
"include": "#variables"
|
||||
}
|
||||
],
|
||||
"repository": {
|
||||
"comments": {
|
||||
"patterns": [
|
||||
{
|
||||
"comment": "line comments",
|
||||
"name": "comment.line.double-slash.zokrates",
|
||||
"match": "\\s*//.*"
|
||||
}
|
||||
]
|
||||
},
|
||||
"block-comments": {
|
||||
"patterns": [
|
||||
{
|
||||
"comment": "empty block comments",
|
||||
"name": "comment.block.zokrates",
|
||||
"match": "/\\*\\*/"
|
||||
},
|
||||
{
|
||||
"comment": "block comments",
|
||||
"name": "comment.block.zokrates",
|
||||
"begin": "/\\*(?!\\*)",
|
||||
"end": "\\*/",
|
||||
"patterns": [
|
||||
{
|
||||
"include": "#block-comments"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
"constants": {
|
||||
"patterns": [
|
||||
{
|
||||
"comment": "ALL CAPS constants",
|
||||
"name": "constant.other.caps.zokrates",
|
||||
"match": "\\b[A-Z]{2}[A-Z0-9_]*\\b"
|
||||
},
|
||||
{
|
||||
"comment": "decimal integers and floats",
|
||||
"name": "constant.numeric.decimal.zokrates",
|
||||
"match": "\\b\\d[\\d_]*(u128|u16|u32|u64|u8|field)?\\b",
|
||||
"captures": {
|
||||
"5": {
|
||||
"name": "entity.name.type.numeric.zokrates"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"comment": "hexadecimal integers",
|
||||
"name": "constant.numeric.hex.zokrates",
|
||||
"match": "\\b0x[\\da-fA-F_]+\\b"
|
||||
},
|
||||
{
|
||||
"comment": "booleans",
|
||||
"name": "constant.language.bool.zokrates",
|
||||
"match": "\\b(true|false)\\b"
|
||||
}
|
||||
]
|
||||
},
|
||||
"imports": {
|
||||
"patterns": [
|
||||
{
|
||||
"comment": "explicit import statement",
|
||||
"name": "meta.import.explicit.zokrates",
|
||||
"match": "\\b(from)\\s+(\\\".*\\\")(import)\\s+([A-Za-z0-9_]+)\\s+((as)\\s+[A-Za-z0-9_]+)?\\b",
|
||||
"patterns": [
|
||||
{
|
||||
"include": "#block-comments"
|
||||
},
|
||||
{
|
||||
"include": "#comments"
|
||||
},
|
||||
{
|
||||
"include": "#keywords"
|
||||
},
|
||||
{
|
||||
"include": "#punctuation"
|
||||
},
|
||||
{
|
||||
"include": "#types"
|
||||
},
|
||||
{
|
||||
"include": "#strings"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"comment": "main import statement",
|
||||
"name": "meta.import.explicit.zokrates",
|
||||
"match": "\\b(import)\\s+(\\\".*\\\")\\s+((as)\\s+[A-Za-z0-9_]+)?\\b",
|
||||
"patterns": [
|
||||
{
|
||||
"include": "#block-comments"
|
||||
},
|
||||
{
|
||||
"include": "#comments"
|
||||
},
|
||||
{
|
||||
"include": "#keywords"
|
||||
},
|
||||
{
|
||||
"include": "#punctuation"
|
||||
},
|
||||
{
|
||||
"include": "#types"
|
||||
},
|
||||
{
|
||||
"include": "#strings"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
"functions": {
|
||||
"patterns": [
|
||||
{
|
||||
"comment": "function definition",
|
||||
"name": "meta.function.definition.zokrates",
|
||||
"begin": "\\b(def)\\s+([A-Za-z0-9_]+)((\\()|(<))",
|
||||
"beginCaptures": {
|
||||
"1": {
|
||||
"name": "keyword.other.def.zokrates"
|
||||
},
|
||||
"2": {
|
||||
"name": "entity.name.function.zokrates"
|
||||
},
|
||||
"4": {
|
||||
"name": "punctuation.brackets.round.zokrates"
|
||||
},
|
||||
"5": {
|
||||
"name": "punctuation.brackets.angle.zokrates"
|
||||
}
|
||||
},
|
||||
"end": "\\:|;",
|
||||
"endCaptures": {
|
||||
"0": {
|
||||
"name": "keyword.punctuation.colon.zokrates"
|
||||
}
|
||||
},
|
||||
"patterns": [
|
||||
{
|
||||
"include": "#block-comments"
|
||||
},
|
||||
{
|
||||
"include": "#comments"
|
||||
},
|
||||
{
|
||||
"include": "#keywords"
|
||||
},
|
||||
{
|
||||
"include": "#constants"
|
||||
},
|
||||
{
|
||||
"include": "#functions"
|
||||
},
|
||||
{
|
||||
"include": "#punctuation"
|
||||
},
|
||||
{
|
||||
"include": "#strings"
|
||||
},
|
||||
{
|
||||
"include": "#types"
|
||||
},
|
||||
{
|
||||
"include": "#variables"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"comment": "function/method calls, chaining",
|
||||
"name": "meta.function.call.zokrates",
|
||||
"begin": "([A-Za-z0-9_]+)(\\()",
|
||||
"beginCaptures": {
|
||||
"1": {
|
||||
"name": "entity.name.function.zokrates"
|
||||
},
|
||||
"2": {
|
||||
"name": "punctuation.brackets.round.zokrates"
|
||||
}
|
||||
},
|
||||
"end": "\\)",
|
||||
"endCaptures": {
|
||||
"0": {
|
||||
"name": "punctuation.brackets.round.zokrates"
|
||||
}
|
||||
},
|
||||
"patterns": [
|
||||
{
|
||||
"include": "#block-comments"
|
||||
},
|
||||
{
|
||||
"include": "#comments"
|
||||
},
|
||||
{
|
||||
"include": "#keywords"
|
||||
},
|
||||
{
|
||||
"include": "#constants"
|
||||
},
|
||||
{
|
||||
"include": "#functions"
|
||||
},
|
||||
{
|
||||
"include": "#punctuation"
|
||||
},
|
||||
{
|
||||
"include": "#strings"
|
||||
},
|
||||
{
|
||||
"include": "#types"
|
||||
},
|
||||
{
|
||||
"include": "#variables"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"comment": "function/method calls with turbofish",
|
||||
"name": "meta.function.call.zokrates",
|
||||
"begin": "([A-Za-z0-9_]+)(?=::<.*>\\()",
|
||||
"beginCaptures": {
|
||||
"1": {
|
||||
"name": "entity.name.function.zokrates"
|
||||
}
|
||||
},
|
||||
"end": "\\)",
|
||||
"endCaptures": {
|
||||
"0": {
|
||||
"name": "punctuation.brackets.round.zokrates"
|
||||
}
|
||||
},
|
||||
"patterns": [
|
||||
{
|
||||
"include": "#block-comments"
|
||||
},
|
||||
{
|
||||
"include": "#comments"
|
||||
},
|
||||
{
|
||||
"include": "#keywords"
|
||||
},
|
||||
{
|
||||
"include": "#constants"
|
||||
},
|
||||
{
|
||||
"include": "#functions"
|
||||
},
|
||||
{
|
||||
"include": "#punctuation"
|
||||
},
|
||||
{
|
||||
"include": "#strings"
|
||||
},
|
||||
{
|
||||
"include": "#types"
|
||||
},
|
||||
{
|
||||
"include": "#variables"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
"keywords": {
|
||||
"patterns": [
|
||||
{
|
||||
"comment": "argument visibility",
|
||||
"name": "keyword.visibility.zokrates",
|
||||
"match": "\\b(public|private)\\b"
|
||||
},
|
||||
{
|
||||
"comment": "control flow keywords",
|
||||
"name": "keyword.control.zokrates",
|
||||
"match": "\\b(do|else|for|do|endfor|if|then|fi|return|assert)\\b"
|
||||
},
|
||||
{
|
||||
"comment": "storage keywords",
|
||||
"name": "storage.type.zokrates",
|
||||
"match": "\\b(struct)\\b"
|
||||
},
|
||||
{
|
||||
"comment": "def",
|
||||
"name": "keyword.other.def.zokrates",
|
||||
"match": "\\bdef\\b"
|
||||
},
|
||||
{
|
||||
"comment": "import keywords",
|
||||
"name": "keyword.other.import.zokrates",
|
||||
"match": "\\b(import|from|as)\\b"
|
||||
},
|
||||
{
|
||||
"comment": "logical operators",
|
||||
"name": "keyword.operator.logical.zokrates",
|
||||
"match": "(\\^|\\||\\|\\||&|&&|<<|>>|!)(?!=)"
|
||||
},
|
||||
{
|
||||
"comment": "single equal",
|
||||
"name": "keyword.operator.assignment.equal.zokrates",
|
||||
"match": "(?<![<>])=(?!=|>)"
|
||||
},
|
||||
{
|
||||
"comment": "comparison operators",
|
||||
"name": "keyword.operator.comparison.zokrates",
|
||||
"match": "(=(=)?(?!>)|!=|<=|(?<!=)>=)"
|
||||
},
|
||||
{
|
||||
"comment": "math operators",
|
||||
"name": "keyword.operator.math.zokrates",
|
||||
"match": "(([+%]|(\\*(?!\\w)))(?!=))|(-(?!>))|(/(?!/))"
|
||||
},
|
||||
{
|
||||
"comment": "less than, greater than (special case)",
|
||||
"match": "(?:\\b|(?:(\\))|(\\])|(\\})))[ \\t]+([<>])[ \\t]+(?:\\b|(?:(\\()|(\\[)|(\\{)))",
|
||||
"captures": {
|
||||
"1": {
|
||||
"name": "punctuation.brackets.round.zokrates"
|
||||
},
|
||||
"2": {
|
||||
"name": "punctuation.brackets.square.zokrates"
|
||||
},
|
||||
"3": {
|
||||
"name": "punctuation.brackets.curly.zokrates"
|
||||
},
|
||||
"4": {
|
||||
"name": "keyword.operator.comparison.zokrates"
|
||||
},
|
||||
"5": {
|
||||
"name": "punctuation.brackets.round.zokrates"
|
||||
},
|
||||
"6": {
|
||||
"name": "punctuation.brackets.square.zokrates"
|
||||
},
|
||||
"7": {
|
||||
"name": "punctuation.brackets.curly.zokrates"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"comment": "dot access",
|
||||
"name": "keyword.operator.access.dot.zokrates",
|
||||
"match": "\\.(?!\\.)"
|
||||
},
|
||||
{
|
||||
"comment": "ranges, range patterns",
|
||||
"name": "keyword.operator.range.zokrates",
|
||||
"match": "\\.{2}(=|\\.)?"
|
||||
},
|
||||
{
|
||||
"comment": "colon",
|
||||
"name": "keyword.operator.colon.zokrates",
|
||||
"match": ":(?!:)"
|
||||
},
|
||||
{
|
||||
"comment": "dashrocket, skinny arrow",
|
||||
"name": "keyword.operator.arrow.skinny.zokrates",
|
||||
"match": "->"
|
||||
}
|
||||
]
|
||||
},
|
||||
"types": {
|
||||
"patterns": [
|
||||
{
|
||||
"comment": "numeric types",
|
||||
"match": "(?<![A-Za-z])(u128|u16|u32|u64|u8|field)\\b",
|
||||
"captures": {
|
||||
"1": {
|
||||
"name": "entity.name.type.numeric.zokrates"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"comment": "parameterized types",
|
||||
"begin": "\\b([A-Z][A-Za-z0-9]*)(<)",
|
||||
"beginCaptures": {
|
||||
"1": {
|
||||
"name": "entity.name.type.zokrates"
|
||||
},
|
||||
"2": {
|
||||
"name": "punctuation.brackets.angle.zokrates"
|
||||
}
|
||||
},
|
||||
"end": ">",
|
||||
"endCaptures": {
|
||||
"0": {
|
||||
"name": "punctuation.brackets.angle.zokrates"
|
||||
}
|
||||
},
|
||||
"patterns": [
|
||||
{
|
||||
"include": "#block-comments"
|
||||
},
|
||||
{
|
||||
"include": "#comments"
|
||||
},
|
||||
{
|
||||
"include": "#keywords"
|
||||
},
|
||||
{
|
||||
"include": "#punctuation"
|
||||
},
|
||||
{
|
||||
"include": "#types"
|
||||
},
|
||||
{
|
||||
"include": "#variables"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"comment": "primitive types",
|
||||
"name": "entity.name.type.primitive.zokrates",
|
||||
"match": "\\b(bool)\\b"
|
||||
},
|
||||
{
|
||||
"comment": "struct declarations",
|
||||
"match": "\\b(struct)\\s+([A-Z][A-Za-z0-9]*)\\b",
|
||||
"captures": {
|
||||
"1": {
|
||||
"name": "storage.type.zokrates"
|
||||
},
|
||||
"2": {
|
||||
"name": "entity.name.type.struct.zokrates"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"comment": "types",
|
||||
"name": "entity.name.type.zokrates",
|
||||
"match": "\\b[A-Z][A-Za-z0-9]*\\b(?!!)"
|
||||
}
|
||||
]
|
||||
},
|
||||
"punctuation": {
|
||||
"patterns": [
|
||||
{
|
||||
"comment": "comma",
|
||||
"name": "punctuation.comma.zokrates",
|
||||
"match": ","
|
||||
},
|
||||
{
|
||||
"comment": "parentheses, round brackets",
|
||||
"name": "punctuation.brackets.round.zokrates",
|
||||
"match": "[()]"
|
||||
},
|
||||
{
|
||||
"comment": "square brackets",
|
||||
"name": "punctuation.brackets.square.zokrates",
|
||||
"match": "[\\[\\]]"
|
||||
},
|
||||
{
|
||||
"comment": "angle brackets",
|
||||
"name": "punctuation.brackets.angle.zokrates",
|
||||
"match": "(?<!=)[<>]"
|
||||
}
|
||||
]
|
||||
},
|
||||
"strings": {
|
||||
"patterns": [
|
||||
{
|
||||
"comment": "double-quoted strings and byte strings",
|
||||
"name": "string.quoted.double.zokrates",
|
||||
"begin": "(b?)(\")",
|
||||
"beginCaptures": {
|
||||
"1": {
|
||||
"name": "string.quoted.byte.raw.zokrates"
|
||||
},
|
||||
"2": {
|
||||
"name": "punctuation.definition.string.zokrates"
|
||||
}
|
||||
},
|
||||
"end": "\"",
|
||||
"endCaptures": {
|
||||
"0": {
|
||||
"name": "punctuation.definition.string.zokrates"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"comment": "double-quoted raw strings and raw byte strings",
|
||||
"name": "string.quoted.double.zokrates",
|
||||
"begin": "(b?r)(#*)(\")",
|
||||
"beginCaptures": {
|
||||
"1": {
|
||||
"name": "string.quoted.byte.raw.zokrates"
|
||||
},
|
||||
"2": {
|
||||
"name": "punctuation.definition.string.raw.zokrates"
|
||||
},
|
||||
"3": {
|
||||
"name": "punctuation.definition.string.zokrates"
|
||||
}
|
||||
},
|
||||
"end": "(\")(\\2)",
|
||||
"endCaptures": {
|
||||
"1": {
|
||||
"name": "punctuation.definition.string.zokrates"
|
||||
},
|
||||
"2": {
|
||||
"name": "punctuation.definition.string.raw.zokrates"
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
"variables": {
|
||||
"patterns": [
|
||||
{
|
||||
"comment": "variables",
|
||||
"name": "variable.other.zokrates",
|
||||
"match": "\\b(?<!(?<!\\.)\\.)[a-z0-9_]+\\b"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
356
zokrates_parser/src/textmate/syntaxes/zokrates.tmLanguage.yaml
Normal file
356
zokrates_parser/src/textmate/syntaxes/zokrates.tmLanguage.yaml
Normal file
|
@ -0,0 +1,356 @@
|
|||
$schema: https://raw.githubusercontent.com/martinring/tmlanguage/master/tmlanguage.json
|
||||
name: ZoKrates
|
||||
fileTypes:
|
||||
- zok
|
||||
scopeName: source.zok
|
||||
patterns:
|
||||
-
|
||||
comment: attributes
|
||||
name: meta.attribute.zokrates
|
||||
begin: '(#)(\!?)(\[)'
|
||||
beginCaptures:
|
||||
1:
|
||||
name: punctuation.definition.attribute.zokrates
|
||||
2:
|
||||
name: keyword.operator.attribute.inner.zokrates
|
||||
3:
|
||||
name: punctuation.brackets.attribute.zokrates
|
||||
end: '\]'
|
||||
endCaptures:
|
||||
0:
|
||||
name: punctuation.brackets.attribute.zokrates
|
||||
patterns:
|
||||
- include: '#block-comments'
|
||||
- include: '#comments'
|
||||
- include: '#keywords'
|
||||
- include: '#lifetimes'
|
||||
- include: '#punctuation'
|
||||
- include: '#strings'
|
||||
- include: '#gtypes'
|
||||
- include: '#types'
|
||||
- include: '#block-comments'
|
||||
- include: '#comments'
|
||||
- include: '#constants'
|
||||
- include: '#functions'
|
||||
- include: '#types'
|
||||
- include: '#keywords'
|
||||
- include: '#punctuation'
|
||||
- include: '#strings'
|
||||
- include: '#variables'
|
||||
repository:
|
||||
comments:
|
||||
patterns:
|
||||
-
|
||||
comment: line comments
|
||||
name: comment.line.double-slash.zokrates
|
||||
match: \s*//.*
|
||||
block-comments:
|
||||
patterns:
|
||||
-
|
||||
comment: empty block comments
|
||||
name: comment.block.zokrates
|
||||
match: /\*\*/
|
||||
-
|
||||
comment: block comments
|
||||
name: comment.block.zokrates
|
||||
begin: /\*(?!\*)
|
||||
end: \*/
|
||||
patterns:
|
||||
- include: '#block-comments'
|
||||
constants:
|
||||
patterns:
|
||||
-
|
||||
comment: ALL CAPS constants
|
||||
name: constant.other.caps.zokrates
|
||||
match: \b[A-Z]{2}[A-Z0-9_]*\b
|
||||
-
|
||||
comment: decimal integers and floats
|
||||
name: constant.numeric.decimal.zokrates
|
||||
match: \b\d[\d_]*(u128|u16|u32|u64|u8|field)?\b
|
||||
captures:
|
||||
5:
|
||||
name: entity.name.type.numeric.zokrates
|
||||
-
|
||||
comment: hexadecimal integers
|
||||
name: constant.numeric.hex.zokrates
|
||||
match: \b0x[\da-fA-F_]+\b
|
||||
-
|
||||
comment: booleans
|
||||
name: constant.language.bool.zokrates
|
||||
match: \b(true|false)\b
|
||||
imports:
|
||||
patterns:
|
||||
-
|
||||
comment: explicit import statement
|
||||
name: meta.import.explicit.zokrates
|
||||
match: \b(from)\s+(\".*\")(import)\s+([A-Za-z0-9_]+)\s+((as)\s+[A-Za-z0-9_]+)?\b
|
||||
patterns:
|
||||
- include: '#block-comments'
|
||||
- include: '#comments'
|
||||
- include: '#keywords'
|
||||
- include: '#punctuation'
|
||||
- include: '#types'
|
||||
- include: '#strings'
|
||||
-
|
||||
comment: main import statement
|
||||
name: meta.import.explicit.zokrates
|
||||
match: \b(import)\s+(\".*\")\s+((as)\s+[A-Za-z0-9_]+)?\b
|
||||
patterns:
|
||||
- include: '#block-comments'
|
||||
- include: '#comments'
|
||||
- include: '#keywords'
|
||||
- include: '#punctuation'
|
||||
- include: '#types'
|
||||
- include: '#strings'
|
||||
functions:
|
||||
patterns:
|
||||
-
|
||||
comment: function definition
|
||||
name: meta.function.definition.zokrates
|
||||
begin: \b(def)\s+([A-Za-z0-9_]+)((\()|(<))
|
||||
beginCaptures:
|
||||
1:
|
||||
name: keyword.other.def.zokrates
|
||||
2:
|
||||
name: entity.name.function.zokrates
|
||||
4:
|
||||
name: punctuation.brackets.round.zokrates
|
||||
5:
|
||||
name: punctuation.brackets.angle.zokrates
|
||||
end: \:|;
|
||||
endCaptures:
|
||||
0:
|
||||
name: keyword.punctuation.colon.zokrates
|
||||
patterns:
|
||||
- include: '#block-comments'
|
||||
- include: '#comments'
|
||||
- include: '#keywords'
|
||||
- include: '#constants'
|
||||
- include: '#functions'
|
||||
- include: '#punctuation'
|
||||
- include: '#strings'
|
||||
- include: '#types'
|
||||
- include: '#variables'
|
||||
-
|
||||
# todo: capitalized functions in most cases represent enum members or tuple structs
|
||||
# separate these out and color them accordingly
|
||||
# this has to be done without breaking struct scoping when the struct keyword is used:
|
||||
# struct MyStruct()
|
||||
# this currently highlights correctly, even with parens
|
||||
comment: function/method calls, chaining
|
||||
name: meta.function.call.zokrates
|
||||
begin: ([A-Za-z0-9_]+)(\()
|
||||
beginCaptures:
|
||||
1:
|
||||
name: entity.name.function.zokrates
|
||||
2:
|
||||
name: punctuation.brackets.round.zokrates
|
||||
end: \)
|
||||
endCaptures:
|
||||
0:
|
||||
name: punctuation.brackets.round.zokrates
|
||||
patterns:
|
||||
- include: '#block-comments'
|
||||
- include: '#comments'
|
||||
- include: '#keywords'
|
||||
- include: '#constants'
|
||||
- include: '#functions'
|
||||
- include: '#punctuation'
|
||||
- include: '#strings'
|
||||
- include: '#types'
|
||||
- include: '#variables'
|
||||
-
|
||||
comment: function/method calls with turbofish
|
||||
name: meta.function.call.zokrates
|
||||
begin: ([A-Za-z0-9_]+)(?=::<.*>\()
|
||||
beginCaptures:
|
||||
1:
|
||||
name: entity.name.function.zokrates
|
||||
end: \)
|
||||
endCaptures:
|
||||
0:
|
||||
name: punctuation.brackets.round.zokrates
|
||||
patterns:
|
||||
- include: '#block-comments'
|
||||
- include: '#comments'
|
||||
- include: '#keywords'
|
||||
- include: '#constants'
|
||||
- include: '#functions'
|
||||
- include: '#punctuation'
|
||||
- include: '#strings'
|
||||
- include: '#types'
|
||||
- include: '#variables'
|
||||
keywords:
|
||||
patterns:
|
||||
-
|
||||
comment: argument visibility
|
||||
name: keyword.visibility.zokrates
|
||||
match: \b(public|private)\b
|
||||
-
|
||||
comment: control flow keywords
|
||||
name: keyword.control.zokrates
|
||||
match: \b(do|else|for|do|endfor|if|then|fi|return|assert)\b
|
||||
-
|
||||
comment: storage keywords
|
||||
name: storage.type.zokrates
|
||||
match: \b(struct)\b
|
||||
-
|
||||
comment: def
|
||||
name: keyword.other.def.zokrates
|
||||
match: \bdef\b
|
||||
-
|
||||
comment: import keywords
|
||||
name: keyword.other.import.zokrates
|
||||
match: \b(import|from|as)\b
|
||||
-
|
||||
comment: logical operators
|
||||
name: keyword.operator.logical.zokrates
|
||||
match: (\^|\||\|\||&|&&|<<|>>|!)(?!=)
|
||||
-
|
||||
comment: single equal
|
||||
name: keyword.operator.assignment.equal.zokrates
|
||||
match: '(?<![<>])=(?!=|>)'
|
||||
-
|
||||
comment: comparison operators
|
||||
name: keyword.operator.comparison.zokrates
|
||||
match: (=(=)?(?!>)|!=|<=|(?<!=)>=)
|
||||
-
|
||||
comment: math operators
|
||||
name: keyword.operator.math.zokrates
|
||||
match: '(([+%]|(\*(?!\w)))(?!=))|(-(?!>))|(/(?!/))'
|
||||
-
|
||||
comment: less than, greater than (special case)
|
||||
match: (?:\b|(?:(\))|(\])|(\})))[ \t]+([<>])[ \t]+(?:\b|(?:(\()|(\[)|(\{)))
|
||||
captures:
|
||||
1:
|
||||
name: punctuation.brackets.round.zokrates
|
||||
2:
|
||||
name: punctuation.brackets.square.zokrates
|
||||
3:
|
||||
name: punctuation.brackets.curly.zokrates
|
||||
4:
|
||||
name: keyword.operator.comparison.zokrates
|
||||
5:
|
||||
name: punctuation.brackets.round.zokrates
|
||||
6:
|
||||
name: punctuation.brackets.square.zokrates
|
||||
7:
|
||||
name: punctuation.brackets.curly.zokrates
|
||||
-
|
||||
comment: dot access
|
||||
name: keyword.operator.access.dot.zokrates
|
||||
match: \.(?!\.)
|
||||
-
|
||||
comment: ranges, range patterns
|
||||
name: keyword.operator.range.zokrates
|
||||
match: \.{2}(=|\.)?
|
||||
-
|
||||
comment: colon
|
||||
name: keyword.operator.colon.zokrates
|
||||
match: ':(?!:)'
|
||||
-
|
||||
comment: dashrocket, skinny arrow
|
||||
name: keyword.operator.arrow.skinny.zokrates
|
||||
match: ->
|
||||
types:
|
||||
patterns:
|
||||
-
|
||||
comment: numeric types
|
||||
match: '(?<![A-Za-z])(u128|u16|u32|u64|u8|field)\b'
|
||||
captures:
|
||||
1:
|
||||
name: entity.name.type.numeric.zokrates
|
||||
-
|
||||
comment: parameterized types
|
||||
begin: \b([A-Z][A-Za-z0-9]*)(<)
|
||||
beginCaptures:
|
||||
1:
|
||||
name: entity.name.type.zokrates
|
||||
2:
|
||||
name: punctuation.brackets.angle.zokrates
|
||||
end: '>'
|
||||
endCaptures:
|
||||
0:
|
||||
name: punctuation.brackets.angle.zokrates
|
||||
patterns:
|
||||
- include: '#block-comments'
|
||||
- include: '#comments'
|
||||
- include: '#keywords'
|
||||
- include: '#punctuation'
|
||||
- include: '#types'
|
||||
- include: '#variables'
|
||||
-
|
||||
comment: primitive types
|
||||
name: entity.name.type.primitive.zokrates
|
||||
match: \b(bool)\b
|
||||
-
|
||||
comment: struct declarations
|
||||
match: \b(struct)\s+([A-Z][A-Za-z0-9]*)\b
|
||||
captures:
|
||||
1:
|
||||
name: storage.type.zokrates
|
||||
2:
|
||||
name: entity.name.type.struct.zokrates
|
||||
-
|
||||
comment: types
|
||||
name: entity.name.type.zokrates
|
||||
match: '\b[A-Z][A-Za-z0-9]*\b(?!!)'
|
||||
punctuation:
|
||||
patterns:
|
||||
-
|
||||
comment: comma
|
||||
name: punctuation.comma.zokrates
|
||||
match: ','
|
||||
-
|
||||
comment: parentheses, round brackets
|
||||
name: punctuation.brackets.round.zokrates
|
||||
match: '[()]'
|
||||
-
|
||||
comment: square brackets
|
||||
name: punctuation.brackets.square.zokrates
|
||||
match: '[\[\]]'
|
||||
-
|
||||
comment: angle brackets
|
||||
name: punctuation.brackets.angle.zokrates
|
||||
match: '(?<!=)[<>]'
|
||||
strings:
|
||||
patterns:
|
||||
-
|
||||
comment: double-quoted strings and byte strings
|
||||
name: string.quoted.double.zokrates
|
||||
begin: '(b?)(")'
|
||||
beginCaptures:
|
||||
1:
|
||||
name: string.quoted.byte.raw.zokrates
|
||||
2:
|
||||
name: punctuation.definition.string.zokrates
|
||||
end: '"'
|
||||
endCaptures:
|
||||
0:
|
||||
name: punctuation.definition.string.zokrates
|
||||
-
|
||||
comment: double-quoted raw strings and raw byte strings
|
||||
name: string.quoted.double.zokrates
|
||||
begin: '(b?r)(#*)(")'
|
||||
beginCaptures:
|
||||
1:
|
||||
name: string.quoted.byte.raw.zokrates
|
||||
2:
|
||||
name: punctuation.definition.string.raw.zokrates
|
||||
3:
|
||||
name: punctuation.definition.string.zokrates
|
||||
end: '(")(\2)'
|
||||
endCaptures:
|
||||
1:
|
||||
name: punctuation.definition.string.zokrates
|
||||
2:
|
||||
name: punctuation.definition.string.raw.zokrates
|
||||
variables:
|
||||
patterns:
|
||||
# In order to capture variables ending ranges, but not struct field access, we match a preceding dot, only if it's preceded by at least one other dot.
|
||||
# The double negation states that the pattern "must not be preceded by a dot that is not preceded by a dot."
|
||||
# Attempting to match on (\.{2,})? won't work, because then struct field access can match after the dot.
|
||||
-
|
||||
comment: variables
|
||||
name: variable.other.zokrates
|
||||
match: \b(?<!(?<!\.)\.)[a-z0-9_]+\b
|
2
zokrates_parser/src/textmate/test.zok
Normal file
2
zokrates_parser/src/textmate/test.zok
Normal file
|
@ -0,0 +1,2 @@
|
|||
def main():
|
||||
return 1
|
29
zokrates_parser/src/textmate/vsc-extension-quickstart.md
Normal file
29
zokrates_parser/src/textmate/vsc-extension-quickstart.md
Normal file
|
@ -0,0 +1,29 @@
|
|||
# Welcome to your VS Code Extension
|
||||
|
||||
## What's in the folder
|
||||
|
||||
* This folder contains all of the files necessary for your extension.
|
||||
* `package.json` - this is the manifest file in which you declare your language support and define the location of the grammar file that has been copied into your extension.
|
||||
* `syntaxes/zokrates.tmLanguage.json` - this is the Text mate grammar file that is used for tokenization.
|
||||
* `language-configuration.json` - this is the language configuration, defining the tokens that are used for comments and brackets.
|
||||
|
||||
## Get up and running straight away
|
||||
|
||||
* Make sure the language configuration settings in `language-configuration.json` are accurate.
|
||||
* Press `F5` to open a new window with your extension loaded.
|
||||
* Create a new file with a file name suffix matching your language.
|
||||
* Verify that syntax highlighting works and that the language configuration settings are working.
|
||||
|
||||
## Make changes
|
||||
|
||||
* You can relaunch the extension from the debug toolbar after making changes to the files listed above.
|
||||
* You can also reload (`Ctrl+R` or `Cmd+R` on Mac) the VS Code window with your extension to load your changes.
|
||||
|
||||
## Add more language features
|
||||
|
||||
* To add features such as intellisense, hovers and validators check out the VS Code extenders documentation at https://code.visualstudio.com/docs
|
||||
|
||||
## Install your extension
|
||||
|
||||
* To start using your extension with Visual Studio Code copy it into the `<user home>/.vscode/extensions` folder and restart Code.
|
||||
* To share your extension with the world, read on https://code.visualstudio.com/docs about publishing an extension.
|
BIN
zokrates_parser/src/textmate/zokrates-0.0.1.vsix
Normal file
BIN
zokrates_parser/src/textmate/zokrates-0.0.1.vsix
Normal file
Binary file not shown.
Loading…
Reference in a new issue