mirror of
https://github.com/microsoft/monaco-editor.git
synced 2025-12-22 18:32:56 +01:00
[clojure] Add support for (comment ...).
This commit is contained in:
parent
1188cfa1bb
commit
c65a13afa1
2 changed files with 56 additions and 6 deletions
|
|
@ -768,6 +768,44 @@ testTokenization('clojure', [
|
|||
';; this is a line comment.',
|
||||
], 'comment'),
|
||||
|
||||
// `comment`
|
||||
[
|
||||
{
|
||||
line: '(comment)',
|
||||
tokens: [
|
||||
{startIndex: 0, type: 'comment.clj'},
|
||||
],
|
||||
},
|
||||
{
|
||||
line: 'foo :bar 42',
|
||||
tokens: [
|
||||
{startIndex: 0, type: 'identifier.clj'},
|
||||
{startIndex: 3, type: 'white.clj'},
|
||||
{startIndex: 4, type: 'constant.clj'},
|
||||
{startIndex: 8, type: 'white.clj'},
|
||||
{startIndex: 9, type: 'number.clj'},
|
||||
],
|
||||
},
|
||||
{
|
||||
line: '(comment (foo [bar :baz 1 "qux"]))',
|
||||
tokens: [
|
||||
{startIndex: 0, type: 'comment.clj'},
|
||||
],
|
||||
},
|
||||
{
|
||||
line: '(comment foo',
|
||||
tokens: [
|
||||
{startIndex: 0, type: 'comment.clj'},
|
||||
],
|
||||
},
|
||||
{
|
||||
line: 'foo',
|
||||
tokens: [
|
||||
{startIndex: 0, type: 'comment.clj'},
|
||||
],
|
||||
},
|
||||
],
|
||||
|
||||
// reader macro characters
|
||||
createTestCases([
|
||||
'#',
|
||||
|
|
|
|||
|
|
@ -716,18 +716,24 @@ export const language = <ILanguage>{
|
|||
|
||||
symbolCharacter: /[!#'*+\-.\/:<=>?_\w\xa1-\uffff]/,
|
||||
|
||||
numbers: /^[+\-]?\d+(?:(?:N|(?:[eE][+\-]?\d+))|(?:\.?\d*(?:M|(?:[eE][+\-]?\d+))?)|\/\d+|[xX][0-9a-fA-F]+|r[0-9a-zA-Z]+)?/,
|
||||
numbers: /[+\-]?\d+(?:(?:N|(?:[eE][+\-]?\d+))|(?:\.?\d*(?:M|(?:[eE][+\-]?\d+))?)|\/\d+|[xX][0-9a-fA-F]+|r[0-9a-zA-Z]+)?/,
|
||||
|
||||
characters: /\\(?:backspace|formfeed|newline|return|space|tab|x[0-9A-Fa-f]{4}|u[0-9A-Fa-f]{4}|o[0-7]{3}|@symbolCharacter|[\\"()\[\]{}])/,
|
||||
|
||||
tokenizer: {
|
||||
root: [
|
||||
// whitespaces and comments
|
||||
{include: '@whitespace'},
|
||||
|
||||
// numbers
|
||||
[/@numbers/, 'number'],
|
||||
|
||||
// characters
|
||||
[/@characters/, 'string'],
|
||||
|
||||
// strings
|
||||
{include: '@string'},
|
||||
|
||||
// brackets
|
||||
[/[()\[\]{}]/, '@brackets'],
|
||||
|
||||
|
|
@ -751,20 +757,26 @@ export const language = <ILanguage>{
|
|||
},
|
||||
],
|
||||
|
||||
{include: '@whitespace'},
|
||||
{include: '@string'},
|
||||
],
|
||||
|
||||
whitespace: [
|
||||
[/[ \t\r\n]+/, 'white'],
|
||||
[/;.*$/, 'comment']],
|
||||
[/\s+/, 'white'],
|
||||
[/;.*$/, 'comment'],
|
||||
[/\(comment/, 'comment', '@comment'],
|
||||
],
|
||||
|
||||
comment: [
|
||||
[/\(/, 'comment', '@push'],
|
||||
[/\)/, 'comment', '@pop'],
|
||||
[/[^)]/, 'comment'],
|
||||
],
|
||||
|
||||
string: [
|
||||
[/"/, 'string', '@multiLineString'],
|
||||
],
|
||||
|
||||
multiLineString: [
|
||||
[/[^\\"$]+/, 'string'],
|
||||
[/[^\\"]+/, 'string'],
|
||||
[/@characters/, 'string'],
|
||||
[/"/, 'string', '@pop']
|
||||
],
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue