-
Notifications
You must be signed in to change notification settings - Fork 0
/
ast.go
97 lines (80 loc) · 1.38 KB
/
ast.go
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
// Copyright 2020 the u-root Authors. All rights reserved
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package pogosh
type command interface {
exec(*State)
}
// ! cmd
type not struct {
cmd command
}
// cmd1 && cmd2
type and struct {
cmd1 command
cmd2 command
}
// cmd1 || cmd2
type or struct {
cmd1 command
cmd2 command
}
// cmd &
type async struct {
cmd command
}
// cmds[0]; cmds[1]; ... cmds[n-1];
type compoundList struct {
cmds []command
}
// cmds[0] | cmds[1] | ... | cmds[n-1]
type pipeline struct {
cmds []command
}
// ( cmd )
type subshell struct {
cmd command
}
// for name in wordlist; do cmd; done
type forClause struct {
name []byte
wordlist [][]byte
cmd command
}
// case word in cases esac
type caseClause struct {
word []byte
cases []caseItem
}
// pattern ) cmd
type caseItem struct {
pattern []byte
cmd command
}
// if cmdPred then cmdThen else cmdElse done
type ifClause struct {
cmdPred command
cmdThen command
cmdElse command
}
// while cmdPred; do cmd; done
type whileClause struct {
cmdPred command
cmd command
}
// name() cmd
type function struct {
name []byte
cmd command
}
// name args... redirects...
type simpleCommand struct {
name []byte
args [][]byte
redirects []redirect
}
// ioOp filename
type redirect struct {
ioOp []byte
filename []byte
}