From c51a594581b77132866b15d90fbd442a7d0d43d9 Mon Sep 17 00:00:00 2001 From: Ayoub Serti Date: Tue, 28 Jan 2020 09:35:42 +0100 Subject: [PATCH] Add support to 4D language (#4767) * add .4dm extensons * no language for the moment * change the source of syntax highlighting for Agda (#4768) * Add interpreters 'csh' and 'tcsh' for language 'Tcsh' (#4760) * Update languages.yml * Create regtest_nmmnest.csh Source: https://github.com/barlage/WRF-kill/blob/master/tools/regtest_nmmnest.csh * Register `.bibtex` as a BibTeX file-extension (#4764) * Register `.dof` as an INI file-extension (#4766) * Register `.epsi` as a PostScript file-extension (#4763) * Add common extensions to Motorola 68k Assembly (#4637) * Add common extensions to Motorola 68k * Revert ACE mode for m68k assembly * Add heuristics for Motorola 68K Assembly * Add SWIG language and `.i` Assembly extension Co-authored-by: John Gardner * Add file extension for SnakeMake (#3953) * Add file extension for SnakeMake Previously a file name was defined for [SnakeMake[(snakemake-wrappers.readthedocs.io): https://github.com/github/linguist/pull/1834 Currently, the canonical extension is `smk` (see [this discussion](https://groups.google.com/forum/#!topic/Snakemake/segLE-RlV_s) with the author (@johanneskoester) of SnakeMake, and the [FAQ](http://snakemake.readthedocs.io/en/stable/project_info/faq.html#how-do-i-enable-syntax-highlighting-in-vim-for-snakefiles)). * Adding two Snakemake (smk) example files * add .4dm extensons * no language for the moment * add lang-4d tmLanguage * link syntax highliting * typo Co-authored-by: Guillaume Brunerie Co-authored-by: friedc <52925889+friedc@users.noreply.github.com> Co-authored-by: John Gardner Co-authored-by: Iggy Drougge Co-authored-by: Nils Homer --- .gitmodules | 3 + grammars.yml | 2 + lib/linguist/languages.yml | 7 ++ samples/4D/generate_project.4dm | 12 +++ samples/4D/play_with_classes.4dm | 121 +++++++++++++++++++++ samples/4D/test_webServerStart.4dm | 47 +++++++++ samples/4D/webArea.4dm | 158 ++++++++++++++++++++++++++++ vendor/README.md | 1 + vendor/grammars/lang-4d | 1 + vendor/licenses/grammar/lang-4d.txt | 27 +++++ 10 files changed, 379 insertions(+) create mode 100644 samples/4D/generate_project.4dm create mode 100644 samples/4D/play_with_classes.4dm create mode 100644 samples/4D/test_webServerStart.4dm create mode 100644 samples/4D/webArea.4dm create mode 160000 vendor/grammars/lang-4d create mode 100644 vendor/licenses/grammar/lang-4d.txt diff --git a/.gitmodules b/.gitmodules index e992c298b7..9e1cd625be 100644 --- a/.gitmodules +++ b/.gitmodules @@ -449,6 +449,9 @@ [submodule "vendor/grammars/json.tmbundle"] path = vendor/grammars/json.tmbundle url = https://github.com/textmate/json.tmbundle +[submodule "vendor/grammars/lang-4d"] + path = vendor/grammars/lang-4d + url = https://github.com/ayoubserti/lang-4d [submodule "vendor/grammars/language-agc"] path = vendor/grammars/language-agc url = https://github.com/Alhadis/language-agc diff --git a/grammars.yml b/grammars.yml index 98574fef61..ea4e16bcbc 100755 --- a/grammars.yml +++ b/grammars.yml @@ -373,6 +373,8 @@ vendor/grammars/jflex.tmbundle: - source.jflex vendor/grammars/json.tmbundle: - source.json +vendor/grammars/lang-4d: +- source.4dm vendor/grammars/language-agc: - source.agc vendor/grammars/language-apl: diff --git a/lib/linguist/languages.yml b/lib/linguist/languages.yml index db9a2b9f08..a2b8cda9ef 100755 --- a/lib/linguist/languages.yml +++ b/lib/linguist/languages.yml @@ -46,6 +46,13 @@ tm_scope: source.bsl ace_mode: text language_id: 0 +4D: + type: programming + extensions: + - ".4dm" + tm_scope: source.4dm + ace_mode: text + language_id: 577529595 ABAP: type: programming color: "#E8274B" diff --git a/samples/4D/generate_project.4dm b/samples/4D/generate_project.4dm new file mode 100644 index 0000000000..5ade4a6404 --- /dev/null +++ b/samples/4D/generate_project.4dm @@ -0,0 +1,12 @@ +//%attributes = {} +$params:=New object:C1471 +$params.PRODUCT_NAME:="strophe" +$params.PRODUCT_VERSION:="1.0" +$params.AUTHOR:="miyako" +$params.CREATE_DATE:=Current date:C33 +$params.COPYRIGHT_YEAR:=Year of:C25(Current date:C33) + +generate_project_source ($params) +generate_project_vs ($params) +generate_project_xcode ($params) +generate_project_plugin_stub ($params) \ No newline at end of file diff --git a/samples/4D/play_with_classes.4dm b/samples/4D/play_with_classes.4dm new file mode 100644 index 0000000000..f26e58b678 --- /dev/null +++ b/samples/4D/play_with_classes.4dm @@ -0,0 +1,121 @@ +//%attributes = {} + // ---------------------------------------------------- + // Project method : object + // ID[5543995AC5E24988A39E024B39541A8F] + // Created 13-9-2019 by Vincent de Lachaux + // ---------------------------------------------------- + // Description: + // + // ---------------------------------------------------- + // Declarations +C_OBJECT:C1216($0) +C_TEXT:C284($1) +C_TEXT:C284($2) + +C_TEXT:C284($t) +C_OBJECT:C1216($o) +C_COLLECTION:C1488($c) + +If (False:C215) + C_OBJECT:C1216(class ;$0) + C_TEXT:C284(class ;$1) + C_TEXT:C284(class ;$2) +End if + + // ---------------------------------------------------- +If (This:C1470[""]=Null:C1517) // Constructor + + If (Count parameters:C259>=1) + + $t:=String:C10($1) + + If (Count parameters:C259>=2) + + // With parameter + $o:=Formula from string:C1601($t+"(\""+String:C10($2)+"\")").call() + + Else + + $o:=Formula from string:C1601($t).call() + + End if + + $o.constructor:=Formula:C1597(class ("constructor")) + + End if + +Else + + Case of + + //______________________________________________________ + : ($1="constructor") // Returns collection of properties and functions + + $o:=New object:C1471(\ + "properties";New collection:C1472;\ + "functions";New collection:C1472;\ + "fomulas";New collection:C1472) + + $c:=New collection:C1472 + + For each ($t;This:C1470) + + $c.push($t) + + End for each + + $c:=$c.orderBy(ck ascending:K85:9) + + For each ($t;$c) + + Case of + + //______________________________________________________ + : ($t=$1) + + //______________________________________________________ + : (Value type:C1509(This:C1470[$t])=Is object:K8:27) + + //If (JSON Stringify(This[$t])="\"[object Formula]\"") + If (This:C1470[$t].source#Null:C1517) + + $o.functions.push($t) + $o.fomulas.push(This:C1470[$t].source) + + Else + + $o.properties.push($t) + + End if + + //______________________________________________________ + Else + + $o.properties.push($t) + + //______________________________________________________ + End case + End for each + + $o.functions:=$o.functions.orderBy(ck ascending:K85:9) + $o.properties:=$o.properties.orderBy(ck ascending:K85:9) + + //________________________________________ + : (This:C1470=Null:C1517) + + ASSERT:C1129(False:C215;"OOPS, this method must be called from a member method") + + //______________________________________________________ + Else + + $o:=This:C1470[$1].call() + + //______________________________________________________ + End case +End if + + // ---------------------------------------------------- + // Return +$0:=$o + // ---------------------------------------------------- + // End \ No newline at end of file diff --git a/samples/4D/test_webServerStart.4dm b/samples/4D/test_webServerStart.4dm new file mode 100644 index 0000000000..e253d97420 --- /dev/null +++ b/samples/4D/test_webServerStart.4dm @@ -0,0 +1,47 @@ +//%attributes = {"preemptive":"capable"} +C_OBJECT:C1216($webObject) +$webObject:=WEB server:C1674(2) //host db webServer + + //some initiatialisation +clear_files + + +C_OBJECT:C1216($settings) +C_OBJECT:C1216($result) +C_OBJECT:C1216($path;$newIndex) +C_TEXT:C284($response) +$settings:=New object:C1471 +$settings.rootFolder:=Folder:C1567(fk web root folder:K87:15).parent.folder("WebFolder2").platformPath +$settings.certificateFolder:=Folder:C1567(fk database folder:K87:14).folder("certificate").platformPath +$settings.HTTPEnabled:=True:C214 +$settings.HTTPPort:=8888 +$settings.HTTPSEnabled:=True:C214 +$settings.HTTPSPort:=4443 +$settings.defaultHomepage:="index2.html" + +$result:=$webObject.start($settings) + +ASSERT:C1129($result#Null:C1517;"result should not be null") +ASSERT:C1129($result.success=True:C214;"result must contain a 'success' attribute and must be true") +ASSERT:C1129($webObject.isRunning=True:C214;"web server 'isRunning' should be true") + + //test HTTP +$statusCode:=HTTP Get:C1157("http://localhost:8888";$response) + +ASSERT:C1129($statusCode=200;"Web Server not started") + +$path:=Folder:C1567($settings.rootFolder;fk platform path:K87:2).file("index2.html") +$newIndex:=File:C1566($path.platformPath;fk platform path:K87:2) + +ASSERT:C1129($response=$newIndex.getText();"unexpected index page content") + + +$statusCode:=HTTP Get:C1157("https://localhost:4443";$response) + +ASSERT:C1129($statusCode=200;"Web Server not started") + +$webObject.stop() + + + + diff --git a/samples/4D/webArea.4dm b/samples/4D/webArea.4dm new file mode 100644 index 0000000000..d6c66ab020 --- /dev/null +++ b/samples/4D/webArea.4dm @@ -0,0 +1,158 @@ +//%attributes = {"invisible":true} + // ---------------------------------------------------- + // Project method : webArea + // ID[400C94A87A6E4C049664710A5F9E71F9] + // Created 10-1-2020 by Vincent de Lachaux + // ---------------------------------------------------- + // Description: + // + // ---------------------------------------------------- + // Declarations +C_OBJECT:C1216($0) +C_TEXT:C284($1) +C_OBJECT:C1216($2) + +C_TEXT:C284($t) +C_OBJECT:C1216($o) + +If (False:C215) + C_OBJECT:C1216(webArea ;$0) + C_TEXT:C284(webArea ;$1) + C_OBJECT:C1216(webArea ;$2) +End if + + // ---------------------------------------------------- +If (This:C1470[""]=Null:C1517) // Constructor + + If (Count parameters:C259>=1) + + $t:=String:C10($1) + + End if + + $o:=New object:C1471(\ + "";"webArea";\ + "name";$t;\ + "url";"";\ + "coordinates";Null:C1517;\ + "windowCoordinates";Null:C1517;\ + "getCoordinates";Formula:C1597(widget ("getCoordinates"));\ + "hide";Formula:C1597(OBJECT SET VISIBLE:C603(*;This:C1470.name;False:C215));\ + "moveHorizontally";Formula:C1597(widget ("setCoordinates";New object:C1471("left";$1)));\ + "moveVertically";Formula:C1597(widget ("setCoordinates";New object:C1471("top";$1)));\ + "resizeHorizontally";Formula:C1597(widget ("setCoordinates";New object:C1471("right";$1)));\ + "resizeVertically";Formula:C1597(widget ("setCoordinates";New object:C1471("bottom";$1)));\ + "setVisible";Formula:C1597(OBJECT SET VISIBLE:C603(*;This:C1470.name;Bool:C1537($1)));\ + "show";Formula:C1597(OBJECT SET VISIBLE:C603(*;This:C1470.name;True:C214));\ + "visible";Formula:C1597(OBJECT Get visible:C1075(*;This:C1470.name));\ + "back";Formula:C1597(WA OPEN BACK URL:C1021(*;This:C1470.name));\ + "content";Formula:C1597(WA Get page content:C1038(*;This:C1470.name));\ + "forward";Formula:C1597(WA OPEN FORWARD URL:C1022(*;This:C1470.name));\ + "init";Formula:C1597(webArea ("init"));\ + "isLoaded";Formula:C1597(WA Get current URL:C1025(*;This:C1470.name)=This:C1470.url);\ + "lastFiltered";Formula:C1597(WA Get last filtered URL:C1035(*;This:C1470.name));\ + "openURL";Formula:C1597(webArea ("openURL";New object:C1471("url";$1)));\ + "refresh";Formula:C1597(webArea ("openURL";New object:C1471("url";$1)));\ + "setContent";Formula:C1597(webArea ("setContent";New object:C1471("content";String:C10($1);"base";$2)));\ + "title";Formula:C1597(WA Get page title:C1036(*;This:C1470.name))\ + ) + + If (Is Windows:C1573) + + $o.openURL() // previously load about:blank + + End if + +Else + + $o:=This:C1470 + + Case of + + //______________________________________________________ + : ($o=Null:C1517) + + ASSERT:C1129(False:C215;"OOPS, this method must be called from a member method") + + //______________________________________________________ + : ($1="init") + + ARRAY TEXT:C222($tTxt_filters;0x0000) + ARRAY BOOLEAN:C223($tBoo_allow;0x0000) + + // All are forbidden + APPEND TO ARRAY:C911($tTxt_filters;"*") // All + APPEND TO ARRAY:C911($tBoo_allow;False:C215) // Forbidden + + // Allow WA SET PAGE CONTENT + APPEND TO ARRAY:C911($tTxt_filters;"file*") + APPEND TO ARRAY:C911($tBoo_allow;True:C214) // to allow including HTML files + + WA SET URL FILTERS:C1030(*;$o.name;$tTxt_filters;$tBoo_allow) + + WA SET PREFERENCE:C1041(*;$o.name;WA enable Java applets:K62:3;False:C215) + WA SET PREFERENCE:C1041(*;$o.name;WA enable JavaScript:K62:4;True:C214) + WA SET PREFERENCE:C1041(*;$o.name;WA enable plugins:K62:5;False:C215) // + + // Active the contextual menu in debug mode + WA SET PREFERENCE:C1041(*;$o.name;WA enable contextual menu:K62:6;Not:C34(Is compiled mode:C492) | (Structure file:C489=Structure file:C489(*))) + WA SET PREFERENCE:C1041(*;$o.name;WA enable Web inspector:K62:7;True:C214) + + //______________________________________________________ + : ($1="openURL") + + If (Value type:C1509($2.url)=Is object:K8:27) // File + + $t:="file:///"+$2.url.path + + Else + + $t:=String:C10($2.url) + + End if + + Case of + + //…………………………………………………………………………………………………… + : (Length:C16($t)=0) + + $t:="about:blank" + + //…………………………………………………………………………………………………… + : ($t="internal") // Current database server + + $t:="127.0.0.1:"+String:C10(WEB Get server info:C1531.options.webPortID) + + //…………………………………………………………………………………………………… + : ($t="localhost")\ + & Is macOS:C1572 //#TURN_AROUND - In some cases, using "localhost" we get the error -30 "Server unreachable" + + $t:="127.0.0.1" + + //…………………………………………………………………………………………………… + End case + + $o.url:=$t + + WA OPEN URL:C1020(*;$o.name;$o.url) + + //______________________________________________________ + : ($1="setContent") + + WA SET PAGE CONTENT:C1037(*;$o.name;$2.content;Choose:C955($2.base=Null:C1517;"/";String:C10($2.base))) + + //______________________________________________________ + Else + + ASSERT:C1129(False:C215;"Unknown entry point: \""+$1+"\"") + + //______________________________________________________ + End case +End if + + // ---------------------------------------------------- + // Return +$0:=$o + + // ---------------------------------------------------- + // End \ No newline at end of file diff --git a/vendor/README.md b/vendor/README.md index d31f110530..1db05aa905 100644 --- a/vendor/README.md +++ b/vendor/README.md @@ -5,6 +5,7 @@ This is a list of grammars that Linguist selects to provide syntax highlighting - **1C Enterprise:** [xDrivenDevelopment/atom-language-1c-bsl](https://github.com/xDrivenDevelopment/atom-language-1c-bsl) +- **4D:** [ayoubserti/lang-4d](https://github.com/ayoubserti/lang-4d) - **ABAP:** [pvl/abap.tmbundle](https://github.com/pvl/abap.tmbundle) - **ABNF:** [Alhadis/language-grammars](https://github.com/Alhadis/language-grammars) - **AGS Script:** [textmate/c.tmbundle](https://github.com/textmate/c.tmbundle) diff --git a/vendor/grammars/lang-4d b/vendor/grammars/lang-4d new file mode 160000 index 0000000000..d2b0554044 --- /dev/null +++ b/vendor/grammars/lang-4d @@ -0,0 +1 @@ +Subproject commit d2b055404473f709db3c6175a41f31a6bf15a8f0 diff --git a/vendor/licenses/grammar/lang-4d.txt b/vendor/licenses/grammar/lang-4d.txt new file mode 100644 index 0000000000..40aeb9554c --- /dev/null +++ b/vendor/licenses/grammar/lang-4d.txt @@ -0,0 +1,27 @@ +--- +type: grammar +name: lang-4d +version: d2b055404473f709db3c6175a41f31a6bf15a8f0 +license: mit +--- +MIT License + +Copyright (c) 2019 Ayoub Serti + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. \ No newline at end of file