aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Moon Flower <moon@coffin.ir> 2025-08-23 23:07:42 +0330
committerGravatar Moon Flower <moon@coffin.ir> 2025-08-23 23:07:42 +0330
commit4fb5091b23dad78709c939f0db263f478d900818 (patch)
tree1aaecdb89dce007f897346bcf081c378c2b54a0d
parentoops (diff)
updated extension grammar
-rw-r--r--pu2/i2-syntax/language-configuration.json79
-rw-r--r--pu2/i2-syntax/syntaxes/i2.tmLanguage.json213
2 files changed, 238 insertions, 54 deletions
diff --git a/pu2/i2-syntax/language-configuration.json b/pu2/i2-syntax/language-configuration.json
index 2cbf13c..2ea7ee0 100644
--- a/pu2/i2-syntax/language-configuration.json
+++ b/pu2/i2-syntax/language-configuration.json
@@ -1,25 +1,74 @@
{
"comments": {
- "lineComment": "//"
+ "lineComment": "//",
+ "blockComment": [
+ "/*",
+ "*/"
+ ]
},
"brackets": [
- ["{", "}"],
- ["[", "]"],
- ["(", ")"]
+ [
+ "{",
+ "}"
+ ],
+ [
+ "[",
+ "]"
+ ],
+ [
+ "(",
+ ")"
+ ]
],
"autoClosingPairs": [
- { "open": "{", "close": "}" },
- { "open": "[", "close": "]" },
- { "open": "(", "close": ")" },
- { "open": "\"", "close": "\"", "notIn": ["string"] },
- { "open": "'", "close": "'", "notIn": ["string"] }
+ {
+ "open": "{",
+ "close": "}"
+ },
+ {
+ "open": "[",
+ "close": "]"
+ },
+ {
+ "open": "(",
+ "close": ")"
+ },
+ {
+ "open": "\"",
+ "close": "\"",
+ "notIn": [
+ "string"
+ ]
+ },
+ {
+ "open": "'",
+ "close": "'",
+ "notIn": [
+ "string"
+ ]
+ }
],
"surroundingPairs": [
- { "open": "{", "close": "}" },
- { "open": "[", "close": "]" },
- { "open": "(", "close": ")" },
- { "open": "\"", "close": "\"" },
- { "open": "'", "close": "'" }
+ {
+ "open": "{",
+ "close": "}"
+ },
+ {
+ "open": "[",
+ "close": "]"
+ },
+ {
+ "open": "(",
+ "close": ")"
+ },
+ {
+ "open": "\"",
+ "close": "\""
+ },
+ {
+ "open": "'",
+ "close": "'"
+ }
],
"folding": {
"markers": {
@@ -27,4 +76,4 @@
"end": "^\\s*\\}"
}
}
-}
+} \ No newline at end of file
diff --git a/pu2/i2-syntax/syntaxes/i2.tmLanguage.json b/pu2/i2-syntax/syntaxes/i2.tmLanguage.json
index 4dc6ee9..b1078e2 100644
--- a/pu2/i2-syntax/syntaxes/i2.tmLanguage.json
+++ b/pu2/i2-syntax/syntaxes/i2.tmLanguage.json
@@ -1,44 +1,119 @@
{
"scopeName": "source.i2",
"name": "I2 IR / Macro language",
- "fileTypes": ["i2"],
+ "fileTypes": [
+ "i2"
+ ],
"patterns": [
- { "include": "#comments" },
- { "include": "#macro-reference" },
- { "include": "#braces" },
- { "include": "#brackets" },
- { "include": "#semicolon" },
- { "include": "#keywords" },
- { "include": "#function-call" },
- { "include": "#memory-index" },
- { "include": "#variables" },
- { "include": "#hex" },
- { "include": "#decimal" },
- { "include": "#string" },
- { "include": "#char" },
- { "include": "#blob" },
+ {
+ "include": "#comments"
+ },
+ {
+ "include": "#block-comments"
+ },
+ {
+ "include": "#macro-reference"
+ },
+ {
+ "include": "#braces"
+ },
+ {
+ "include": "#brackets"
+ },
+ {
+ "include": "#semicolon"
+ },
+ {
+ "include": "#jump-call"
+ },
+ {
+ "include": "#keywords"
+ },
+ {
+ "include": "#function-call"
+ },
+ {
+ "include": "#memory-index"
+ },
+ {
+ "include": "#label"
+ },
+ {
+ "include": "#variables"
+ },
+ {
+ "include": "#hex"
+ },
+ {
+ "include": "#decimal"
+ },
+ {
+ "include": "#string"
+ },
+ {
+ "include": "#char"
+ },
+ {
+ "include": "#blob"
+ },
{
"begin": "\\b(macro)\\b\\s+([A-Za-z_][A-Za-z0-9_]*)\\s*(?=\\()",
"beginCaptures": {
- "1": { "name": "keyword.control.macro.i2" },
- "2": { "name": "entity.name.function.macro.i2" }
+ "1": {
+ "name": "keyword.control.macro.i2"
+ },
+ "2": {
+ "name": "entity.name.function.macro.i2"
+ }
},
"end": "\\}",
"name": "meta.macro.definition.i2",
"patterns": [
- { "include": "#comments" },
- { "include": "#macro-reference" },
- { "include": "#braces" },
- { "include": "#semicolon" },
- { "include": "#keywords" },
- { "include": "#function-call" },
- { "include": "#memory-index" },
- { "include": "#variables" },
- { "include": "#hex" },
- { "include": "#decimal" },
- { "include": "#string" },
- { "include": "#char" },
- { "include": "#blob" }
+ {
+ "include": "#comments"
+ },
+ {
+ "include": "#macro-reference"
+ },
+ {
+ "include": "#braces"
+ },
+ {
+ "include": "#semicolon"
+ },
+ {
+ "include": "#jump-call"
+ },
+ {
+ "include": "#keywords"
+ },
+ {
+ "include": "#function-call"
+ },
+ {
+ "include": "#memory-index"
+ },
+ {
+ "include": "#label"
+ },
+ {
+ "include": "#variables"
+ },
+ {
+ "include": "#hex"
+ },
+ {
+ "include": "#decimal"
+ },
+ {
+ "include": "#string"
+ },
+ {
+ "include": "#char"
+ },
+ {
+ "include": "#blob"
+ }
]
}
],
@@ -47,6 +122,16 @@
"name": "comment.line.double-slash.i2",
"match": "//.*$"
},
+ "block-comments": {
+ "name": "comment.block.i2",
+ "begin": "/\\*",
+ "end": "\\*/",
+ "patterns": [
+ {
+ "include": "#block-comments"
+ }
+ ]
+ },
"braces": {
"name": "punctuation.section.block.i2",
"match": "[\\{\\}]"
@@ -61,22 +146,64 @@
},
"keywords": {
"name": "keyword.control.i2",
- "match": "\\b(?:macro|system|exit)\\b"
+ "match": "\\b(?:macro|system|exit|let|while|if)\\b"
+ },
+ "jump-call": {
+ "begin": "\\b(?:jmp|jz|jnz)\\s*\\(",
+ "beginCaptures": {
+ "0": {
+ "name": "keyword.control.i2"
+ }
+ },
+ "end": "\\)",
+ "name": "meta.function.jump-call.i2",
+ "patterns": [
+ {
+ "include": "#comments"
+ },
+ {
+ "include": "#macro-reference"
+ },
+ {
+ "include": "#memory-index"
+ },
+ {
+ "name": "punctuation.separator.comma.i2",
+ "match": ","
+ },
+ {
+ "name": "entity.name.type.i2",
+ "match": "\\b[A-Za-z_][A-Za-z0-9_]*\\b"
+ },
+ {
+ "include": "#decimal"
+ },
+ {
+ "include": "#hex"
+ },
+ {
+ "include": "#string"
+ }
+ ]
},
"function-call": {
"name": "entity.name.function.i2",
"match": "\\b[a-zA-Z_][a-zA-Z0-9_]*\\s*(?=\\()"
},
"variables": {
- "name": "variable.other.i2",
+ "name": "source.i2",
"match": "\\b[a-zA-Z_][a-zA-Z0-9_]*\\b"
},
+ "label": {
+ "name": "entity.name.type.i2",
+ "match": "^[ \\t]*[A-Za-z_][A-Za-z0-9_]*:"
+ },
"memory-index": {
- "name": "variable.parameter.memory-index.i2",
+ "name": "constant.language.i2",
"match": "@\\s*\\d+"
},
"macro-reference": {
- "name": "constant.other.macro-reference.i2",
+ "name": "variable.other.i2",
"match": "/[^/\\r\\n]+/"
},
"hex": {
@@ -90,11 +217,15 @@
"string": {
"begin": "\"",
"beginCaptures": {
- "0": { "name": "punctuation.definition.string.begin.i2" }
+ "0": {
+ "name": "punctuation.definition.string.begin.i2"
+ }
},
"end": "\"",
"endCaptures": {
- "0": { "name": "punctuation.definition.string.end.i2" }
+ "0": {
+ "name": "punctuation.definition.string.end.i2"
+ }
},
"name": "string.quoted.double.i2",
"patterns": [
@@ -113,8 +244,12 @@
"end": "\\]",
"name": "meta.bracket.blob.i2",
"patterns": [
- { "include": "#char" },
- { "include": "#decimal" },
+ {
+ "include": "#char"
+ },
+ {
+ "include": "#decimal"
+ },
{
"name": "punctuation.separator.comma.i2",
"match": ","
@@ -122,4 +257,4 @@
]
}
}
-}
+} \ No newline at end of file