Documentation ¶
Index ¶
- Constants
- Variables
- type AssignmentNode
- type BindFnNode
- type BlockNode
- type CommandNode
- func (n *CommandNode) AddArg(a Expr)
- func (n *CommandNode) AddRedirect(redir *RedirectNode)
- func (n *CommandNode) Args() []Expr
- func (n *CommandNode) IsEqual(other Node) bool
- func (n *CommandNode) IsMulti() bool
- func (n *CommandNode) Name() string
- func (n *CommandNode) Redirects() []*RedirectNode
- func (n *CommandNode) SetArgs(args []Expr)
- func (n *CommandNode) SetMulti(b bool)
- func (n *CommandNode) String() string
- type CommentNode
- type ConcatExpr
- type DumpNode
- type ExecAssignNode
- type Expr
- type FnDeclNode
- func (n *FnDeclNode) AddArg(arg string)
- func (n *FnDeclNode) Args() []string
- func (n *FnDeclNode) IsEqual(other Node) bool
- func (n *FnDeclNode) Name() string
- func (n *FnDeclNode) SetName(a string)
- func (n *FnDeclNode) SetTree(t *Tree)
- func (n *FnDeclNode) String() string
- func (n *FnDeclNode) Tree() *Tree
- type FnInvNode
- type ForNode
- type IfNode
- func (n *IfNode) ElseTree() *Tree
- func (n *IfNode) IfTree() *Tree
- func (n *IfNode) IsElseIf() bool
- func (n *IfNode) IsEqual(other Node) bool
- func (n *IfNode) Lvalue() Expr
- func (n *IfNode) Op() string
- func (n *IfNode) Rvalue() Expr
- func (n *IfNode) SetElseTree(t *Tree)
- func (n *IfNode) SetElseif(b bool)
- func (n *IfNode) SetIfTree(t *Tree)
- func (n *IfNode) SetLvalue(arg Expr)
- func (n *IfNode) SetOp(op string)
- func (n *IfNode) SetRvalue(arg Expr)
- func (n *IfNode) String() string
- type ImportNode
- type IndexExpr
- type IntExpr
- type ListExpr
- type Node
- type NodeType
- type PipeNode
- type RedirMap
- type RedirectNode
- type ReturnNode
- type RforkNode
- type SetenvNode
- type StringExpr
- type Tree
- type VarExpr
Constants ¶
const ( // RedirMapNoValue indicates the pipe has not redirection RedirMapNoValue = -1 // RedirMapSupress indicates the rhs of map was suppressed RedirMapSupress = -2 RforkFlags = "umnips" )
Variables ¶
var (
DebugCmp bool
)
Functions ¶
This section is empty.
Types ¶
type AssignmentNode ¶
AssignmentNode is a node for variable assignments
func NewAssignmentNode ¶
func NewAssignmentNode(info token.FileInfo, ident string, value Expr) *AssignmentNode
NewAssignmentNode creates a new assignment
func (*AssignmentNode) Identifier ¶
func (n *AssignmentNode) Identifier() string
Identifier return the name of the variable.
func (*AssignmentNode) IsEqual ¶
func (n *AssignmentNode) IsEqual(other Node) bool
IsEqual returns if it is equal to the other node.
func (*AssignmentNode) SetIdentifier ¶
func (n *AssignmentNode) SetIdentifier(a string)
SetIdentifier sets the name of the variable
func (*AssignmentNode) SetValue ¶
func (n *AssignmentNode) SetValue(val Expr)
SetValue sets the value of the list
func (*AssignmentNode) String ¶
func (n *AssignmentNode) String() string
String returns the string representation of assignment statement
func (*AssignmentNode) Value ¶
func (n *AssignmentNode) Value() Expr
Value returns the assigned object
type BindFnNode ¶
A BindFnNode represents the "bindfn" keyword.
func NewBindFnNode ¶
func NewBindFnNode(info token.FileInfo, name, cmd string) *BindFnNode
NewBindFnNode creates a new bindfn statement
func (*BindFnNode) IsEqual ¶
func (n *BindFnNode) IsEqual(other Node) bool
func (*BindFnNode) String ¶
func (n *BindFnNode) String() string
String returns the string representation of bindfn
type BlockNode ¶
BlockNode is the block
func NewBlockNode ¶
NewBlockNode creates a new block
type CommandNode ¶
A CommandNode is a node for commands
func NewCommandNode ¶
func NewCommandNode(info token.FileInfo, name string, multiline bool) *CommandNode
NewCommandNode creates a new node for commands
func (*CommandNode) AddArg ¶
func (n *CommandNode) AddArg(a Expr)
AddArg adds a new argument to the command
func (*CommandNode) AddRedirect ¶
func (n *CommandNode) AddRedirect(redir *RedirectNode)
AddRedirect adds a new redirect node to command
func (*CommandNode) Args ¶
func (n *CommandNode) Args() []Expr
Args returns the list of arguments supplied to command.
func (*CommandNode) IsEqual ¶
func (n *CommandNode) IsEqual(other Node) bool
IsEqual returns if it is equal to the other node.
func (*CommandNode) IsMulti ¶
func (n *CommandNode) IsMulti() bool
func (*CommandNode) Redirects ¶
func (n *CommandNode) Redirects() []*RedirectNode
Redirects return the list of redirect maps of the command.
func (*CommandNode) SetArgs ¶
func (n *CommandNode) SetArgs(args []Expr)
SetArgs sets an array of args to command
func (*CommandNode) SetMulti ¶
func (n *CommandNode) SetMulti(b bool)
func (*CommandNode) String ¶
func (n *CommandNode) String() string
type CommentNode ¶
CommentNode is the node for comments
func NewCommentNode ¶
func NewCommentNode(info token.FileInfo, val string) *CommentNode
NewCommentNode creates a new node for comments
func (*CommentNode) IsEqual ¶
func (n *CommentNode) IsEqual(other Node) bool
func (*CommentNode) String ¶
func (n *CommentNode) String() string
String returns the string representation of comment
type ConcatExpr ¶
ConcatExpr is a concatenation of arguments
func NewConcatExpr ¶
func NewConcatExpr(info token.FileInfo, parts []Expr) *ConcatExpr
func (*ConcatExpr) IsEqual ¶
func (c *ConcatExpr) IsEqual(other Node) bool
func (*ConcatExpr) List ¶
func (c *ConcatExpr) List() []Expr
func (*ConcatExpr) PushExpr ¶
func (c *ConcatExpr) PushExpr(a Expr)
PushExpr push an expression to end of the concat list
func (*ConcatExpr) SetConcat ¶
func (c *ConcatExpr) SetConcat(v []Expr)
SetConcatList set the concatenation parts
func (*ConcatExpr) String ¶
func (c *ConcatExpr) String() string
type DumpNode ¶
A DumpNode represents the "dump" keyword.
func NewDumpNode ¶
NewDumpNode creates a new dump statement
func (*DumpNode) SetFilename ¶
SetFilename set the dump filename
type ExecAssignNode ¶
An ExecAssignNode represents the node for execution assignment.
func NewExecAssignNode ¶
NewExecAssignNode creates a new node for executing something and store the result on a new variable. The assignment could be made using an operating system command, a pipe of commands or a function invocation. It returns a *ExecAssignNode ready to be executed or error when n is not a valid node for execution.
func (*ExecAssignNode) Command ¶
func (n *ExecAssignNode) Command() Node
Command returns the command (or r-value). Command could be a CommandNode or FnNode
func (*ExecAssignNode) Identifier ¶
func (n *ExecAssignNode) Identifier() string
Name returns the identifier (l-value)
func (*ExecAssignNode) IsEqual ¶
func (n *ExecAssignNode) IsEqual(other Node) bool
func (*ExecAssignNode) SetCommand ¶
func (n *ExecAssignNode) SetCommand(c Node)
SetCommand set the command part (NodeCommand or NodeFnDecl)
func (*ExecAssignNode) SetName ¶
func (n *ExecAssignNode) SetName(name string)
SetName set the assignment identifier (l-value)
func (*ExecAssignNode) String ¶
func (n *ExecAssignNode) String() string
String returns the string representation of command assignment statement
type FnDeclNode ¶
A FnDeclNode represents a function declaration.
func NewFnDeclNode ¶
func NewFnDeclNode(info token.FileInfo, name string) *FnDeclNode
NewFnDeclNode creates a new function declaration
func (*FnDeclNode) AddArg ¶
func (n *FnDeclNode) AddArg(arg string)
AddArg add a new argument to end of argument list
func (*FnDeclNode) IsEqual ¶
func (n *FnDeclNode) IsEqual(other Node) bool
func (*FnDeclNode) String ¶
func (n *FnDeclNode) String() string
String returns the string representation of function declaration
type FnInvNode ¶
A FnInvNode represents a function invocation statement.
func NewFnInvNode ¶
NewFnInvNode creates a new function invocation
type ForNode ¶
A ForNode represents the "for" keyword.
func NewForNode ¶
NewForNode create a new for statement
func (*ForNode) Identifier ¶
Identifier return the identifier part
func (*ForNode) SetIdentifier ¶
SetIdentifier set the for indentifier
type IfNode ¶
IfNode represents the node for the "if" keyword.
func (*IfNode) SetElseTree ¶
SetElseTree sets the block of statements of the else block
type ImportNode ¶
An ImportNode represents the node for an "import" keyword.
func NewImportNode ¶
func NewImportNode(info token.FileInfo, path *StringExpr) *ImportNode
NewImportNode creates a new ImportNode object
func (*ImportNode) IsEqual ¶
func (n *ImportNode) IsEqual(other Node) bool
IsEqual returns if it is equal to the other node.
func (*ImportNode) String ¶
func (n *ImportNode) String() string
String returns the string representation of the import
type ListExpr ¶
ListExpr is a list argument
type Node ¶
type Node interface { Type() NodeType IsEqual(Node) bool // Line of node in the file Line() int // Column of the node in the file Column() int // String representation of the node. // Note that it could not match the correspondent node in // the source code. String() string }
Node represents nodes in the grammar
type NodeType ¶
type NodeType int
NodeType is the types of grammar
const ( // NodeSetenv is the type for "setenv" builtin keyword NodeSetenv NodeType = iota + 1 // NodeBlock represents a program scope. NodeBlock // NodeAssignment is the type for simple variable assignment NodeAssignment // NodeExecAssign is the type for command or function assignment NodeExecAssign // NodeImport is the type for "import" builtin keyword NodeImport // NodeCommand is the type for command execution NodeCommand // NodePipe is the type for pipeline execution NodePipe // NodeRedirect is the type for redirection nodes NodeRedirect // NodeFnInv is the type for function invocation NodeFnInv // NodeStringExpr is the type of string expression (quoted or not). NodeStringExpr // NodeIntExpr is the type of integer expression (commonly list indexing) NodeIntExpr // NodeVarExpr is the type of variable expressions. NodeVarExpr // NodeListExpr is the type of list expression. NodeListExpr // NodeIndexExpr is the type of indexing expressions. NodeIndexExpr // NodeConcatExpr is the type of concatenation expressions. NodeConcatExpr // NodeString are nodes for argument strings NodeString // NodeRfork is the type for rfork statement NodeRfork // NodeRforkFlags are nodes for rfork flags NodeRforkFlags // NodeIf is the type for if statements NodeIf // NodeComment are nodes for comment NodeComment // NodeFnDecl is the type for function declaration NodeFnDecl // NodeReturn is the type for return statement NodeReturn // NodeBindFn is the type for bindfn statements NodeBindFn // NodeDump is the type for dump statements NodeDump // NodeFor is the type for "for" statements NodeFor )
func (NodeType) IsExecutable ¶
IsExecutable returns if the node is executable
type PipeNode ¶
PipeNode represents the node for a command pipeline.
func NewPipeNode ¶
NewPipeNode creates a new command pipeline
func (*PipeNode) AddCmd ¶
func (n *PipeNode) AddCmd(c *CommandNode)
AddCmd add another command to end of the pipeline
func (*PipeNode) Commands ¶
func (n *PipeNode) Commands() []*CommandNode
Commands returns the list of pipeline commands
type RedirMap ¶
type RedirMap struct {
// contains filtered or unexported fields
}
RedirMap is the map of file descriptors of the redirection
type RedirectNode ¶
RedirectNode represents the output redirection part of a command
func NewRedirectNode ¶
func NewRedirectNode(info token.FileInfo) *RedirectNode
NewRedirectNode creates a new redirection node for commands
func (*RedirectNode) IsEqual ¶
func (r *RedirectNode) IsEqual(other Node) bool
IsEqual return if it is equal to the other node.
func (*RedirectNode) LeftFD ¶
func (r *RedirectNode) LeftFD() int
LeftFD return the lhs of the redirection map.
func (*RedirectNode) Location ¶
func (r *RedirectNode) Location() Expr
Location return the location of the redirection.
func (*RedirectNode) RightFD ¶
func (r *RedirectNode) RightFD() int
RightFD return the rhs of the redirection map.
func (*RedirectNode) SetLocation ¶
func (r *RedirectNode) SetLocation(s Expr)
SetLocation of the output
func (*RedirectNode) SetMap ¶
func (r *RedirectNode) SetMap(lfd int, rfd int)
SetMap sets the redirection map. Eg.: [2=1]
func (*RedirectNode) String ¶
func (r *RedirectNode) String() string
String returns the string representation of redirect
type ReturnNode ¶
A ReturnNode represents the "return" keyword.
func NewReturnNode ¶
func NewReturnNode(info token.FileInfo) *ReturnNode
NewReturnNode create a return statement
func (*ReturnNode) IsEqual ¶
func (n *ReturnNode) IsEqual(other Node) bool
func (*ReturnNode) Return ¶
func (n *ReturnNode) Return() Expr
Return returns the argument being returned
func (*ReturnNode) SetReturn ¶
func (n *ReturnNode) SetReturn(a Expr)
SetReturn set the arguments to return
func (*ReturnNode) String ¶
func (n *ReturnNode) String() string
String returns the string representation of return statement
type RforkNode ¶
RforkNode is a builtin node for rfork
func NewRforkNode ¶
NewRforkNode creates a new node for rfork
func (*RforkNode) Arg ¶
func (n *RforkNode) Arg() *StringExpr
Arg return the string argument of the rfork.
func (*RforkNode) SetFlags ¶
func (n *RforkNode) SetFlags(a *StringExpr)
SetFlags sets the rfork flags
type SetenvNode ¶
A SetenvNode represents the node for a "setenv" keyword.
func NewSetenvNode ¶
NewSetenvNode creates a new assignment node
func (*SetenvNode) Assignment ¶ added in v0.2.1
func (n *SetenvNode) Assignment() Node
Assignment returns the setenv assignment (if any)
func (*SetenvNode) Identifier ¶
func (n *SetenvNode) Identifier() string
Identifier returns the environment name.
func (*SetenvNode) IsEqual ¶
func (n *SetenvNode) IsEqual(other Node) bool
IsEqual returns if it is equal to the other node.
func (*SetenvNode) String ¶
func (n *SetenvNode) String() string
String returns the string representation of assignment
type StringExpr ¶
StringExpr is a string argument
func NewStringExpr ¶
func NewStringExpr(info token.FileInfo, value string, quoted bool) *StringExpr
NewArgString creates a new string argument
func (*StringExpr) IsEqual ¶
func (s *StringExpr) IsEqual(other Node) bool
func (*StringExpr) SetValue ¶
func (s *StringExpr) SetValue(a string)
func (*StringExpr) String ¶
func (s *StringExpr) String() string
func (*StringExpr) Value ¶
func (s *StringExpr) Value() string
Value returns the argument string value