-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgrammar.js
56 lines (47 loc) · 1.2 KB
/
grammar.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
const newline = '\n'
const terminator = choice(newline, ';')
const terminator2 = choice(newline, ';', ';;', '\n', '&')
// prettier-ignore
const wordDelimiters = [
'&', '|', ';', '<', '>', '(', ')',
'&&', '||', '<<', '>>'
]
// prettier-ignore
module.exports = grammar({
name: 'tcsh',
extras: $ => [
$.comment,
/\s/
],
rules: {
program: $ => repeat(choice(
seq($._statement, terminator),
)),
comment: $ => seq('#', /.*/),
_statement: $ => repeat1(choice(
$.string_doublequote,
$.string_singlequote,
$.string_raw
)),
_statement_terminated: $ => seq(
$._statement,
terminator2
),
redirections: $ => seq(
'<', '<<',
'>', '>!', '>&', '>&!',
'>>', '>>&', '>>!', '>>&!'
),
// substitution_history: $ => seq(),
// substitution_alias: $ => seq(),
// substitution_variable: $ => seq(),
// command, filename, directory stack substitution
// substitution_command: $ => seq('`', '`'),
// substitution_filename: $ => seq(),
// substitution_directory_stack: $ => seq(),
string_doublequote: $ => seq('"', /[a-z]*/, '"'),
string_singlequote: $ => seq("'", /[a-z]*/, "'"),
string_dollarquote: $ => seq("$'", /[a-z]*/, "'"),
string_raw: $ => /[a-z]+/,
},
})