-
-
Notifications
You must be signed in to change notification settings - Fork 31
/
source.peggy.js
94 lines (92 loc) · 2.54 KB
/
source.peggy.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
// This is a TextMate grammar distributed by `starry-night`.
// This grammar is developed at
// <https://github.com/peggyjs/code-peggy-language>
// and licensed `mit`.
// See <https://github.com/wooorm/starry-night> for more info.
/**
* @import {Grammar} from '@wooorm/starry-night'
*/
/** @type {Grammar} */
const grammar = {
dependencies: ['source.js'],
extensions: ['.pegjs', '.peggy'],
names: ['peg.js'],
patterns: [
{include: '#comment'},
{include: '#label'},
{include: '#defRule'},
{include: '#rule'},
{include: '#literal'},
{include: '#charclass'},
{include: '#operators'},
{include: '#inlinejs'}
],
repository: {
charclass: {
begin: '\\[',
end: '\\]',
name: 'declaration.keyword.peggy',
patterns: [{match: '\\\\.', name: 'constant.character.escape.peggy'}]
},
comment: {
patterns: [
{begin: '/\\*', end: '\\*/', name: 'comment.block.peggy'},
{match: '//.*$\\n?', name: 'comment.line.double-slash.peggy'}
]
},
defRule: {
captures: {1: {name: 'entity.name.function.peggy'}},
match: '(\\w+)\\s*(?=\\=)'
},
inlinejs: {
begin: '{',
end: '}',
name: 'meta.embedded.block.javascript',
patterns: [{include: 'source.js'}]
},
label: {
captures: {1: {name: 'entity.other.attribute-name.attribute.peggy'}},
match: '(\\w+)\\s*(?=:)'
},
literal: {
patterns: [
{
begin: '"',
end: '"',
name: 'string.quoted.double.peggy',
patterns: [
{
match:
'\\\\(x[[:xdigit:]]{2}|[0-2][0-7]{0,2}|3[0-6][0-7]|37[0-7]?|[4-7][0-7]?|.)',
name: 'constant.character.escape.peggy'
},
{
match: '[^"]*[^\\n\\r"\\\\]$',
name: 'invalid.illegal.string.peggy'
}
]
},
{
begin: "'",
end: "'",
name: 'string.quoted.single.peggy',
patterns: [
{
match:
'\\\\(x[[:xdigit:]]{2}|[0-2][0-7]{0,2}|3[0-6][0-7]?|37[0-7]?|[4-7][0-7]?|.)',
name: 'constant.character.escape.peggy'
},
{
match: "[^']*[^\\n\\r'\\\\]$",
name: 'invalid.illegal.string.peggy'
}
]
}
]
},
operators: {match: '[*?/.!=+&@]', name: 'keyword.operator.peggy'},
rule: {match: '[a-zA-Z_][a-zA-Z_0-9$]*', name: 'entity.name.function.peggy'}
},
scopeName: 'source.peggy'
}
export default grammar