Documentation
¶
Overview ¶
Package parser tokenizes and parses DOS-style command lines and batch constructs.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func EvalArith ¶
EvalArith evaluates a DOS-style SET /A expression string. Any assignments in the expression update e. Returns the value of the rightmost subexpression.
func ParseLabel ¶
ParseLabel returns the label name if line is a batch label (:name), else "". Leading whitespace is ignored.
func StripEchoSuppress ¶
StripEchoSuppress returns the line without a leading @ and whether @ was present. Only a @ at the very start (after optional whitespace) is stripped.
Types ¶
type Command ¶
type Command struct {
Name string
Args []string
Redirects []Redirect
AtPrefix bool // @ was present on this line
}
Command is a parsed single command ready for dispatch.
type Pipeline ¶
type Pipeline struct {
Commands []*Command
Next *Pipeline // next pipeline in a && or || chain; nil if last
NextOp TokenType // TokenAnd or TokenOr; meaningful only when Next != nil
}
Pipeline is one or more Commands connected by pipes, optionally chained to another Pipeline via && or ||.
type TokenType ¶
type TokenType int
TokenType classifies a lexical token.
const ( TokenWord TokenType = iota // bare word or quoted string TokenRedirectOut // > TokenRedirectApp // >> TokenRedirectIn // < TokenRedirectErr // 2> TokenRedirectErrApp // 2>> TokenRedirectErrOut // 2>&1 TokenPipe // | TokenAnd // && TokenOr // || TokenAtPrefix // @ (echo suppression; produced by StripEchoSuppress, not Tokenize) )