You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
42 lines
663 B
Go
42 lines
663 B
Go
package shell
|
|
|
|
import "io"
|
|
|
|
type Token interface {
|
|
Tokens() []Token
|
|
AddToken(Token)
|
|
String() string
|
|
}
|
|
|
|
type Expandable interface {
|
|
Expand(state State, stdin io.Reader, stderr io.Writer) ([]string, uint8)
|
|
}
|
|
|
|
type Evalable interface {
|
|
Evaluate(state State, stdin io.Reader, stdout io.Writer, stderr io.Writer) uint8
|
|
}
|
|
|
|
type BaseToken struct {
|
|
tokens []Token
|
|
}
|
|
|
|
func (t *BaseToken) Tokens() []Token {
|
|
return t.tokens
|
|
}
|
|
|
|
func (t *BaseToken) AddToken(token Token) {
|
|
if token != nil {
|
|
t.tokens = append(t.tokens, token)
|
|
}
|
|
}
|
|
|
|
func (t *BaseToken) String() string {
|
|
var str string
|
|
|
|
for _, token := range t.Tokens() {
|
|
str += token.String()
|
|
}
|
|
|
|
return str
|
|
}
|