Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
Jolie: Improved tokenization (#3221)
- Loading branch information
1 parent
563cd73
commit dfbb202
Showing
9 changed files
with
355 additions
and
210 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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]*:)/ | ||
} | ||
}); |
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 |
---|---|---|
@@ -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"] | ||
] |
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,14 @@ | ||
// single line | ||
|
||
/* | ||
multiple | ||
lines | ||
*/ | ||
|
||
---------------------------------------------------- | ||
|
||
[ | ||
["comment", "// single line"], | ||
|
||
["comment", "/*\r\nmultiple\r\nlines\r\n*/"] | ||
] |
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
Oops, something went wrong.