-
-
Notifications
You must be signed in to change notification settings - Fork 33
/
source.qsharp.js
84 lines (82 loc) · 2.23 KB
/
source.qsharp.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
// This is a TextMate grammar distributed by `starry-night`.
// This grammar is developed at
// <https://github.com/microsoft/qsharp>
// and licensed `mit`.
// See <https://github.com/wooorm/starry-night> for more info.
/**
* @import {Grammar} from '@wooorm/starry-night'
*/
/** @type {Grammar} */
const grammar = {
extensions: ['.qs'],
names: ['q#', 'qsharp'],
patterns: [
{include: '#comments'},
{include: '#keywords'},
{include: '#operators'},
{include: '#types'},
{include: '#constants'},
{include: '#strings'}
],
repository: {
comments: {
patterns: [
{match: '\\/\\/.*$', name: 'comment.line.double-slash'},
{match: '\\/\\/\\/.*$', name: 'comment.documentation'}
]
},
constants: {
patterns: [
{
match: '\\b(true|false|Pauli(I|X|Y|Z))\\b',
name: 'constant.language.qsharp'
},
{match: '\\b(One|Zero)\\b', name: 'constant.other.result.qsharp'}
]
},
keywords: {
patterns: [
{
match:
'\\b(use|borrow|mutable|let|set|if|elif|else|repeat|until|fixup|for|in|while|return|fail|within|apply)\\b',
name: 'keyword.control.qsharp'
},
{
match:
'\\b(namespace|open|import|export|as|internal|newtype|struct|operation|function|new|body|(a|A)djoint|(c|C)ontrolled|self|auto|distribute|invert|intrinsic)\\b',
name: 'keyword.other.qsharp'
}
]
},
operators: {
patterns: [
{
match:
'\\b(not|and|or)\\b|\\b(w/)|(=)|(!)|(<)|(>)|(\\+)|(-)|(\\*)|(\\/)|(\\^)|(%)|(\\|)|(\\&\\&\\&)|(\\~\\~\\~)|(\\.\\.\\.)|(\\.\\.)|(\\?)',
name: 'keyword.other.operator.qsharp'
}
]
},
strings: {
patterns: [
{
begin: '(\\$|)"',
end: '"',
name: 'string.quoted.double.qsharp',
patterns: [{match: '\\\\.', name: 'constant.character.escape.qsharp'}]
}
]
},
types: {
patterns: [
{
match:
'\\b(Int|BigInt|Double|Bool|Qubit|Pauli|Result|Range|String|Unit|Ctl|Adj|is)\\b',
name: 'storage.type.qsharp'
}
]
}
},
scopeName: 'source.qsharp'
}
export default grammar