diff --git a/docs.json b/docs.json index 0cdfb8ba8..a67f6e899 100644 --- a/docs.json +++ b/docs.json @@ -24,7 +24,23 @@ "background": "/resources/logo/og-image-bg.svg" }, "styling": { - "eyebrows": "breadcrumbs" + "eyebrows": "breadcrumbs", + "codeblocks": { + "theme": { + "light": "github-light-default", + "dark": "dark-plus" + }, + "languages": { + "custom": [ + "resources/syntaxes/tolk.tmLanguage.json", + "resources/syntaxes/tlb.tmLanguage.json", + "resources/syntaxes/fift.tmLanguage.json", + "resources/syntaxes/tasm.tmLanguage.json", + "resources/syntaxes/func.tmLanguage.json", + "resources/syntaxes/tact.tmLanguage.json" + ] + } + } }, "contextual": { "options": [ diff --git a/package-lock.json b/package-lock.json index f9c10355f..409d7de37 100644 --- a/package-lock.json +++ b/package-lock.json @@ -7,7 +7,7 @@ "name": "ton-docs", "dependencies": { "cspell": "^9.2.1", - "mint": "^4.2.186", + "mint": "^4.2.202", "remark": "^15.0.1", "remark-cli": "^12.0.1", "remark-frontmatter": "^5.0.0", diff --git a/package.json b/package.json index 87ae8ae64..694806da5 100644 --- a/package.json +++ b/package.json @@ -23,7 +23,7 @@ }, "dependencies": { "cspell": "^9.2.1", - "mint": "^4.2.186", + "mint": "^4.2.202", "remark": "^15.0.1", "remark-cli": "^12.0.1", "remark-frontmatter": "^5.0.0", diff --git a/resources/syntaxes/fift.tmLanguage.json b/resources/syntaxes/fift.tmLanguage.json new file mode 100644 index 000000000..0c96631b7 --- /dev/null +++ b/resources/syntaxes/fift.tmLanguage.json @@ -0,0 +1,147 @@ +{ + "$schema": "https://raw.githubusercontent.com/martinring/tmlanguage/master/tmlanguage.json", + "name": "fift", + "scopeName": "source.fift", + "fileTypes": [ + "fif" + ], + "patterns": [ + { + "include": "#comments" + }, + { + "include": "#strings" + }, + { + "include": "#numbers" + }, + { + "include": "#stack_words" + }, + { + "include": "#program_words" + }, + { + "include": "#control_words" + }, + { + "include": "#literals" + }, + { + "include": "#commands" + } + ], + "repository": { + "comments": { + "patterns": [ + { + "match": "//.*$", + "name": "comment.line.double-slash.fift" + } + ] + }, + "strings": { + "patterns": [ + { + "begin": "\"", + "end": "\"", + "name": "string.quoted.double.fift", + "patterns": [ + { + "match": "\\\\.", + "name": "constant.character.escape.fift" + } + ] + }, + { + "match": "abort\"[^\"]*\"", + "name": "string.quoted.double.abort.fift" + }, + { + "match": "\\.\"[^\"]*\"", + "name": "string.quoted.double.print.fift" + } + ] + }, + "numbers": { + "patterns": [ + { + "match": "\\b-?[0-9]+(/-?[0-9]+)?\\b", + "name": "constant.numeric.decimal.fift" + }, + { + "match": "\\b0x[0-9a-fA-F]+\\b", + "name": "constant.numeric.hex.fift" + }, + { + "match": "\\b0b[01]+\\b", + "name": "constant.numeric.binary.fift" + } + ] + }, + "stack_words": { + "patterns": [ + { + "match": "\\b(dup|drop|swap|rot|-rot|over|tuck|nip|2dup|2drop|2swap|pick|roll|-roll|exch|exch2|\\?dup)\\b", + "name": "keyword.operator.stack.fift" + } + ] + }, + "program_words": { + "patterns": [ + { + "match": "\\b(PROGRAM|END>c|PROC|PROCINLINE|DECLPROC|DECLMETHOD)\\b", + "name": "keyword.control.program.fift" + }, + { + "match": "\\b(CALLDICT|INLINECALLDICT)\\b", + "name": "keyword.control.call.fift" + } + ] + }, + "control_words": { + "patterns": [ + { + "match": "\\b(if|ifnot|cond|until|while|times)\\b", + "name": "keyword.control.flow.fift" + }, + { + "match": "\\b(include)\\b", + "name": "keyword.control.import.fift" + } + ] + }, + "literals": { + "patterns": [ + { + "match": "\\b(true|false)\\b", + "name": "constant.language.boolean.fift" + }, + { + "match": "b\\{[01]+\\}", + "name": "constant.other.binary-slice.fift" + }, + { + "match": "x\\{[0-9a-fA-F_]+\\}", + "name": "constant.other.hex-slice.fift" + }, + { + "match": "B\\{[0-9a-fA-F_]+\\}", + "name": "constant.other.hex-bytes.fift" + }, + { + "match": "char .", + "name": "constant.character.fift" + } + ] + }, + "commands": { + "patterns": [ + { + "match": "\\b[A-Z][A-Z0-9_]*\\b", + "name": "keyword.other.command.fift" + } + ] + } + } +} diff --git a/resources/syntaxes/func.tmLanguage.json b/resources/syntaxes/func.tmLanguage.json new file mode 100644 index 000000000..902a4e500 --- /dev/null +++ b/resources/syntaxes/func.tmLanguage.json @@ -0,0 +1,195 @@ +{ + "$schema": "https://raw.githubusercontent.com/martinring/tmlanguage/master/tmlanguage.json", + "name": "func", + "scopeName": "source.func", + "fileTypes": [ + "fc", + "func" + ], + "patterns": [ + { + "include": "#comments" + }, + { + "include": "#strings" + }, + { + "include": "#numbers" + }, + { + "include": "#directives" + }, + { + "include": "#keywords" + }, + { + "include": "#types" + }, + { + "include": "#specifiers" + }, + { + "include": "#operators" + }, + { + "include": "#function-calls" + }, + { + "include": "#punctuation" + }, + { + "include": "#identifiers" + } + ], + "repository": { + "comments": { + "patterns": [ + { + "name": "comment.line.double-semicolon.func", + "match": ";;.*$" + }, + { + "name": "comment.block.func", + "begin": "\\{-", + "end": "-\\}", + "patterns": [ + { + "include": "#comments" + } + ] + } + ] + }, + "strings": { + "patterns": [ + { + "name": "string.quoted.double.func", + "match": "\"(?:[^\\\"\\\\]|\\\\.)*\"[Hhcu]?" + } + ] + }, + "numbers": { + "patterns": [ + { + "name": "constant.numeric.hex.func", + "match": "(?=|<=>|<<=|>>=|~>>=|\\^>>=|<<|>>|~>>|\\^>>|->|=|\\+=|-=|\\*=|\\/=|~\\/=|\\^\\/=|%|~%=|\\^%|&|\\|\\||~|\\^|\\?|\\.)" + } + ] + }, + "function-calls": { + "patterns": [ + { + "name": "meta.function-call.builtin.func", + "match": "(?x)\\b(?:throw_unless|equal_slices|send_raw_message|accept_message)\\b(?=\\s*\\()", + "captures": { + "0": { + "name": "support.function.builtin.func" + } + } + }, + { + "name": "meta.function-call.method.func", + "begin": "(?<=\\.|~)\\s*(`[^`]+`|[A-Za-z_\\$][^\\s+\\-*\\/%,.;(){}\\[\\]=<>|\\^~]*)\\s*(?=\\()", + "beginCaptures": { + "1": { + "name": "support.function.method.func" + } + }, + "end": "(?=)", + "patterns": [] + }, + { + "name": "meta.function-call.func", + "begin": "(?x)(?|\\^~]*)\\s*(?=\\()", + "beginCaptures": { + "1": { + "name": "support.function.call.func" + } + }, + "end": "(?=)", + "patterns": [] + } + ] + }, + "punctuation": { + "patterns": [ + { + "name": "punctuation.brackets.func", + "match": "[()\\[\\]{}]" + }, + { + "name": "punctuation.separator.func", + "match": "[,:;]" + } + ] + }, + "identifiers": { + "patterns": [ + { + "name": "entity.name.function.definition.func", + "match": "(?x)(?<=^|[;{]\\s*)(`[^`]+`|[A-Za-z_\\$][^\\s+\\-*\\/%,.;(){}\\[\\]=<>|\\^~]*)\\s*(?=\\()" + }, + { + "name": "variable.other.func", + "match": "`[^`]+`|[A-Za-z_\\$][^\\s+\\-*\\/%,.;(){}\\[\\]=<>|\\^~]*" + } + ] + } + } +} diff --git a/resources/syntaxes/tact.tmLanguage.json b/resources/syntaxes/tact.tmLanguage.json new file mode 100644 index 000000000..1f83feab7 --- /dev/null +++ b/resources/syntaxes/tact.tmLanguage.json @@ -0,0 +1,617 @@ +{ + "name": "tact", + "scopeName": "source.tact", + "fileTypes": [ + "tact" + ], + "patterns": [ + { + "include": "#comment" + }, + { + "include": "#annotation" + }, + { + "include": "#literal" + }, + { + "include": "#invalid" + }, + { + "include": "#constant" + }, + { + "include": "#type" + }, + { + "include": "#expression" + }, + { + "include": "#punctuation" + }, + { + "include": "#keyword" + }, + { + "include": "#function" + }, + { + "include": "#variable" + } + ], + "repository": { + "comment": { + "patterns": [ + { + "name": "comment.line.double-slash.tact", + "begin": "//", + "beginCaptures": { + "0": { + "name": "punctuation.definition.comment.line.double-slash.tact" + } + }, + "patterns": [ + { + "include": "#todo" + } + ], + "end": "$" + }, + { + "name": "comment.block.tact", + "begin": "\\s*/\\*", + "beginCaptures": { + "0": { + "name": "comment.block.begin.tact punctuation.definition.comment.begin.tact" + } + }, + "patterns": [ + { + "include": "#todo" + } + ], + "end": "\\*/", + "endCaptures": { + "0": { + "name": "comment.block.end.tact punctuation.definition.comment.end.tact" + } + } + } + ] + }, + + "todo": { + "match": "\\b(FIXME|TODO|CHANGED|XXX|IDEA|HACK|NOTE|REVIEW|NB|BUG)\\b", + "name": "keyword.comment.todo.tact" + }, + + "annotation": { + "patterns": [ + { + "comment": "@name() in native functions", + "begin": "^\\s*(@name)\\s*(\\()", + "beginCaptures": { + "1": { + "name": "entity.other.attribute-name.tact" + }, + "2": { + "name": "punctuation.brackets.round.tact" + } + }, + "patterns": [ + { + "comment": "FunC identifier", + "match": "(.*?)", + "name": "entity.name.function.func.tact" + } + ], + "end": "\\)", + "endCaptures": { + "0": { + "name": "punctuation.brackets.round.tact" + } + } + }, + { + "comment": "One or more @interface() before traits and contracts", + "begin": "(?", + "name": "keyword.operator.mapsto.tact" + }, + { + "comment": "Decimal integer WITH leading zero", + "match": "\\b(0[0-9]*)\\b", + "name": "constant.numeric.decimal.tact" + }, + { + "comment": "Decimal integer WITHOUT leading zero", + "match": "\\b([1-9](?:_?[0-9])*)\\b", + "name": "constant.numeric.decimal.tact" + } + ], + "end": "\\)", + "endCaptures": { + "0": { + "name": "punctuation.brackets.round.tact" + } + } + }, + { + "comment": "Fallback match", + "match": "(?", + "begin": "(?", + "endCaptures": { + "0": { + "name": "punctuation.brackets.angle.tact" + } + } + }, + { + "comment": "map or set", + "begin": "(?", + "endCaptures": { + "0": { + "name": "punctuation.brackets.angle.tact" + } + } + }, + { + "include": "#as-tlb" + } + ] + }, + + "simple-type": { + "comment": "Simple types", + "match": "(?>)(?!=)", + "name": "keyword.operator.bitwise.tact" + }, + { + "comment": "Augmented assignment operators", + "match": "(\\+=|-=|\\*=|/=|%=|\\^=|&=|\\|=|\\|\\|=|&&=|<<=|>>=)", + "name": "keyword.operator.assignment.tact" + }, + { + "comment": "Assignment operator", + "match": "(?])=(?!=)", + "name": "keyword.operator.assignment.equal.tact" + }, + { + "comment": "Comparison operators", + "match": "([!=]=|<=?|>=?)", + "name": "keyword.operator.comparison.tact" + }, + { + "comment": "Arithmetic operators", + "match": "([+%*\\-])|(/(?!/))", + "name": "keyword.operator.arithmetic.tact" + }, + { + "comment": "initOf expression", + "match": "\\b(initOf)\\b", + "name": "keyword.operator.new.tact" + }, + { + "comment": "codeOf expression", + "match": "\\b(codeOf)\\b", + "name": "keyword.operator.new.tact" + }, + { + "comment": "Ternary expression", + "begin": "(?!\\?\\.\\s*[^[:digit:]])(\\?)(?!\\?)", + "beginCaptures": { + "1": { + "name": "keyword.operator.ternary.tact" + } + }, + "patterns": [ + { + "include": "$self" + } + ], + "end": "\\s*(:)", + "endCaptures": { + "1": { + "name": "keyword.operator.ternary.tact" + } + } + } + ] + }, + + "punctuation": { + "patterns": [ + { + "match": ",", + "name": "punctuation.comma.tact" + }, + { + "match": "[{}]", + "name": "punctuation.brackets.curly.tact" + }, + { + "match": "[()]", + "name": "punctuation.brackets.round.tact" + }, + { + "match": ";", + "name": "punctuation.semi.tact" + }, + { + "match": ":", + "name": "punctuation.colon.tact" + }, + { + "match": "\\.", + "name": "punctuation.dot.tact" + } + ] + }, + + "keyword": { + "patterns": [ + { + "match": "(?", + "match": "=>", + "name": "keyword.operator.mapsto.tasm" + }, + { + "include": "#literal" + }, + { + "include": "#code_block" + }, + { + "include": "#punctuation" + } + ] + }, + "punctuation": { + "patterns": [ + { + "match": ",", + "name": "punctuation.comma.tasm" + }, + { + "match": ";", + "name": "punctuation.semi.tasm" + }, + { + "match": ":", + "name": "punctuation.colon.tasm" + } + ] + } + } +} diff --git a/resources/syntaxes/tlb.tmLanguage.json b/resources/syntaxes/tlb.tmLanguage.json new file mode 100644 index 000000000..a3cc49450 --- /dev/null +++ b/resources/syntaxes/tlb.tmLanguage.json @@ -0,0 +1,264 @@ +{ + "$schema": "https://raw.githubusercontent.com/martinring/tmlanguage/master/tmlanguage.json", + "name": "tlb", + "scopeName": "source.tlb", + "fileTypes": [ + "tlb" + ], + "patterns": [ + { + "include": "#comment" + }, + { + "include": "#constructors" + }, + { + "include": "#typeDefinitions" + }, + { + "include": "#typeParameters" + }, + { + "include": "#fields" + }, + { + "include": "#hashExpressions" + }, + { + "include": "#operators" + }, + { + "include": "#primitiveTypes" + }, + { + "include": "#arrays" + }, + { + "include": "#numbers" + }, + { + "include": "#declarations" + } + ], + "repository": { + "comment": { + "patterns": [ + { + "name": "comment.line.double-slash.tlb", + "begin": "//", + "beginCaptures": { + "0": { + "name": "punctuation.definition.comment.line.double-slash.tlb" + } + }, + "end": "$" + }, + { + "name": "comment.block.tlb", + "begin": "\\s*/\\*", + "beginCaptures": { + "0": { + "name": "comment.block.begin.tlb punctuation.definition.comment.begin.tlb" + } + }, + "end": "\\*/", + "endCaptures": { + "0": { + "name": "comment.block.end.tlb punctuation.definition.comment.end.tlb" + } + } + } + ] + }, + "constructors": { + "patterns": [ + { + "match": "([a-zA-Z_][a-zA-Z0-9_]*)\\s*(\\$[01_]+|#[0-9a-fA-F_]*)", + "captures": { + "1": { + "name": "entity.name.type.constructor.tlb" + }, + "2": { + "name": "constant.numeric.constructor-tag.tlb" + } + } + } + ] + }, + "typeParameters": { + "patterns": [ + { + "match": "\\{([A-Z][a-zA-Z0-9]*):Type\\}", + "captures": { + "1": { + "name": "support.type.parameter.tlb" + } + } + }, + { + "match": "\\{([a-z][a-zA-Z0-9]*):([^}]+)\\}", + "captures": { + "1": { + "name": "variable.parameter.tlb" + }, + "2": { + "name": "support.type.parameter.tlb" + } + } + } + ] + }, + "fields": { + "patterns": [ + { + "match": "([a-zA-Z_][a-zA-Z0-9_]*)\\s*(:)", + "captures": { + "1": { + "name": "variable.other.property.tlb" + }, + "2": { + "name": "keyword.operator.colon.tlb" + } + } + }, + { + "match": "\\^\\s*\\(([^)]+)\\)", + "captures": { + "1": { + "patterns": [ + { + "include": "#expressions" + } + ] + }, + "0": { + "name": "keyword.operator.reference.tlb" + } + } + } + ] + }, + "hashExpressions": { + "patterns": [ + { + "match": "(##)\\s*\\(([^)]+)\\)", + "captures": { + "1": { + "name": "entity.name.function.macro.tlb" + }, + "2": { + "patterns": [ + { + "include": "#expressions" + } + ] + } + } + }, + { + "match": "(##|~)", + "name": "entity.name.function.macro.tlb" + } + ] + }, + "operators": { + "patterns": [ + { + "match": "(\\+|\\-|\\*|\\|<=|>=|!=|=|<|>|\\^|~|\\?)", + "name": "keyword.operator.tlb" + } + ] + }, + "primitiveTypes": { + "patterns": [ + { + "match": "\\b((u)?int\\d+|Type|Bit|Maybe)\\b", + "name": "support.type.primitive.tlb" + } + ] + }, + "arrays": { + "patterns": [ + { + "begin": "\\[", + "end": "\\]", + "patterns": [ + { + "include": "#expressions" + } + ], + "name": "meta.array.tlb" + } + ] + }, + "numbers": { + "patterns": [ + { + "match": "\\b\\d+\\b", + "name": "constant.numeric.decimal.tlb" + }, + { + "match": "\\b0x[0-9a-fA-F]+\\b", + "name": "constant.numeric.hex.tlb" + } + ] + }, + "expressions": { + "patterns": [ + { + "include": "#hashExpressions" + }, + { + "include": "#operators" + }, + { + "include": "#primitiveTypes" + }, + { + "include": "#arrays" + }, + { + "include": "#numbers" + }, + { + "match": "\\b[a-zA-Z_][a-zA-Z0-9_]*\\b", + "name": "variable.other.tlb" + } + ] + }, + "typeDefinitions": { + "patterns": [ + { + "match": "=\\s*([A-Z][a-zA-Z0-9]*)(?:\\s+([a-zA-Z0-9_\\s]+))?\\s*(?:X)?\\s*;", + "captures": { + "1": { + "name": "entity.name.class.tlb" + }, + "2": { + "patterns": [ + { + "include": "#expressions" + } + ] + } + } + } + ] + }, + "declarations": { + "patterns": [ + { + "match": "([a-zA-Z_][a-zA-Z0-9_]*)#([0-9a-fA-F]+)", + "captures": { + "1": { + "name": "entity.name.type.tlb" + }, + "2": { + "name": "constant.numeric.hex.tlb" + } + } + } + ] + } + } +} diff --git a/resources/syntaxes/tolk.tmLanguage.json b/resources/syntaxes/tolk.tmLanguage.json new file mode 100644 index 000000000..e1fb6feff --- /dev/null +++ b/resources/syntaxes/tolk.tmLanguage.json @@ -0,0 +1,83 @@ +{ + "$schema": "https://raw.githubusercontent.com/martinring/tmlanguage/master/tmlanguage.json", + "name": "tolk", + "scopeName": "source.tolk", + "fileTypes": [ + "tolk" + ], + "foldingStartMarker": "\\{\\s*$", + "foldingStopMarker": "^\\s*\\}", + "patterns": [ + { + "name": "comment.line.double-slash", + "match": "//(.*)" + }, + { + "name": "comment.block", + "begin": "/\\*", + "end": "\\*/" + }, + { + "name": "string.quoted.triple", + "begin": "\"\"\"", + "end": "\"\"\"", + "patterns": [ + { + "name": "constant.character.escape", + "match": "\\\\." + } + ] + }, + { + "name": "string.quoted.double", + "begin": "\"", + "end": "\"", + "patterns": [ + { + "name": "constant.character.escape", + "match": "\\\\." + } + ] + }, + { + "name": "constant.numeric", + "match": "(-?([\\d]+|0x[\\da-fA-F]+|0b[01]+))\\b" + }, + { + "name": "keyword.control", + "match": "\\b(do|if|try|else|while|break|throw|catch|return|assert|repeat|continue|asm|builtin|match|lazy)\\b" + }, + { + "name": "keyword.operator", + "match": "\\+|-|\\*|/|%|\\?|:|,|;|\\(|\\)|\\[|\\]|{|}|=|<|>|!|&|\\||\\^|==|!=|<=|>=|<<|>>|&&|\\|\\||~/|\\^/|\\+=|-=|\\*=|/=|%=|&=|\\|=|\\^=|->|<=>|~>>|\\^>>|<<=|>>=|=>" + }, + { + "name": "keyword.other", + "match": "\\b(import|export|private|readonly|true|false|null|redef|mutate|tolk|as|is|!is)\\b" + }, + { + "name": "storage.type", + "match": "\\b(type|int|cell|void|bool|slice|tuple|builder|continuation|never|coins|int\\d+|uint\\d+)\\b" + }, + { + "name": "storage.modifier", + "match": "\\b(global|const|var|val|fun|get|struct|enum|private|readonly)\\b" + }, + { + "name": "entity.name.type", + "match": "@\\w+" + }, + { + "name": "entity.name.function", + "match": "(`[^`]+`|[a-zA-Z$_][a-zA-Z0-9$_]*)(?=\\()" + }, + { + "name": "variable.language", + "match": "\bself\b" + }, + { + "name": "variable.name", + "match": "`[^`]+`|[a-zA-Z$_][a-zA-Z0-9$_]*" + } + ] +}