-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add support for the Jolie language (#1014)
* Added component for the Jolie language * Added Jolie among the supported components * update for merge - revised jolie component - added tests - added code example - minified with `gulp` * fixes * fixes * fixed Jolie html file example and highlight for punctuation * fixed indentation in test html file and added comma as punctuation
- Loading branch information
Showing
11 changed files
with
473 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
Prism.languages.jolie = Prism.languages.extend('clike', { | ||
'keyword': /\b(?:include|define|is_defined|undef|main|init|outputPort|inputPort|Location|Protocol|Interfaces|RequestResponse|OneWay|type|interface|extender|throws|cset|csets|forward|Aggregates|Redirects|embedded|courier|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)\b/g, | ||
'builtin': /\b(?:undefined|string|int|void|long|Byte|bool|double|float|char|any)\b/, | ||
'number': /\b\d*\.?\d+(?:e[+-]?\d+)?l?\b/i, | ||
'operator': /->|<<|[!+-<>=*]?=|[:<>!?*\/%^]|&&|\|\||--?|\+\+?/g, | ||
'symbol': /[|;@]/, | ||
'punctuation': /[,.]/, | ||
'string': { | ||
pattern: /(["'])(\\(?:\r\n|[\s\S])|(?!\1)[^\\\r\n])*\1/, | ||
greedy: true | ||
}, | ||
}); | ||
|
||
delete Prism.languages.jolie['class-name']; | ||
delete Prism.languages.jolie['function']; | ||
|
||
Prism.languages.insertBefore( 'jolie', 'keyword', { | ||
'function': | ||
{ | ||
pattern: /((?:\b(?:outputPort|inputPort|in|service|courier)\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: { | ||
'withExtension': { | ||
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: true, | ||
inside: { | ||
'punctuation': { | ||
pattern: /,/ | ||
}, | ||
'function': { | ||
pattern: /\w+/g | ||
}, | ||
'symbol': { | ||
pattern: /=>/g | ||
} | ||
} | ||
} | ||
}); |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,165 @@ | ||
<h1>Jolie</h1> | ||
<p>To use this language, use the class "language-jolie".</p> | ||
|
||
<h2>Comments</h2> | ||
<pre><code>// Single line comment | ||
/* Multi-line | ||
comment */</code></pre> | ||
|
||
<h2>Strings</h2> | ||
<pre><code>"foo \"bar\" baz"; | ||
'foo \'bar\' baz'</code></pre> | ||
|
||
<h2>Numbers</h2> | ||
<pre><code>42 | ||
42L | ||
1.2e3 | ||
0.1E-4 | ||
0.2e+1 | ||
</code></pre> | ||
|
||
<h2>Full example</h2> | ||
<pre><code>include "console.iol" | ||
|
||
type HubType: void { | ||
.sid: undefined | ||
.nodes[1,*] : NodeType | ||
} | ||
|
||
type NodeType: void { | ||
.sid: string | ||
.node: string | ||
.load?: int | ||
} | ||
|
||
type NetType: HubType | NodeType | ||
|
||
interface NetInterface { | ||
OneWay: start( string ), addElement( NetType ), removeElement( NetType ), quit( void ) | ||
RequestResponse: showElements( void )( NetType ) throws SomeFault | ||
} | ||
|
||
type LogType: void { | ||
.message: string | ||
} | ||
|
||
interface LoggerInterface { | ||
RequestResponse: log( LogType )( void ) | ||
} | ||
|
||
outputPort LoggerService { | ||
Interfaces: LoggerInterface | ||
} | ||
|
||
embedded { | ||
Jolie: "logger.ol" in LoggerService | ||
} | ||
|
||
type AuthenticationData: void { | ||
.key:string | ||
} | ||
|
||
interface extender AuthInterfaceExtender { | ||
OneWay: *(AuthenticationData) | ||
} | ||
|
||
service SubService | ||
{ | ||
Interfaces: NetInterface | ||
|
||
main | ||
{ | ||
println@Console( "I do nothing" )() | ||
} | ||
} | ||
|
||
inputPort ExtLogger { | ||
Location: "socket://localhost:9000" | ||
Protocol: sodep | ||
Interfaces: LoggerInterface | ||
Aggregates: LoggerService with AuthInterfaceExtender | ||
} | ||
|
||
courier ExtLogger { | ||
[interface LoggerInterface( request )] { | ||
if ( key == "secret" ){ | ||
forward ( request ) | ||
} | ||
} | ||
} | ||
|
||
inputPort In { | ||
Location: "socket://localhost:8000" | ||
Protocol: http { | ||
.debug = true; | ||
.debug.showContent = true | ||
} | ||
Interfaces: NetInterface | ||
Aggregates: SubService, | ||
LoggerService | ||
Redirects: A => SubService, | ||
B => SubService | ||
} | ||
|
||
cset { | ||
sid: HubType.sid NodeType.sid | ||
} | ||
|
||
execution{ concurrent } | ||
|
||
define netmodule { | ||
if( request.load == 0 || request.load < 1 && | ||
request.load <= 2 || request.load >= 3 && | ||
request.load > 4 || request.load%4 == 2 | ||
) { | ||
scope( scopeName ) { | ||
// inline comment | ||
install( MyFault => println@Console( "Something \"Went\" Wrong" + ' but it\'s ok' )() ); | ||
/* | ||
* Multi-line | ||
* Comment | ||
*/ | ||
install( this => cH; println@Console( "Something went wrong: " + ^load )() ); | ||
install( default => comp( scopeName ); println@Console( "Something went wrong" )() ); | ||
load -> request.( "load" ); | ||
{ ++load | load++ | --load | load-- }; | ||
throw( MyFault ) | ||
} | ||
} else { | ||
foreach ( node -> request.nodes ) { | ||
with( node ){ | ||
while( .load != 100 ) { | ||
.load++ | ||
} | ||
} | ||
} | ||
} | ||
} | ||
|
||
main | ||
{ | ||
start( sid ); | ||
synchronized( unneededSync ){ | ||
csets.sid = sid; | ||
undef( sid ) | ||
}; | ||
provide | ||
[ addElement( request ) ]{ | ||
if( request instanceof NodeType ) { | ||
netmodule | ||
} | ||
} | ||
[ removeElement() ] | ||
[ showElements()( response ){ | ||
/* | ||
* assemble response | ||
*/ | ||
nullProcess | ||
}]{ | ||
// log the request | ||
log@LoggerService( new )(); | ||
log @ LoggerService( new )() | ||
} | ||
until | ||
[ quit() ]{ exit } | ||
}</code></pre> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
Aggregates: First, Second with Third | ||
Redirects: First => Second, Third => Fourth | ||
Jolie: "logger.ol" in LoggerService | ||
log@LoggerService( new )(); | ||
println @ Console( "none" )() | ||
---------------------------------------------------- | ||
[ | ||
[ "keyword", "Aggregates" ], | ||
[ "operator", ":" ], | ||
[ "aggregates", [ | ||
[ "function", "First" ], [ "punctuation", ","], | ||
[ "function", "Second" ], | ||
[ "withExtension", [ | ||
[ "keyword", "with" ], " Third" ] | ||
] | ||
] | ||
], | ||
[ "keyword", "Redirects" ], | ||
[ "operator", ":" ], | ||
[ "redirects", | ||
[ | ||
[ "function", "First" ], | ||
[ "symbol", "=>" ], | ||
[ "function", "Second" ], [ "punctuation", ","], | ||
[ "function", "Third" ], | ||
[ "symbol", "=>" ], | ||
[ "function", "Fourth" ] | ||
] | ||
], | ||
[ "keyword", "Jolie" ], | ||
[ "operator", ":" ], | ||
[ "string", "\"logger.ol\"" ], | ||
[ "keyword", "in" ], | ||
[ "function", "LoggerService" ], | ||
"\nlog", [ "symbol", "@" ], [ "function", "LoggerService" ], | ||
"( ", [ "keyword", "new" ], " )()", [ "symbol", ";" ], | ||
"\nprintln ", [ "symbol", "@" ], [ "function", "Console" ], | ||
"( ", [ "string", "\"none\"" ], " )()" | ||
] | ||
|
||
---------------------------------------------------- | ||
|
||
Checks for outputPorts and Aggregates and Redirect constructs. |
Oops, something went wrong.