elvish/eval/boilerplate.go

184 lines
4.0 KiB
Go
Raw Normal View History

2016-01-23 01:05:15 +08:00
package eval
2016-01-25 01:10:54 +08:00
import "github.com/elves/elvish/parse"
2016-01-23 01:05:15 +08:00
2016-02-20 07:48:13 +08:00
func (cp *compiler) chunkOp(n *parse.Chunk) Op {
return Op{cp.chunk(n), n.Begin(), n.End()}
}
func (cp *compiler) chunkOps(ns []*parse.Chunk) []Op {
2016-02-08 06:23:16 +08:00
ops := make([]Op, len(ns))
2016-01-23 01:05:15 +08:00
for i, n := range ns {
2016-02-20 07:48:13 +08:00
ops[i] = cp.chunkOp(n)
2016-01-23 01:05:15 +08:00
}
return ops
}
2016-02-20 07:48:13 +08:00
func (cp *compiler) pipelineOp(n *parse.Pipeline) Op {
return Op{cp.pipeline(n), n.Begin(), n.End()}
}
2016-01-23 01:05:15 +08:00
2016-02-20 07:48:13 +08:00
func (cp *compiler) pipelineOps(ns []*parse.Pipeline) []Op {
2016-02-08 06:23:16 +08:00
ops := make([]Op, len(ns))
2016-01-23 01:05:15 +08:00
for i, n := range ns {
2016-02-20 07:48:13 +08:00
ops[i] = cp.pipelineOp(n)
2016-01-23 01:05:15 +08:00
}
return ops
}
2016-02-20 07:48:13 +08:00
func (cp *compiler) formOp(n *parse.Form) Op {
return Op{cp.form(n), n.Begin(), n.End()}
}
2016-01-23 01:05:15 +08:00
2016-02-20 07:48:13 +08:00
func (cp *compiler) formOps(ns []*parse.Form) []Op {
2016-02-08 06:23:16 +08:00
ops := make([]Op, len(ns))
2016-01-23 01:05:15 +08:00
for i, n := range ns {
2016-02-20 07:48:13 +08:00
ops[i] = cp.formOp(n)
2016-01-23 01:05:15 +08:00
}
return ops
}
2016-02-20 07:48:13 +08:00
func (cp *compiler) controlOp(n *parse.Control) Op {
return Op{cp.control(n), n.Begin(), n.End()}
}
2016-01-23 01:05:15 +08:00
2016-02-20 07:48:13 +08:00
func (cp *compiler) controlOps(ns []*parse.Control) []Op {
ops := make([]Op, len(ns))
for i, n := range ns {
2016-02-20 07:48:13 +08:00
ops[i] = cp.controlOp(n)
}
return ops
}
2016-02-20 07:48:13 +08:00
func (cp *compiler) assignmentOp(n *parse.Assignment) Op {
return Op{cp.assignment(n), n.Begin(), n.End()}
}
2016-02-20 07:48:13 +08:00
func (cp *compiler) assignmentOps(ns []*parse.Assignment) []Op {
2016-02-08 06:23:16 +08:00
ops := make([]Op, len(ns))
2016-02-01 03:36:14 +08:00
for i, n := range ns {
2016-02-20 07:48:13 +08:00
ops[i] = cp.assignmentOp(n)
2016-02-01 03:36:14 +08:00
}
return ops
}
2016-02-20 07:48:13 +08:00
func (cp *compiler) redirOp(n *parse.Redir) Op {
return Op{cp.redir(n), n.Begin(), n.End()}
}
2016-02-01 03:36:14 +08:00
2016-02-20 07:48:13 +08:00
func (cp *compiler) redirOps(ns []*parse.Redir) []Op {
ops := make([]Op, len(ns))
for i, n := range ns {
2016-02-20 07:48:13 +08:00
ops[i] = cp.redirOp(n)
}
return ops
}
2016-02-20 07:48:13 +08:00
func (cp *compiler) compoundOp(n *parse.Compound) ValuesOp {
return ValuesOp{cp.compound(n), n.Begin(), n.End()}
}
2016-02-20 07:48:13 +08:00
func (cp *compiler) compoundOps(ns []*parse.Compound) []ValuesOp {
ops := make([]ValuesOp, len(ns))
2016-01-23 01:05:15 +08:00
for i, n := range ns {
2016-02-20 07:48:13 +08:00
ops[i] = cp.compoundOp(n)
2016-01-23 01:05:15 +08:00
}
return ops
}
2016-02-20 07:48:13 +08:00
func (cp *compiler) arrayOp(n *parse.Array) ValuesOp {
return ValuesOp{cp.array(n), n.Begin(), n.End()}
}
2016-01-23 01:05:15 +08:00
2016-02-20 07:48:13 +08:00
func (cp *compiler) arrayOps(ns []*parse.Array) []ValuesOp {
2016-02-08 06:23:16 +08:00
ops := make([]ValuesOp, len(ns))
2016-01-23 01:05:15 +08:00
for i, n := range ns {
2016-02-20 07:48:13 +08:00
ops[i] = cp.arrayOp(n)
2016-01-23 01:05:15 +08:00
}
return ops
}
2016-02-20 07:48:13 +08:00
func (cp *compiler) indexingOp(n *parse.Indexing) ValuesOp {
return ValuesOp{cp.indexing(n), n.Begin(), n.End()}
}
2016-01-23 01:05:15 +08:00
2016-02-20 07:48:13 +08:00
func (cp *compiler) indexingOps(ns []*parse.Indexing) []ValuesOp {
2016-02-08 06:23:16 +08:00
ops := make([]ValuesOp, len(ns))
2016-01-23 01:05:15 +08:00
for i, n := range ns {
2016-02-20 07:48:13 +08:00
ops[i] = cp.indexingOp(n)
2016-01-23 01:05:15 +08:00
}
return ops
}
2016-02-20 07:48:13 +08:00
func (cp *compiler) primaryOp(n *parse.Primary) ValuesOp {
return ValuesOp{cp.primary(n), n.Begin(), n.End()}
}
2016-01-23 01:05:15 +08:00
2016-02-20 07:48:13 +08:00
func (cp *compiler) primaryOps(ns []*parse.Primary) []ValuesOp {
2016-02-08 06:23:16 +08:00
ops := make([]ValuesOp, len(ns))
2016-01-23 01:05:15 +08:00
for i, n := range ns {
2016-02-20 07:48:13 +08:00
ops[i] = cp.primaryOp(n)
2016-01-23 01:05:15 +08:00
}
return ops
}
2016-02-20 07:48:13 +08:00
func (cp *compiler) errorCaptureOp(n *parse.Chunk) ValuesOp {
return ValuesOp{cp.errorCapture(n), n.Begin(), n.End()}
}
2016-01-23 01:05:15 +08:00
2016-02-20 07:48:13 +08:00
func (cp *compiler) errorCaptureOps(ns []*parse.Chunk) []ValuesOp {
2016-02-08 06:23:16 +08:00
ops := make([]ValuesOp, len(ns))
2016-01-23 01:05:15 +08:00
for i, n := range ns {
2016-02-20 07:48:13 +08:00
ops[i] = cp.errorCaptureOp(n)
2016-01-23 01:05:15 +08:00
}
return ops
}
2016-02-20 07:48:13 +08:00
func (cp *compiler) outputCaptureOp(n *parse.Primary) ValuesOp {
return ValuesOp{cp.outputCapture(n), n.Begin(), n.End()}
}
2016-02-20 07:48:13 +08:00
func (cp *compiler) outputCaptureOps(ns []*parse.Primary) []ValuesOp {
ops := make([]ValuesOp, len(ns))
for i, n := range ns {
2016-02-20 07:48:13 +08:00
ops[i] = cp.outputCaptureOp(n)
}
return ops
}
2016-02-20 07:48:13 +08:00
func (cp *compiler) lambdaOp(n *parse.Primary) ValuesOp {
return ValuesOp{cp.lambda(n), n.Begin(), n.End()}
}
2016-02-20 07:48:13 +08:00
func (cp *compiler) lambdaOps(ns []*parse.Primary) []ValuesOp {
2016-02-08 06:23:16 +08:00
ops := make([]ValuesOp, len(ns))
for i, n := range ns {
2016-02-20 07:48:13 +08:00
ops[i] = cp.lambdaOp(n)
}
return ops
}
2016-02-20 07:48:13 +08:00
func (cp *compiler) map_Op(n *parse.Primary) ValuesOp {
return ValuesOp{cp.map_(n), n.Begin(), n.End()}
}
2016-02-20 07:48:13 +08:00
func (cp *compiler) map_Ops(ns []*parse.Primary) []ValuesOp {
2016-02-08 06:23:16 +08:00
ops := make([]ValuesOp, len(ns))
for i, n := range ns {
2016-02-20 07:48:13 +08:00
ops[i] = cp.map_Op(n)
}
return ops
}
2016-02-20 07:48:13 +08:00
func (cp *compiler) bracedOp(n *parse.Primary) ValuesOp {
return ValuesOp{cp.braced(n), n.Begin(), n.End()}
}
2016-02-20 07:48:13 +08:00
func (cp *compiler) bracedOps(ns []*parse.Primary) []ValuesOp {
2016-02-08 06:23:16 +08:00
ops := make([]ValuesOp, len(ns))
for i, n := range ns {
2016-02-20 07:48:13 +08:00
ops[i] = cp.bracedOp(n)
}
return ops
}