Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

enhancement: new keywords and syntax support #3

Merged
merged 8 commits into from
Aug 9, 2023
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
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"displayName": "Cocolang",
"icon": "icons/coco.png",
"description": "Syntax Highlighting for Cocolang on Visual Studio Code",
"version": "0.1.0",
"version": "0.1.1",
"license": "MIT",
"publisher": "sarvalabs",
"author": {
Expand Down
64 changes: 49 additions & 15 deletions syntaxes/coco.tmLanguage.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@
{
"include": "#contract_name"
},
{
"include": "#endpoints"
},
{
"include": "#exceptions"
},
Expand All @@ -36,7 +39,7 @@
"include": "#methods"
},
{
"include": "#mutate"
"include": "#state_access"
},
{
"include": "#operators"
Expand Down Expand Up @@ -126,6 +129,25 @@
}
]
},
"endpoints": {
"patterns": [
{
"comment": "Callable Endpoints",
"match": "^(endpoint)\\s+(invokable|deployer)\\s+(\\w+!?)\\(",
"captures": {
"1": {
"name": "keyword.function.coco"
},
"2": {
"name": "storage.modifier.func.coco"
},
"3": {
"name": "entity.name.function.coco"
}
}
}
]
},
"exceptions": {
"patterns": [
{
Expand Down Expand Up @@ -157,22 +179,19 @@
"patterns": [
{
"comment": "Function declarations",
"match": "^(func)\\s+(?:(invokable|deployer|local)\\s+)?(\\w+!?)\\(",
"match": "^(func)\\s+(?:()\\s+)?(\\w+!?)\\(",
"captures": {
"1": {
"name": "keyword.function.coco"
},
"2": {
"name": "storage.modifier.func.coco"
},
"3": {
"name": "entity.name.function.coco"
}
}
},
{
"comment": "Supporting functions",
"match": "\\b(append|popend|haskey|merge|polorize|depolorize)\\b(?=\\()",
"match": "\\b(append|popend|merge)\\b(?=\\()",
"name": "support.function.builtin.coco"
}
]
Expand All @@ -182,12 +201,12 @@
{
"comment": "Control Keywords",
"name": "keyword.control.coco",
"match": "\\b(if|elif|else|for|break|pass|continue|return|yield|from|in)\\b"
"match": "\\b(if|else|for|break|pass|continue|return|yield|from|in)\\b"
},
{
"comment": "Action Keywords",
"name": "keyword.action.coco",
"match": "\\b(observe|transfer|polorize|depolorize)\\b"
"match": "\\b(observe|transfer)\\b"
},
{
"comment": "Exception Handling",
Expand All @@ -211,13 +230,23 @@
},
{
"comment": "State Keyword",
"name": "keyword.state.coco",
"name": "keyword.state.accessor.coco",
"match": "\\b(state)\\b"
},
{
"comment": "Crypto Builtins",
"name": "keyword.builtins.coco",
"match": "\\b(Blake2b|Keccak256|len|Sha256)\\b"
"match": "\\b(blake2b|keccak256|sha256|sigverify)\\b"
},
{
"comment": "Serial Builtins",
"name": "keyword.builtins.coco",
"match": "\\b(polorize|depolorize)\\b"
},
{
"comment": "Special Methods",
"name": "keyword.special.coco",
"match": "\\b(len|join)\\b"
}
]
},
Expand All @@ -243,14 +272,14 @@
}
]
},
"mutate": {
"state_access": {
"patterns": [
{
"comment": "Open/Closed Mutate Statement",
"match": "\\b(mutate)\\b|(<-|->)\\s*|([A-Za-z_][A-Za-z0-9_]*)\\.(State|Sender|Receiver)\\s*",
"comment": "Open/Closed State Access Statement",
"match": "\\b(mutate|observe)\\b|(<-|->)\\s*|([A-Za-z_][A-Za-z0-9_]*)\\.(State|Sender|Receiver)\\s*",
"captures": {
"1": {
"name": "keyword.mutate.coco"
"name": "keyword.state.coco"
sarvalabs-manish marked this conversation as resolved.
Show resolved Hide resolved
},
"2": {
"name": "keyword.operator.assignment.coco"
Expand Down Expand Up @@ -296,6 +325,11 @@
"comment": "Logical Operators",
"match": "(&&|\\|\\||!)",
"name": "keyword.operator.logical.coco"
},
{
"comment": "Inclusivity Operator",
"match": "\\?(?=(?:[^'\"]|\"[^\"]*\"|'[^']*')*$)",
"name": "keyword.operator.inclusivity.coco"
}
]
},
Expand Down Expand Up @@ -436,7 +470,7 @@
{
"comment": "Variable Declaration",
"name": "variable.declaration.coco",
"match": "\\b(var)\\b\\s+([a-zA-Z_][a-zA-Z0-9_]*)\\s+([a-zA-Z_][a-zA-Z0-9_]*\\b)?",
"match": "\\b(var)\\b\\s+((?:[a-zA-Z_][a-zA-Z0-9_]*\\s*,\\s*)*[a-zA-Z_][a-zA-Z0-9_]*)\\s+([a-zA-Z_][a-zA-Z0-9_]+\\b)?",
"captures": {
"1": {
"name": "keyword.var.coco"
Expand Down