From eb38c8dcf8236979945d02d8c72701baf4c675d4 Mon Sep 17 00:00:00 2001 From: thesave Date: Wed, 26 Apr 2017 20:04:25 +0200 Subject: [PATCH] [Add Language] Jolie (#3574) * added support for Jolie language * added support for Jolie language * added samples for Jolie --- .gitmodules | 3 + grammars.yml | 2 + lib/linguist/languages.yml | 11 +++ samples/Jolie/common.iol | 37 ++++++++++ samples/Jolie/exam.ol | 39 ++++++++++ samples/Jolie/examiner.ol | 26 +++++++ samples/Jolie/hanoi.ol | 84 ++++++++++++++++++++++ samples/Jolie/student.ol | 29 ++++++++ vendor/README.md | 6 +- vendor/grammars/language-jolie | 1 + vendor/licenses/grammar/language-jolie.txt | 26 +++++++ 11 files changed, 262 insertions(+), 2 deletions(-) create mode 100644 samples/Jolie/common.iol create mode 100644 samples/Jolie/exam.ol create mode 100644 samples/Jolie/examiner.ol create mode 100644 samples/Jolie/hanoi.ol create mode 100644 samples/Jolie/student.ol create mode 160000 vendor/grammars/language-jolie create mode 100644 vendor/licenses/grammar/language-jolie.txt diff --git a/.gitmodules b/.gitmodules index 49516335..0a35e63f 100644 --- a/.gitmodules +++ b/.gitmodules @@ -836,3 +836,6 @@ [submodule "vendor/grammars/marko-tmbundle"] path = vendor/grammars/marko-tmbundle url = https://github.com/marko-js/marko-tmbundle +[submodule "vendor/grammars/language-jolie"] + path = vendor/grammars/language-jolie + url = https://github.com/fmontesi/language-jolie diff --git a/grammars.yml b/grammars.yml index 6ce1c294..c57c10c0 100755 --- a/grammars.yml +++ b/grammars.yml @@ -410,6 +410,8 @@ vendor/grammars/language-jison: - source.jison - source.jisonlex - source.jisonlex-injection +vendor/grammars/language-jolie: +- source.jolie vendor/grammars/language-jsoniq: - source.jq - source.xq diff --git a/lib/linguist/languages.yml b/lib/linguist/languages.yml index de361310..707ca67e 100755 --- a/lib/linguist/languages.yml +++ b/lib/linguist/languages.yml @@ -2041,6 +2041,17 @@ Jison Lex: tm_scope: source.jisonlex ace_mode: text language_id: 406395330 +Jolie: + type: programming + extensions: + - ".ol" + - ".iol" + interpreters: + - jolie + color: "#843179" + ace_mode: text + tm_scope: source.jolie + language_id: 998078858 Julia: type: programming extensions: diff --git a/samples/Jolie/common.iol b/samples/Jolie/common.iol new file mode 100644 index 00000000..ca628c6c --- /dev/null +++ b/samples/Jolie/common.iol @@ -0,0 +1,37 @@ +include "types/Binding.iol" + +constants { + Location_Exam = "socket://localhost:8000" +} + +type StartExamRequest:void { + .examName:string + .studentName:string + .student:Binding +} + +type MakeQuestionRequest:void { + .question:string + .examName:string + .studentName:string +} + +type DecisionMessage:void { + .studentName:string + .examName:string +} + +interface ExamInterface { +OneWay: + startExam(StartExamRequest), + pass(DecisionMessage), fail(DecisionMessage) +RequestResponse: + makeQuestion(MakeQuestionRequest)(int) +} + +interface StudentInterface { +OneWay: + sendMessage(string) +RequestResponse: + makeQuestion(MakeQuestionRequest)(int) +} \ No newline at end of file diff --git a/samples/Jolie/exam.ol b/samples/Jolie/exam.ol new file mode 100644 index 00000000..f20ee942 --- /dev/null +++ b/samples/Jolie/exam.ol @@ -0,0 +1,39 @@ +include "common.iol" + +cset { +studentName: + StartExamRequest.studentName + DecisionMessage.studentName + MakeQuestionRequest.studentName, +examName: + StartExamRequest.examName + DecisionMessage.examName + MakeQuestionRequest.examName +} + +execution { concurrent } + +outputPort Student { +Interfaces: StudentInterface +} + +inputPort ExamInput { +Location: Location_Exam +Protocol: sodep +Interfaces: ExamInterface +} + +main +{ + startExam( examRequest ); + Student << examRequest.student; + makeQuestion( question )( answer ) { + makeQuestion@Student( question )( answer ) + }; + [ pass( message ) ] { + sendMessage@Student( "You passed!" ) + } + [ fail( message ) ] { + sendMessage@Student( "You failed!" ) + } +} \ No newline at end of file diff --git a/samples/Jolie/examiner.ol b/samples/Jolie/examiner.ol new file mode 100644 index 00000000..b94f92fb --- /dev/null +++ b/samples/Jolie/examiner.ol @@ -0,0 +1,26 @@ +include "common.iol" +include "ui/swing_ui.iol" +include "console.iol" + +outputPort Exam { +Location: Location_Exam +Protocol: sodep +Interfaces: ExamInterface +} + +main +{ + question.studentName = "John"; + question.examName = "SPLG"; + question.question = "Random question"; + makeQuestion@Exam( question )( answer ); + showYesNoQuestionDialog@SwingUI( "Do you want to accept answer " + answer + " ?" )( decision ); + + message.studentName = "John"; + message.examName = "SPLG"; + if ( decision == 0 ) { + pass@Exam( message ) + } else { + fail@Exam( message ) + } +} diff --git a/samples/Jolie/hanoi.ol b/samples/Jolie/hanoi.ol new file mode 100644 index 00000000..e79adb69 --- /dev/null +++ b/samples/Jolie/hanoi.ol @@ -0,0 +1,84 @@ +// https://github.com/jolie/website/blob/master/docs/documentation/locations/code/local.ol + +include "runtime.iol" +include "string_utils.iol" + +type HanoiRequest: void{ + .src: string + .aux: string + .dst: string + .n: int + .sid?: string +} + +type HanoiReponse: void { + .move?: string +} + +interface LocalOperations{ + RequestResponse: + hanoiSolver( HanoiRequest )( HanoiReponse ) +} + +interface ExternalOperations{ + RequestResponse: + hanoi( HanoiRequest )( string ) +} + +outputPort Self{ + Interfaces: LocalOperations +} + +inputPort Self { + Location: "local" + Interfaces: LocalOperations +} + +inputPort PowerService { + Location: "socket://localhost:8000" + Protocol: http{ + .format = "html" + } + Interfaces: ExternalOperations +} + +execution { concurrent } + +init +{ + getLocalLocation@Runtime()( Self.location ) +} + +main +{ + [ hanoi( request )( response ){ + getRandomUUID@StringUtils()(request.sid); + hanoiSolver@Self( request )( subRes ); + response = subRes.move + }]{ nullProcess } + + [ hanoiSolver( request )( response ){ + if ( request.n > 0 ){ + subReq.n = request.n; + subReq.n--; + with( request ){ + subReq.aux = .dst; + subReq.dst = .aux; + subReq.src = .src; + subReq.sid = .sid + }; + hanoiSolver@Self( subReq )( response ); + response.move += "
" + + ++global.counters.(request.sid) + + ") Move from " + request.src + + " to " + request.dst + ";"; + with ( request ){ + subReq.src = .aux; + subReq.aux = .src; + subReq.dst = .dst + }; + hanoiSolver@Self( subReq )( subRes ); + response.move += subRes.move + } + }]{ nullProcess } +} \ No newline at end of file diff --git a/samples/Jolie/student.ol b/samples/Jolie/student.ol new file mode 100644 index 00000000..e1097082 --- /dev/null +++ b/samples/Jolie/student.ol @@ -0,0 +1,29 @@ +include "common.iol" +include "ui/swing_ui.iol" +include "console.iol" + +outputPort Exam { +Location: Location_Exam +Protocol: sodep +Interfaces: ExamInterface +} + +inputPort StudentInput { +Location: "socket://localhost:8001/" +Protocol: sodep +Interfaces: StudentInterface +} + +main +{ + request.studentName = "John"; + request.examName = "SPLG"; + request.student.location = "socket://localhost:8001/"; + request.student.protocol = "sodep"; + startExam@Exam( request ); + makeQuestion( question )( answer ) { + showYesNoQuestionDialog@SwingUI( question.question )( answer ) + }; + sendMessage( message ); + println@Console( message )() +} \ No newline at end of file diff --git a/vendor/README.md b/vendor/README.md index 93e2cea7..c823e046 100644 --- a/vendor/README.md +++ b/vendor/README.md @@ -165,6 +165,8 @@ This is a list of grammars that Linguist selects to provide syntax highlighting - **Java Server Pages:** [textmate/java.tmbundle](https://github.com/textmate/java.tmbundle) - **JavaScript:** [atom/language-javascript](https://github.com/atom/language-javascript) - **JFlex:** [jflex-de/jflex.tmbundle](https://github.com/jflex-de/jflex.tmbundle) +- **Jison:** [cdibbs/language-jison](https://github.com/cdibbs/language-jison) +- **Jison Lex:** [cdibbs/language-jison](https://github.com/cdibbs/language-jison) - **JSON:** [textmate/json.tmbundle](https://github.com/textmate/json.tmbundle) - **JSON5:** [atom/language-javascript](https://github.com/atom/language-javascript) - **JSONiq:** [wcandillon/language-jsoniq](https://github.com/wcandillon/language-jsoniq) @@ -270,8 +272,8 @@ This is a list of grammars that Linguist selects to provide syntax highlighting - **Puppet:** [russCloak/SublimePuppet](https://github.com/russCloak/SublimePuppet) - **PureScript:** [purescript-contrib/atom-language-purescript](https://github.com/purescript-contrib/atom-language-purescript) - **Python:** [MagicStack/MagicPython](https://github.com/MagicStack/MagicPython) -- **Python console:** [atom/language-python](https://github.com/atom/language-python) -- **Python traceback:** [atom/language-python](https://github.com/atom/language-python) +- **Python console:** [MagicStack/MagicPython](https://github.com/MagicStack/MagicPython) +- **Python traceback:** [MagicStack/MagicPython](https://github.com/MagicStack/MagicPython) - **QMake:** [textmate/cpp-qt.tmbundle](https://github.com/textmate/cpp-qt.tmbundle) - **QML:** [skozlovf/Sublime-QML](https://github.com/skozlovf/Sublime-QML) - **R:** [textmate/r.tmbundle](https://github.com/textmate/r.tmbundle) diff --git a/vendor/grammars/language-jolie b/vendor/grammars/language-jolie new file mode 160000 index 00000000..c0415b5d --- /dev/null +++ b/vendor/grammars/language-jolie @@ -0,0 +1 @@ +Subproject commit c0415b5dac3c765f50b1f9344a581654493e3444 diff --git a/vendor/licenses/grammar/language-jolie.txt b/vendor/licenses/grammar/language-jolie.txt new file mode 100644 index 00000000..f2dd2567 --- /dev/null +++ b/vendor/licenses/grammar/language-jolie.txt @@ -0,0 +1,26 @@ +--- +type: grammar +name: language-jolie +license: mit +--- +The MIT License (MIT) + +Copyright (c) 2015 Fabrizio Montesi + +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.