-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Conversation
@@ -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, |
There was a problem hiding this comment.
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.
Thanks for contributing. Please take a look at the few comments I made on the code. Also, it would be truly awesome if you could:
|
'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, | ||
'operator': /[-+]{1,2}|!|<=?|>=?|={1,3}|&{1,2}|\|\||\*|\//g, | ||
'punctuation': /[{}[\]()\.:]/g, |
There was a problem hiding this comment.
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.
- revised jolie component - added tests - added code example - minified with `gulp`
Hi, thanks for the very useful comments :) |
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(?:\b\d*\.?\d*(e[+-]?\d*)?[l]?)\b/i, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is not need for the square brackets around [l]
. Also, the second \b
seems redundant to me. Finally, it looks like your regexp may match nothing at all, since everything is optional. Please replace one of the two first \d*
occurrences with \d+
. I also suspect this part e[+-]?\d*
should be e[+-]?\d+
since numbers after the exponent symbol are usually not optional.
I reviewed your additions and made a bunch of comments about them. Please take a look when you can. Those additions would also need test files ;) |
Hi, thank you very much for your review, I really appreciate it :) |
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, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The outer parentheses are not needed here. And the inner ones should be made non-capturing.
/\b\d*\.?\d+(?:e[+-]?\d+)?l?\b/i
lookbehind: true | ||
}, | ||
'aggregates': { | ||
pattern: /(\bAggregates\s*:\s*)(?:\w+(\s+with\s+\w+)?\s*,\s*)*\w+(?:\s+with\s+\w+)?/, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is still a group here (\s+with\s+\w+)?
that should be made non-capturing.
Great! Almost there! |
* PrismJS/gh-pages: Autoloader plugin: don't try to load "none" component. Fix PrismJS#1000 Optimized block regexps to prevent struggling on large files. Fixes PrismJS#1001 Revert PrismJS#998 + run normalize-whitespace and remove-initial-line-feed plugins in the before-sanity-check hook. Fix PrismJS#1018 (see issue for discussion) Run gulp # Conflicts: # plugins/autoloader/prism-autoloader.min.js
Did the required fixes. |
The code looks quite good to me now. I pulled your branch to test it a bit, and I noticed your examples for strings and numbers aren't exactly working well, though. Most of those cases don't appear to be handled by the current regexps. Either we need to handle them or they should not appear in the examples. Can you take a look? Also, in the full example, I'm curious about the color of the parentheses and commas. They probably should go inside the |
* PrismJS/gh-pages: update patterns (PrismJS#1032) Test suite: fixed missing diff in error message Reverse prism markup min JSON: Fixed issues with properties and strings + added tests. Fix PrismJS#1025 Fix grammar in Readme Update CHANGELOG Update APL minified file + update test for iota underbar function Add iota underbar (PrismJS#1024) Fix typo `Fload` to `Float` in prism-ruby.js (PrismJS#1023) update min file and reverse core add prefix feature for custom class plugin add plugin custom class name # Conflicts: # plugins/autoloader/prism-autoloader.min.js
Sorry for the late reply. Work swamped me :) |
Sorry for the late answer too. It's merged now. |
Thank you very much for your time :) |
* PrismJS/gh-pages: Plugins: Toolbar & Copy to Clipboard (PrismJS#891) Ini: Fix test after PrismJS#1047 Add support for the Jolie language (PrismJS#1014) Fix order of decoding entities in groovy (PrismJS#1049) (PrismJS#1050) Ruby: Make strings greedy. Fixes PrismJS#1048 Ini: Remove newline at end of minified file. Ruby: Fix test after PrismJS#1023 Remove important token in ini definition (PrismJS#1047) Add missing `from` keyword to typescript & set `ts` as alias. (PrismJS#1042) Fix greedy-flag bug Add yarn.lock (PrismJS#1035)
No description provided.