-
-
Notifications
You must be signed in to change notification settings - Fork 30
/
source.scad.js
102 lines (100 loc) · 3.36 KB
/
source.scad.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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
// This is a TextMate grammar distributed by `starry-night`.
// This grammar is developed at
// <https://github.com/tbuser/openscad.tmbundle>
// and licensed `mit`.
// See <https://github.com/wooorm/starry-night> for more info.
/**
* @import {Grammar} from '@wooorm/starry-night'
*/
/** @type {Grammar} */
const grammar = {
extensions: ['.scad'],
names: ['openscad'],
patterns: [
{
captures: {1: {name: 'keyword.control.scad'}},
match: '^(module)\\s.*$',
name: 'meta.function.scad'
},
{
match:
'\\b(if|else|for|intersection_for|assign|render|function|include|use)\\b',
name: 'keyword.control.scad'
},
{
begin: '/\\*\\*(?!/)',
captures: {0: {name: 'punctuation.definition.comment.scad'}},
end: '\\*/',
name: 'comment.block.documentation.scad'
},
{
begin: '/\\*',
captures: {0: {name: 'punctuation.definition.comment.scad'}},
end: '\\*/',
name: 'comment.block.scad'
},
{
captures: {1: {name: 'punctuation.definition.comment.scad'}},
match: '(//).*$\\n?',
name: 'comment.line.double-slash.scad'
},
{
begin: '"',
end: '"',
name: 'string.quoted.double.scad',
patterns: [{match: '\\\\.', name: 'constant.character.escape.scad'}]
},
{
begin: "'",
beginCaptures: {0: {name: 'punctuation.definition.string.begin.scad'}},
end: "'",
endCaptures: {0: {name: 'punctuation.definition.string.end.scad'}},
name: 'string.quoted.single.scad',
patterns: [
{
match:
'\\\\(x[0-9A-Fa-f]{2}|[0-2][0-7]{0,2}|3[0-6][0-7]?|37[0-7]?|[4-7][0-7]?|.)',
name: 'constant.character.escape.scad'
}
]
},
{
begin: '"',
beginCaptures: {0: {name: 'punctuation.definition.string.begin.scad'}},
end: '"',
endCaptures: {0: {name: 'punctuation.definition.string.end.scad'}},
name: 'string.quoted.double.scad',
patterns: [
{
match:
'\\\\(x[0-9A-Fa-f]{2}|[0-2][0-7]{0,2}|3[0-6][0-7]|37[0-7]?|[4-7][0-7]?|.)',
name: 'constant.character.escape.scad'
}
]
},
{
match:
'\\b(abs|acos|asun|atan|atan2|ceil|cos|exp|floor|ln|log|lookup|max|min|pow|rands|round|sign|sin|sqrt|tan|str|cube|sphere|cylinder|polyhedron|scale|rotate|translate|mirror|multimatrix|color|minkowski|hull|union|difference|intersection|echo)\\b',
name: 'support.function.scad'
},
{match: '\\;', name: 'punctuation.terminator.statement.scad'},
{match: ',[ |\\t]*', name: 'meta.delimiter.object.comma.scad'},
{match: '\\.', name: 'meta.delimiter.method.period.scad'},
{match: '\\{|\\}', name: 'meta.brace.curly.scad'},
{match: '\\(|\\)', name: 'meta.brace.round.scad'},
{match: '\\[|\\]', name: 'meta.brace.square.scad'},
{
match:
'!|\\$|%|&|\\*|\\-\\-|\\-|\\+\\+|\\+|~|===|==|=|!=|!==|<=|>=|<<=|>>=|>>>=|<>|<|>|!|&&|\\|\\||\\?\\:|\\*=|(?<!\\()/=|%=|\\+=|\\-=|&=|\\^=|\\b(in|instanceof|new|delete|typeof|void)\\b',
name: 'keyword.operator.scad'
},
{
match: '\\b((0(x|X)[0-9a-fA-F]+)|([0-9]+(\\.[0-9]+)?))\\b',
name: 'constant.numeric.scad'
},
{match: '\\btrue\\b', name: 'constant.language.boolean.true.scad'},
{match: '\\bfalse\\b', name: 'constant.language.boolean.false.scad'}
],
scopeName: 'source.scad'
}
export default grammar