-
Notifications
You must be signed in to change notification settings - Fork 6
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
Try to update syntax highlighting #59
base: master
Are you sure you want to change the base?
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,48 +5,51 @@ import ITheme = monaco.editor.IStandaloneThemeData; | |
|
||
export const syntax = <ILanguage>{ | ||
// defaultToken: 'invalid', | ||
tokenPostfix: '.effekt', | ||
|
||
keywords: [ | ||
'module', 'import', 'def', 'val', 'var', 'effect', 'type', 'match', | ||
'case', 'record', 'extern', 'include', 'resume', 'with', 'if', 'try', | ||
'else', 'do', 'handle', 'while', 'fun', 'region', 'in', 'new', | ||
'box', 'unbox', 'interface', 'resource', 'and', 'is', 'namespace' | ||
'box', 'unbox', 'interface', 'resource', 'and', 'is', 'namespace', | ||
'return', 'as' | ||
], | ||
|
||
definitionKeywords: [ | ||
'def', 'type', 'effect' | ||
'def', 'type', 'effect', 'val', 'var', 'extern', 'fun', 'interface', 'resource', 'namespace' | ||
], | ||
|
||
literals: ['true', 'false'], | ||
|
||
operators: [ | ||
'=', '>', '<', '!', '~', '?', ':', '==', '<=', '>=', '!=', | ||
'&&', '||', '++', '--', '+', '-', '*', '/', '&', '|', '^', '%', | ||
'<<', '>>', '>>>', '+=', '-=', '*=', '/=', '&=', '|=', '^=', | ||
'%=', '<<=', '>>=', '>>>=' | ||
'=', | ||
':', | ||
'>', '<', '==', '<=', '>=', '!=', | ||
'&&', '||', | ||
'++', | ||
'+', '-', '*', '/', | ||
'=>', '::' | ||
], | ||
|
||
// we include these common regular expressions | ||
symbols: /[=><!~?:&|+\-*\/\^%]+/, | ||
|
||
// supported escapes | ||
escapes: /\\(?:[btnfr\\"']|u[0-9A-Fa-f]{4})/, | ||
|
||
// The main tokenizer for our languages | ||
tokenizer: { | ||
root: [ | ||
// identifiers and keywords | ||
[/[a-z_$][\w$?!]*/, { | ||
cases: { | ||
'@keywords': { | ||
cases: { | ||
'@definitionKeywords': { token: 'keyword', next: '@definition' }, | ||
'@default': 'keyword' | ||
} | ||
}, | ||
'@definitionKeywords': { token: 'keyword', next: '@definition' }, | ||
'@keywords': 'keyword', | ||
'@literals': 'literal', | ||
'@default': 'identifier' | ||
} | ||
}], | ||
|
||
[/[A-Z][\w\$?!]*/, 'type.identifier' ], | ||
[/[A-Z][\w\$?!]*/, 'type.identifier'], | ||
|
||
// whitespace | ||
{ include: '@whitespace' }, | ||
|
@@ -55,7 +58,7 @@ export const syntax = <ILanguage>{ | |
[/[{}()\[\]]/, '@brackets'], | ||
[/[<>](?!@symbols)/, '@brackets'], | ||
[/@symbols/, { cases: { '@operators': 'operator', | ||
'@default' : '' } } ], | ||
'@default': '' } } ], | ||
|
||
// numbers | ||
[/\d*\.\d+([eE][\-+]?\d+)?/, 'number.float'], | ||
|
@@ -71,6 +74,7 @@ export const syntax = <ILanguage>{ | |
|
||
// characters | ||
[/'[^\\']'/, 'string'], | ||
[/(')(@escapes)(')/, ['string', 'string.escape', 'string']], | ||
[/'/, 'string.invalid'] | ||
], | ||
|
||
|
@@ -81,13 +85,25 @@ export const syntax = <ILanguage>{ | |
], | ||
|
||
comment: [ | ||
[/[^\/*]+/, 'comment' ] | ||
[/[^\/*]+/, 'comment'], | ||
[/\/\*/, 'comment', '@push'], | ||
["\\*/", 'comment', '@pop'], | ||
[/[\/*]/, 'comment'] | ||
], | ||
|
||
string: [ | ||
[/[^\\"]+/, 'string'], | ||
[/\\./, 'string.escape.invalid'], | ||
[/"/, { token: 'string.quote', bracket: '@close', next: '@pop' } ] | ||
[/[^\\"$]+/, 'string'], | ||
[/@escapes/, 'string.escape'], | ||
[/\\./, 'string.escape.invalid'], | ||
[/\$\{/, { token: 'delimiter.bracket', next: '@bracketCounting' }], | ||
[/\$[a-z_][\w$]*/, 'variable'], | ||
[/"/, { token: 'string.quote', bracket: '@close', next: '@pop' }] | ||
], | ||
|
||
bracketCounting: [ | ||
[/\{/, 'delimiter.bracket', '@bracketCounting'], | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This does seem to get confused on this example:
Here, the |
||
[/\}/, 'delimiter.bracket', '@pop'], | ||
{ include: 'root' } | ||
], | ||
|
||
whitespace: [ | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -66,40 +66,9 @@ hljs.registerLanguage("effekt", function highlightEffekt(hljs) { | |
relevance: 0 | ||
}; | ||
|
||
var CLASS = { | ||
className: 'class', | ||
beginKeywords: 'class object trait type', | ||
end: /[:={\[\n;]/, | ||
Comment on lines
-69
to
-72
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't think we really used this anywhere except for |
||
excludeEnd: true, | ||
contains: [ | ||
{ | ||
beginKeywords: 'extends with', | ||
relevance: 10 | ||
}, | ||
{ | ||
begin: /\[/, | ||
end: /\]/, | ||
excludeBegin: true, | ||
excludeEnd: true, | ||
relevance: 0, | ||
contains: [TYPE] | ||
}, | ||
{ | ||
className: 'params', | ||
begin: /\(/, | ||
end: /\)/, | ||
excludeBegin: true, | ||
excludeEnd: true, | ||
relevance: 0, | ||
contains: [TYPE] | ||
}, | ||
NAME | ||
] | ||
}; | ||
|
||
var METHOD = { | ||
var DEFINITION = { | ||
className: 'function', | ||
beginKeywords: 'def', | ||
beginKeywords: 'def effect type val var extern fun interface resource namespace', | ||
end: /[:={\[(\n;]/, | ||
excludeEnd: true, | ||
contains: [NAME] | ||
|
@@ -108,7 +77,7 @@ hljs.registerLanguage("effekt", function highlightEffekt(hljs) { | |
return { | ||
name: 'Effekt', | ||
keywords: { | ||
literal: 'true false null', | ||
literal: 'true false', | ||
keyword: 'module effect type def with val var if for while import return else case try match resume do record region in new interface let box unbox fun extern and is namespace' | ||
}, | ||
contains: [ | ||
|
@@ -117,8 +86,7 @@ hljs.registerLanguage("effekt", function highlightEffekt(hljs) { | |
STRING, | ||
SYMBOL, | ||
TYPE, | ||
METHOD, | ||
CLASS, | ||
DEFINITION, | ||
hljs.C_NUMBER_MODE, | ||
ANNOTATION | ||
] | ||
|
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.
Apparently this does not work (as before):
Here, the lines following beyond the
*/
are also greyed out