Merge branch 'master' of https://github.com/Microsoft/monaco-languages
commit
7e0f9bc899
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,14 @@
|
||||
/*---------------------------------------------------------------------------------------------
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the MIT License. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
'use strict';
|
||||
|
||||
import { registerLanguage } from '../_.contribution';
|
||||
|
||||
registerLanguage({
|
||||
id: 'cameligo',
|
||||
extensions: ['.mligo'],
|
||||
aliases: ['Cameligo'],
|
||||
loader: () => import('./cameligo')
|
||||
});
|
@ -0,0 +1,140 @@
|
||||
/*---------------------------------------------------------------------------------------------
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the MIT License. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
'use strict';
|
||||
|
||||
import { testTokenization } from '../test/testRunner';
|
||||
|
||||
testTokenization('cameligo', [
|
||||
|
||||
// Comments - single line
|
||||
[{
|
||||
line: '//',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'comment.cameligo' }
|
||||
]
|
||||
}],
|
||||
|
||||
[{
|
||||
line: ' // a comment',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'white.cameligo' },
|
||||
{ startIndex: 4, type: 'comment.cameligo' }
|
||||
]
|
||||
}],
|
||||
|
||||
[{
|
||||
line: '// a comment',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'comment.cameligo' }
|
||||
]
|
||||
}],
|
||||
|
||||
[{
|
||||
line: '//sticky comment',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'comment.cameligo' }
|
||||
]
|
||||
}],
|
||||
|
||||
// Comments - multi line (single line)
|
||||
[{
|
||||
line: '(**)',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'comment.cameligo' }
|
||||
]
|
||||
}],
|
||||
|
||||
[{
|
||||
line: ' (* a comment *)',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'white.cameligo' },
|
||||
{ startIndex: 4, type: 'comment.cameligo' }
|
||||
]
|
||||
}],
|
||||
|
||||
[{
|
||||
line: '(* a comment *)',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'comment.cameligo' }
|
||||
]
|
||||
}],
|
||||
|
||||
[{
|
||||
line: '(*sticky comment*)',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'comment.cameligo' }
|
||||
]
|
||||
}],
|
||||
|
||||
// Comments - multi line (multi line)
|
||||
[{
|
||||
line: '(* start of multiline comment ',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'comment.cameligo' }
|
||||
]
|
||||
}, {
|
||||
line: 'a comment between curly',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'comment.cameligo'}
|
||||
]
|
||||
}, {
|
||||
line: 'end of multiline comment*)',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'comment.cameligo'}
|
||||
]
|
||||
}],
|
||||
|
||||
// Keywords
|
||||
[{
|
||||
line: 'let check if Current.amount',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'keyword.let.cameligo'},
|
||||
{ startIndex: 3, type: 'white.cameligo'},
|
||||
{ startIndex: 4, type: 'identifier.cameligo'},
|
||||
{ startIndex: 9, type: 'white.cameligo'},
|
||||
{ startIndex: 10, type: 'keyword.if.cameligo'},
|
||||
{ startIndex: 12, type: 'white.cameligo'},
|
||||
{ startIndex: 13, type: 'keyword.current.cameligo'},
|
||||
{ startIndex: 20, type: 'delimiter.cameligo'},
|
||||
{ startIndex: 21, type: 'identifier.cameligo'},
|
||||
]
|
||||
}],
|
||||
|
||||
// Numbers
|
||||
[{
|
||||
line: '0',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'number.cameligo'}
|
||||
]
|
||||
}],
|
||||
[{
|
||||
line: '0;',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'number.cameligo'},
|
||||
{ startIndex: 1, type: 'delimiter.cameligo'}
|
||||
]
|
||||
}],
|
||||
[{
|
||||
line: '2.4',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'number.float.cameligo'}
|
||||
]
|
||||
}],
|
||||
[{
|
||||
line: '2.4;',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'number.float.cameligo'},
|
||||
{ startIndex: 3, type: 'delimiter.cameligo'}
|
||||
]
|
||||
}],
|
||||
[{
|
||||
line: '$123FF',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'number.hex.cameligo'}
|
||||
]
|
||||
}]
|
||||
|
||||
]);
|
@ -0,0 +1,131 @@
|
||||
/*---------------------------------------------------------------------------------------------
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the MIT License. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
'use strict';
|
||||
|
||||
import IRichLanguageConfiguration = monaco.languages.LanguageConfiguration;
|
||||
import ILanguage = monaco.languages.IMonarchLanguage;
|
||||
|
||||
export const conf: IRichLanguageConfiguration = {
|
||||
comments: {
|
||||
lineComment: '//',
|
||||
blockComment: ['(*', '*)'],
|
||||
},
|
||||
brackets: [
|
||||
['{', '}'],
|
||||
['[', ']'],
|
||||
['(', ')'],
|
||||
['<', '>'],
|
||||
],
|
||||
autoClosingPairs: [
|
||||
{ open: '{', close: '}' },
|
||||
{ open: '[', close: ']' },
|
||||
{ open: '(', close: ')' },
|
||||
{ open: '<', close: '>' },
|
||||
{ open: '\'', close: '\'' },
|
||||
],
|
||||
surroundingPairs: [
|
||||
{ open: '{', close: '}' },
|
||||
{ open: '[', close: ']' },
|
||||
{ open: '(', close: ')' },
|
||||
{ open: '<', close: '>' },
|
||||
{ open: '\'', close: '\'' },
|
||||
]
|
||||
};
|
||||
|
||||
export const language = <ILanguage>{
|
||||
defaultToken: '',
|
||||
tokenPostfix: '.cameligo',
|
||||
ignoreCase: true,
|
||||
|
||||
brackets: [
|
||||
{ open: '{', close: '}', token: 'delimiter.curly' },
|
||||
{ open: '[', close: ']', token: 'delimiter.square' },
|
||||
{ open: '(', close: ')', token: 'delimiter.parenthesis' },
|
||||
{ open: '<', close: '>', token: 'delimiter.angle' }
|
||||
],
|
||||
|
||||
keywords: [
|
||||
'abs', 'begin', 'Bytes', 'Crypto', 'Current', 'else', 'end', 'failwith',
|
||||
'false', 'fun', 'if', 'in', 'let', 'let%entry', 'let%init', 'List', 'list',
|
||||
'Map', 'map', 'match', 'match%nat', 'mod', 'not', 'operation', 'Operation', 'of',
|
||||
'Set', 'set', 'sender', 'source', 'String', 'then', 'true', 'type', 'with',
|
||||
],
|
||||
|
||||
typeKeywords: [
|
||||
'int', 'unit', 'string', 'tz',
|
||||
],
|
||||
|
||||
operators: [
|
||||
'=', '>', '<', '<=', '>=', '<>', ':', ':=', 'and', 'mod', 'or',
|
||||
'+', '-', '*', '/', '@', '&', '^', '%', '->', '<-'
|
||||
],
|
||||
|
||||
// we include these common regular expressions
|
||||
symbols: /[=><:@\^&|+\-*\/\^%]+/,
|
||||
|
||||
// The main tokenizer for our languages
|
||||
tokenizer: {
|
||||
root: [
|
||||
// identifiers and keywords
|
||||
[/[a-zA-Z_][\w]*/, {
|
||||
cases: {
|
||||
'@keywords': { token: 'keyword.$0' },
|
||||
'@default': 'identifier'
|
||||
}
|
||||
}],
|
||||
|
||||
// whitespace
|
||||
{ include: '@whitespace' },
|
||||
|
||||
// delimiters and operators
|
||||
[/[{}()\[\]]/, '@brackets'],
|
||||
[/[<>](?!@symbols)/, '@brackets'],
|
||||
[/@symbols/, {
|
||||
cases: {
|
||||
'@operators': 'delimiter',
|
||||
'@default': ''
|
||||
}
|
||||
}],
|
||||
|
||||
// numbers
|
||||
[/\d*\.\d+([eE][\-+]?\d+)?/, 'number.float'],
|
||||
[/\$[0-9a-fA-F]{1,16}/, 'number.hex'],
|
||||
[/\d+/, 'number'],
|
||||
|
||||
// delimiter: after number because of .\d floats
|
||||
[/[;,.]/, 'delimiter'],
|
||||
|
||||
// strings
|
||||
[/'([^'\\]|\\.)*$/, 'string.invalid'], // non-teminated string
|
||||
[/'/, 'string', '@string'],
|
||||
|
||||
// characters
|
||||
[/'[^\\']'/, 'string'],
|
||||
[/'/, 'string.invalid'],
|
||||
[/\#\d+/,'string']
|
||||
],
|
||||
/* */
|
||||
|
||||
comment: [
|
||||
[/[^\(\*]+/, 'comment' ],
|
||||
//[/\(\*/, 'comment', '@push' ], // nested comment not allowed :-(
|
||||
[/\*\)/, 'comment', '@pop' ],
|
||||
[/\(\*/, 'comment' ]
|
||||
],
|
||||
|
||||
string: [
|
||||
[/[^\\']+/, 'string'],
|
||||
[/\\./, 'string.escape.invalid'],
|
||||
[/'/, { token: 'string.quote', bracket: '@close', next: '@pop' } ]
|
||||
],
|
||||
|
||||
whitespace: [
|
||||
[/[ \t\r\n]+/, 'white'],
|
||||
[/\(\*/, 'comment', '@comment' ],
|
||||
[/\/\/.*$/, 'comment'],
|
||||
],
|
||||
},
|
||||
};
|
Loading…
Reference in New Issue