Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for the Jolie language #1014

Merged
merged 9 commits into from
Nov 9, 2016
5 changes: 5 additions & 0 deletions components.js
Original file line number Diff line number Diff line change
Expand Up @@ -272,6 +272,11 @@ var components = {
"require": "clike",
"owner": "sherblot"
},
"jolie": {
"title": "jolie",
"require": "clike",
"owner": "thesave"
},
"json": {
"title": "JSON",
"owner": "CupOfTea696"
Expand Down
16 changes: 16 additions & 0 deletions components/prism-jolie.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
Prism.languages.jolie = Prism.languages.extend('java', {
'keyword': /(<-|=>)|\b(is_defined|undef|include|main|outputPort|inputPort|Location|Protocol|RequestResponse|throw|OneWay|interface|any|long|type|void|sequential|raw|scope|forward|install|execution|single|concurrent|Interfaces|cset|csets|double|global|linkIn|linkOut|string|bool|int|synchronized|courier|extender|throws|this|new|Interfaces|nullprocess|Redirects|embedded|extender|Aggregates|spawn|constants|with|foreach|instanceof|<-|over|define)\b/g,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the arrow <- near the end of the regexp was not intended to be there anymore.

'builtin': /\b(string|int|long|Byte|bool|double|float|char|any)\b/g,
'number': /\b0x[\da-f]*\.?[\da-f\-]+\b|\b\d*\.?\d+[e]?[\d]*[dfl]?\b/gi,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is no need for the square brackets around [e] or [\d]. This would be fine: e?\d*

'operator': /[-+]{1,2}|!|<=?|>=?|={1,3}|&{1,2}|\|\||\*|\//g,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are -+ and +- valid operators in Jolie? If not, you should write something like --?|\+\+? instead of [-+]{1,2}.

Also, you could make the regexp more clear by combining all single symbols into a character class : [!*\/]

'punctuation': /[{}[\]()\.:]/g,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The dot . does not need escaping inside a character class.

'operation': /[a-z][A-Za-z0-9_]+(?=\@)/gm,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The @ character does not need escaping in regexps in JS. (This comment applies to the regexp for 'services', below, too)

Also, why the m flag?

'service': {
pattern: /((?:(?:\@\s*)))[A-Z][A-Za-z0-9_]+/ig,
lookbehind: true,
},
'symbol': /\||;|\@/g,
Copy link
Contributor

@Golmote Golmote Aug 19, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here, a character class would make the regexp more clear, IMO: [|;@]

'string': /(""")[\W\w]*?\1|("|\/)[\W\w]*?\2|('.')/g
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Finally, could you add the non-capturing part ?: inside all parenthesized group that do not need capture? Like the last one in this regexp, and also in the words list in 'keyword' and 'builtin', at the top. ;)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The last pair of parentheses looks unneeded to me. There is nothing to group or capture here ;)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I still don't see any use for the last pair of parentheses. They should be removed.

});
delete Prism.languages.jolie['class-name'];
delete Prism.languages.jolie['function'];