Explorar o código

Merge remote-tracking branch 'origin/main' into pr/akonatala/137

Alex Dima %!s(int64=4) %!d(string=hai) anos
pai
achega
5f9cbb44b5

+ 1 - 1
.github/workflows/ci.yml

@@ -1,6 +1,6 @@
 name: CI
 
-on: push
+on: [push, pull_request]
 
 jobs:
   ci:

+ 41 - 0
SECURITY.md

@@ -0,0 +1,41 @@
+<!-- BEGIN MICROSOFT SECURITY.MD V0.0.5 BLOCK -->
+
+## Security
+
+Microsoft takes the security of our software products and services seriously, which includes all source code repositories managed through our GitHub organizations, which include [Microsoft](https://github.com/Microsoft), [Azure](https://github.com/Azure), [DotNet](https://github.com/dotnet), [AspNet](https://github.com/aspnet), [Xamarin](https://github.com/xamarin), and [our GitHub organizations](https://opensource.microsoft.com/).
+
+If you believe you have found a security vulnerability in any Microsoft-owned repository that meets [Microsoft's definition of a security vulnerability](<https://docs.microsoft.com/en-us/previous-versions/tn-archive/cc751383(v=technet.10)>), please report it to us as described below.
+
+## Reporting Security Issues
+
+**Please do not report security vulnerabilities through public GitHub issues.**
+
+Instead, please report them to the Microsoft Security Response Center (MSRC) at [https://msrc.microsoft.com/create-report](https://msrc.microsoft.com/create-report).
+
+If you prefer to submit without logging in, send email to [secure@microsoft.com](mailto:secure@microsoft.com). If possible, encrypt your message with our PGP key; please download it from the [Microsoft Security Response Center PGP Key page](https://www.microsoft.com/en-us/msrc/pgp-key-msrc).
+
+You should receive a response within 24 hours. If for some reason you do not, please follow up via email to ensure we received your original message. Additional information can be found at [microsoft.com/msrc](https://www.microsoft.com/msrc).
+
+Please include the requested information listed below (as much as you can provide) to help us better understand the nature and scope of the possible issue:
+
+-   Type of issue (e.g. buffer overflow, SQL injection, cross-site scripting, etc.)
+-   Full paths of source file(s) related to the manifestation of the issue
+-   The location of the affected source code (tag/branch/commit or direct URL)
+-   Any special configuration required to reproduce the issue
+-   Step-by-step instructions to reproduce the issue
+-   Proof-of-concept or exploit code (if possible)
+-   Impact of the issue, including how an attacker might exploit the issue
+
+This information will help us triage your report more quickly.
+
+If you are reporting for a bug bounty, more complete reports can contribute to a higher bounty award. Please visit our [Microsoft Bug Bounty Program](https://microsoft.com/msrc/bounty) page for more details about our active programs.
+
+## Preferred Languages
+
+We prefer all communications to be in English.
+
+## Policy
+
+Microsoft follows the principle of [Coordinated Vulnerability Disclosure](https://www.microsoft.com/en-us/msrc/cvd).
+
+<!-- END MICROSOFT SECURITY.MD BLOCK -->

A diferenza do arquivo foi suprimida porque é demasiado grande
+ 305 - 287
package-lock.json


+ 8 - 8
package.json

@@ -1,6 +1,6 @@
 {
 	"name": "monaco-languages",
-	"version": "2.1.1",
+	"version": "2.4.0",
 	"description": "Bundle of many languages for the Monaco Editor.",
 	"scripts": {
 		"compile": "mrmdir ./out && tsc -p ./src/tsconfig.json && tsc -p ./src/tsconfig.esm.json",
@@ -22,16 +22,16 @@
 	"devDependencies": {
 		"@types/tape": "^4.13.0",
 		"glob": "^7.1.6",
-		"husky": "^4.3.0",
+		"husky": "^4.3.8",
 		"jsdom": "^16.4.0",
-		"monaco-editor-core": "0.21.0",
+		"monaco-editor-core": "0.24.0",
 		"monaco-plugin-helpers": "^1.0.3",
-		"prettier": "^2.1.2",
-		"pretty-quick": "^3.0.2",
+		"prettier": "^2.2.1",
+		"pretty-quick": "^3.1.0",
 		"requirejs": "^2.3.6",
-		"tape": "^5.0.1",
-		"terser": "^5.3.2",
-		"typescript": "4.0.3"
+		"tape": "^5.1.1",
+		"terser": "^5.5.1",
+		"typescript": "4.1.3"
 	},
 	"husky": {
 		"hooks": {

+ 13 - 0
src/bicep/bicep.contribution.ts

@@ -0,0 +1,13 @@
+/*---------------------------------------------------------------------------------------------
+ *  Copyright (c) Microsoft Corporation. All rights reserved.
+ *  Licensed under the MIT License. See License.txt in the project root for license information.
+ *--------------------------------------------------------------------------------------------*/
+
+import { registerLanguage } from '../_.contribution';
+
+registerLanguage({
+	id: 'bicep',
+	extensions: ['.bicep'],
+	aliases: ['Bicep'],
+	loader: () => import('./bicep')
+});

+ 1069 - 0
src/bicep/bicep.test.ts

@@ -0,0 +1,1069 @@
+/*---------------------------------------------------------------------------------------------
+ *  Copyright (c) Microsoft Corporation. All rights reserved.
+ *  Licensed under the MIT License. See License.txt in the project root for license information.
+ *--------------------------------------------------------------------------------------------*/
+
+/* To generate an initial baseline from a .bicep file, uncomment:
+
+import { testTokenization } from '../test/testRunner';
+import { readFileSync } from 'fs';
+
+const lines = readFileSync('/Users/ant/Code/bicep/src/monarch/test/baselines/basic.bicep', { encoding: 'utf-8' }).split(/\r?\n/);
+
+testTokenization('bicep', [
+  lines.map(line => ({
+    line,
+    tokens: [],
+  }))
+]);
+*/
+
+import { testTokenization } from '../test/testRunner';
+
+testTokenization('bicep', [
+	[
+		// https://github.com/Azure/bicep/blob/bc9fc9ce09d1d8da21144d84db01655e042e74bf/src/monarch/test/baselines/comments.bicep
+		{
+			line: '',
+			tokens: []
+		},
+		{
+			line: "resource test 'Microsoft.AAD/domainServices@2021-03-01' = {",
+			tokens: [
+				{ startIndex: 0, type: 'keyword.bicep' },
+				{ startIndex: 8, type: '' },
+				{ startIndex: 9, type: 'identifier.bicep' },
+				{ startIndex: 13, type: '' },
+				{ startIndex: 14, type: 'string.quote.bicep' },
+				{ startIndex: 15, type: 'string.bicep' },
+				{ startIndex: 55, type: '' }
+			]
+		},
+		{
+			line: "  name: 'asdfsdf'",
+			tokens: [
+				{ startIndex: 0, type: '' },
+				{ startIndex: 2, type: 'identifier.bicep' },
+				{ startIndex: 6, type: '' },
+				{ startIndex: 8, type: 'string.quote.bicep' },
+				{ startIndex: 9, type: 'string.bicep' }
+			]
+		},
+		{
+			line: '  // this is a comment',
+			tokens: [
+				{ startIndex: 0, type: '' },
+				{ startIndex: 2, type: 'comment.bicep' }
+			]
+		},
+		{
+			line: '  properties: {/*comment*/',
+			tokens: [
+				{ startIndex: 0, type: '' },
+				{ startIndex: 2, type: 'identifier.bicep' },
+				{ startIndex: 12, type: '' },
+				{ startIndex: 15, type: 'comment.bicep' }
+			]
+		},
+		{
+			line:
+				"    domainConfigurationType/*comment*/:/*comment*/'as//notacomment!d/* also not a comment */fsdf'// test!/*",
+			tokens: [
+				{ startIndex: 0, type: '' },
+				{ startIndex: 4, type: 'identifier.bicep' },
+				{ startIndex: 27, type: 'comment.bicep' },
+				{ startIndex: 38, type: '' },
+				{ startIndex: 39, type: 'comment.bicep' },
+				{ startIndex: 50, type: 'string.quote.bicep' },
+				{ startIndex: 51, type: 'string.bicep' },
+				{ startIndex: 97, type: 'comment.bicep' }
+			]
+		},
+		{
+			line: '    /* multi',
+			tokens: [
+				{ startIndex: 0, type: '' },
+				{ startIndex: 4, type: 'comment.bicep' }
+			]
+		},
+		{
+			line: '    line',
+			tokens: [{ startIndex: 0, type: 'comment.bicep' }]
+		},
+		{
+			line: '    comment */ domainName: /*',
+			tokens: [
+				{ startIndex: 0, type: 'comment.bicep' },
+				{ startIndex: 14, type: '' },
+				{ startIndex: 15, type: 'identifier.bicep' },
+				{ startIndex: 25, type: '' },
+				{ startIndex: 27, type: 'comment.bicep' }
+			]
+		},
+		{
+			line: "    asdf*/'test'",
+			tokens: [
+				{ startIndex: 0, type: 'comment.bicep' },
+				{ startIndex: 10, type: 'string.quote.bicep' },
+				{ startIndex: 11, type: 'string.bicep' }
+			]
+		},
+		{
+			line: '    // comment',
+			tokens: [
+				{ startIndex: 0, type: '' },
+				{ startIndex: 4, type: 'comment.bicep' }
+			]
+		},
+		{
+			line: '  }',
+			tokens: [{ startIndex: 0, type: '' }]
+		},
+		{
+			line: '}',
+			tokens: [{ startIndex: 0, type: '' }]
+		},
+		{
+			line: '',
+			tokens: []
+		}
+	],
+	[
+		// https://github.com/Azure/bicep/blob/bc9fc9ce09d1d8da21144d84db01655e042e74bf/src/monarch/test/baselines/basic.bicep
+		{
+			line: '// test',
+			tokens: [{ startIndex: 0, type: 'comment.bicep' }]
+		},
+		{
+			line: '/* test 2 */',
+			tokens: [{ startIndex: 0, type: 'comment.bicep' }]
+		},
+		{
+			line: "targetScope = 'resourceGroup'",
+			tokens: [
+				{ startIndex: 0, type: 'keyword.bicep' },
+				{ startIndex: 11, type: '' },
+				{ startIndex: 14, type: 'string.quote.bicep' },
+				{ startIndex: 15, type: 'string.bicep' }
+			]
+		},
+		{
+			line: '',
+			tokens: []
+		},
+		{
+			line: "resource avcsdd 'Microsoft.Cache/redis@2020-06-01' = { // line comment",
+			tokens: [
+				{ startIndex: 0, type: 'keyword.bicep' },
+				{ startIndex: 8, type: '' },
+				{ startIndex: 9, type: 'identifier.bicep' },
+				{ startIndex: 15, type: '' },
+				{ startIndex: 16, type: 'string.quote.bicep' },
+				{ startIndex: 17, type: 'string.bicep' },
+				{ startIndex: 50, type: '' },
+				{ startIndex: 55, type: 'comment.bicep' }
+			]
+		},
+		{
+			line: "  name: 'def' /* block",
+			tokens: [
+				{ startIndex: 0, type: '' },
+				{ startIndex: 2, type: 'identifier.bicep' },
+				{ startIndex: 6, type: '' },
+				{ startIndex: 8, type: 'string.quote.bicep' },
+				{ startIndex: 9, type: 'string.bicep' },
+				{ startIndex: 13, type: '' },
+				{ startIndex: 14, type: 'comment.bicep' }
+			]
+		},
+		{
+			line: '  comment */',
+			tokens: [{ startIndex: 0, type: 'comment.bicep' }]
+		},
+		{
+			line: "  location: 'somewhere'",
+			tokens: [
+				{ startIndex: 0, type: '' },
+				{ startIndex: 2, type: 'identifier.bicep' },
+				{ startIndex: 10, type: '' },
+				{ startIndex: 12, type: 'string.quote.bicep' },
+				{ startIndex: 13, type: 'string.bicep' }
+			]
+		},
+		{
+			line: '  properties: {',
+			tokens: [
+				{ startIndex: 0, type: '' },
+				{ startIndex: 2, type: 'identifier.bicep' },
+				{ startIndex: 12, type: '' }
+			]
+		},
+		{
+			line: '    sku: {',
+			tokens: [
+				{ startIndex: 0, type: '' },
+				{ startIndex: 4, type: 'identifier.bicep' },
+				{ startIndex: 7, type: '' }
+			]
+		},
+		{
+			line: '      capacity: 123',
+			tokens: [
+				{ startIndex: 0, type: '' },
+				{ startIndex: 6, type: 'identifier.bicep' },
+				{ startIndex: 14, type: '' },
+				{ startIndex: 16, type: 'number.bicep' }
+			]
+		},
+		{
+			line: "      family: 'C'",
+			tokens: [
+				{ startIndex: 0, type: '' },
+				{ startIndex: 6, type: 'identifier.bicep' },
+				{ startIndex: 12, type: '' },
+				{ startIndex: 14, type: 'string.quote.bicep' },
+				{ startIndex: 15, type: 'string.bicep' }
+			]
+		},
+		{
+			line: "      name: 'Basic'",
+			tokens: [
+				{ startIndex: 0, type: '' },
+				{ startIndex: 6, type: 'identifier.bicep' },
+				{ startIndex: 10, type: '' },
+				{ startIndex: 12, type: 'string.quote.bicep' },
+				{ startIndex: 13, type: 'string.bicep' }
+			]
+		},
+		{
+			line: '    }',
+			tokens: [{ startIndex: 0, type: '' }]
+		},
+		{
+			line: '  }',
+			tokens: [{ startIndex: 0, type: '' }]
+		},
+		{
+			line: '}',
+			tokens: [{ startIndex: 0, type: '' }]
+		},
+		{
+			line: '',
+			tokens: []
+		},
+		{
+			line: 'var secretsObject = {',
+			tokens: [
+				{ startIndex: 0, type: 'keyword.bicep' },
+				{ startIndex: 3, type: '' },
+				{ startIndex: 4, type: 'identifier.bicep' },
+				{ startIndex: 17, type: '' }
+			]
+		},
+		{
+			line: '  secrets: [',
+			tokens: [
+				{ startIndex: 0, type: '' },
+				{ startIndex: 2, type: 'identifier.bicep' },
+				{ startIndex: 9, type: '' }
+			]
+		},
+		{
+			line: "    'abc'",
+			tokens: [
+				{ startIndex: 0, type: '' },
+				{ startIndex: 4, type: 'string.quote.bicep' },
+				{ startIndex: 5, type: 'string.bicep' }
+			]
+		},
+		{
+			line: "    'def'",
+			tokens: [
+				{ startIndex: 0, type: '' },
+				{ startIndex: 4, type: 'string.quote.bicep' },
+				{ startIndex: 5, type: 'string.bicep' }
+			]
+		},
+		{
+			line: '  ]',
+			tokens: [{ startIndex: 0, type: '' }]
+		},
+		{
+			line: '}',
+			tokens: [{ startIndex: 0, type: '' }]
+		},
+		{
+			line: '',
+			tokens: []
+		},
+		{
+			line: "var parent = 'abc'",
+			tokens: [
+				{ startIndex: 0, type: 'keyword.bicep' },
+				{ startIndex: 3, type: '' },
+				{ startIndex: 4, type: 'identifier.bicep' },
+				{ startIndex: 10, type: '' },
+				{ startIndex: 13, type: 'string.quote.bicep' },
+				{ startIndex: 14, type: 'string.bicep' }
+			]
+		},
+		{
+			line: '',
+			tokens: []
+		},
+		{
+			line: "resource secrets0 'Microsoft.KeyVault/vaults/secrets@2018-02-14' = {",
+			tokens: [
+				{ startIndex: 0, type: 'keyword.bicep' },
+				{ startIndex: 8, type: '' },
+				{ startIndex: 9, type: 'identifier.bicep' },
+				{ startIndex: 17, type: '' },
+				{ startIndex: 18, type: 'string.quote.bicep' },
+				{ startIndex: 19, type: 'string.bicep' },
+				{ startIndex: 64, type: '' }
+			]
+		},
+		{
+			line: "  name: '${parent}/child'",
+			tokens: [
+				{ startIndex: 0, type: '' },
+				{ startIndex: 2, type: 'identifier.bicep' },
+				{ startIndex: 6, type: '' },
+				{ startIndex: 8, type: 'string.quote.bicep' },
+				{ startIndex: 9, type: 'delimiter.bracket.bicep' },
+				{ startIndex: 11, type: 'identifier.bicep' },
+				{ startIndex: 17, type: 'delimiter.bracket.bicep' },
+				{ startIndex: 18, type: 'string.bicep' }
+			]
+		},
+		{
+			line: '  properties: {',
+			tokens: [
+				{ startIndex: 0, type: '' },
+				{ startIndex: 2, type: 'identifier.bicep' },
+				{ startIndex: 12, type: '' }
+			]
+		},
+		{
+			line: '    attributes:  {',
+			tokens: [
+				{ startIndex: 0, type: '' },
+				{ startIndex: 4, type: 'identifier.bicep' },
+				{ startIndex: 14, type: '' }
+			]
+		},
+		{
+			line: '      enabled: true',
+			tokens: [
+				{ startIndex: 0, type: '' },
+				{ startIndex: 6, type: 'identifier.bicep' },
+				{ startIndex: 13, type: '' },
+				{ startIndex: 15, type: 'keyword.bicep' }
+			]
+		},
+		{
+			line: '    }',
+			tokens: [{ startIndex: 0, type: '' }]
+		},
+		{
+			line: '  }',
+			tokens: [{ startIndex: 0, type: '' }]
+		},
+		{
+			line: '}',
+			tokens: [{ startIndex: 0, type: '' }]
+		},
+		{
+			line:
+				"resource secrets1 'Microsoft.KeyVault/vaults/secrets@2018-02-14' = if (secrets0.id == '') {",
+			tokens: [
+				{ startIndex: 0, type: 'keyword.bicep' },
+				{ startIndex: 8, type: '' },
+				{ startIndex: 9, type: 'identifier.bicep' },
+				{ startIndex: 17, type: '' },
+				{ startIndex: 18, type: 'string.quote.bicep' },
+				{ startIndex: 19, type: 'string.bicep' },
+				{ startIndex: 64, type: '' },
+				{ startIndex: 67, type: 'keyword.bicep' },
+				{ startIndex: 69, type: '' },
+				{ startIndex: 71, type: 'identifier.bicep' },
+				{ startIndex: 79, type: '' },
+				{ startIndex: 80, type: 'identifier.bicep' },
+				{ startIndex: 82, type: '' },
+				{ startIndex: 86, type: 'string.quote.bicep' },
+				{ startIndex: 87, type: 'string.bicep' },
+				{ startIndex: 88, type: '' }
+			]
+		},
+		{
+			line: "  name: '${parent}/child1'",
+			tokens: [
+				{ startIndex: 0, type: '' },
+				{ startIndex: 2, type: 'identifier.bicep' },
+				{ startIndex: 6, type: '' },
+				{ startIndex: 8, type: 'string.quote.bicep' },
+				{ startIndex: 9, type: 'delimiter.bracket.bicep' },
+				{ startIndex: 11, type: 'identifier.bicep' },
+				{ startIndex: 17, type: 'delimiter.bracket.bicep' },
+				{ startIndex: 18, type: 'string.bicep' }
+			]
+		},
+		{
+			line: '  properties: {',
+			tokens: [
+				{ startIndex: 0, type: '' },
+				{ startIndex: 2, type: 'identifier.bicep' },
+				{ startIndex: 12, type: '' }
+			]
+		},
+		{
+			line: '  }',
+			tokens: [{ startIndex: 0, type: '' }]
+		},
+		{
+			line: '}',
+			tokens: [{ startIndex: 0, type: '' }]
+		},
+		{
+			line: '',
+			tokens: []
+		},
+		{
+			line:
+				"resource secrets2 'Microsoft.KeyVault/vaults/secrets@2018-02-14' = [for secret in secretsObject.secrets: {",
+			tokens: [
+				{ startIndex: 0, type: 'keyword.bicep' },
+				{ startIndex: 8, type: '' },
+				{ startIndex: 9, type: 'identifier.bicep' },
+				{ startIndex: 17, type: '' },
+				{ startIndex: 18, type: 'string.quote.bicep' },
+				{ startIndex: 19, type: 'string.bicep' },
+				{ startIndex: 64, type: '' },
+				{ startIndex: 68, type: 'keyword.bicep' },
+				{ startIndex: 71, type: '' },
+				{ startIndex: 72, type: 'identifier.bicep' },
+				{ startIndex: 78, type: '' },
+				{ startIndex: 79, type: 'keyword.bicep' },
+				{ startIndex: 81, type: '' },
+				{ startIndex: 82, type: 'identifier.bicep' },
+				{ startIndex: 95, type: '' },
+				{ startIndex: 96, type: 'identifier.bicep' },
+				{ startIndex: 103, type: '' }
+			]
+		},
+		{
+			line: "  name: 'asdfsd/forloop'",
+			tokens: [
+				{ startIndex: 0, type: '' },
+				{ startIndex: 2, type: 'identifier.bicep' },
+				{ startIndex: 6, type: '' },
+				{ startIndex: 8, type: 'string.quote.bicep' },
+				{ startIndex: 9, type: 'string.bicep' }
+			]
+		},
+		{
+			line: '  properties: {}',
+			tokens: [
+				{ startIndex: 0, type: '' },
+				{ startIndex: 2, type: 'identifier.bicep' },
+				{ startIndex: 12, type: '' }
+			]
+		},
+		{
+			line: '}]',
+			tokens: [{ startIndex: 0, type: '' }]
+		},
+		{
+			line: '',
+			tokens: []
+		},
+		{
+			line:
+				"resource secrets3 'Microsoft.KeyVault/vaults/secrets@2018-02-14' = [for secret in secretsObject.secrets: {",
+			tokens: [
+				{ startIndex: 0, type: 'keyword.bicep' },
+				{ startIndex: 8, type: '' },
+				{ startIndex: 9, type: 'identifier.bicep' },
+				{ startIndex: 17, type: '' },
+				{ startIndex: 18, type: 'string.quote.bicep' },
+				{ startIndex: 19, type: 'string.bicep' },
+				{ startIndex: 64, type: '' },
+				{ startIndex: 68, type: 'keyword.bicep' },
+				{ startIndex: 71, type: '' },
+				{ startIndex: 72, type: 'identifier.bicep' },
+				{ startIndex: 78, type: '' },
+				{ startIndex: 79, type: 'keyword.bicep' },
+				{ startIndex: 81, type: '' },
+				{ startIndex: 82, type: 'identifier.bicep' },
+				{ startIndex: 95, type: '' },
+				{ startIndex: 96, type: 'identifier.bicep' },
+				{ startIndex: 103, type: '' }
+			]
+		},
+		{
+			line: "  name: 'jk${true}asdf${23}.\\${SDF${secretsObject['secrets'][1]}'",
+			tokens: [
+				{ startIndex: 0, type: '' },
+				{ startIndex: 2, type: 'identifier.bicep' },
+				{ startIndex: 6, type: '' },
+				{ startIndex: 8, type: 'string.quote.bicep' },
+				{ startIndex: 9, type: 'string.bicep' },
+				{ startIndex: 11, type: 'delimiter.bracket.bicep' },
+				{ startIndex: 13, type: 'keyword.bicep' },
+				{ startIndex: 17, type: 'delimiter.bracket.bicep' },
+				{ startIndex: 18, type: 'string.bicep' },
+				{ startIndex: 22, type: 'delimiter.bracket.bicep' },
+				{ startIndex: 24, type: 'number.bicep' },
+				{ startIndex: 26, type: 'delimiter.bracket.bicep' },
+				{ startIndex: 27, type: 'string.bicep' },
+				{ startIndex: 28, type: 'string.escape.bicep' },
+				{ startIndex: 31, type: 'string.bicep' },
+				{ startIndex: 34, type: 'delimiter.bracket.bicep' },
+				{ startIndex: 36, type: 'identifier.bicep' },
+				{ startIndex: 49, type: '' },
+				{ startIndex: 50, type: 'string.quote.bicep' },
+				{ startIndex: 51, type: 'string.bicep' },
+				{ startIndex: 59, type: '' },
+				{ startIndex: 61, type: 'number.bicep' },
+				{ startIndex: 62, type: '' },
+				{ startIndex: 63, type: 'delimiter.bracket.bicep' },
+				{ startIndex: 64, type: 'string.bicep' }
+			]
+		},
+		{
+			line: '  properties: {',
+			tokens: [
+				{ startIndex: 0, type: '' },
+				{ startIndex: 2, type: 'identifier.bicep' },
+				{ startIndex: 12, type: '' }
+			]
+		},
+		{
+			line: '  }',
+			tokens: [{ startIndex: 0, type: '' }]
+		},
+		{
+			line: '}]',
+			tokens: [{ startIndex: 0, type: '' }]
+		},
+		{
+			line: '',
+			tokens: []
+		},
+		{
+			line:
+				"resource secrets4 'Microsoft.KeyVault/vaults/secrets@2018-02-14' = [for secret in secretsObject.secrets: if (true) {",
+			tokens: [
+				{ startIndex: 0, type: 'keyword.bicep' },
+				{ startIndex: 8, type: '' },
+				{ startIndex: 9, type: 'identifier.bicep' },
+				{ startIndex: 17, type: '' },
+				{ startIndex: 18, type: 'string.quote.bicep' },
+				{ startIndex: 19, type: 'string.bicep' },
+				{ startIndex: 64, type: '' },
+				{ startIndex: 68, type: 'keyword.bicep' },
+				{ startIndex: 71, type: '' },
+				{ startIndex: 72, type: 'identifier.bicep' },
+				{ startIndex: 78, type: '' },
+				{ startIndex: 79, type: 'keyword.bicep' },
+				{ startIndex: 81, type: '' },
+				{ startIndex: 82, type: 'identifier.bicep' },
+				{ startIndex: 95, type: '' },
+				{ startIndex: 96, type: 'identifier.bicep' },
+				{ startIndex: 103, type: '' },
+				{ startIndex: 105, type: 'keyword.bicep' },
+				{ startIndex: 107, type: '' },
+				{ startIndex: 109, type: 'keyword.bicep' },
+				{ startIndex: 113, type: '' }
+			]
+		},
+		{
+			line: "  'name': 'test'",
+			tokens: [
+				{ startIndex: 0, type: '' },
+				{ startIndex: 2, type: 'string.quote.bicep' },
+				{ startIndex: 3, type: 'string.bicep' },
+				{ startIndex: 8, type: '' },
+				{ startIndex: 10, type: 'string.quote.bicep' },
+				{ startIndex: 11, type: 'string.bicep' }
+			]
+		},
+		{
+			line: '  properties:{',
+			tokens: [
+				{ startIndex: 0, type: '' },
+				{ startIndex: 2, type: 'identifier.bicep' },
+				{ startIndex: 12, type: '' }
+			]
+		},
+		{
+			line: '  }',
+			tokens: [{ startIndex: 0, type: '' }]
+		},
+		{
+			line: '}]',
+			tokens: [{ startIndex: 0, type: '' }]
+		},
+		{
+			line: '',
+			tokens: []
+		},
+		{
+			line:
+				"resource virtualNetwork 'Microsoft.Network/virtualNetworks@2020-08-01' existing = {",
+			tokens: [
+				{ startIndex: 0, type: 'keyword.bicep' },
+				{ startIndex: 8, type: '' },
+				{ startIndex: 9, type: 'identifier.bicep' },
+				{ startIndex: 23, type: '' },
+				{ startIndex: 24, type: 'string.quote.bicep' },
+				{ startIndex: 25, type: 'string.bicep' },
+				{ startIndex: 70, type: '' },
+				{ startIndex: 71, type: 'keyword.bicep' },
+				{ startIndex: 79, type: '' }
+			]
+		},
+		{
+			line: "  name: 'myVnet'",
+			tokens: [
+				{ startIndex: 0, type: '' },
+				{ startIndex: 2, type: 'identifier.bicep' },
+				{ startIndex: 6, type: '' },
+				{ startIndex: 8, type: 'string.quote.bicep' },
+				{ startIndex: 9, type: 'string.bicep' }
+			]
+		},
+		{
+			line: '}',
+			tokens: [{ startIndex: 0, type: '' }]
+		},
+		{
+			line: '',
+			tokens: []
+		},
+		{
+			line: "var multi = ''''''",
+			tokens: [
+				{ startIndex: 0, type: 'keyword.bicep' },
+				{ startIndex: 3, type: '' },
+				{ startIndex: 4, type: 'identifier.bicep' },
+				{ startIndex: 9, type: '' },
+				{ startIndex: 12, type: 'string.quote.bicep' }
+			]
+		},
+		{
+			line: "var multi2 = '''",
+			tokens: [
+				{ startIndex: 0, type: 'keyword.bicep' },
+				{ startIndex: 3, type: '' },
+				{ startIndex: 4, type: 'identifier.bicep' },
+				{ startIndex: 10, type: '' },
+				{ startIndex: 13, type: 'string.quote.bicep' }
+			]
+		},
+		{
+			line: '      hello!',
+			tokens: [{ startIndex: 0, type: 'string.bicep' }]
+		},
+		{
+			line: "'''",
+			tokens: [{ startIndex: 0, type: 'string.quote.bicep' }]
+		},
+		{
+			line: '',
+			tokens: []
+		},
+		{
+			line: 'var func = resourceGroup().location',
+			tokens: [
+				{ startIndex: 0, type: 'keyword.bicep' },
+				{ startIndex: 3, type: '' },
+				{ startIndex: 4, type: 'identifier.bicep' },
+				{ startIndex: 8, type: '' },
+				{ startIndex: 11, type: 'identifier.bicep' },
+				{ startIndex: 24, type: '' },
+				{ startIndex: 27, type: 'identifier.bicep' }
+			]
+		},
+		{
+			line: "var func2 = reference('Microsoft.KeyVault/vaults/secrets', func)",
+			tokens: [
+				{ startIndex: 0, type: 'keyword.bicep' },
+				{ startIndex: 3, type: '' },
+				{ startIndex: 4, type: 'identifier.bicep' },
+				{ startIndex: 9, type: '' },
+				{ startIndex: 12, type: 'identifier.bicep' },
+				{ startIndex: 21, type: '' },
+				{ startIndex: 22, type: 'string.quote.bicep' },
+				{ startIndex: 23, type: 'string.bicep' },
+				{ startIndex: 57, type: '' },
+				{ startIndex: 59, type: 'identifier.bicep' },
+				{ startIndex: 63, type: '' }
+			]
+		},
+		{
+			line: 'var func3 = union({',
+			tokens: [
+				{ startIndex: 0, type: 'keyword.bicep' },
+				{ startIndex: 3, type: '' },
+				{ startIndex: 4, type: 'identifier.bicep' },
+				{ startIndex: 9, type: '' },
+				{ startIndex: 12, type: 'identifier.bicep' },
+				{ startIndex: 17, type: '' }
+			]
+		},
+		{
+			line: "  'abc': resourceGroup().id",
+			tokens: [
+				{ startIndex: 0, type: '' },
+				{ startIndex: 2, type: 'string.quote.bicep' },
+				{ startIndex: 3, type: 'string.bicep' },
+				{ startIndex: 7, type: '' },
+				{ startIndex: 9, type: 'identifier.bicep' },
+				{ startIndex: 22, type: '' },
+				{ startIndex: 25, type: 'identifier.bicep' }
+			]
+		},
+		{
+			line: '}, {',
+			tokens: [{ startIndex: 0, type: '' }]
+		},
+		{
+			line: "  'def': 'test'",
+			tokens: [
+				{ startIndex: 0, type: '' },
+				{ startIndex: 2, type: 'string.quote.bicep' },
+				{ startIndex: 3, type: 'string.bicep' },
+				{ startIndex: 7, type: '' },
+				{ startIndex: 9, type: 'string.quote.bicep' },
+				{ startIndex: 10, type: 'string.bicep' }
+			]
+		},
+		{
+			line: '})',
+			tokens: [{ startIndex: 0, type: '' }]
+		},
+		{
+			line: '',
+			tokens: []
+		},
+		{
+			line: '@allowed([',
+			tokens: [
+				{ startIndex: 0, type: '' },
+				{ startIndex: 1, type: 'identifier.bicep' },
+				{ startIndex: 8, type: '' }
+			]
+		},
+		{
+			line: "  'hello!'",
+			tokens: [
+				{ startIndex: 0, type: '' },
+				{ startIndex: 2, type: 'string.quote.bicep' },
+				{ startIndex: 3, type: 'string.bicep' }
+			]
+		},
+		{
+			line: "  'hi!'",
+			tokens: [
+				{ startIndex: 0, type: '' },
+				{ startIndex: 2, type: 'string.quote.bicep' },
+				{ startIndex: 3, type: 'string.bicep' }
+			]
+		},
+		{
+			line: '])',
+			tokens: [{ startIndex: 0, type: '' }]
+		},
+		{
+			line: '@secure()',
+			tokens: [
+				{ startIndex: 0, type: '' },
+				{ startIndex: 1, type: 'identifier.bicep' },
+				{ startIndex: 7, type: '' }
+			]
+		},
+		{
+			line: "param secureParam string = 'hello!'",
+			tokens: [
+				{ startIndex: 0, type: 'keyword.bicep' },
+				{ startIndex: 5, type: '' },
+				{ startIndex: 6, type: 'identifier.bicep' },
+				{ startIndex: 17, type: '' },
+				{ startIndex: 18, type: 'identifier.bicep' },
+				{ startIndex: 24, type: '' },
+				{ startIndex: 27, type: 'string.quote.bicep' },
+				{ startIndex: 28, type: 'string.bicep' }
+			]
+		},
+		{
+			line: '',
+			tokens: []
+		},
+		{
+			line: "var emojis = '💪😊😈🍕☕'",
+			tokens: [
+				{ startIndex: 0, type: 'keyword.bicep' },
+				{ startIndex: 3, type: '' },
+				{ startIndex: 4, type: 'identifier.bicep' },
+				{ startIndex: 10, type: '' },
+				{ startIndex: 13, type: 'string.quote.bicep' },
+				{ startIndex: 14, type: 'string.bicep' }
+			]
+		},
+		{
+			line: "var ninjaCat = '🐱‍👤'",
+			tokens: [
+				{ startIndex: 0, type: 'keyword.bicep' },
+				{ startIndex: 3, type: '' },
+				{ startIndex: 4, type: 'identifier.bicep' },
+				{ startIndex: 12, type: '' },
+				{ startIndex: 15, type: 'string.quote.bicep' },
+				{ startIndex: 16, type: 'string.bicep' }
+			]
+		},
+		{
+			line: '',
+			tokens: []
+		},
+		{
+			line: '/* block */',
+			tokens: [{ startIndex: 0, type: 'comment.bicep' }]
+		},
+		{
+			line: '',
+			tokens: []
+		},
+		{
+			line: '/*',
+			tokens: [{ startIndex: 0, type: 'comment.bicep' }]
+		},
+		{
+			line: '朝辞白帝彩云间',
+			tokens: [{ startIndex: 0, type: 'comment.bicep' }]
+		},
+		{
+			line: '千里江陵一日还',
+			tokens: [{ startIndex: 0, type: 'comment.bicep' }]
+		},
+		{
+			line: '两岸猿声啼不住',
+			tokens: [{ startIndex: 0, type: 'comment.bicep' }]
+		},
+		{
+			line: '轻舟已过万重山',
+			tokens: [{ startIndex: 0, type: 'comment.bicep' }]
+		},
+		{
+			line: '*/',
+			tokens: [{ startIndex: 0, type: 'comment.bicep' }]
+		},
+		{
+			line: '',
+			tokens: []
+		},
+		{
+			line: '// greek letters in comment: Π π Φ φ plus emoji 😎',
+			tokens: [{ startIndex: 0, type: 'comment.bicep' }]
+		},
+		{
+			line: 'var variousAlphabets = {',
+			tokens: [
+				{ startIndex: 0, type: 'keyword.bicep' },
+				{ startIndex: 3, type: '' },
+				{ startIndex: 4, type: 'identifier.bicep' },
+				{ startIndex: 20, type: '' }
+			]
+		},
+		{
+			line: "  'α': 'α'",
+			tokens: [
+				{ startIndex: 0, type: '' },
+				{ startIndex: 2, type: 'string.quote.bicep' },
+				{ startIndex: 3, type: 'string.bicep' },
+				{ startIndex: 5, type: '' },
+				{ startIndex: 7, type: 'string.quote.bicep' },
+				{ startIndex: 8, type: 'string.bicep' }
+			]
+		},
+		{
+			line: "  'Ωω': [",
+			tokens: [
+				{ startIndex: 0, type: '' },
+				{ startIndex: 2, type: 'string.quote.bicep' },
+				{ startIndex: 3, type: 'string.bicep' },
+				{ startIndex: 6, type: '' }
+			]
+		},
+		{
+			line: "    'Θμ'",
+			tokens: [
+				{ startIndex: 0, type: '' },
+				{ startIndex: 4, type: 'string.quote.bicep' },
+				{ startIndex: 5, type: 'string.bicep' }
+			]
+		},
+		{
+			line: '  ]',
+			tokens: [{ startIndex: 0, type: '' }]
+		},
+		{
+			line: "  'ążźćłóę': 'Cześć!'",
+			tokens: [
+				{ startIndex: 0, type: '' },
+				{ startIndex: 2, type: 'string.quote.bicep' },
+				{ startIndex: 3, type: 'string.bicep' },
+				{ startIndex: 11, type: '' },
+				{ startIndex: 13, type: 'string.quote.bicep' },
+				{ startIndex: 14, type: 'string.bicep' }
+			]
+		},
+		{
+			line: "  'áéóúñü': '¡Hola!'",
+			tokens: [
+				{ startIndex: 0, type: '' },
+				{ startIndex: 2, type: 'string.quote.bicep' },
+				{ startIndex: 3, type: 'string.bicep' },
+				{ startIndex: 10, type: '' },
+				{ startIndex: 12, type: 'string.quote.bicep' },
+				{ startIndex: 13, type: 'string.bicep' }
+			]
+		},
+		{
+			line: '',
+			tokens: []
+		},
+		{
+			line: "  '二头肌': '二头肌'",
+			tokens: [
+				{ startIndex: 0, type: '' },
+				{ startIndex: 2, type: 'string.quote.bicep' },
+				{ startIndex: 3, type: 'string.bicep' },
+				{ startIndex: 7, type: '' },
+				{ startIndex: 9, type: 'string.quote.bicep' },
+				{ startIndex: 10, type: 'string.bicep' }
+			]
+		},
+		{
+			line: '}',
+			tokens: [{ startIndex: 0, type: '' }]
+		},
+		{
+			line: '',
+			tokens: []
+		},
+		{
+			line: "output concatUnicodeStrings string = concat('Θμ', '二头肌', 'α')",
+			tokens: [
+				{ startIndex: 0, type: 'keyword.bicep' },
+				{ startIndex: 6, type: '' },
+				{ startIndex: 7, type: 'identifier.bicep' },
+				{ startIndex: 27, type: '' },
+				{ startIndex: 28, type: 'identifier.bicep' },
+				{ startIndex: 34, type: '' },
+				{ startIndex: 37, type: 'identifier.bicep' },
+				{ startIndex: 43, type: '' },
+				{ startIndex: 44, type: 'string.quote.bicep' },
+				{ startIndex: 45, type: 'string.bicep' },
+				{ startIndex: 48, type: '' },
+				{ startIndex: 50, type: 'string.quote.bicep' },
+				{ startIndex: 51, type: 'string.bicep' },
+				{ startIndex: 55, type: '' },
+				{ startIndex: 57, type: 'string.quote.bicep' },
+				{ startIndex: 58, type: 'string.bicep' },
+				{ startIndex: 60, type: '' }
+			]
+		},
+		{
+			line: "output interpolateUnicodeStrings string = 'Θμ二${emojis}头肌${ninjaCat}α'",
+			tokens: [
+				{ startIndex: 0, type: 'keyword.bicep' },
+				{ startIndex: 6, type: '' },
+				{ startIndex: 7, type: 'identifier.bicep' },
+				{ startIndex: 32, type: '' },
+				{ startIndex: 33, type: 'identifier.bicep' },
+				{ startIndex: 39, type: '' },
+				{ startIndex: 42, type: 'string.quote.bicep' },
+				{ startIndex: 43, type: 'string.bicep' },
+				{ startIndex: 46, type: 'delimiter.bracket.bicep' },
+				{ startIndex: 48, type: 'identifier.bicep' },
+				{ startIndex: 54, type: 'delimiter.bracket.bicep' },
+				{ startIndex: 55, type: 'string.bicep' },
+				{ startIndex: 57, type: 'delimiter.bracket.bicep' },
+				{ startIndex: 59, type: 'identifier.bicep' },
+				{ startIndex: 67, type: 'delimiter.bracket.bicep' },
+				{ startIndex: 68, type: 'string.bicep' }
+			]
+		},
+		{
+			line: '',
+			tokens: []
+		},
+		{
+			line: '// all of these should produce the same string',
+			tokens: [{ startIndex: 0, type: 'comment.bicep' }]
+		},
+		{
+			line: "var surrogate_char      = '𐐷'",
+			tokens: [
+				{ startIndex: 0, type: 'keyword.bicep' },
+				{ startIndex: 3, type: '' },
+				{ startIndex: 4, type: 'identifier.bicep' },
+				{ startIndex: 18, type: '' },
+				{ startIndex: 26, type: 'string.quote.bicep' },
+				{ startIndex: 27, type: 'string.bicep' }
+			]
+		},
+		{
+			line: "var surrogate_codepoint = '\\u{10437}'",
+			tokens: [
+				{ startIndex: 0, type: 'keyword.bicep' },
+				{ startIndex: 3, type: '' },
+				{ startIndex: 4, type: 'identifier.bicep' },
+				{ startIndex: 23, type: '' },
+				{ startIndex: 26, type: 'string.quote.bicep' },
+				{ startIndex: 27, type: 'string.escape.bicep' },
+				{ startIndex: 36, type: 'string.bicep' }
+			]
+		},
+		{
+			line: "var surrogate_pairs     = '\\u{D801}\\u{DC37}'",
+			tokens: [
+				{ startIndex: 0, type: 'keyword.bicep' },
+				{ startIndex: 3, type: '' },
+				{ startIndex: 4, type: 'identifier.bicep' },
+				{ startIndex: 19, type: '' },
+				{ startIndex: 26, type: 'string.quote.bicep' },
+				{ startIndex: 27, type: 'string.escape.bicep' },
+				{ startIndex: 43, type: 'string.bicep' }
+			]
+		},
+		{
+			line: '',
+			tokens: []
+		},
+		{
+			line: '// ascii escapes',
+			tokens: [{ startIndex: 0, type: 'comment.bicep' }]
+		},
+		{
+			line: "var hello = '❆ Hello\\u{20}World\\u{21} ❁'",
+			tokens: [
+				{ startIndex: 0, type: 'keyword.bicep' },
+				{ startIndex: 3, type: '' },
+				{ startIndex: 4, type: 'identifier.bicep' },
+				{ startIndex: 9, type: '' },
+				{ startIndex: 12, type: 'string.quote.bicep' },
+				{ startIndex: 13, type: 'string.bicep' },
+				{ startIndex: 20, type: 'string.escape.bicep' },
+				{ startIndex: 26, type: 'string.bicep' },
+				{ startIndex: 31, type: 'string.escape.bicep' },
+				{ startIndex: 37, type: 'string.bicep' }
+			]
+		},
+		{
+			line: '',
+			tokens: []
+		}
+	]
+]);

+ 131 - 0
src/bicep/bicep.ts

@@ -0,0 +1,131 @@
+// Copyright (c) Microsoft Corporation.
+// Licensed under the MIT License.
+
+import type { languages } from '../fillers/monaco-editor-core';
+
+const bounded = (text: string) => `\\b${text}\\b`;
+
+const identifierStart = '[_a-zA-Z]';
+const identifierContinue = '[_a-zA-Z0-9]';
+const identifier = bounded(`${identifierStart}${identifierContinue}*`);
+
+const keywords = [
+	'targetScope',
+	'resource',
+	'module',
+	'param',
+	'var',
+	'output',
+	'for',
+	'in',
+	'if',
+	'existing'
+];
+
+const namedLiterals = ['true', 'false', 'null'];
+
+const nonCommentWs = `[ \\t\\r\\n]`;
+
+const numericLiteral = `[0-9]+`;
+
+export const conf: languages.LanguageConfiguration = {
+	comments: {
+		lineComment: '//',
+		blockComment: ['/*', '*/']
+	},
+	brackets: [
+		['{', '}'],
+		['[', ']'],
+		['(', ')']
+	],
+	surroundingPairs: [
+		{ open: '{', close: '}' },
+		{ open: '[', close: ']' },
+		{ open: '(', close: ')' },
+		{ open: "'", close: "'" },
+		{ open: "'''", close: "'''" }
+	],
+	autoClosingPairs: [
+		{ open: '{', close: '}' },
+		{ open: '[', close: ']' },
+		{ open: '(', close: ')' },
+		{ open: "'", close: "'", notIn: ['string', 'comment'] },
+		{ open: "'''", close: "'''", notIn: ['string', 'comment'] }
+	],
+	autoCloseBefore: ":.,=}])' \n\t",
+	indentationRules: {
+		increaseIndentPattern: new RegExp(
+			'^((?!\\/\\/).)*(\\{[^}"\'`]*|\\([^)"\'`]*|\\[[^\\]"\'`]*)$'
+		),
+		decreaseIndentPattern: new RegExp('^((?!.*?\\/\\*).*\\*/)?\\s*[\\}\\]].*$')
+	}
+};
+
+export const language = <languages.IMonarchLanguage>{
+	defaultToken: '',
+	tokenPostfix: '.bicep',
+
+	brackets: [
+		{ open: '{', close: '}', token: 'delimiter.curly' },
+		{ open: '[', close: ']', token: 'delimiter.square' },
+		{ open: '(', close: ')', token: 'delimiter.parenthesis' }
+	],
+
+	symbols: /[=><!~?:&|+\-*/^%]+/,
+
+	keywords,
+	namedLiterals,
+
+	escapes: `\\\\(u{[0-9A-Fa-f]+}|n|r|t|\\\\|'|\\\${)`,
+
+	tokenizer: {
+		root: [{ include: '@expression' }, { include: '@whitespace' }],
+
+		stringVerbatim: [
+			{ regex: `(|'|'')[^']`, action: { token: 'string' } },
+			{ regex: `'''`, action: { token: 'string.quote', next: '@pop' } }
+		],
+
+		stringLiteral: [
+			{ regex: `\\\${`, action: { token: 'delimiter.bracket', next: '@bracketCounting' } },
+			{ regex: `[^\\\\'$]+`, action: { token: 'string' } },
+			{ regex: '@escapes', action: { token: 'string.escape' } },
+			{ regex: `\\\\.`, action: { token: 'string.escape.invalid' } },
+			{ regex: `'`, action: { token: 'string', next: '@pop' } }
+		],
+
+		bracketCounting: [
+			{ regex: `{`, action: { token: 'delimiter.bracket', next: '@bracketCounting' } },
+			{ regex: `}`, action: { token: 'delimiter.bracket', next: '@pop' } },
+			{ include: 'expression' }
+		],
+
+		comment: [
+			{ regex: `[^\\*]+`, action: { token: 'comment' } },
+			{ regex: `\\*\\/`, action: { token: 'comment', next: '@pop' } },
+			{ regex: `[\\/*]`, action: { token: 'comment' } }
+		],
+
+		whitespace: [
+			{ regex: nonCommentWs },
+			{ regex: `\\/\\*`, action: { token: 'comment', next: '@comment' } },
+			{ regex: `\\/\\/.*$`, action: { token: 'comment' } }
+		],
+
+		expression: [
+			{ regex: `'''`, action: { token: 'string.quote', next: '@stringVerbatim' } },
+			{ regex: `'`, action: { token: 'string.quote', next: '@stringLiteral' } },
+			{ regex: numericLiteral, action: { token: 'number' } },
+			{
+				regex: identifier,
+				action: {
+					cases: {
+						'@keywords': { token: 'keyword' },
+						'@namedLiterals': { token: 'keyword' },
+						'@default': { token: 'identifier' }
+					}
+				}
+			}
+		]
+	}
+};

+ 99 - 5
src/cpp/cpp.test.ts

@@ -439,7 +439,7 @@ testTokenization('cpp', [
 		{
 			line: '#ifdef VAR',
 			tokens: [
-				{ startIndex: 0, type: 'keyword.cpp' },
+				{ startIndex: 0, type: 'keyword.directive.cpp' },
 				{ startIndex: 6, type: '' },
 				{ startIndex: 7, type: 'identifier.cpp' }
 			]
@@ -447,7 +447,7 @@ testTokenization('cpp', [
 		{
 			line: '#define SUM(A,B) (A) + (B)',
 			tokens: [
-				{ startIndex: 0, type: 'keyword.cpp' },
+				{ startIndex: 0, type: 'keyword.directive.cpp' },
 				{ startIndex: 7, type: '' },
 				{ startIndex: 8, type: 'identifier.cpp' },
 				{ startIndex: 11, type: 'delimiter.parenthesis.cpp' },
@@ -784,12 +784,12 @@ testTokenization('cpp', [
 		},
 		{
 			line: '#endif',
-			tokens: [{ startIndex: 0, type: 'keyword.cpp' }]
+			tokens: [{ startIndex: 0, type: 'keyword.directive.cpp' }]
 		},
 		{
 			line: '#    ifdef VAR',
 			tokens: [
-				{ startIndex: 0, type: 'keyword.cpp' },
+				{ startIndex: 0, type: 'keyword.directive.cpp' },
 				{ startIndex: 10, type: '' },
 				{ startIndex: 11, type: 'identifier.cpp' }
 			]
@@ -797,7 +797,7 @@ testTokenization('cpp', [
 		{
 			line: '#	define SUM(A,B) (A) + (B)',
 			tokens: [
-				{ startIndex: 0, type: 'keyword.cpp' },
+				{ startIndex: 0, type: 'keyword.directive.cpp' },
 				{ startIndex: 8, type: '' },
 				{ startIndex: 9, type: 'identifier.cpp' },
 				{ startIndex: 12, type: 'delimiter.parenthesis.cpp' },
@@ -856,5 +856,99 @@ testTokenization('cpp', [
 				{ startIndex: 4, type: 'comment.cpp' }
 			]
 		}
+	],
+
+	// Annotations
+	[
+		{
+			line: '[[nodiscard]]',
+			tokens: [{ startIndex: 0, type: 'annotation.cpp' }]
+		}
+	],
+	[
+		{
+			// Example from http://eel.is/c++draft/dcl.attr
+			line: '[[using CC: opt(1), debug]]',
+			tokens: [
+				{ startIndex: 0, type: 'annotation.cpp' }, // [[
+				{ startIndex: 2, type: 'keyword.cpp' }, // using
+				{ startIndex: 7, type: '' },
+				{ startIndex: 8, type: 'annotation.cpp' }, // CC
+				{ startIndex: 10, type: 'delimiter.cpp' }, // colon
+				{ startIndex: 11, type: '' },
+				{ startIndex: 12, type: 'annotation.cpp' }, // opt
+				{ startIndex: 15, type: 'delimiter.parenthesis.cpp' }, // (
+				{ startIndex: 16, type: 'annotation.cpp' }, // 1
+				{ startIndex: 17, type: 'delimiter.parenthesis.cpp' }, // )
+				{ startIndex: 18, type: 'delimiter.cpp' }, // ,
+				{ startIndex: 19, type: '' },
+				{ startIndex: 20, type: 'annotation.cpp' } // debug]]
+			]
+		}
+	],
+	[
+		// Multiline and comments.
+		{
+			line: '[[nodiscard /*commented*/',
+			tokens: [
+				{ startIndex: 0, type: 'annotation.cpp' },
+				{ startIndex: 11, type: '' },
+				{ startIndex: 12, type: 'comment.cpp' }
+			]
+		},
+		{
+			line: ']] int i;',
+			tokens: [
+				{ startIndex: 0, type: 'annotation.cpp' },
+				{ startIndex: 2, type: '' },
+				{ startIndex: 3, type: 'keyword.int.cpp' },
+				{ startIndex: 6, type: '' },
+				{ startIndex: 7, type: 'identifier.cpp' },
+				{ startIndex: 8, type: 'delimiter.cpp' }
+			]
+		}
+	],
+	[
+		// We don't support newlines between annotation square brackets, but we do support other whitespace.
+		{
+			line: '[ [nodiscard] ]',
+			tokens: [{ startIndex: 0, type: 'annotation.cpp' }]
+		}
+	],
+
+	// Preprocessor directives with whitespace inamongst the characters,
+	// and crucially checking with whitespace before the initial #.
+	[
+		{
+			line: ' # if defined(SOMETHING)',
+			tokens: [
+				{ startIndex: 0, type: 'keyword.directive.cpp' },
+				{ startIndex: 5, type: '' },
+				{ startIndex: 6, type: 'identifier.cpp' },
+				{ startIndex: 13, type: 'delimiter.parenthesis.cpp' },
+				{ startIndex: 14, type: 'identifier.cpp' },
+				{ startIndex: 23, type: 'delimiter.parenthesis.cpp' }
+			]
+		},
+		{
+			line: '        #include <io.h>',
+			tokens: [
+				{ startIndex: 0, type: 'keyword.directive.include.cpp' },
+				{ startIndex: 16, type: '' },
+				{ startIndex: 17, type: 'keyword.directive.include.begin.cpp' },
+				{ startIndex: 18, type: 'string.include.identifier.cpp' },
+				{ startIndex: 22, type: 'keyword.directive.include.end.cpp' }
+			]
+		},
+		{
+			line: '      #  include <io.h>',
+			tokens: [
+				{ startIndex: 0, type: 'keyword.directive.include.cpp' },
+				{ startIndex: 16, type: '' },
+				{ startIndex: 17, type: 'keyword.directive.include.begin.cpp' },
+				{ startIndex: 18, type: 'string.include.identifier.cpp' },
+				{ startIndex: 22, type: 'keyword.directive.include.end.cpp' }
+			]
+		}
 	]
 ]);

+ 19 - 7
src/cpp/cpp.ts

@@ -294,17 +294,20 @@ export const language = <languages.IMonarchLanguage>{
 				}
 			],
 
-			// whitespace
-			{ include: '@whitespace' },
-
-			// [[ attributes ]].
-			[/\[\[.*\]\]/, 'annotation'],
+			// The preprocessor checks must be before whitespace as they check /^\s*#/ which
+			// otherwise fails to match later after other whitespace has been removed.
 
-			[/^\s*#include/, { token: 'keyword.directive.include', next: '@include' }],
+			// Inclusion
+			[/^\s*#\s*include/, { token: 'keyword.directive.include', next: '@include' }],
 
 			// Preprocessor directive
-			[/^\s*#\s*\w+/, 'keyword'],
+			[/^\s*#\s*\w+/, 'keyword.directive'],
 
+			// whitespace
+			{ include: '@whitespace' },
+
+			// [[ attributes ]].
+			[/\[\s*\[/, { token: 'annotation', next: '@annotation' }],
 			// delimiters and operators
 			[/[{}()\[\]]/, '@brackets'],
 			[/[<>](?!@symbols)/, '@brackets'],
@@ -384,6 +387,15 @@ export const language = <languages.IMonarchLanguage>{
 			[/.*/, 'string.raw']
 		],
 
+		annotation: [
+			{ include: '@whitespace' },
+			[/using|alignas/, 'keyword'],
+			[/[a-zA-Z0-9_]+/, 'annotation'],
+			[/[,:]/, 'delimiter'],
+			[/[()]/, '@brackets'],
+			[/\]\s*\]/, { token: 'annotation', next: '@pop' }]
+		],
+
 		include: [
 			[
 				/(\s*)(<)([^<>]*)(>)/,

+ 0 - 1
src/csharp/csharp.ts

@@ -125,7 +125,6 @@ export const language = <languages.IMonarchLanguage>{
 		'event',
 		'method',
 		'param',
-		'property',
 		'public',
 		'protected',
 		'internal',

+ 12 - 0
src/css/css.test.ts

@@ -577,5 +577,17 @@ testTokenization('css', [
 				{ startIndex: 8, type: 'delimiter.bracket.css' }
 			]
 		}
+	],
+
+	[
+		{
+			line: "@import 'https://example.com/test.css';",
+			tokens: [
+				{ startIndex: 0, type: 'keyword.css' },
+				{ startIndex: 7, type: '' },
+				{ startIndex: 8, type: 'string.css' },
+				{ startIndex: 38, type: 'delimiter.css' }
+			]
+		}
 	]
 ]);

+ 1 - 0
src/css/css.ts

@@ -113,6 +113,7 @@ export const language = <languages.IMonarchLanguage>{
 			{ include: '@functioninvocation' },
 			{ include: '@numbers' },
 			{ include: '@name' },
+			{ include: '@strings' },
 			['([<>=\\+\\-\\*\\/\\^\\|\\~,])', 'delimiter'],
 			[',', 'delimiter']
 		],

+ 1 - 1
src/dart/dart.ts

@@ -181,7 +181,7 @@ export const language = <languages.IMonarchLanguage>{
 					}
 				}
 			],
-			[/(?<![a-zA-Z0-9_$])([_$]*[A-Z][a-zA-Z0-9_$]*)/, 'type.identifier'], // to show class names nicely
+			[/[A-Z_$][\w\$]*/, 'type.identifier'], // show class names
 			// [/[A-Z][\w\$]*/, 'identifier'],
 
 			// whitespace

+ 13 - 0
src/elixir/elixir.contribution.ts

@@ -0,0 +1,13 @@
+/*---------------------------------------------------------------------------------------------
+ *  Copyright (c) Microsoft Corporation. All rights reserved.
+ *  Licensed under the MIT License. See License.txt in the project root for license information.
+ *--------------------------------------------------------------------------------------------*/
+
+import { registerLanguage } from '../_.contribution';
+
+registerLanguage({
+	id: 'elixir',
+	extensions: ['.ex', '.exs'],
+	aliases: ['Elixir', 'elixir', 'ex'],
+	loader: () => import('./elixir')
+});

+ 376 - 0
src/elixir/elixir.test.ts

@@ -0,0 +1,376 @@
+/*---------------------------------------------------------------------------------------------
+ *  Copyright (c) Microsoft Corporation. All rights reserved.
+ *  Licensed under the MIT License. See License.txt in the project root for license information.
+ *--------------------------------------------------------------------------------------------*/
+
+import { testTokenization } from '../test/testRunner';
+
+testTokenization('elixir', [
+	// Keywords - module definition
+	[
+		{
+			line: 'defmodule Foo do end',
+			tokens: [
+				{ startIndex: 0, type: 'keyword.declaration.elixir' },
+				{ startIndex: 9, type: 'white.elixir' },
+				{ startIndex: 10, type: 'type.identifier.elixir' },
+				{ startIndex: 13, type: 'white.elixir' },
+				{ startIndex: 14, type: 'keyword.elixir' },
+				{ startIndex: 16, type: 'white.elixir' },
+				{ startIndex: 17, type: 'keyword.elixir' }
+			]
+		}
+	],
+	// Keywords - function definition
+	[
+		{
+			line: 'def foo(x) do end',
+			tokens: [
+				{ startIndex: 0, type: 'keyword.declaration.elixir' },
+				{ startIndex: 3, type: 'white.elixir' },
+				{ startIndex: 4, type: 'function.elixir' },
+				{ startIndex: 7, type: 'delimiter.parenthesis.elixir' },
+				{ startIndex: 8, type: 'identifier.elixir' },
+				{ startIndex: 9, type: 'delimiter.parenthesis.elixir' },
+				{ startIndex: 10, type: 'white.elixir' },
+				{ startIndex: 11, type: 'keyword.elixir' },
+				{ startIndex: 13, type: 'white.elixir' },
+				{ startIndex: 14, type: 'keyword.elixir' }
+			]
+		}
+	],
+	// Keywords - macro
+	[
+		{
+			line: 'defmacro mac(name) do quote do def unquote(name)() do nil end end end',
+			tokens: [
+				{ startIndex: 0, type: 'keyword.declaration.elixir' },
+				{ startIndex: 8, type: 'white.elixir' },
+				{ startIndex: 9, type: 'function.elixir' },
+				{ startIndex: 12, type: 'delimiter.parenthesis.elixir' },
+				{ startIndex: 13, type: 'identifier.elixir' },
+				{ startIndex: 17, type: 'delimiter.parenthesis.elixir' },
+				{ startIndex: 18, type: 'white.elixir' },
+				{ startIndex: 19, type: 'keyword.elixir' },
+				{ startIndex: 21, type: 'white.elixir' },
+				{ startIndex: 22, type: 'keyword.elixir' },
+				{ startIndex: 27, type: 'white.elixir' },
+				{ startIndex: 28, type: 'keyword.elixir' },
+				{ startIndex: 30, type: 'white.elixir' },
+				{ startIndex: 31, type: 'keyword.declaration.elixir' },
+				{ startIndex: 34, type: 'white.elixir' },
+				{ startIndex: 35, type: 'keyword.elixir' },
+				{ startIndex: 42, type: 'delimiter.parenthesis.elixir' },
+				{ startIndex: 43, type: 'identifier.elixir' },
+				{ startIndex: 47, type: 'delimiter.parenthesis.elixir' },
+				{ startIndex: 50, type: 'white.elixir' },
+				{ startIndex: 51, type: 'keyword.elixir' },
+				{ startIndex: 53, type: 'white.elixir' },
+				{ startIndex: 54, type: 'constant.language.elixir' },
+				{ startIndex: 57, type: 'white.elixir' },
+				{ startIndex: 58, type: 'keyword.elixir' },
+				{ startIndex: 61, type: 'white.elixir' },
+				{ startIndex: 62, type: 'keyword.elixir' },
+				{ startIndex: 65, type: 'white.elixir' },
+				{ startIndex: 66, type: 'keyword.elixir' }
+			]
+		}
+	],
+	// Comments
+	[
+		{
+			line: 'nil # comment',
+			tokens: [
+				{ startIndex: 0, type: 'constant.language.elixir' },
+				{ startIndex: 3, type: 'white.elixir' },
+				{ startIndex: 4, type: 'comment.punctuation.elixir' },
+				{ startIndex: 5, type: 'comment.elixir' }
+			]
+		}
+	],
+	// Keyword list shorthand
+	[
+		{
+			line: '["key": value]',
+			tokens: [
+				{ startIndex: 0, type: 'delimiter.square.elixir' },
+				{ startIndex: 1, type: 'constant.delimiter.elixir' },
+				{ startIndex: 2, type: 'constant.elixir' },
+				{ startIndex: 5, type: 'constant.delimiter.elixir' },
+				{ startIndex: 7, type: 'white.elixir' },
+				{ startIndex: 8, type: 'identifier.elixir' },
+				{ startIndex: 13, type: 'delimiter.square.elixir' }
+			]
+		}
+	],
+	// Numbers
+	[
+		{
+			line: '[1,1.23,1.23e-10,0xab,0o171,0b01001]',
+			tokens: [
+				{ startIndex: 0, type: 'delimiter.square.elixir' },
+				{ startIndex: 1, type: 'number.elixir' },
+				{ startIndex: 2, type: 'punctuation.elixir' },
+				{ startIndex: 3, type: 'number.float.elixir' },
+				{ startIndex: 7, type: 'punctuation.elixir' },
+				{ startIndex: 8, type: 'number.float.elixir' },
+				{ startIndex: 16, type: 'punctuation.elixir' },
+				{ startIndex: 17, type: 'number.hex.elixir' },
+				{ startIndex: 21, type: 'punctuation.elixir' },
+				{ startIndex: 22, type: 'number.octal.elixir' },
+				{ startIndex: 27, type: 'punctuation.elixir' },
+				{ startIndex: 28, type: 'number.binary.elixir' },
+				{ startIndex: 35, type: 'delimiter.square.elixir' }
+			]
+		}
+	],
+	// Unused bindings
+	[
+		{
+			line: 'def foo(_x) do _y = 1 end',
+			tokens: [
+				{ startIndex: 0, type: 'keyword.declaration.elixir' },
+				{ startIndex: 3, type: 'white.elixir' },
+				{ startIndex: 4, type: 'function.elixir' },
+				{ startIndex: 7, type: 'delimiter.parenthesis.elixir' },
+				{ startIndex: 8, type: 'comment.unused.elixir' },
+				{ startIndex: 10, type: 'delimiter.parenthesis.elixir' },
+				{ startIndex: 11, type: 'white.elixir' },
+				{ startIndex: 12, type: 'keyword.elixir' },
+				{ startIndex: 14, type: 'white.elixir' },
+				{ startIndex: 15, type: 'comment.unused.elixir' },
+				{ startIndex: 17, type: 'white.elixir' },
+				{ startIndex: 18, type: 'operator.elixir' },
+				{ startIndex: 19, type: 'white.elixir' },
+				{ startIndex: 20, type: 'number.elixir' },
+				{ startIndex: 21, type: 'white.elixir' },
+				{ startIndex: 22, type: 'keyword.elixir' }
+			]
+		}
+	],
+	// Function calls
+	[
+		{
+			line: 'foo(x)',
+			tokens: [
+				{ startIndex: 0, type: 'function.call.elixir' },
+				{ startIndex: 3, type: 'delimiter.parenthesis.elixir' },
+				{ startIndex: 4, type: 'identifier.elixir' },
+				{ startIndex: 5, type: 'delimiter.parenthesis.elixir' }
+			]
+		}
+	],
+	[
+		{
+			line: 'foo.()',
+			tokens: [
+				{ startIndex: 0, type: 'function.call.elixir' },
+				{ startIndex: 3, type: 'operator.elixir' },
+				{ startIndex: 4, type: 'delimiter.parenthesis.elixir' }
+			]
+		}
+	],
+	[
+		{
+			line: 'Mod.foo()',
+			tokens: [
+				{ startIndex: 0, type: 'type.identifier.elixir' },
+				{ startIndex: 3, type: 'operator.elixir' },
+				{ startIndex: 4, type: 'function.call.elixir' },
+				{ startIndex: 7, type: 'delimiter.parenthesis.elixir' }
+			]
+		}
+	],
+	// Function call (Erlang module)
+	[
+		{
+			line: ':mo.foo()',
+			tokens: [
+				{ startIndex: 0, type: 'constant.punctuation.elixir' },
+				{ startIndex: 1, type: 'constant.elixir' },
+				{ startIndex: 3, type: 'operator.elixir' },
+				{ startIndex: 4, type: 'function.call.elixir' },
+				{ startIndex: 7, type: 'delimiter.parenthesis.elixir' }
+			]
+		}
+	],
+	// Function call (pipe)
+	[
+		{
+			line: '1 |> abs()',
+			tokens: [
+				{ startIndex: 0, type: 'number.elixir' },
+				{ startIndex: 1, type: 'white.elixir' },
+				{ startIndex: 2, type: 'operator.elixir' },
+				{ startIndex: 4, type: 'white.elixir' },
+				{ startIndex: 5, type: 'function.call.elixir' },
+				{ startIndex: 8, type: 'delimiter.parenthesis.elixir' }
+			]
+		}
+	],
+	// Function reference
+	[
+		{
+			line: '&max(&1,&2)',
+			tokens: [
+				{ startIndex: 0, type: 'operator.elixir' },
+				{ startIndex: 1, type: 'function.call.elixir' },
+				{ startIndex: 4, type: 'delimiter.parenthesis.elixir' },
+				{ startIndex: 5, type: 'operator.elixir' },
+				{ startIndex: 7, type: 'punctuation.elixir' },
+				{ startIndex: 8, type: 'operator.elixir' },
+				{ startIndex: 10, type: 'delimiter.parenthesis.elixir' }
+			]
+		}
+	],
+	// Strings
+	[
+		{
+			line: '"foo"',
+			tokens: [
+				{ startIndex: 0, type: 'string.delimiter.elixir' },
+				{ startIndex: 1, type: 'string.elixir' },
+				{ startIndex: 4, type: 'string.delimiter.elixir' }
+			]
+		}
+	],
+	[
+		{
+			line: '"foo \\u0065\\u0301 #{1}"',
+			tokens: [
+				{ startIndex: 0, type: 'string.delimiter.elixir' },
+				{ startIndex: 1, type: 'string.elixir' },
+				{ startIndex: 5, type: 'constant.character.escape.elixir' },
+				{ startIndex: 17, type: 'string.elixir' },
+				{ startIndex: 18, type: 'delimiter.bracket.embed.elixir' },
+				{ startIndex: 20, type: 'number.elixir' },
+				{ startIndex: 21, type: 'delimiter.bracket.embed.elixir' },
+				{ startIndex: 22, type: 'string.delimiter.elixir' }
+			]
+		}
+	],
+	[
+		{
+			line: '"""heredoc"""',
+			tokens: [
+				{ startIndex: 0, type: 'string.delimiter.elixir' },
+				{ startIndex: 3, type: 'string.elixir' },
+				{ startIndex: 10, type: 'string.delimiter.elixir' }
+			]
+		}
+	],
+	// Atom strings
+	[
+		{
+			line: ':"atom"',
+			tokens: [
+				{ startIndex: 0, type: 'constant.delimiter.elixir' },
+				{ startIndex: 2, type: 'constant.elixir' },
+				{ startIndex: 6, type: 'constant.delimiter.elixir' }
+			]
+		}
+	],
+	// Sigils (string)
+	[
+		{
+			line: '~s{foo}',
+			tokens: [
+				{ startIndex: 0, type: 'string.delimiter.elixir' },
+				{ startIndex: 3, type: 'string.elixir' },
+				{ startIndex: 6, type: 'string.delimiter.elixir' }
+			]
+		}
+	],
+	// Sigils (regexp)
+	[
+		{
+			line: '~r/foo/',
+			tokens: [
+				{ startIndex: 0, type: 'regexp.delimiter.elixir' },
+				{ startIndex: 3, type: 'regexp.elixir' },
+				{ startIndex: 6, type: 'regexp.delimiter.elixir' }
+			]
+		}
+	],
+	// Sigils (other)
+	[
+		{
+			line: '~D/foo/',
+			tokens: [
+				{ startIndex: 0, type: 'sigil.delimiter.elixir' },
+				{ startIndex: 3, type: 'sigil.elixir' },
+				{ startIndex: 6, type: 'sigil.delimiter.elixir' }
+			]
+		}
+	],
+	// Sigils (no interpolation)
+	[
+		{
+			line: '~W/foo#{1}/',
+			tokens: [
+				{ startIndex: 0, type: 'sigil.delimiter.elixir' },
+				{ startIndex: 3, type: 'sigil.elixir' },
+				{ startIndex: 10, type: 'sigil.delimiter.elixir' }
+			]
+		}
+	],
+	// Module attributes
+	[
+		{
+			line: '@attr 1',
+			tokens: [
+				{ startIndex: 0, type: 'variable.elixir' },
+				{ startIndex: 5, type: 'white.elixir' },
+				{ startIndex: 6, type: 'number.elixir' }
+			]
+		}
+	],
+	// Module attributes (docs)
+	[
+		{
+			line: '@doc "foo"',
+			tokens: [{ startIndex: 0, type: 'comment.block.documentation.elixir' }]
+		}
+	],
+	// Operator definition
+	[
+		{
+			line: 'def a ~> b, do: max(a,b)',
+			tokens: [
+				{ startIndex: 0, type: 'keyword.declaration.elixir' },
+				{ startIndex: 3, type: 'white.elixir' },
+				{ startIndex: 4, type: 'identifier.elixir' },
+				{ startIndex: 5, type: 'white.elixir' },
+				{ startIndex: 6, type: 'operator.elixir' },
+				{ startIndex: 8, type: 'white.elixir' },
+				{ startIndex: 9, type: 'identifier.elixir' },
+				{ startIndex: 10, type: 'punctuation.elixir' },
+				{ startIndex: 11, type: 'white.elixir' },
+				{ startIndex: 12, type: 'constant.elixir' },
+				{ startIndex: 14, type: 'constant.punctuation.elixir' },
+				{ startIndex: 15, type: 'white.elixir' },
+				{ startIndex: 16, type: 'function.call.elixir' },
+				{ startIndex: 19, type: 'delimiter.parenthesis.elixir' },
+				{ startIndex: 20, type: 'identifier.elixir' },
+				{ startIndex: 21, type: 'punctuation.elixir' },
+				{ startIndex: 22, type: 'identifier.elixir' },
+				{ startIndex: 23, type: 'delimiter.parenthesis.elixir' }
+			]
+		}
+	],
+	// Constants
+	[
+		{
+			line: '[true,false,nil]',
+			tokens: [
+				{ startIndex: 0, type: 'delimiter.square.elixir' },
+				{ startIndex: 1, type: 'constant.language.elixir' },
+				{ startIndex: 5, type: 'punctuation.elixir' },
+				{ startIndex: 6, type: 'constant.language.elixir' },
+				{ startIndex: 11, type: 'punctuation.elixir' },
+				{ startIndex: 12, type: 'constant.language.elixir' },
+				{ startIndex: 15, type: 'delimiter.square.elixir' }
+			]
+		}
+	]
+]);

+ 631 - 0
src/elixir/elixir.ts

@@ -0,0 +1,631 @@
+/*---------------------------------------------------------------------------------------------
+ *  Copyright (c) Microsoft Corporation. All rights reserved.
+ *  Licensed under the MIT License. See License.txt in the project root for license information.
+ *--------------------------------------------------------------------------------------------*/
+
+import type { languages } from '../fillers/monaco-editor-core';
+
+export const conf: languages.LanguageConfiguration = {
+	comments: {
+		lineComment: '#'
+	},
+	brackets: [
+		['{', '}'],
+		['[', ']'],
+		['(', ')']
+	],
+	surroundingPairs: [
+		{ open: '{', close: '}' },
+		{ open: '[', close: ']' },
+		{ open: '(', close: ')' },
+		{ open: "'", close: "'" },
+		{ open: '"', close: '"' }
+	],
+	autoClosingPairs: [
+		{ open: "'", close: "'", notIn: ['string', 'comment'] },
+		{ open: '"', close: '"', notIn: ['comment'] },
+		{ open: '"""', close: '"""' },
+		{ open: '`', close: '`', notIn: ['string', 'comment'] },
+		{ open: '(', close: ')' },
+		{ open: '{', close: '}' },
+		{ open: '[', close: ']' },
+		{ open: '<<', close: '>>' }
+	],
+	indentationRules: {
+		increaseIndentPattern: /^\s*(after|else|catch|rescue|fn|[^#]*(do|<\-|\->|\{|\[|\=))\s*$/,
+		decreaseIndentPattern: /^\s*((\}|\])\s*$|(after|else|catch|rescue|end)\b)/
+	}
+};
+
+/**
+ * A Monarch lexer for the Elixir language.
+ *
+ * References:
+ *
+ * * Monarch documentation - https://microsoft.github.io/monaco-editor/monarch.html
+ * * Elixir lexer - https://github.com/elixir-makeup/makeup_elixir/blob/master/lib/makeup/lexers/elixir_lexer.ex
+ * * TextMate lexer (elixir-tmbundle) - https://github.com/elixir-editors/elixir-tmbundle/blob/master/Syntaxes/Elixir.tmLanguage
+ * * TextMate lexer (vscode-elixir-ls) - https://github.com/elixir-lsp/vscode-elixir-ls/blob/master/syntaxes/elixir.json
+ */
+export const language = <languages.IMonarchLanguage>{
+	defaultToken: 'source',
+	tokenPostfix: '.elixir',
+
+	brackets: [
+		{ open: '[', close: ']', token: 'delimiter.square' },
+		{ open: '(', close: ')', token: 'delimiter.parenthesis' },
+		{ open: '{', close: '}', token: 'delimiter.curly' },
+		{ open: '<<', close: '>>', token: 'delimiter.angle.special' }
+	],
+
+	// Below are lists/regexps to which we reference later.
+
+	declarationKeywords: [
+		'def',
+		'defp',
+		'defn',
+		'defnp',
+		'defguard',
+		'defguardp',
+		'defmacro',
+		'defmacrop',
+		'defdelegate',
+		'defcallback',
+		'defmacrocallback',
+		'defmodule',
+		'defprotocol',
+		'defexception',
+		'defimpl',
+		'defstruct'
+	],
+	operatorKeywords: ['and', 'in', 'not', 'or', 'when'],
+	namespaceKeywords: ['alias', 'import', 'require', 'use'],
+	otherKeywords: [
+		'after',
+		'case',
+		'catch',
+		'cond',
+		'do',
+		'else',
+		'end',
+		'fn',
+		'for',
+		'if',
+		'quote',
+		'raise',
+		'receive',
+		'rescue',
+		'super',
+		'throw',
+		'try',
+		'unless',
+		'unquote_splicing',
+		'unquote',
+		'with'
+	],
+	constants: ['true', 'false', 'nil'],
+	nameBuiltin: ['__MODULE__', '__DIR__', '__ENV__', '__CALLER__', '__STACKTRACE__'],
+
+	// Matches any of the operator names:
+	// <<< >>> ||| &&& ^^^ ~~~ === !== ~>> <~> |~> <|> == != <= >= && || \\ <> ++ -- |> =~ -> <- ~> <~ :: .. = < > + - * / | . ^ & !
+	operator: /-[->]?|!={0,2}|\*|\/|\\\\|&{1,3}|\.\.?|\^(?:\^\^)?|\+\+?|<(?:-|<<|=|>|\|>|~>?)?|=~|={1,3}|>(?:=|>>)?|\|~>|\|>|\|{1,3}|~>>?|~~~|::/,
+
+	// See https://hexdocs.pm/elixir/syntax-reference.html#variables
+	variableName: /[a-z_][a-zA-Z0-9_]*[?!]?/,
+
+	// See https://hexdocs.pm/elixir/syntax-reference.html#atoms
+	atomName: /[a-zA-Z_][a-zA-Z0-9_@]*[?!]?|@specialAtomName|@operator/,
+	specialAtomName: /\.\.\.|<<>>|%\{\}|%|\{\}/,
+
+	aliasPart: /[A-Z][a-zA-Z0-9_]*/,
+	moduleName: /@aliasPart(?:\.@aliasPart)*/,
+
+	// Sigil pairs are: """ """, ''' ''', " ", ' ', / /, | |, < >, { }, [ ], ( )
+	sigilSymmetricDelimiter: /"""|'''|"|'|\/|\|/,
+	sigilStartDelimiter: /@sigilSymmetricDelimiter|<|\{|\[|\(/,
+	sigilEndDelimiter: /@sigilSymmetricDelimiter|>|\}|\]|\)/,
+
+	decimal: /\d(?:_?\d)*/,
+	hex: /[0-9a-fA-F](_?[0-9a-fA-F])*/,
+	octal: /[0-7](_?[0-7])*/,
+	binary: /[01](_?[01])*/,
+
+	// See https://hexdocs.pm/elixir/master/String.html#module-escape-characters
+	escape: /\\u[0-9a-fA-F]{4}|\\x[0-9a-fA-F]{2}|\\./,
+
+	// The keys below correspond to tokenizer states.
+	// We start from the root state and match against its rules
+	// until we explicitly transition into another state.
+	// The `include` simply brings in all operations from the given state
+	// and is useful for improving readability.
+	tokenizer: {
+		root: [
+			{ include: '@whitespace' },
+			{ include: '@comments' },
+			// Keywords start as either an identifier or a string,
+			// but end with a : so it's important to match this first.
+			{ include: '@keywordsShorthand' },
+			{ include: '@numbers' },
+			{ include: '@identifiers' },
+			{ include: '@strings' },
+			{ include: '@atoms' },
+			{ include: '@sigils' },
+			{ include: '@attributes' },
+			{ include: '@symbols' }
+		],
+
+		// Whitespace
+
+		whitespace: [[/\s+/, 'white']],
+
+		// Comments
+
+		comments: [[/(#)(.*)/, ['comment.punctuation', 'comment']]],
+
+		// Keyword list shorthand
+
+		keywordsShorthand: [
+			[/(@atomName)(:)/, ['constant', 'constant.punctuation']],
+			// Use positive look-ahead to ensure the string is followed by :
+			// and should be considered a keyword.
+			[
+				/"(?=([^"]|#\{.*?\}|\\")*":)/,
+				{ token: 'constant.delimiter', next: '@doubleQuotedStringKeyword' }
+			],
+			[
+				/'(?=([^']|#\{.*?\}|\\')*':)/,
+				{ token: 'constant.delimiter', next: '@singleQuotedStringKeyword' }
+			]
+		],
+
+		doubleQuotedStringKeyword: [
+			[/":/, { token: 'constant.delimiter', next: '@pop' }],
+			{ include: '@stringConstantContentInterpol' }
+		],
+
+		singleQuotedStringKeyword: [
+			[/':/, { token: 'constant.delimiter', next: '@pop' }],
+			{ include: '@stringConstantContentInterpol' }
+		],
+
+		// Numbers
+
+		numbers: [
+			[/0b@binary/, 'number.binary'],
+			[/0o@octal/, 'number.octal'],
+			[/0x@hex/, 'number.hex'],
+			[/@decimal\.@decimal([eE]-?@decimal)?/, 'number.float'],
+			[/@decimal/, 'number']
+		],
+
+		// Identifiers
+
+		identifiers: [
+			// Tokenize identifier name in function-like definitions.
+			// Note: given `def a + b, do: nil`, `a` is not a function name,
+			// so we use negative look-ahead to ensure there's no operator.
+			[
+				/\b(defp?|defnp?|defmacrop?|defguardp?|defdelegate)(\s+)(@variableName)(?!\s+@operator)/,
+				[
+					'keyword.declaration',
+					'white',
+					{
+						cases: {
+							unquote: 'keyword',
+							'@default': 'function'
+						}
+					}
+				]
+			],
+			// Tokenize function calls
+			[
+				// In-scope call - an identifier followed by ( or .(
+				/(@variableName)(?=\s*\.?\s*\()/,
+				{
+					cases: {
+						// Tokenize as keyword in cases like `if(..., do: ..., else: ...)`
+						'@declarationKeywords': 'keyword.declaration',
+						'@namespaceKeywords': 'keyword',
+						'@otherKeywords': 'keyword',
+						'@default': 'function.call'
+					}
+				}
+			],
+			[
+				// Referencing function in a module
+				/(@moduleName)(\s*)(\.)(\s*)(@variableName)/,
+				['type.identifier', 'white', 'operator', 'white', 'function.call']
+			],
+			[
+				// Referencing function in an Erlang module
+				/(:)(@atomName)(\s*)(\.)(\s*)(@variableName)/,
+				['constant.punctuation', 'constant', 'white', 'operator', 'white', 'function.call']
+			],
+			[
+				// Piping into a function (tokenized separately as it may not have parentheses)
+				/(\|>)(\s*)(@variableName)/,
+				[
+					'operator',
+					'white',
+					{
+						cases: {
+							'@otherKeywords': 'keyword',
+							'@default': 'function.call'
+						}
+					}
+				]
+			],
+			[
+				// Function reference passed to another function
+				/(&)(\s*)(@variableName)/,
+				['operator', 'white', 'function.call']
+			],
+			// Language keywords, builtins, constants and variables
+			[
+				/@variableName/,
+				{
+					cases: {
+						'@declarationKeywords': 'keyword.declaration',
+						'@operatorKeywords': 'keyword.operator',
+						'@namespaceKeywords': 'keyword',
+						'@otherKeywords': 'keyword',
+						'@constants': 'constant.language',
+						'@nameBuiltin': 'variable.language',
+						'_.*': 'comment.unused',
+						'@default': 'identifier'
+					}
+				}
+			],
+			// Module names
+			[/@moduleName/, 'type.identifier']
+		],
+
+		// Strings
+
+		strings: [
+			[/"""/, { token: 'string.delimiter', next: '@doubleQuotedHeredoc' }],
+			[/'''/, { token: 'string.delimiter', next: '@singleQuotedHeredoc' }],
+			[/"/, { token: 'string.delimiter', next: '@doubleQuotedString' }],
+			[/'/, { token: 'string.delimiter', next: '@singleQuotedString' }]
+		],
+
+		doubleQuotedHeredoc: [
+			[/"""/, { token: 'string.delimiter', next: '@pop' }],
+			{ include: '@stringContentInterpol' }
+		],
+
+		singleQuotedHeredoc: [
+			[/'''/, { token: 'string.delimiter', next: '@pop' }],
+			{ include: '@stringContentInterpol' }
+		],
+
+		doubleQuotedString: [
+			[/"/, { token: 'string.delimiter', next: '@pop' }],
+			{ include: '@stringContentInterpol' }
+		],
+
+		singleQuotedString: [
+			[/'/, { token: 'string.delimiter', next: '@pop' }],
+			{ include: '@stringContentInterpol' }
+		],
+
+		// Atoms
+
+		atoms: [
+			[/(:)(@atomName)/, ['constant.punctuation', 'constant']],
+			[/:"/, { token: 'constant.delimiter', next: '@doubleQuotedStringAtom' }],
+			[/:'/, { token: 'constant.delimiter', next: '@singleQuotedStringAtom' }]
+		],
+
+		doubleQuotedStringAtom: [
+			[/"/, { token: 'constant.delimiter', next: '@pop' }],
+			{ include: '@stringConstantContentInterpol' }
+		],
+
+		singleQuotedStringAtom: [
+			[/'/, { token: 'constant.delimiter', next: '@pop' }],
+			{ include: '@stringConstantContentInterpol' }
+		],
+
+		// Sigils
+
+		// See https://elixir-lang.org/getting-started/sigils.html
+		// Sigils allow for typing values using their textual representation.
+		// All sigils start with ~ followed by a letter indicating sigil type
+		// and then a delimiter pair enclosing the textual representation.
+		// Optional modifiers are allowed after the closing delimiter.
+		// For instance a regular expressions can be written as:
+		// ~r/foo|bar/ ~r{foo|bar} ~r/foo|bar/g
+		//
+		// In general lowercase sigils allow for interpolation
+		// and escaped characters, whereas uppercase sigils don't
+		//
+		// During tokenization we want to distinguish some
+		// specific sigil types, namely string and regexp,
+		// so that they cen be themed separately.
+		//
+		// To reasonably handle all those combinations we leverage
+		// dot-separated states, so if we transition to @sigilStart.interpol.s.{.}
+		// then "sigilStart.interpol.s" state will match and also all
+		// the individual dot-separated parameters can be accessed.
+
+		sigils: [
+			[/~[a-z]@sigilStartDelimiter/, { token: '@rematch', next: '@sigil.interpol' }],
+			[/~[A-Z]@sigilStartDelimiter/, { token: '@rematch', next: '@sigil.noInterpol' }]
+		],
+
+		sigil: [
+			[/~([a-zA-Z])\{/, { token: '@rematch', switchTo: '@sigilStart.$S2.$1.{.}' }],
+			[/~([a-zA-Z])\[/, { token: '@rematch', switchTo: '@sigilStart.$S2.$1.[.]' }],
+			[/~([a-zA-Z])\(/, { token: '@rematch', switchTo: '@sigilStart.$S2.$1.(.)' }],
+			[/~([a-zA-Z])\</, { token: '@rematch', switchTo: '@sigilStart.$S2.$1.<.>' }],
+			[
+				/~([a-zA-Z])(@sigilSymmetricDelimiter)/,
+				{ token: '@rematch', switchTo: '@sigilStart.$S2.$1.$2.$2' }
+			]
+		],
+
+		// The definitions below expect states to be of the form:
+		//
+		// sigilStart.<interpol-or-noInterpol>.<sigil-letter>.<start-delimiter>.<end-delimiter>
+		// sigilContinue.<interpol-or-noInterpol>.<sigil-letter>.<start-delimiter>.<end-delimiter>
+		//
+		// The sigilStart state is used only to properly classify the token (as string/regex/sigil)
+		// and immediately switches to the sigilContinue sate, which handles the actual content
+		// and waits for the corresponding end delimiter.
+
+		'sigilStart.interpol.s': [
+			[
+				/~s@sigilStartDelimiter/,
+				{
+					token: 'string.delimiter',
+					switchTo: '@sigilContinue.$S2.$S3.$S4.$S5'
+				}
+			]
+		],
+
+		'sigilContinue.interpol.s': [
+			[
+				/(@sigilEndDelimiter)[a-zA-Z]*/,
+				{
+					cases: {
+						'$1==$S5': { token: 'string.delimiter', next: '@pop' },
+						'@default': 'string'
+					}
+				}
+			],
+			{ include: '@stringContentInterpol' }
+		],
+
+		'sigilStart.noInterpol.S': [
+			[
+				/~S@sigilStartDelimiter/,
+				{
+					token: 'string.delimiter',
+					switchTo: '@sigilContinue.$S2.$S3.$S4.$S5'
+				}
+			]
+		],
+
+		'sigilContinue.noInterpol.S': [
+			// Ignore escaped sigil end
+			[/(^|[^\\])\\@sigilEndDelimiter/, 'string'],
+			[
+				/(@sigilEndDelimiter)[a-zA-Z]*/,
+				{
+					cases: {
+						'$1==$S5': { token: 'string.delimiter', next: '@pop' },
+						'@default': 'string'
+					}
+				}
+			],
+			{ include: '@stringContent' }
+		],
+
+		'sigilStart.interpol.r': [
+			[
+				/~r@sigilStartDelimiter/,
+				{
+					token: 'regexp.delimiter',
+					switchTo: '@sigilContinue.$S2.$S3.$S4.$S5'
+				}
+			]
+		],
+
+		'sigilContinue.interpol.r': [
+			[
+				/(@sigilEndDelimiter)[a-zA-Z]*/,
+				{
+					cases: {
+						'$1==$S5': { token: 'regexp.delimiter', next: '@pop' },
+						'@default': 'regexp'
+					}
+				}
+			],
+			{ include: '@regexpContentInterpol' }
+		],
+
+		'sigilStart.noInterpol.R': [
+			[
+				/~R@sigilStartDelimiter/,
+				{
+					token: 'regexp.delimiter',
+					switchTo: '@sigilContinue.$S2.$S3.$S4.$S5'
+				}
+			]
+		],
+
+		'sigilContinue.noInterpol.R': [
+			// Ignore escaped sigil end
+			[/(^|[^\\])\\@sigilEndDelimiter/, 'regexp'],
+			[
+				/(@sigilEndDelimiter)[a-zA-Z]*/,
+				{
+					cases: {
+						'$1==$S5': { token: 'regexp.delimiter', next: '@pop' },
+						'@default': 'regexp'
+					}
+				}
+			],
+			{ include: '@regexpContent' }
+		],
+
+		// Fallback to the generic sigil by default
+		'sigilStart.interpol': [
+			[
+				/~([a-zA-Z])@sigilStartDelimiter/,
+				{
+					token: 'sigil.delimiter',
+					switchTo: '@sigilContinue.$S2.$S3.$S4.$S5'
+				}
+			]
+		],
+
+		'sigilContinue.interpol': [
+			[
+				/(@sigilEndDelimiter)[a-zA-Z]*/,
+				{
+					cases: {
+						'$1==$S5': { token: 'sigil.delimiter', next: '@pop' },
+						'@default': 'sigil'
+					}
+				}
+			],
+			{ include: '@sigilContentInterpol' }
+		],
+
+		'sigilStart.noInterpol': [
+			[
+				/~([a-zA-Z])@sigilStartDelimiter/,
+				{
+					token: 'sigil.delimiter',
+					switchTo: '@sigilContinue.$S2.$S3.$S4.$S5'
+				}
+			]
+		],
+
+		'sigilContinue.noInterpol': [
+			// Ignore escaped sigil end
+			[/(^|[^\\])\\@sigilEndDelimiter/, 'sigil'],
+			[
+				/(@sigilEndDelimiter)[a-zA-Z]*/,
+				{
+					cases: {
+						'$1==$S5': { token: 'sigil.delimiter', next: '@pop' },
+						'@default': 'sigil'
+					}
+				}
+			],
+			{ include: '@sigilContent' }
+		],
+
+		// Attributes
+
+		attributes: [
+			// Module @doc* attributes - tokenized as comments
+			[
+				/\@(module|type)?doc (~[sS])?"""/,
+				{
+					token: 'comment.block.documentation',
+					next: '@doubleQuotedHeredocDocstring'
+				}
+			],
+			[
+				/\@(module|type)?doc (~[sS])?"/,
+				{
+					token: 'comment.block.documentation',
+					next: '@doubleQuotedStringDocstring'
+				}
+			],
+			[/\@(module|type)?doc false/, 'comment.block.documentation'],
+			// Module attributes
+			[/\@(@variableName)/, 'variable']
+		],
+
+		doubleQuotedHeredocDocstring: [
+			[/"""/, { token: 'comment.block.documentation', next: '@pop' }],
+			{ include: '@docstringContent' }
+		],
+
+		doubleQuotedStringDocstring: [
+			[/"/, { token: 'comment.block.documentation', next: '@pop' }],
+			{ include: '@docstringContent' }
+		],
+
+		// Operators, punctuation, brackets
+
+		symbols: [
+			// Code point operator (either with regular character ?a or an escaped one ?\n)
+			[/\?(\\.|[^\\\s])/, 'number.constant'],
+			// Anonymous function arguments
+			[/&\d+/, 'operator'],
+			// Bitshift operators (must go before delimiters, so that << >> don't match first)
+			[/<<<|>>>/, 'operator'],
+			// Delimiter pairs
+			[/[()\[\]\{\}]|<<|>>/, '@brackets'],
+			// Triple dot is a valid name (must go before operators, so that .. doesn't match instead)
+			[/\.\.\./, 'identifier'],
+			// Punctuation => (must go before operators, so it's not tokenized as = then >)
+			[/=>/, 'punctuation'],
+			// Operators
+			[/@operator/, 'operator'],
+			// Punctuation
+			[/[:;,.%]/, 'punctuation']
+		],
+
+		// Generic helpers
+
+		stringContentInterpol: [
+			{ include: '@interpolation' },
+			{ include: '@escapeChar' },
+			{ include: '@stringContent' }
+		],
+
+		stringContent: [[/./, 'string']],
+
+		stringConstantContentInterpol: [
+			{ include: '@interpolation' },
+			{ include: '@escapeChar' },
+			{ include: '@stringConstantContent' }
+		],
+
+		stringConstantContent: [[/./, 'constant']],
+
+		regexpContentInterpol: [
+			{ include: '@interpolation' },
+			{ include: '@escapeChar' },
+			{ include: '@regexpContent' }
+		],
+
+		regexpContent: [
+			// # may be a regular regexp char, so we use a heuristic
+			// assuming a # surrounded by whitespace is actually a comment.
+			[/(\s)(#)(\s.*)$/, ['white', 'comment.punctuation', 'comment']],
+			[/./, 'regexp']
+		],
+
+		sigilContentInterpol: [
+			{ include: '@interpolation' },
+			{ include: '@escapeChar' },
+			{ include: '@sigilContent' }
+		],
+
+		sigilContent: [[/./, 'sigil']],
+
+		docstringContent: [[/./, 'comment.block.documentation']],
+
+		escapeChar: [[/@escape/, 'constant.character.escape']],
+
+		interpolation: [
+			[/#{/, { token: 'delimiter.bracket.embed', next: '@interpolationContinue' }]
+		],
+
+		interpolationContinue: [
+			[/}/, { token: 'delimiter.bracket.embed', next: '@pop' }],
+			// Interpolation brackets may contain arbitrary code,
+			// so we simply match against all the root rules,
+			// until we reach interpolation end (the above matches).
+			{ include: '@root' }
+		]
+	}
+};

+ 1 - 1
src/handlebars/handlebars.contribution.ts

@@ -8,7 +8,7 @@ import { registerLanguage } from '../_.contribution';
 registerLanguage({
 	id: 'handlebars',
 	extensions: ['.handlebars', '.hbs'],
-	aliases: ['Handlebars', 'handlebars'],
+	aliases: ['Handlebars', 'handlebars', 'hbs'],
 	mimetypes: ['text/x-handlebars-template'],
 	loader: () => import('./handlebars')
 });

+ 1 - 1
src/julia/julia.ts

@@ -404,7 +404,7 @@ export const language = <languages.IMonarchLanguage>{
 			[/\$\w+/, 'key'],
 			[/\$\(/, 'key', '@paste'],
 
-			[/@@ident/, 'annotation'],
+			[/@@@ident/, 'annotation'],
 
 			// whitespace
 			{ include: '@whitespace' },

+ 14 - 0
src/liquid/liquid.contribution.ts

@@ -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.
+ *--------------------------------------------------------------------------------------------*/
+
+import { registerLanguage } from '../_.contribution';
+
+registerLanguage({
+	id: 'liquid',
+	extensions: ['.liquid', '.html.liquid'],
+	aliases: ['Liquid', 'liquid'],
+	mimetypes: ['application/liquid'],
+	loader: () => import('./liquid')
+});

+ 211 - 0
src/liquid/liquid.test.ts

@@ -0,0 +1,211 @@
+/*---------------------------------------------------------------------------------------------
+ *  Copyright (c) Microsoft Corporation. All rights reserved.
+ *  Licensed under the MIT License. See License.txt in the project root for license information.
+ *--------------------------------------------------------------------------------------------*/
+
+import { testTokenization } from '../test/testRunner';
+
+testTokenization(
+	['liquid', 'css'],
+	[
+		// Just HTML
+		[
+			{
+				line: '<h1>liquid!</h1>',
+				tokens: [
+					{ startIndex: 0, type: 'delimiter.html' },
+					{ startIndex: 1, type: 'tag.html' },
+					{ startIndex: 3, type: 'delimiter.html' },
+					{ startIndex: 4, type: '' },
+					{ startIndex: 11, type: 'delimiter.html' },
+					{ startIndex: 13, type: 'tag.html' },
+					{ startIndex: 15, type: 'delimiter.html' }
+				]
+			}
+		],
+
+		// Simple output
+		[
+			{
+				line: '<h1>{{ title }}</h1>',
+				tokens: [
+					{ startIndex: 0, type: 'delimiter.html' },
+					{ startIndex: 1, type: 'tag.html' },
+					{ startIndex: 3, type: 'delimiter.html' },
+					{ startIndex: 4, type: 'delimiter.output.liquid' },
+					{ startIndex: 6, type: '' },
+					{ startIndex: 7, type: 'variable.liquid' },
+					{ startIndex: 12, type: '' },
+					{ startIndex: 13, type: 'delimiter.output.liquid' },
+					{ startIndex: 15, type: 'delimiter.html' },
+					{ startIndex: 17, type: 'tag.html' },
+					{ startIndex: 19, type: 'delimiter.html' }
+				]
+			}
+		],
+
+		// // Output filter
+		[
+			{
+				line: '<h1>{{ 3.14159265 | round | default: "pi"  }}</h1>',
+				tokens: [
+					{ startIndex: 0, type: 'delimiter.html' },
+					{ startIndex: 1, type: 'tag.html' },
+					{ startIndex: 3, type: 'delimiter.html' },
+					{ startIndex: 4, type: 'delimiter.output.liquid' },
+					{ startIndex: 6, type: '' },
+					{ startIndex: 7, type: 'number.liquid' },
+					{ startIndex: 17, type: '' },
+					{ startIndex: 20, type: 'predefined.liquid' },
+					{ startIndex: 25, type: '' },
+					{ startIndex: 28, type: 'predefined.liquid' },
+					{ startIndex: 35, type: 'variable.liquid' },
+					{ startIndex: 36, type: '' },
+					{ startIndex: 37, type: 'string.liquid' },
+					{ startIndex: 41, type: '' },
+					{ startIndex: 43, type: 'delimiter.output.liquid' },
+					{ startIndex: 45, type: 'delimiter.html' },
+					{ startIndex: 47, type: 'tag.html' },
+					{ startIndex: 49, type: 'delimiter.html' }
+				]
+			}
+		],
+
+		// Simple Tag
+		[
+			{
+				line: '<div>{% render "files/file123.html" %}</div>',
+				tokens: [
+					{ startIndex: 0, type: 'delimiter.html' },
+					{ startIndex: 1, type: 'tag.html' },
+					{ startIndex: 4, type: 'delimiter.html' },
+					{ startIndex: 5, type: 'delimiter.tag.liquid' },
+					{ startIndex: 7, type: '' },
+					{ startIndex: 8, type: 'predefined.liquid' },
+					{ startIndex: 14, type: '' },
+					{ startIndex: 15, type: 'string.liquid' },
+					{ startIndex: 35, type: '' },
+					{ startIndex: 36, type: 'delimiter.tag.liquid' },
+					{ startIndex: 38, type: 'delimiter.html' },
+					{ startIndex: 40, type: 'tag.html' },
+					{ startIndex: 43, type: 'delimiter.html' }
+				]
+			}
+		],
+
+		// Tag with drop
+		[
+			{
+				line: '<div>{{ thing.other_thing }}</div>',
+				tokens: [
+					{ startIndex: 0, type: 'delimiter.html' },
+					{ startIndex: 1, type: 'tag.html' },
+					{ startIndex: 4, type: 'delimiter.html' },
+					{ startIndex: 5, type: 'delimiter.output.liquid' },
+					{ startIndex: 7, type: '' },
+					{ startIndex: 8, type: 'variable.liquid' },
+					{ startIndex: 13, type: '' },
+					{ startIndex: 14, type: 'variable.liquid' },
+					{ startIndex: 25, type: '' },
+					{ startIndex: 26, type: 'delimiter.output.liquid' },
+					{ startIndex: 28, type: 'delimiter.html' },
+					{ startIndex: 30, type: 'tag.html' },
+					{ startIndex: 33, type: 'delimiter.html' }
+				]
+			}
+		],
+
+		// If tag / keywords / block style tags
+		[
+			{
+				line:
+					'<div>{% if true=false %}<div>True</div>{% else %}<div>False</div>{% endif %}</div>',
+				tokens: [
+					{ startIndex: 0, type: 'delimiter.html' },
+					{ startIndex: 1, type: 'tag.html' },
+					{ startIndex: 4, type: 'delimiter.html' },
+					{ startIndex: 5, type: 'delimiter.tag.liquid' },
+					{ startIndex: 7, type: '' },
+					{ startIndex: 8, type: 'predefined.liquid' },
+					{ startIndex: 10, type: '' },
+					{ startIndex: 11, type: 'keyword.liquid' },
+					{ startIndex: 15, type: '' },
+					{ startIndex: 16, type: 'keyword.liquid' },
+					{ startIndex: 21, type: '' },
+					{ startIndex: 22, type: 'delimiter.tag.liquid' },
+					{ startIndex: 24, type: 'delimiter.html' },
+					{ startIndex: 25, type: 'tag.html' },
+					{ startIndex: 28, type: 'delimiter.html' },
+					{ startIndex: 29, type: '' },
+					{ startIndex: 33, type: 'delimiter.html' },
+					{ startIndex: 35, type: 'tag.html' },
+					{ startIndex: 38, type: 'delimiter.html' },
+					{ startIndex: 39, type: 'delimiter.tag.liquid' },
+					{ startIndex: 41, type: '' },
+					{ startIndex: 42, type: 'predefined.liquid' },
+					{ startIndex: 46, type: '' },
+					{ startIndex: 47, type: 'delimiter.tag.liquid' },
+					{ startIndex: 49, type: 'delimiter.html' },
+					{ startIndex: 50, type: 'tag.html' },
+					{ startIndex: 53, type: 'delimiter.html' },
+					{ startIndex: 54, type: '' },
+					{ startIndex: 59, type: 'delimiter.html' },
+					{ startIndex: 61, type: 'tag.html' },
+					{ startIndex: 64, type: 'delimiter.html' },
+					{ startIndex: 65, type: 'delimiter.tag.liquid' },
+					{ startIndex: 67, type: '' },
+					{ startIndex: 68, type: 'predefined.liquid' },
+					{ startIndex: 73, type: '' },
+					{ startIndex: 74, type: 'delimiter.tag.liquid' },
+					{ startIndex: 76, type: 'delimiter.html' },
+					{ startIndex: 78, type: 'tag.html' },
+					{ startIndex: 81, type: 'delimiter.html' }
+				]
+			}
+		],
+
+		// Comment tag
+		[
+			{
+				line: '<div>Anything you put between {% comment %} and {% endcomment %} tags</div>',
+				tokens: [
+					{ startIndex: 0, type: 'delimiter.html' },
+					{ startIndex: 1, type: 'tag.html' },
+					{ startIndex: 4, type: 'delimiter.html' },
+					{ startIndex: 5, type: '' },
+					{ startIndex: 30, type: 'comment.start.liquid' },
+					{ startIndex: 43, type: 'comment.content.liquid' },
+					{ startIndex: 48, type: 'comment.end.liquid' },
+					{ startIndex: 64, type: '' },
+					{ startIndex: 69, type: 'delimiter.html' },
+					{ startIndex: 71, type: 'tag.html' },
+					{ startIndex: 74, type: 'delimiter.html' }
+				]
+			}
+		],
+
+		// Raw tag
+		[
+			{
+				line:
+					'<div>Everything here should be escaped {% raw %} In Handlebars, {{ this }} will be HTML-escaped, but {{{ that }}} will not. {% endraw %}</div>',
+				tokens: [
+					{ startIndex: 0, type: 'delimiter.html' },
+					{ startIndex: 1, type: 'tag.html' },
+					{ startIndex: 4, type: 'delimiter.html' },
+					{ startIndex: 5, type: '' },
+					{ startIndex: 39, type: 'delimiter.tag.liquid' },
+					{ startIndex: 41, type: '' },
+					{ startIndex: 42, type: 'delimiter.tag.liquid' },
+					{ startIndex: 48, type: '' },
+					{ startIndex: 124, type: 'delimiter.tag.liquid' },
+					{ startIndex: 126, type: '' },
+					{ startIndex: 134, type: 'delimiter.tag.liquid' },
+					{ startIndex: 136, type: 'delimiter.html' },
+					{ startIndex: 138, type: 'tag.html' },
+					{ startIndex: 141, type: 'delimiter.html' }
+				]
+			}
+		]
+	]
+);

+ 251 - 0
src/liquid/liquid.ts

@@ -0,0 +1,251 @@
+/*---------------------------------------------------------------------------------------------
+ *  Copyright (c) Microsoft Corporation. All rights reserved.
+ *  Licensed under the MIT License. See License.txt in the project root for license information.
+ *--------------------------------------------------------------------------------------------*/
+
+import { languages } from '../fillers/monaco-editor-core';
+
+const EMPTY_ELEMENTS: string[] = [
+	'area',
+	'base',
+	'br',
+	'col',
+	'embed',
+	'hr',
+	'img',
+	'input',
+	'keygen',
+	'link',
+	'menuitem',
+	'meta',
+	'param',
+	'source',
+	'track',
+	'wbr'
+];
+
+export const conf: languages.LanguageConfiguration = {
+	wordPattern: /(-?\d*\.\d\w*)|([^\`\~\!\@\$\^\&\*\(\)\=\+\[\{\]\}\\\|\;\:\'\"\,\.\<\>\/\s]+)/g,
+
+	brackets: [
+		['<!--', '-->'],
+		['<', '>'],
+		['{{', '}}'],
+		['{%', '%}'],
+		['{', '}'],
+		['(', ')']
+	],
+
+	autoClosingPairs: [
+		{ open: '{', close: '}' },
+		{ open: '%', close: '%' },
+		{ open: '[', close: ']' },
+		{ open: '(', close: ')' },
+		{ open: '"', close: '"' },
+		{ open: "'", close: "'" }
+	],
+
+	surroundingPairs: [
+		{ open: '<', close: '>' },
+		{ open: '"', close: '"' },
+		{ open: "'", close: "'" }
+	],
+
+	onEnterRules: [
+		{
+			beforeText: new RegExp(
+				`<(?!(?:${EMPTY_ELEMENTS.join('|')}))(\\w[\\w\\d]*)([^/>]*(?!/)>)[^<]*$`,
+				'i'
+			),
+			afterText: /^<\/(\w[\w\d]*)\s*>$/i,
+			action: {
+				indentAction: languages.IndentAction.IndentOutdent
+			}
+		},
+		{
+			beforeText: new RegExp(
+				`<(?!(?:${EMPTY_ELEMENTS.join('|')}))(\\w[\\w\\d]*)([^/>]*(?!/)>)[^<]*$`,
+				'i'
+			),
+			action: { indentAction: languages.IndentAction.Indent }
+		}
+	]
+};
+
+export const language = <languages.IMonarchLanguage>{
+	defaultToken: '',
+	tokenPostfix: '',
+
+	builtinTags: [
+		'if',
+		'else',
+		'elseif',
+		'endif',
+		'render',
+		'assign',
+		'capture',
+		'endcapture',
+		'case',
+		'endcase',
+		'comment',
+		'endcomment',
+		'cycle',
+		'decrement',
+		'for',
+		'endfor',
+		'include',
+		'increment',
+		'layout',
+		'raw',
+		'endraw',
+		'render',
+		'tablerow',
+		'endtablerow',
+		'unless',
+		'endunless'
+	],
+
+	builtinFilters: [
+		'abs',
+		'append',
+		'at_least',
+		'at_most',
+		'capitalize',
+		'ceil',
+		'compact',
+		'date',
+		'default',
+		'divided_by',
+		'downcase',
+		'escape',
+		'escape_once',
+		'first',
+		'floor',
+		'join',
+		'json',
+		'last',
+		'lstrip',
+		'map',
+		'minus',
+		'modulo',
+		'newline_to_br',
+		'plus',
+		'prepend',
+		'remove',
+		'remove_first',
+		'replace',
+		'replace_first',
+		'reverse',
+		'round',
+		'rstrip',
+		'size',
+		'slice',
+		'sort',
+		'sort_natural',
+		'split',
+		'strip',
+		'strip_html',
+		'strip_newlines',
+		'times',
+		'truncate',
+		'truncatewords',
+		'uniq',
+		'upcase',
+		'url_decode',
+		'url_encode',
+		'where'
+	],
+
+	constants: ['true', 'false'],
+	operators: ['==', '!=', '>', '<', '>=', '<='],
+
+	symbol: /[=><!]+/,
+	identifier: /[a-zA-Z_][\w]*/,
+
+	tokenizer: {
+		root: [
+			[/\{\%\s*comment\s*\%\}/, 'comment.start.liquid', '@comment'],
+			[/\{\{/, { token: '@rematch', switchTo: '@liquidState.root' }],
+			[/\{\%/, { token: '@rematch', switchTo: '@liquidState.root' }],
+			[/(<)(\w+)(\/>)/, ['delimiter.html', 'tag.html', 'delimiter.html']],
+			[/(<)([:\w]+)/, ['delimiter.html', { token: 'tag.html', next: '@otherTag' }]],
+			[/(<\/)(\w+)/, ['delimiter.html', { token: 'tag.html', next: '@otherTag' }]],
+			[/</, 'delimiter.html'],
+			[/\{/, 'delimiter.html'],
+			[/[^<{]+/] // text
+		],
+
+		comment: [
+			[/\{\%\s*endcomment\s*\%\}/, 'comment.end.liquid', '@pop'],
+			[/./, 'comment.content.liquid']
+		],
+
+		otherTag: [
+			[
+				/\{\{/,
+				{
+					token: '@rematch',
+					switchTo: '@liquidState.otherTag'
+				}
+			],
+			[
+				/\{\%/,
+				{
+					token: '@rematch',
+					switchTo: '@liquidState.otherTag'
+				}
+			],
+			[/\/?>/, 'delimiter.html', '@pop'],
+			[/"([^"]*)"/, 'attribute.value'],
+			[/'([^']*)'/, 'attribute.value'],
+			[/[\w\-]+/, 'attribute.name'],
+			[/=/, 'delimiter'],
+			[/[ \t\r\n]+/] // whitespace
+		],
+
+		liquidState: [
+			[/\{\{/, 'delimiter.output.liquid'],
+			[/\}\}/, { token: 'delimiter.output.liquid', switchTo: '@$S2.$S3' }],
+			[/\{\%/, 'delimiter.tag.liquid'],
+			[/raw\s*\%\}/, 'delimiter.tag.liquid', '@liquidRaw'],
+			[/\%\}/, { token: 'delimiter.tag.liquid', switchTo: '@$S2.$S3' }],
+			{ include: 'liquidRoot' }
+		],
+
+		liquidRaw: [
+			[/^(?!\{\%\s*endraw\s*\%\}).+/],
+			[/\{\%/, 'delimiter.tag.liquid'],
+			[/@identifier/],
+			[/\%\}/, { token: 'delimiter.tag.liquid', next: '@root' }],
+		],
+
+		liquidRoot: [
+			[/\d+(\.\d+)?/, 'number.liquid'],
+			[/"[^"]*"/, 'string.liquid'],
+			[/'[^']*'/, 'string.liquid'],
+			[/\s+/],
+			[
+				/@symbol/,
+				{
+					cases: {
+						'@operators': 'operator.liquid',
+						'@default': ''
+					}
+				}
+			],
+			[/\./],
+			[
+				/@identifier/,
+				{
+					cases: {
+						'@constants': 'keyword.liquid',
+						'@builtinFilters': 'predefined.liquid',
+						'@builtinTags': 'predefined.liquid',
+						'@default': 'variable.liquid'
+					}
+				}
+			],
+			[/[^}|%]/, 'variable.liquid']
+		]
+	}
+};

+ 3 - 0
src/monaco.contribution.ts

@@ -7,6 +7,7 @@ import './abap/abap.contribution';
 import './apex/apex.contribution';
 import './azcli/azcli.contribution';
 import './bat/bat.contribution';
+import './bicep/bicep.contribution';
 import './cameligo/cameligo.contribution';
 import './clojure/clojure.contribution';
 import './coffee/coffee.contribution';
@@ -17,6 +18,7 @@ import './css/css.contribution';
 import './dart/dart.contribution';
 import './dockerfile/dockerfile.contribution';
 import './ecl/ecl.contribution';
+import './elixir/elixir.contribution';
 import './fsharp/fsharp.contribution';
 import './go/go.contribution';
 import './graphql/graphql.contribution';
@@ -31,6 +33,7 @@ import './kotlin/kotlin.contribution';
 import './less/less.contribution';
 import './lexon/lexon.contribution';
 import './lua/lua.contribution';
+import './liquid/liquid.contribution';
 import './m3/m3.contribution';
 import './markdown/markdown.contribution';
 import './mips/mips.contribution';

+ 1 - 1
src/razor/razor.ts

@@ -81,7 +81,7 @@ export const language = <languages.IMonarchLanguage>{
 	// The main tokenizer for our languages
 	tokenizer: {
 		root: [
-			[/@@/], // text
+			[/@@@@/], // text
 			[/@[^@]/, { token: '@rematch', switchTo: '@razorInSimpleState.root' }],
 			[/<!DOCTYPE/, 'metatag.html', '@doctype'],
 			[/<!--/, 'comment.html', '@comment'],

+ 1 - 0
src/redshift/redshift.ts

@@ -58,6 +58,7 @@ export const language = <languages.IMonarchLanguage>{
 		'BINARY',
 		'BLANKSASNULL',
 		'BOTH',
+		'BY',
 		'BYTEDICT',
 		'BZIP2',
 		'CASE',

+ 2 - 2
src/ruby/ruby.ts

@@ -282,7 +282,7 @@ export const language = <languages.IMonarchLanguage>{
 			[/[A-Z][\w]*[!?=]?/, 'constructor.identifier'], // constant
 			[/\$[\w]*/, 'global.constant'], // global
 			[/@[\w]*/, 'namespace.instance.identifier'], // instance
-			[/@@[\w]*/, 'namespace.class.identifier'], // class
+			[/@@@[\w]*/, 'namespace.class.identifier'], // class
 
 			// here document
 			[/<<[-~](@heredelim).*/, { token: 'string.heredoc.delimiter', next: '@heredoc.$1' }],
@@ -444,7 +444,7 @@ export const language = <languages.IMonarchLanguage>{
 		interpolated: [
 			[/\$\w*/, 'global.constant', '@pop'],
 			[/@\w*/, 'namespace.class.identifier', '@pop'],
-			[/@@\w*/, 'namespace.instance.identifier', '@pop'],
+			[/@@@\w*/, 'namespace.instance.identifier', '@pop'],
 			[
 				/[{]/,
 				{

+ 4 - 0
src/rust/rust.ts

@@ -42,11 +42,14 @@ export const language = <languages.IMonarchLanguage>{
 	defaultToken: 'invalid',
 	keywords: [
 		'as',
+		'async',
+		'await',
 		'box',
 		'break',
 		'const',
 		'continue',
 		'crate',
+		'dyn',
 		'else',
 		'enum',
 		'extern',
@@ -71,6 +74,7 @@ export const language = <languages.IMonarchLanguage>{
 		'super',
 		'trait',
 		'true',
+		'try',
 		'type',
 		'unsafe',
 		'use',

+ 1 - 1
src/swift/swift.ts

@@ -200,7 +200,7 @@ export const language = <languages.IMonarchLanguage>{
 
 		attribute: [
 			[
-				/\@@identifier/,
+				/@@@identifier/,
 				{
 					cases: {
 						'@attributes': 'keyword.control',

+ 1 - 1
src/yaml/yaml.contribution.ts

@@ -9,6 +9,6 @@ registerLanguage({
 	id: 'yaml',
 	extensions: ['.yaml', '.yml'],
 	aliases: ['YAML', 'yaml', 'YML', 'yml'],
-	mimetypes: ['application/x-yaml'],
+	mimetypes: ['application/x-yaml', 'text/x-yaml'],
 	loader: () => import('./yaml')
 });

+ 25 - 0
src/yaml/yaml.test.ts

@@ -449,5 +449,30 @@ testTokenization('yaml', [
 				}
 			]
 		}
+	],
+	[
+		{
+			line:
+				"text: Pretty vector drawing. #this is comment doesn't have proper syntax higlighting",
+			tokens: [
+				{ startIndex: 0, type: 'type.yaml' },
+				{ startIndex: 4, type: 'operators.yaml' },
+				{ startIndex: 5, type: 'white.yaml' },
+				{ startIndex: 6, type: 'string.yaml' },
+				{ startIndex: 29, type: 'comment.yaml' }
+			]
+		}
+	],
+	[
+		{
+			line: "number: 3 #this comment also doesn't have proper syntax highlighting",
+			tokens: [
+				{ startIndex: 0, type: 'type.yaml' },
+				{ startIndex: 6, type: 'operators.yaml' },
+				{ startIndex: 7, type: 'white.yaml' },
+				{ startIndex: 8, type: 'string.yaml' },
+				{ startIndex: 10, type: 'comment.yaml' }
+			]
+		}
 	]
 ]);

+ 1 - 1
src/yaml/yaml.ts

@@ -84,7 +84,7 @@ export const language = <languages.IMonarchLanguage>{
 
 			// String nodes
 			[
-				/.+$/,
+				/[^#]+/,
 				{
 					cases: {
 						'@keywords': 'keyword',

+ 10 - 1
test/all.js

@@ -21,7 +21,16 @@ global.self = global;
 global.document.queryCommandSupported = function () {
 	return false;
 };
-global.window = { location: {}, navigator: tmp.window.navigator };
+global.window = {
+	location: {},
+	navigator: tmp.window.navigator,
+	matchMedia: function () {
+		return {
+			matches: false,
+			addListener: function () {}
+		};
+	}
+};
 
 requirejs(
 	['./test/setup'],

+ 3 - 1
test/setup.js

@@ -20,4 +20,6 @@ define('vs/nls', [], {
 	}
 });
 
-define(['vs/editor/editor.main', function () {}]);
+define(['vs/editor/editor.main'], function (api) {
+	global.monaco = api;
+});

Algúns arquivos non se mostraron porque demasiados arquivos cambiaron neste cambio