Documentation
¶
Overview ¶
Package ast declares the types used to represent syntax trees for the Shell Command Language.
Index ¶
- type AndOr
- type AndOrList
- type ArithEval
- type ArithExp
- type Assign
- type CaseClause
- type CaseItem
- type Cmd
- type CmdExpr
- type CmdSubst
- type Command
- type Comment
- type ElifClause
- type ElseClause
- type ElsePart
- type ForClause
- type FuncDef
- type Group
- type IfClause
- type List
- type Lit
- type Node
- type ParamExp
- type Pipe
- type Pipeline
- type Pos
- type Quote
- type Redir
- type SimpleCmd
- type Subshell
- type UntilClause
- type WhileClause
- type Word
- type WordPart
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AndOr ¶
type AndOr struct { OpPos Pos // position of Op Op string // "&&" or "||" operator Pipeline *Pipeline // pipeline }
AndOr represents a pipeline of the AND-OR list.
type AndOrList ¶
type AndOrList struct { Pipeline *Pipeline // pipeline List []*AndOr // pipelines separated by "&&" or "||" operator; or nil SepPos Pos // position of "&" or ";" operator (zero if there is no operator) Sep string }
AndOrList represents an AND-OR list.
type ArithEval ¶
type ArithEval struct { Left Pos // position of "((" operator Expr Word // expression Right Pos // position of "))" operator }
ArithEval represents an arithmetic evaluation.
type ArithExp ¶
type ArithExp struct { Left Pos // position of "$((" Expr Word // expression Right Pos // position of "))" }
ArithExp represents an arithmetic expansion.
type CaseClause ¶
type CaseClause struct { Case Pos // position of reserved word "case" Word Word // word In Pos // position of reserved word "in" Items []*CaseItem // patterns and commands; or nil Esac Pos // position of reserved word "esac" }
CaseClause represents a case conditional construct.
func (*CaseClause) End ¶
func (x *CaseClause) End() Pos
func (*CaseClause) Pos ¶
func (x *CaseClause) Pos() Pos
type CaseItem ¶
type CaseItem struct { Lparen Pos // position of "(" operator (zero if there is no "(" operator) Patterns []Word // patterns Rparen Pos // position of ")" operator List []Command // commands Break Pos // position of ";;" operator (zero if there is no ";;" operator) }
CaseItem represents patterns and commands of the case conditional construct.
type CmdExpr ¶
type CmdExpr interface { Node // contains filtered or unexported methods }
CmdExpr represents a detail of the command.
type CmdSubst ¶
type CmdSubst struct { Dollar bool // whether this is enclosed in "$()". Left Pos // position of "(" or "`". List []Command // commands Right Pos // position of ")" or "`". }
CmdSubst represents a command substisution.
type Command ¶
type Command interface { Node // contains filtered or unexported methods }
Command represents a command.
type ElifClause ¶
type ElifClause struct { Elif Pos // position of reserved word "elif" Cond []Command // condition Then Pos // position of reserved word "then" List []Command // commands }
ElifClause represents an elif clause of the if conditional construct.
func (*ElifClause) End ¶
func (e *ElifClause) End() Pos
func (*ElifClause) Pos ¶
func (e *ElifClause) Pos() Pos
type ElseClause ¶
ElseClause represents an else clause of the if conditional construct.
func (*ElseClause) End ¶
func (e *ElseClause) End() Pos
func (*ElseClause) Pos ¶
func (e *ElseClause) Pos() Pos
type ElsePart ¶
type ElsePart interface { Node // contains filtered or unexported methods }
ElsePart represents an elif clause or an else clause.
type ForClause ¶
type ForClause struct { For Pos // position of reserved word "for" Name *Lit // variable name In Pos // position of reserved word "in" (zero if there is no "in") Items []Word // list of words; or nil Semicolon Pos // position of ";" operator (zero if there is no ";" operator) Do Pos // position of reserved word "do" List []Command // commands Done Pos // position of reserved word "done" }
ForClause represents a for loop.
type FuncDef ¶
type FuncDef struct { Name *Lit // function name Lparen Pos // position of '(' operator Rparen Pos // position of ')' operator Body Command // compound command }
FuncDef represents a function definition command.
type Group ¶
type Group struct { Lbrace Pos // position of reserved word "{" List []Command // commands Rbrace Pos // position of reserved word "}" }
Group represents a sequence of commands that executes in the current process environment.
type IfClause ¶
type IfClause struct { If Pos // position of reserved word "if" Cond []Command // condition Then Pos // position of reserved word "then" List []Command // commands Else []ElsePart // elif clauses and/or an else clause Fi Pos // position of reserved word "fi" }
IfClause represents an if conditional construct.
type Node ¶
type Node interface { Pos() Pos // position of the first character of the node End() Pos // position of the character immediately after the node }
Node represents an abstract syntax tree.
type ParamExp ¶
type ParamExp struct { Dollar Pos // position of "$" Braces bool // whether this is enclosed in braces Name *Lit // parameter name OpPos Pos // position of Op Op string // operator Word Word // nil means string length }
ParamExp represents a parameter expansion.
type Pipeline ¶
type Pipeline struct { Bang Pos // position of reserved word "!" Cmd *Cmd // command List []*Pipe // commands separated by "|" operator; or nil }
Pipeline represents a pipeline.
type Pos ¶
type Pos struct {
// contains filtered or unexported fields
}
Pos represents a position.
type Redir ¶
type Redir struct { N *Lit OpPos Pos Op string Word Word Heredoc Word // here-document; or nil Delim Word // here-document delimiter; or nil }
Redir represents an I/O redirection.
type SimpleCmd ¶
type SimpleCmd struct { Assigns []*Assign // variable assignments; or nil Args []Word // command line arguments }
SimpleCmd represents a simple command.
type Subshell ¶
type Subshell struct { Lparen Pos // position of "(" operator List []Command // commands Rparen Pos // position of ")" operator }
Subshell represents a sequence of commands that executes in a subshell environment.
type UntilClause ¶
type UntilClause struct { Until Pos // position of reserved word "until" Cond []Command // condition Do Pos // position of reserved word "do" List []Command // commands Done Pos // position of reserved word "done" }
UntilClause represents an until loop.
func (*UntilClause) End ¶
func (x *UntilClause) End() Pos
func (*UntilClause) Pos ¶
func (x *UntilClause) Pos() Pos
type WhileClause ¶
type WhileClause struct { While Pos // position of reserved word "while" Cond []Command // condition Do Pos // position of reserved word "do" List []Command // commands Done Pos // position of reserved word "done" }
WhileClause represents a while loop.
func (*WhileClause) End ¶
func (x *WhileClause) End() Pos
func (*WhileClause) Pos ¶
func (x *WhileClause) Pos() Pos