diff --git a/components/prism-jolie.js b/components/prism-jolie.js index d8f784f675..6b54f86472 100644 --- a/components/prism-jolie.js +++ b/components/prism-jolie.js @@ -1,55 +1,41 @@ Prism.languages.jolie = Prism.languages.extend('clike', { 'string': { - pattern: /(["'])(?:\\(?:\r\n|[\s\S])|(?!\1)[^\\\r\n])*\1/, + pattern: /(^|[^\\])"(?:\\[\s\S]|[^"\\])*"/, + lookbehind: true, greedy: true }, - 'keyword': /\b(?:Aggregates|Interfaces|Java|Javascript|Jolie|Location|OneWay|Protocol|Redirects|RequestResponse|cH|comp|concurrent|constants|courier|cset|csets|default|define|else|embedded|execution|exit|extender|for|foreach|forward|global|if|in|include|init|inputPort|install|instanceof|interface|is_defined|linkIn|linkOut|main|new|nullProcess|outputPort|over|provide|scope|sequential|service|single|spawn|synchronized|this|throw|throws|type|undef|until|while|with)\b/, + 'class-name': { + pattern: /((?:\b(?:as|courier|embed|in|inputPort|outputPort|service)\b|@)[ \t]*)\w+/, + lookbehind: true + }, + 'keyword': /\b(?:as|cH|comp|concurrent|constants|courier|cset|csets|default|define|else|embed|embedded|execution|exit|extender|for|foreach|forward|from|global|if|import|in|include|init|inputPort|install|instanceof|interface|is_defined|linkIn|linkOut|main|new|nullProcess|outputPort|over|private|provide|public|scope|sequential|service|single|spawn|synchronized|this|throw|throws|type|undef|until|while|with)\b/, + 'function': /\b[a-z_]\w*(?=[ \t]*[@(])/i, 'number': /(?:\b\d+(?:\.\d*)?|\B\.\d+)(?:e[+-]?\d+)?l?/i, - 'operator': /-[-=>]?|\+[+=]?|<[<=]?|[>=*!]=?|&&|\|\||[:?\/%^]/, - 'punctuation': /[,.]/, - 'builtin': /\b(?:Byte|any|bool|char|double|float|int|long|string|undefined|void)\b/, - 'symbol': /[|;@]/ + 'operator': /-[-=>]?|\+[+=]?|<[<=]?|[>=*!]=?|&&|\|\||[?\/%^@|]/, + 'punctuation': /[()[\]{},;.:]/, + 'builtin': /\b(?:Byte|any|bool|char|double|enum|float|int|length|long|ranges|regex|string|undefined|void)\b/ }); -delete Prism.languages.jolie['class-name']; - Prism.languages.insertBefore('jolie', 'keyword', { - 'function': - { - pattern: /((?:\b(?:courier|in|inputPort|outputPort|service)\b|@)\s*)\w+/, - lookbehind: true - }, 'aggregates': { pattern: /(\bAggregates\s*:\s*)(?:\w+(?:\s+with\s+\w+)?\s*,\s*)*\w+(?:\s+with\s+\w+)?/, lookbehind: true, inside: { - 'with-extension': { - pattern: /\bwith\s+\w+/, - inside: { - 'keyword': /\bwith\b/ - } - }, - 'function': { - pattern: /\w+/ - }, - 'punctuation': { - pattern: /,/ - } + 'keyword': /\bwith\b/, + 'class-name': /\w+/, + 'punctuation': /,/ } }, 'redirects': { pattern: /(\bRedirects\s*:\s*)(?:\w+\s*=>\s*\w+\s*,\s*)*(?:\w+\s*=>\s*\w+)/, lookbehind: true, inside: { - 'punctuation': { - pattern: /,/ - }, - 'function': { - pattern: /\w+/ - }, - 'symbol': { - pattern: /=>/ - } + 'punctuation': /,/, + 'class-name': /\w+/, + 'operator': /=>/ } + }, + 'property': { + pattern: /\b(?:Aggregates|[Ii]nterfaces|Java|Javascript|Jolie|[Ll]ocation|OneWay|[Pp]rotocol|Redirects|RequestResponse)\b(?=[ \t]*:)/ } }); diff --git a/components/prism-jolie.min.js b/components/prism-jolie.min.js index b5750aba64..1ee8f0f3df 100644 --- a/components/prism-jolie.min.js +++ b/components/prism-jolie.min.js @@ -1 +1 @@ -Prism.languages.jolie=Prism.languages.extend("clike",{string:{pattern:/(["'])(?:\\(?:\r\n|[\s\S])|(?!\1)[^\\\r\n])*\1/,greedy:!0},keyword:/\b(?:Aggregates|Interfaces|Java|Javascript|Jolie|Location|OneWay|Protocol|Redirects|RequestResponse|cH|comp|concurrent|constants|courier|cset|csets|default|define|else|embedded|execution|exit|extender|for|foreach|forward|global|if|in|include|init|inputPort|install|instanceof|interface|is_defined|linkIn|linkOut|main|new|nullProcess|outputPort|over|provide|scope|sequential|service|single|spawn|synchronized|this|throw|throws|type|undef|until|while|with)\b/,number:/(?:\b\d+(?:\.\d*)?|\B\.\d+)(?:e[+-]?\d+)?l?/i,operator:/-[-=>]?|\+[+=]?|<[<=]?|[>=*!]=?|&&|\|\||[:?\/%^]/,punctuation:/[,.]/,builtin:/\b(?:Byte|any|bool|char|double|float|int|long|string|undefined|void)\b/,symbol:/[|;@]/}),delete Prism.languages.jolie["class-name"],Prism.languages.insertBefore("jolie","keyword",{function:{pattern:/((?:\b(?:courier|in|inputPort|outputPort|service)\b|@)\s*)\w+/,lookbehind:!0},aggregates:{pattern:/(\bAggregates\s*:\s*)(?:\w+(?:\s+with\s+\w+)?\s*,\s*)*\w+(?:\s+with\s+\w+)?/,lookbehind:!0,inside:{"with-extension":{pattern:/\bwith\s+\w+/,inside:{keyword:/\bwith\b/}},function:{pattern:/\w+/},punctuation:{pattern:/,/}}},redirects:{pattern:/(\bRedirects\s*:\s*)(?:\w+\s*=>\s*\w+\s*,\s*)*(?:\w+\s*=>\s*\w+)/,lookbehind:!0,inside:{punctuation:{pattern:/,/},function:{pattern:/\w+/},symbol:{pattern:/=>/}}}}); \ No newline at end of file +Prism.languages.jolie=Prism.languages.extend("clike",{string:{pattern:/(^|[^\\])"(?:\\[\s\S]|[^"\\])*"/,lookbehind:!0,greedy:!0},"class-name":{pattern:/((?:\b(?:as|courier|embed|in|inputPort|outputPort|service)\b|@)[ \t]*)\w+/,lookbehind:!0},keyword:/\b(?:as|cH|comp|concurrent|constants|courier|cset|csets|default|define|else|embed|embedded|execution|exit|extender|for|foreach|forward|from|global|if|import|in|include|init|inputPort|install|instanceof|interface|is_defined|linkIn|linkOut|main|new|nullProcess|outputPort|over|private|provide|public|scope|sequential|service|single|spawn|synchronized|this|throw|throws|type|undef|until|while|with)\b/,function:/\b[a-z_]\w*(?=[ \t]*[@(])/i,number:/(?:\b\d+(?:\.\d*)?|\B\.\d+)(?:e[+-]?\d+)?l?/i,operator:/-[-=>]?|\+[+=]?|<[<=]?|[>=*!]=?|&&|\|\||[?\/%^@|]/,punctuation:/[()[\]{},;.:]/,builtin:/\b(?:Byte|any|bool|char|double|enum|float|int|length|long|ranges|regex|string|undefined|void)\b/}),Prism.languages.insertBefore("jolie","keyword",{aggregates:{pattern:/(\bAggregates\s*:\s*)(?:\w+(?:\s+with\s+\w+)?\s*,\s*)*\w+(?:\s+with\s+\w+)?/,lookbehind:!0,inside:{keyword:/\bwith\b/,"class-name":/\w+/,punctuation:/,/}},redirects:{pattern:/(\bRedirects\s*:\s*)(?:\w+\s*=>\s*\w+\s*,\s*)*(?:\w+\s*=>\s*\w+)/,lookbehind:!0,inside:{punctuation:/,/,"class-name":/\w+/,operator:/=>/}},property:{pattern:/\b(?:Aggregates|[Ii]nterfaces|Java|Javascript|Jolie|[Ll]ocation|OneWay|[Pp]rotocol|Redirects|RequestResponse)\b(?=[ \t]*:)/}}); \ No newline at end of file diff --git a/tests/languages/jolie/builtin_feature.test b/tests/languages/jolie/builtin_feature.test index 3571e81a8c..e76e16fbde 100644 --- a/tests/languages/jolie/builtin_feature.test +++ b/tests/languages/jolie/builtin_feature.test @@ -1,27 +1,35 @@ -undefined -string -int -void -long Byte +any bool +char double +enum float -char -any +int +length +long +ranges +regex +string +undefined +void ---------------------------------------------------- [ - ["builtin", "undefined"], - ["builtin", "string"], - ["builtin", "int"], - ["builtin", "void"], - ["builtin", "long"], ["builtin", "Byte"], + ["builtin", "any"], ["builtin", "bool"], + ["builtin", "char"], ["builtin", "double"], + ["builtin", "enum"], ["builtin", "float"], - ["builtin", "char"], - ["builtin", "any"] + ["builtin", "int"], + ["builtin", "length"], + ["builtin", "long"], + ["builtin", "ranges"], + ["builtin", "regex"], + ["builtin", "string"], + ["builtin", "undefined"], + ["builtin", "void"] ] diff --git a/tests/languages/jolie/comment_feature.test b/tests/languages/jolie/comment_feature.test new file mode 100644 index 0000000000..90816a5b11 --- /dev/null +++ b/tests/languages/jolie/comment_feature.test @@ -0,0 +1,14 @@ +// single line + +/* +multiple +lines +*/ + +---------------------------------------------------- + +[ + ["comment", "// single line"], + + ["comment", "/*\r\nmultiple\r\nlines\r\n*/"] +] diff --git a/tests/languages/jolie/deployment_features.test b/tests/languages/jolie/deployment_features.test index 7400ccba78..52e8f5122b 100644 --- a/tests/languages/jolie/deployment_features.test +++ b/tests/languages/jolie/deployment_features.test @@ -1,56 +1,152 @@ Aggregates: First, Second with Third + Redirects: First => Second, Third => Fourth + Jolie: "logger.ol" in LoggerService + log@LoggerService( new )(); println @ Console( "none" )() +outputPort OutputPort3 { + location: "socket://localhost:9002/" + protocol: sodep + interfaces: Interface3 +} + +interface MyInterface { +OneWay: + myOW( string ) +RequestResponse: + myRR( string )( string ) +} + +private service MainService { + embed ConfigurationService( ) as Conf + main { + getDBConn@Conf( )( res ) + } +} + ---------------------------------------------------- [ - ["keyword", "Aggregates"], - ["operator", ":"], + ["property", "Aggregates"], + ["punctuation", ":"], ["aggregates", [ - ["function", "First"], + ["class-name", "First"], ["punctuation", ","], - ["function", "Second"], - ["with-extension", [ - ["keyword", "with"], - " Third" - ]] + ["class-name", "Second"], + ["keyword", "with"], + ["class-name", "Third"] ]], - ["keyword", "Redirects"], - ["operator", ":"], + ["property", "Redirects"], + ["punctuation", ":"], ["redirects", [ - ["function", "First"], - ["symbol", "=>"], - ["function", "Second"], + ["class-name", "First"], + ["operator", "=>"], + ["class-name", "Second"], ["punctuation", ","], - ["function", "Third"], - ["symbol", "=>"], - ["function", "Fourth"] + ["class-name", "Third"], + ["operator", "=>"], + ["class-name", "Fourth"] ]], - ["keyword", "Jolie"], - ["operator", ":"], + ["property", "Jolie"], + ["punctuation", ":"], ["string", "\"logger.ol\""], ["keyword", "in"], - ["function", "LoggerService"], + ["class-name", "LoggerService"], - "\r\nlog", - ["symbol", "@"], - ["function", "LoggerService"], - "( ", + ["function", "log"], + ["operator", "@"], + ["class-name", "LoggerService"], + ["punctuation", "("], ["keyword", "new"], - " )()", - ["symbol", ";"], + ["punctuation", ")"], + ["punctuation", "("], + ["punctuation", ")"], + ["punctuation", ";"], - "\r\nprintln ", - ["symbol", "@"], - ["function", "Console"], - "( ", + ["function", "println"], + ["operator", "@"], + ["class-name", "Console"], + ["punctuation", "("], ["string", "\"none\""], - " )()" + ["punctuation", ")"], + ["punctuation", "("], + ["punctuation", ")"], + + ["keyword", "outputPort"], + ["class-name", "OutputPort3"], + ["punctuation", "{"], + + ["property", "location"], + ["punctuation", ":"], + ["string", "\"socket://localhost:9002/\""], + + ["property", "protocol"], + ["punctuation", ":"], + " sodep\r\n ", + + ["property", "interfaces"], + ["punctuation", ":"], + " Interface3\r\n", + + ["punctuation", "}"], + + ["keyword", "interface"], + " MyInterface ", + ["punctuation", "{"], + + ["property", "OneWay"], + ["punctuation", ":"], + + ["function", "myOW"], + ["punctuation", "("], + ["builtin", "string"], + ["punctuation", ")"], + + ["property", "RequestResponse"], + ["punctuation", ":"], + + ["function", "myRR"], + ["punctuation", "("], + ["builtin", "string"], + ["punctuation", ")"], + ["punctuation", "("], + ["builtin", "string"], + ["punctuation", ")"], + + ["punctuation", "}"], + + ["keyword", "private"], + ["keyword", "service"], + ["class-name", "MainService"], + ["punctuation", "{"], + + ["keyword", "embed"], + ["class-name", "ConfigurationService"], + ["punctuation", "("], + ["punctuation", ")"], + ["keyword", "as"], + ["class-name", "Conf"], + + ["keyword", "main"], + ["punctuation", "{"], + + ["function", "getDBConn"], + ["operator", "@"], + ["class-name", "Conf"], + ["punctuation", "("], + ["punctuation", ")"], + ["punctuation", "("], + " res ", + ["punctuation", ")"], + + ["punctuation", "}"], + + ["punctuation", "}"] ] ---------------------------------------------------- diff --git a/tests/languages/jolie/keyword_feature.test b/tests/languages/jolie/keyword_feature.test index 9f04596221..b6b5fac9fb 100644 --- a/tests/languages/jolie/keyword_feature.test +++ b/tests/languages/jolie/keyword_feature.test @@ -1,130 +1,117 @@ -include -define -is_defined -undef -main -init -outputPort ; -inputPort ; -Location -Protocol -Interfaces -RequestResponse -OneWay -type -interface -extender -throws -cset -csets -forward -courier ; -Aggregates -Redirects -embedded -extender -execution -sequential -concurrent -single -scope -install -throw -comp -cH -default -global -linkIn -linkOut -synchronized -this -new -for -if -else -while -in ; -Jolie -Java -Javascript -nullProcess -spawn -constants -with -provide -until -exit -foreach -instanceof -over -service +as; +cH; +comp; +concurrent; +constants; +courier; +cset; +csets; +default; +define; +else; +embed; +embedded; +execution; +exit; +extender; +for; +foreach; +forward; +from; +global; +if; +import; +in; +include; +init; +inputPort; +install; +instanceof; +interface; +is_defined; +linkIn; +linkOut; +main; +new; +nullProcess; +outputPort; +over; +private; +provide; +public; +scope; +sequential; +service; +single; +spawn; +synchronized; +this; +throw; +throws; +type; +undef; +until; +while; +with; ---------------------------------------------------- + [ - ["keyword", "include"], - ["keyword", "define"], - ["keyword", "is_defined"], - ["keyword", "undef"], - ["keyword", "main"], - ["keyword", "init"], - ["keyword", "outputPort"], - ["symbol", ";"], - ["keyword", "inputPort"], - ["symbol", ";"], - ["keyword", "Location"], - ["keyword", "Protocol"], - ["keyword", "Interfaces"], - ["keyword", "RequestResponse"], - ["keyword", "OneWay"], - ["keyword", "type"], - ["keyword", "interface"], - ["keyword", "extender"], - ["keyword", "throws"], - ["keyword", "cset"], - ["keyword", "csets"], - ["keyword", "forward"], - ["keyword", "courier"], - ["symbol", ";"], - ["keyword", "Aggregates"], - ["keyword", "Redirects"], - ["keyword", "embedded"], - ["keyword", "extender"], - ["keyword", "execution"], - ["keyword", "sequential"], - ["keyword", "concurrent"], - ["keyword", "single"], - ["keyword", "scope"], - ["keyword", "install"], - ["keyword", "throw"], - ["keyword", "comp"], - ["keyword", "cH"], - ["keyword", "default"], - ["keyword", "global"], - ["keyword", "linkIn"], - ["keyword", "linkOut"], - ["keyword", "synchronized"], - ["keyword", "this"], - ["keyword", "new"], - ["keyword", "for"], - ["keyword", "if"], - ["keyword", "else"], - ["keyword", "while"], - ["keyword", "in"], - ["symbol", ";"], - ["keyword", "Jolie"], - ["keyword", "Java"], - ["keyword", "Javascript"], - ["keyword", "nullProcess"], - ["keyword", "spawn"], - ["keyword", "constants"], - ["keyword", "with"], - ["keyword", "provide"], - ["keyword", "until"], - ["keyword", "exit"], - ["keyword", "foreach"], - ["keyword", "instanceof"], - ["keyword", "over"], - ["keyword", "service"] + ["keyword", "as"], ["punctuation", ";"], + ["keyword", "cH"], ["punctuation", ";"], + ["keyword", "comp"], ["punctuation", ";"], + ["keyword", "concurrent"], ["punctuation", ";"], + ["keyword", "constants"], ["punctuation", ";"], + ["keyword", "courier"], ["punctuation", ";"], + ["keyword", "cset"], ["punctuation", ";"], + ["keyword", "csets"], ["punctuation", ";"], + ["keyword", "default"], ["punctuation", ";"], + ["keyword", "define"], ["punctuation", ";"], + ["keyword", "else"], ["punctuation", ";"], + ["keyword", "embed"], ["punctuation", ";"], + ["keyword", "embedded"], ["punctuation", ";"], + ["keyword", "execution"], ["punctuation", ";"], + ["keyword", "exit"], ["punctuation", ";"], + ["keyword", "extender"], ["punctuation", ";"], + ["keyword", "for"], ["punctuation", ";"], + ["keyword", "foreach"], ["punctuation", ";"], + ["keyword", "forward"], ["punctuation", ";"], + ["keyword", "from"], ["punctuation", ";"], + ["keyword", "global"], ["punctuation", ";"], + ["keyword", "if"], ["punctuation", ";"], + ["keyword", "import"], ["punctuation", ";"], + ["keyword", "in"], ["punctuation", ";"], + ["keyword", "include"], ["punctuation", ";"], + ["keyword", "init"], ["punctuation", ";"], + ["keyword", "inputPort"], ["punctuation", ";"], + ["keyword", "install"], ["punctuation", ";"], + ["keyword", "instanceof"], ["punctuation", ";"], + ["keyword", "interface"], ["punctuation", ";"], + ["keyword", "is_defined"], ["punctuation", ";"], + ["keyword", "linkIn"], ["punctuation", ";"], + ["keyword", "linkOut"], ["punctuation", ";"], + ["keyword", "main"], ["punctuation", ";"], + ["keyword", "new"], ["punctuation", ";"], + ["keyword", "nullProcess"], ["punctuation", ";"], + ["keyword", "outputPort"], ["punctuation", ";"], + ["keyword", "over"], ["punctuation", ";"], + ["keyword", "private"], ["punctuation", ";"], + ["keyword", "provide"], ["punctuation", ";"], + ["keyword", "public"], ["punctuation", ";"], + ["keyword", "scope"], ["punctuation", ";"], + ["keyword", "sequential"], ["punctuation", ";"], + ["keyword", "service"], ["punctuation", ";"], + ["keyword", "single"], ["punctuation", ";"], + ["keyword", "spawn"], ["punctuation", ";"], + ["keyword", "synchronized"], ["punctuation", ";"], + ["keyword", "this"], ["punctuation", ";"], + ["keyword", "throw"], ["punctuation", ";"], + ["keyword", "throws"], ["punctuation", ";"], + ["keyword", "type"], ["punctuation", ";"], + ["keyword", "undef"], ["punctuation", ";"], + ["keyword", "until"], ["punctuation", ";"], + ["keyword", "while"], ["punctuation", ";"], + ["keyword", "with"], ["punctuation", ";"] ] ---------------------------------------------------- diff --git a/tests/languages/jolie/operator_feature.test b/tests/languages/jolie/operator_feature.test index 7e329b027b..3789605d0b 100644 --- a/tests/languages/jolie/operator_feature.test +++ b/tests/languages/jolie/operator_feature.test @@ -4,7 +4,7 @@ < <= > >= -> << = == && -? * / % ; : | @ +? * / % | @ ---------------------------------------------------- @@ -12,28 +12,32 @@ ["operator", "+"], ["operator", "++"], ["operator", "+="], + ["operator", "-"], ["operator", "--"], ["operator", "-="], + ["operator", "!"], ["operator", "!="], + ["operator", "<"], ["operator", "<="], ["operator", ">"], ["operator", ">="], ["operator", "->"], ["operator", "<<"], + ["operator", "="], ["operator", "=="], + ["operator", "&&"], + ["operator", "?"], ["operator", "*"], ["operator", "/"], ["operator", "%"], - ["symbol", ";"], - ["operator", ":"], - ["symbol", "|"], - ["symbol", "@"] + ["operator", "|"], + ["operator", "@"] ] ---------------------------------------------------- diff --git a/tests/languages/jolie/punctuation_feature.test b/tests/languages/jolie/punctuation_feature.test index 4d0041ea5d..1713f5143c 100644 --- a/tests/languages/jolie/punctuation_feature.test +++ b/tests/languages/jolie/punctuation_feature.test @@ -1,8 +1,18 @@ -, . +( ) [ ] { } +, ; . : ---------------------------------------------------- [ + ["punctuation", "("], + ["punctuation", ")"], + ["punctuation", "["], + ["punctuation", "]"], + ["punctuation", "{"], + ["punctuation", "}"], + ["punctuation", ","], - ["punctuation", "."] + ["punctuation", ";"], + ["punctuation", "."], + ["punctuation", ":"] ] diff --git a/tests/languages/jolie/string_feature.test b/tests/languages/jolie/string_feature.test new file mode 100644 index 0000000000..f84281043b --- /dev/null +++ b/tests/languages/jolie/string_feature.test @@ -0,0 +1,40 @@ +"" +"10" +" +JOLIE preserves formatting. + This line will be indented. + This line too. +" + +jsonValue = "{ + \"int\": 123, + \"bool\": true, + \"long\": 124, + \"double\": 123.4, + \"string\": \"string\", + \"void\": {}, + \"array\": [123, true,\"ciccio\",124,{}], + \"obj\" : { + \"int\": 1243, + \"bool\": true, + \"long\": 1234, + \"double\": 1234.4, + \"string\": \"string\", + \"void\": {} + } + }" +; + +---------------------------------------------------- + +[ + ["string", "\"\""], + ["string", "\"10\""], + ["string", "\"\r\nJOLIE preserves formatting.\r\n This line will be indented.\r\n This line too.\r\n\""], + + "\r\n\r\njsonValue ", + ["operator", "="], + ["string", "\"{\r\n \\\"int\\\": 123,\r\n \\\"bool\\\": true,\r\n \\\"long\\\": 124,\r\n \\\"double\\\": 123.4,\r\n \\\"string\\\": \\\"string\\\",\r\n \\\"void\\\": {},\r\n \\\"array\\\": [123, true,\\\"ciccio\\\",124,{}],\r\n \\\"obj\\\" : {\r\n \\\"int\\\": 1243,\r\n \\\"bool\\\": true,\r\n \\\"long\\\": 1234,\r\n \\\"double\\\": 1234.4,\r\n \\\"string\\\": \\\"string\\\",\r\n \\\"void\\\": {}\r\n }\r\n }\""], + + ["punctuation", ";"] +]