From 78692d4adda6865ce331a48e40c0ff8f61324295 Mon Sep 17 00:00:00 2001 From: SeeBasTStick <sebastian.stock@hhu.de> Date: Tue, 26 May 2020 14:30:55 +0200 Subject: [PATCH] added syntax highlighting --- package.json | 30 ++- syntaxes/classicalb.tmLanguage.json | 334 ++++++++++++++++++++++++++++ 2 files changed, 347 insertions(+), 17 deletions(-) create mode 100644 syntaxes/classicalb.tmLanguage.json diff --git a/package.json b/package.json index acf5483..c833a8a 100644 --- a/package.json +++ b/package.json @@ -1,15 +1,15 @@ { - "name": "b-eventb-language-extension", - "displayName": "B/Event-B/ProB language extension", - "description": "Compiler and language support for B and Event-B via ProB", + "name": "b-language-extension", + "displayName": "B/ProB Language Support", + "description": "Compiler and language support for B and via ProB", "version": "0.3.0", "publisher": "SeeBasTStick", - "icon": "media/prob2-ui.png", + "icon": "./media/prob2-ui.png", "author": "Sebastian Stock", "license": "MIT", "repository": { "type": "git", - "url": "https://github.com/SeeBasTStick/b-eventb-language-extension" + "url": "https://github.com/hhu-stups/b-language-extension" }, "engines": { "vscode": "^1.45.0" @@ -20,13 +20,11 @@ "keywords": [ "classical B", "B", - "Event-B", "ProB" ], "activationEvents": [ - "onLanguage:classicalb", - "onLanguage:event" - ], + "onLanguage:classicalb" + ], "main": "./client/out/extension", "contributes": { "configuration": { @@ -89,15 +87,13 @@ "B", "classical B" ] - }, + } + ], + "grammars": [ { - "id": "eventb", - "extensions": [ - ".sys" - ], - "aliases": [ - "Event-B" - ] + "language": "classicalb", + "scopeName": "source.classicalb", + "path": "./syntaxes/classicalb.tmLanguage.json" } ] }, diff --git a/syntaxes/classicalb.tmLanguage.json b/syntaxes/classicalb.tmLanguage.json new file mode 100644 index 0000000..05faf12 --- /dev/null +++ b/syntaxes/classicalb.tmLanguage.json @@ -0,0 +1,334 @@ +{ + "name": "Classical B", + "scopeName": "source.classicalb", + "patterns": [ + { + "include": "source.classicalb.rules" + }, + { + "include": "#pragma" + }, + { + "include": "#comments" + }, + { + "include": "#strings" + }, + { + "include": "#components" + }, + { + "include": "#machineclauses" + }, + { + "include": "#control_blocks" + }, + { + "include": "#keyword_control" + }, + { + "include": "#keyword_operators" + }, + { + "include": "#constant_values" + }, + { + "include": "#preferences" + }, + { + "include": "#identifiers" + }, + { + "include": "#invalid" + } + ], + "repository": { + "identifiers": { + "patterns": [ + { + "match": "\\b[a-zA-Z][a-zA-Z0-9_]*\\b", + "name": "identifier.classicalb" + } + ] + }, + "pragma": { + "patterns": [ + { + "begin": "/\\*@\\b(package|import-package|import_package|symbolic|unit|label|desc|description|conversion|file)\\b", + "captures": { + "0": { + "name": "punctuation.definition.tag.classicalb" + } + }, + "end": "\\*/", + "name": "identifier.classicalb" + } + ] + }, + "comments": { + "patterns": [ + { + "begin": "/\\*", + "captures": { + "0": { + "name": "punctuation.definition.comment.classicalb" + } + }, + "end": "\\*/", + "name": "comment.block.classicalb" + }, + { + "begin": "//", + "captures": { + "0": { + "name": "punctuation.definition.comment.classicalb" + } + }, + "end": "\n", + "name": "comment.line.classicalb" + } + ] + }, + "strings": { + "patterns": [ + { + "begin": "\"", + "beginCaptures": { + "0": { + "name": "punctuation.definition.string.begin.classicalb" + } + }, + "end": "\"", + "endCaptures": { + "0": { + "name": "punctuation.definition.string.end.classicalb" + } + }, + "name": "string.quoted.double.classicalb", + "patterns": [ + { + "match": "\\\\.", + "name": "constant.character.escape.classicalb" + }, + { + "match": "\"\"", + "name": "constant.character.escape.quote.classicalb" + } + ] + }, + { + "begin": "'''", + "captures": { + "0": { + "name": "punctuation.definition.string.begin.classicalb" + } + }, + "end": "'''", + "name": "string.quoted.triple.classicalb" + } + ] + }, + "machineclauses": { + "patterns": [ + { + "match": "(?x)\n\\b(INITIALIZATION|INITIALISATION|ASSERTIONS|OPERATIONS|SEES|PROMOTES|USES\n|INCLUDES|IMPORTS|REFINES|EXTENDS|INVARIANT|CONCRETE_VARIABLES\n|ABSTRACT_VARIABLES|VARIABLES|PROPERTIES|CONSTANTS|ABSTRACT_CONSTANTS\n|CONCRETE_CONSTANTS|CONSTRAINTS|SETS|DEFINITIONS|VALUES)\\b", + "name": "storage.type.clause.classicalb" + } + ] + }, + "keyword_control": { + "patterns": [ + { + "match": "(?x)\n\\b(skip|BE|DO|VARIANT|ELSIF|THEN|ELSE|EITHER|CASE|SELECT\n|ASSERT|WHEN|WHERE|OR|OF|IN)\\b", + "name": "keyword.control.classicalb" + } + ] + }, + "keyword_operators": { + "patterns": [ + { + "match": "\\bnot\\b|¬|\\bor\\b|∨", + "name": "keyword.operator.logical.classicalb" + }, + { + "match": "!|#|∀|∃|&|∧|<=>|=>|⇔|⇒", + "name": "keyword.operator.logical.classicalb" + }, + { + "match": "≠|/=|=|==", + "name": "keyword.operator.equality.classicalb" + }, + { + "match": "\\b(first|last|tail|front|rev|seq|seq1|conc)\\b", + "name": "keyword.operator.sequence.classicalb" + }, + { + "match": "\\b(tree|btree|top|const|rank|father|son|sons|subtree|arity|bin|left|right|sizet|prefix|postfix|mirror|infix)\\b", + "name": "keyword.operator.tree.classicalb" + }, + { + "match": "\\b(mod|succ|pred)\\b", + "name": "keyword.operator.numeric.classicalb" + }, + { + "match": "\\b(rec|struct)\\b", + "name": "keyword.operator.record.classicalb" + }, + { + "match": "\\b(ran|dom|id|prj1|prj2|closure1|closure|interate|fnc|rel)\\b|%|λ", + "name": "keyword.operator.relation.classicalb" + }, + { + "match": "bool", + "name": "keyword.operator.boolean.classicalb" + }, + { + "match": "<--|:=|::", + "name": "keyword.operator.assignment.classicalb" + }, + { + "match": "\\b(INTER|UNION|SIGMA|PI|POW|POW1|union|inter)\\b|⋂|⋃|∑|∏", + "name": "keyword.operator.set.classicalb" + }, + { + "match": "\\b(min|max|card|size)\\b", + "name": "keyword.operator.set.classicalb" + }, + { + "match": ":|∈|∉|\\\\/|/\\\\|∪|∩|⊄|⊈|⊂|⊆", + "name": "keyword.operator.set.classicalb" + }, + { + "begin": "{", + "beginCaptures": { + "0": { + "name": "punctuation.definition.set.begin.classicalb" + } + }, + "end": "}", + "endCaptures": { + "0": { + "name": "punctuation.definition.set.end.classicalb" + } + }, + "patterns": [ + { + "include": "$self" + } + ] + }, + { + "match": "-->|-->(>)?|>->(>)?|<->|>+>(>)?", + "name": "keyword.operator.relation.classicalb" + }, + { + "match": "(\\|>(>)?)|((<)?<\\|)|(\\|->)", + "name": "keyword.operator.relation.classicalb" + }, + { + "match": "↠|↦|⤀|⤖|⇸|⤔|◀|←|→|↔|↣|▶|⇾|⋖|⊗|◁|▷|⇽", + "name": "keyword.operator.relation.classicalb" + }, + { + "match": "\\|\\|", + "name": "keyword.operator.parallel.classicalb" + }, + { + "match": ">|<|>=|=<|≤|≥", + "name": "keyword.operator.numeric.classicalb" + } + ] + }, + "constant_values": { + "patterns": [ + { + "match": "\\b\\d+", + "name": "constant.numeric.classicalb" + }, + { + "match": "{}|∅", + "name": "constant.set.classicalb" + }, + { + "match": "\\b(TRUE|FALSE)\\b", + "name": "constant.language.boolean.classicalb" + }, + { + "match": "\\b(BOOL|STRING|INT(EGER)?|NAT(URAL)?(1)?|MININT|MAXINT)\\b", + "name": "constant.other.sets.classicalb" + } + ] + }, + "control_blocks": { + "patterns": [ + { + "begin": "(?x)\n\\b(BEGIN|PRE|SELECT|ANY|LET|VAR|ASSERT|WHILE|IF|CHOICE|CASE|EITHER)\\b", + "beginCaptures": { + "0": { + "name": "keyword.control.classicalb" + } + }, + "end": "\\bEND\\b", + "endCaptures": { + "0": { + "name": "keyword.control.classicalb" + } + }, + "patterns": [ + { + "match": "\\bINVARIANT\\b", + "name": "keyword.control.classicalb" + }, + { + "include": "$self" + } + ] + } + ] + }, + "components": { + "patterns": [ + { + "begin": "\\b(MACHINE|SYSTEM|MODEL|REFINEMENT|IMPLEMENTATION)\\b", + "beginCaptures": { + "0": { + "name": "storage.type.machine.start.classicalb" + } + }, + "end": "\\bEND\\b", + "endCaptures": { + "0": { + "name": "storage.type.machine.end.classicalb" + } + }, + "name": "meta.machine.classicalb", + "patterns": [ + { + "include": "$self" + } + ] + } + ] + }, + "preferences": { + "patterns": [ + { + "match": "(?x)\n\\b(GOAL|SET_PREF_\\w*|FORCE_SYMMETRY_\\w*|GOAL|ANIMATION_FUNCTION_DEFAULT\n|HEURISTIC_FUNCTION|ANIMATION_FUNCTION[0-9]*|ANIMATION_IMG\\w*\n|ANIMATION_STR\\w*|ASSERT_(LTL|CTL)\\w*)\\b", + "name": "entity.other.attribute-name.classicalb" + } + ] + }, + "invalid": { + "patterns": [ + { + "match": "@|\\?|€", + "name": "invalid.illegal.other.classicalb" + }, + { + "match": ";(\\s)*;", + "name": "invalid.illegal.other.classicalb" + } + ] + } + } + } \ No newline at end of file -- GitLab