aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPartouf <partouf@gmail.com>2018-10-06 22:39:46 +0200
committerPartouf <partouf@gmail.com>2018-10-06 23:56:57 +0200
commit0f5a89f590c7e17b00d121342654a79fe688a3cb (patch)
tree980aafbea7e97f5047b8b1b0cb8f51b512b70e7f
parentf7c0e75075c50c0f73d72e2c017284b06c66b822 (diff)
downloadcompiler-explorer-0f5a89f590c7e17b00d121342654a79fe688a3cb.tar.gz
compiler-explorer-0f5a89f590c7e17b00d121342654a79fe688a3cb.zip
clean colorings
-rw-r--r--static/modes/clean-mode.js89
-rw-r--r--static/modes/haskell-mode.js87
2 files changed, 47 insertions, 129 deletions
diff --git a/static/modes/clean-mode.js b/static/modes/clean-mode.js
index 1b37f8154..2e3333696 100644
--- a/static/modes/clean-mode.js
+++ b/static/modes/clean-mode.js
@@ -21,108 +21,67 @@
// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
// POSSIBILITY OF SUCH DAMAGE.
-
"use strict";
function definition() {
return {
- // Set defaultToken to invalid to see what you do not tokenize yet
- // defaultToken: 'invalid',
+ defaultToken: 'invalid',
keywords: [
- 'module', 'import'
+ 'module', 'import', 'Start', 'where', 'otherwise', 'definition', 'implementation', 'from', 'class', 'instance', 'abort'
],
- typeKeywords: [
- 'Int'
+ builtintypes: [
+ 'Int', 'Real', 'String'
],
operators: [
- '=', '>', '<', '!', '~', '?', ':', '==', '<=', '>=', '!=',
- '&&', '||', '++', '--', '+', '-', '*', '/', '&', '|', '^', '%',
- '<<', '>>', '>>>', '+=', '-=', '*=', '/=', '&=', '|=', '^=',
- '%=', '<<=', '>>=', '>>>='
+ '=', '==', '>=', '<=', '+', '-', '*', '/', '::', '->', '=:', '=>', '|'
],
- // we include these common regular expressions
- symbols: /[=><!~?:&|+\-*/^%]+/,
-
- // C# style strings
- escapes: /\\(?:[abfnrtv\\"']|x[0-9A-Fa-f]{1,4}|u[0-9A-Fa-f]{4}|U[0-9A-Fa-f]{8})/,
+ numbers: /-?[0-9.]/,
- // The main tokenizer for our languages
tokenizer: {
root: [
- // identifiers and keywords
- [/[a-z_$][\w$]*/, {
- cases: {
- '@typeKeywords': 'keyword',
- '@keywords': 'keyword',
- '@default': 'identifier'
- }
- }],
- [/[A-Z][\w$]*/, 'type.identifier'], // to show class names nicely
+ { include: '@whitespace' },
+
+ [/->/, 'operators'],
+
+ [/\|/, 'operators'],
- // whitespace
- {include: '@whitespace'},
+ [/(\w*)(\s?)(::)/, ['keyword', 'white', 'operators']],
- // delimiters and operators
- [/[{}()[\]]/, '@brackets'],
- [/[<>](?!@symbols)/, '@brackets'],
- [/@symbols/, {
+ [/[+\-*\/=<>]/, 'operators'],
+
+ [/[a-zA-Z_][a-zA-Z0-9_]*/, {
cases: {
- '@operators': 'operator',
+ '@builtintypes': 'type',
+ '@keywords': 'keyword',
'@default': ''
}
}],
- // @ annotations.
- // As an example, we emit a debugging log message on these tokens.
- // Note: message are supressed during the first load -- change some lines to see them.
- // [/@\s*[a-zA-Z_\$][\w\$]*/, { token: 'annotation', log: 'annotation token: $0' }],
-
- // numbers
- [/\d*\.\d+([eE][-+]?\d+)?/, 'number.float'],
- [/0[xX][0-9a-fA-F]+/, 'number.hex'],
- [/\d+/, 'number'],
-
- // delimiter: after number because of .\d floats
- [/[;,.]/, 'delimiter'],
+ [/[()\[\],:]/, 'delimiter'],
- // strings
- [/"([^"\\]|\\.)*$/, 'string.invalid'], // non-teminated string
- [/"/, {token: 'string.quote', bracket: '@open', next: '@string'}],
+ [/@numbers/, 'number'],
- // characters
- [/'[^\\']'/, 'string'],
- [/(')(@escapes)(')/, ['string', 'string.escape', 'string']],
- [/'/, 'string.invalid']
+ [/(")(.*)(")/, ['string', 'string', 'string']]
],
comment: [
[/[^/*]+/, 'comment'],
- [/\/\*/, 'comment', '@push'], // nested comment
- ["\\*/", 'comment', '@pop'],
+ [/\*\//, 'comment', '@pop'],
[/[/*]/, 'comment']
],
- string: [
- [/[^\\"]+/, 'string'],
- [/@escapes/, 'string.escape'],
- [/\\./, 'string.escape.invalid'],
- [/"/, {token: 'string.quote', bracket: '@close', next: '@pop'}]
- ],
-
whitespace: [
[/[ \t\r\n]+/, 'white'],
[/\/\*/, 'comment', '@comment'],
- [/\/\/.*$/, 'comment'],
- [/^;;.*$/, 'comment']
-
- ]
+ [/\/\/.*$/, 'comment']
+ ],
}
};
}
-monaco.languages.register({id: 'clean'});
+monaco.languages.register({ id: 'clean' });
monaco.languages.setMonarchTokensProvider('clean', definition());
diff --git a/static/modes/haskell-mode.js b/static/modes/haskell-mode.js
index 10153e328..a07440ee9 100644
--- a/static/modes/haskell-mode.js
+++ b/static/modes/haskell-mode.js
@@ -21,105 +21,64 @@
// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
// POSSIBILITY OF SUCH DAMAGE.
-
"use strict";
function definition() {
return {
- // Set defaultToken to invalid to see what you do not tokenize yet
- // defaultToken: 'invalid',
+ defaultToken: 'invalid',
keywords: [
- 'module', 'import'
+ 'module', 'import', 'Start', 'where', 'otherwise', 'definition', 'implementation', 'from', 'class', 'instance', 'abort'
],
- typeKeywords: [
- 'Int'
+ builtintypes: [
+ 'Int', 'Real', 'String'
],
operators: [
- '=', '>', '<', '!', '~', '?', ':', '==', '<=', '>=', '!=',
- '&&', '||', '++', '--', '+', '-', '*', '/', '&', '|', '^', '%',
- '<<', '>>', '>>>', '+=', '-=', '*=', '/=', '&=', '|=', '^=',
- '%=', '<<=', '>>=', '>>>='
+ '=', '==', '>=', '<=', '+', '-', '*', '/', '::', '->', '=:', '=>', '|'
],
- // we include these common regular expressions
- symbols: /[=><!~?:&|+\-*/^%]+/,
-
- // C# style strings
- escapes: /\\(?:[abfnrtv\\"']|x[0-9A-Fa-f]{1,4}|u[0-9A-Fa-f]{4}|U[0-9A-Fa-f]{8})/,
+ numbers: /-?[0-9.]/,
- // The main tokenizer for our languages
tokenizer: {
root: [
- // identifiers and keywords
- [/[a-z_$][\w$]*/, {
- cases: {
- '@typeKeywords': 'keyword',
- '@keywords': 'keyword',
- '@default': 'identifier'
- }
- }],
- [/[A-Z][\w$]*/, 'type.identifier'], // to show class names nicely
+ { include: '@whitespace' },
+
+ [/->/, 'operators'],
+
+ [/\|/, 'operators'],
- // whitespace
- {include: '@whitespace'},
+ [/(\w*)(\s?)(::)/, ['keyword', 'white', 'operators']],
- // delimiters and operators
- [/[{}()[\]]/, '@brackets'],
- [/[<>](?!@symbols)/, '@brackets'],
- [/@symbols/, {
+ [/[+\-*\/=<>]/, 'operators'],
+
+ [/[a-zA-Z_][a-zA-Z0-9_]*/, {
cases: {
- '@operators': 'operator',
+ '@builtintypes': 'type',
+ '@keywords': 'keyword',
'@default': ''
}
}],
- // @ annotations.
- // As an example, we emit a debugging log message on these tokens.
- // Note: message are supressed during the first load -- change some lines to see them.
- // [/@\s*[a-zA-Z_\$][\w\$]*/, { token: 'annotation', log: 'annotation token: $0' }],
-
- // numbers
- [/\d*\.\d+([eE][-+]?\d+)?/, 'number.float'],
- [/0[xX][0-9a-fA-F]+/, 'number.hex'],
- [/\d+/, 'number'],
-
- // delimiter: after number because of .\d floats
- [/[;,.]/, 'delimiter'],
+ [/[()\[\],:]/, 'delimiter'],
- // strings
- [/"([^"\\]|\\.)*$/, 'string.invalid'], // non-teminated string
- [/"/, {token: 'string.quote', bracket: '@open', next: '@string'}],
+ [/@numbers/, 'number'],
- // characters
- [/'[^\\']'/, 'string'],
- [/(')(@escapes)(')/, ['string', 'string.escape', 'string']],
- [/'/, 'string.invalid']
+ [/(")(.*)(")/, ['string', 'string', 'string']]
],
comment: [
[/[^/*]+/, 'comment'],
- [/\/\*/, 'comment', '@push'], // nested comment
- ["\\*/", 'comment', '@pop'],
+ [/\*\//, 'comment', '@pop'],
[/[/*]/, 'comment']
],
- string: [
- [/[^\\"]+/, 'string'],
- [/@escapes/, 'string.escape'],
- [/\\./, 'string.escape.invalid'],
- [/"/, {token: 'string.quote', bracket: '@close', next: '@pop'}]
- ],
-
whitespace: [
[/[ \t\r\n]+/, 'white'],
[/\/\*/, 'comment', '@comment'],
- [/\/\/.*$/, 'comment'],
- [/^;;.*$/, 'comment']
-
- ]
+ [/\/\/.*$/, 'comment']
+ ],
}
};
}