From 0296fb60c18d24b9d2de52aa31bf6650914f5859 Mon Sep 17 00:00:00 2001 From: EvgeniyPeshkov <50870158+EvgeniyPeshkov@users.noreply.github.com> Date: Fri, 31 May 2019 17:28:44 +0300 Subject: [PATCH] PHP language --- CHANGELOG.md | 10 +++ README.md | 1 + grammars/php.json | 166 ++++++++++++++++++++++++++++++++++++++++++++++ package-lock.json | 11 ++- package.json | 15 +++-- 5 files changed, 198 insertions(+), 5 deletions(-) create mode 100644 grammars/php.json diff --git a/CHANGELOG.md b/CHANGELOG.md index a8b49a9..29456fc 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,15 @@ # Syntax Highlighter Change Log +## **Version 0.2.6** +#### New programming languages: +* PHP + +#### Fixes: +* TypeScript and Javascript highlighting has been fixed +* In Rust "_" is highlighted as variable +* Internal improvements + + ## **Version 0.2.6** #### Changes: * More consistent names of syntax terms diff --git a/README.md b/README.md index 23dbb2b..2a5251b 100644 --- a/README.md +++ b/README.md @@ -10,6 +10,7 @@ * JavaScript * Go * Rust +* Php * More to come... #### Description diff --git a/grammars/php.json b/grammars/php.json new file mode 100644 index 0000000..4bc4415 --- /dev/null +++ b/grammars/php.json @@ -0,0 +1,166 @@ +{ + "simpleTerms": { + + "variable_name": "variable", + + "__construct": "function", + "\"echo\"": "function", + "\"print\"": "function", + "\"unset\"": "function", + "\"isset\"": "function", + "\"eval\"": "function", + "\"array\"": "function", + "\"list\"": "function", + "\"empty\"": "function", + + "require_once": "function", + "require": "function", + "include_once": "function", + "include": "function", + + "\"callable\"": "modifier", + "\"var\"": "modifier", + "\"trait\"": "modifier", + "\"class\"": "modifier", + "\"interface\"": "modifier", + "\"function\"": "modifier", + "\"type\"": "modifier", + + "\"static\"": "modifier", + "\"public\"": "modifier", + "\"private\"": "modifier", + "\"protected\"": "modifier", + "\"global\"": "modifier", + "\"const\"": "modifier", + "\"abstract\"": "modifier", + "\"extends\"": "modifier", + "\"implements\"": "modifier", + "\"final\"": "modifier", + + "integer": "number", + "float": "number", + "string": "string", + "regex": "string", + + "true": "constant", + "false": "constant", + + "comment": "comment", + + "\"if\"": "control", + "\"do\"": "control", + "\"else\"": "control", + "\"elseif\"": "control", + "\"endif\"": "control", + "\"while\"": "control", + "\"endwhile\"": "control", + "\"for\"": "control", + "\"endfor\"": "control", + "\"foreach\"": "control", + "\"endforeach\"": "control", + "\"declare\"": "control", + "\"enddeclare\"": "control", + "\"return\"": "control", + "\"break\"": "control", + "\"continue\"": "control", + "\"throw\"": "control", + "\"try\"": "control", + "\"catch\"": "control", + "\"finally\"": "control", + "\"switch\"": "control", + "\"endswitch\"": "control", + "\"case\"": "control", + "\"default\"": "control", + "\"yield\"": "control", + "\"goto\"": "control", + "\"exit\"": "control", + "\"die\"": "control", + + "\"new\"": "operator", + "\"clone\"": "operator", + "\"insteadof\"": "operator", + "\"instanceof\"": "operator", + + "\"+\"": "operator", + "\"-\"": "operator", + "\"*\"": "operator", + "\"/\"": "operator", + "\"%\"": "operator", + "\"**\"": "operator", + "\"=\"": "operator", + "\"==\"": "operator", + "\"===\"": "operator", + "\"!=\"": "operator", + "\"!==\"": "operator", + "\"<\"": "operator", + "\">\"": "operator", + "\"<>\"": "operator", + "\"<=\"": "operator", + "\"=>\"": "operator", + "\">=\"": "operator", + "\"<=>\"": "operator", + "\"&\"": "operator", + "\"$\"": "operator", + "\"|\"": "operator", + "\"^\"": "operator", + "\"~\"": "operator", + "\"<<\"": "operator", + "\">>\"": "operator", + "\"++\"": "operator", + "\"--\"": "operator", + "\"and\"": "operator", + "\"or\"": "operator", + "\"xor\"": "operator", + "\"!\"": "operator", + "\"&&\"": "operator", + "\"||\"": "operator", + "\".\"": "operator", + "\"?\"": "operator", + "\":\"": "operator", + "\"??\"": "operator", + "\"->\"": "operator", + "\"as\"": "operator", + + "\"use\"": "directive", + "\"namespace\"": "directive", + + "\"(\"": "punctuation", + "\")\"": "punctuation", + "\"{\"": "punctuation", + "\"}\"": "punctuation", + "\"[\"": "punctuation", + "\"]\"": "punctuation", + "\";\"": "punctuation", + "\",\"": "punctuation", + + }, + + "complexTerms": ["name", "simple_variable"], + + "complexScopes": { + "class_declaration > name": "type", + "catch_clause > qualified_name > name": "type", + "class_base_clause > qualified_name > name": "type", + "interface_declaration > name": "type", + "class_interface_clause > qualified_name > name": "type", + "object_creation_expression > qualified_name > name": "type", + "cast_expression > cast_type": "type", + "object_creation_expression > new_variable > simple_variable": "type", + + "name": "variable", + "member_access_expression > name": "variable", + + "function_definition > name": "function", + "function_call_expression > name": "function", + "function_call_expression > qualified_name": "function", + "method_declaration > name": "function", + "method_declaration > function_definition > name": "function", + "scoped_call_expression > name": "function", + "member_call_expression > name": "function", + + "const_element > name": "constant", + "class_constant_access_expression > name": "constant", + "qualified_name > name": "constant", + + } +} diff --git a/package-lock.json b/package-lock.json index 397f811..98c76e4 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "syntax-highlighter", - "version": "0.2.6", + "version": "0.2.7", "lockfileVersion": 1, "requires": true, "dependencies": { @@ -1541,6 +1541,15 @@ "nan": "^2.4.0" } }, + "tree-sitter-php": { + "version": "0.13.1", + "resolved": "https://registry.npmjs.org/tree-sitter-php/-/tree-sitter-php-0.13.1.tgz", + "integrity": "sha512-Qc7w4D0XG3KGcfcEM9K/YBighVw2uijTIENmqPp32HcCR/8IZwzuNSbAkbD44PPw1WQFvtBZVJqOc91kMH+LPA==", + "dev": true, + "requires": { + "nan": "^2.10.0" + } + }, "tree-sitter-python": { "version": "0.14.0", "resolved": "https://registry.npmjs.org/tree-sitter-python/-/tree-sitter-python-0.14.0.tgz", diff --git a/package.json b/package.json index c447359..77d945a 100644 --- a/package.json +++ b/package.json @@ -3,10 +3,14 @@ "displayName": "Syntax Highlighter", "description": "Syntax highlighting based on Tree-sitter", "homepage": "https://github.com/EvgeniyPeshkov/syntax-highlighter", - "version": "0.2.6", + "version": "0.2.7", "publisher": "evgeniypeshkov", "license": "MIT", "icon": "images/syntax.png", + "galleryBanner": { + "color": "#263238", + "theme": "light" + }, "repository": { "url": "https://github.com/EvgeniyPeshkov/syntax-highlighter" }, @@ -34,7 +38,8 @@ "TypeScript", "JavaScript", "Go", - "Rust" + "Rust", + "PHP" ], "engines": { "vscode": "^1.15.0" @@ -46,7 +51,8 @@ "onLanguage:typescript", "onLanguage:javascript", "onLanguage:go", - "onLanguage:rust" + "onLanguage:rust", + "onLanguage:php" ], "main": "./out/extension.js", "scripts": { @@ -73,7 +79,8 @@ "tree-sitter-typescript": "^0.13.6", "tree-sitter-javascript": "^0.13.10", "tree-sitter-go": "^0.13.3", - "tree-sitter-rust": "^0.13.7" + "tree-sitter-rust": "^0.13.7", + "tree-sitter-php": "^0.13.1" }, "contributes": { "colors": [