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-08 06:23:16 +08:00
|
|
|
func (cp *compiler) chunks(ns []*parse.Chunk) []Op {
|
|
|
|
ops := make([]Op, len(ns))
|
2016-01-23 01:05:15 +08:00
|
|
|
for i, n := range ns {
|
|
|
|
ops[i] = cp.chunk(n)
|
|
|
|
}
|
|
|
|
return ops
|
|
|
|
}
|
2016-02-07 21:13:12 +08:00
|
|
|
func chunkBegins(ns []*parse.Chunk) []int {
|
|
|
|
begins := make([]int, len(ns))
|
|
|
|
for i, n := range ns {
|
|
|
|
begins[i] = n.Begin()
|
|
|
|
}
|
|
|
|
return begins
|
|
|
|
}
|
2016-01-23 01:05:15 +08:00
|
|
|
|
2016-02-08 06:23:16 +08:00
|
|
|
func (cp *compiler) pipelines(ns []*parse.Pipeline) []Op {
|
|
|
|
ops := make([]Op, len(ns))
|
2016-01-23 01:05:15 +08:00
|
|
|
for i, n := range ns {
|
|
|
|
ops[i] = cp.pipeline(n)
|
|
|
|
}
|
|
|
|
return ops
|
|
|
|
}
|
2016-02-07 21:13:12 +08:00
|
|
|
func pipelineBegins(ns []*parse.Pipeline) []int {
|
|
|
|
begins := make([]int, len(ns))
|
|
|
|
for i, n := range ns {
|
|
|
|
begins[i] = n.Begin()
|
|
|
|
}
|
|
|
|
return begins
|
|
|
|
}
|
2016-01-23 01:05:15 +08:00
|
|
|
|
2016-02-08 06:23:16 +08:00
|
|
|
func (cp *compiler) forms(ns []*parse.Form) []Op {
|
|
|
|
ops := make([]Op, len(ns))
|
2016-01-23 01:05:15 +08:00
|
|
|
for i, n := range ns {
|
|
|
|
ops[i] = cp.form(n)
|
|
|
|
}
|
|
|
|
return ops
|
|
|
|
}
|
2016-02-07 21:13:12 +08:00
|
|
|
func formBegins(ns []*parse.Form) []int {
|
|
|
|
begins := make([]int, len(ns))
|
|
|
|
for i, n := range ns {
|
|
|
|
begins[i] = n.Begin()
|
|
|
|
}
|
|
|
|
return begins
|
|
|
|
}
|
2016-01-23 01:05:15 +08:00
|
|
|
|
2016-02-08 06:23:16 +08:00
|
|
|
func (cp *compiler) assignments(ns []*parse.Assignment) []Op {
|
|
|
|
ops := make([]Op, len(ns))
|
2016-02-01 03:36:14 +08:00
|
|
|
for i, n := range ns {
|
|
|
|
ops[i] = cp.assignment(n)
|
|
|
|
}
|
|
|
|
return ops
|
|
|
|
}
|
2016-02-07 21:13:12 +08:00
|
|
|
func assignmentBegins(ns []*parse.Assignment) []int {
|
|
|
|
begins := make([]int, len(ns))
|
|
|
|
for i, n := range ns {
|
|
|
|
begins[i] = n.Begin()
|
|
|
|
}
|
|
|
|
return begins
|
|
|
|
}
|
2016-02-01 03:36:14 +08:00
|
|
|
|
2016-02-08 06:23:16 +08:00
|
|
|
func (cp *compiler) indexingVars(ns []*parse.Indexing, msg string) []VariableOp {
|
|
|
|
ops := make([]VariableOp, len(ns))
|
2016-02-01 18:42:28 +08:00
|
|
|
for i, n := range ns {
|
2016-02-03 23:36:12 +08:00
|
|
|
ops[i] = cp.indexingVar(n, msg)
|
2016-02-01 18:42:28 +08:00
|
|
|
}
|
|
|
|
return ops
|
|
|
|
}
|
2016-02-07 21:13:12 +08:00
|
|
|
func indexingVarBegins(ns []*parse.Indexing) []int {
|
|
|
|
begins := make([]int, len(ns))
|
|
|
|
for i, n := range ns {
|
|
|
|
begins[i] = n.Begin()
|
|
|
|
}
|
|
|
|
return begins
|
|
|
|
}
|
2016-02-01 18:42:28 +08:00
|
|
|
|
2016-02-08 06:23:16 +08:00
|
|
|
func (cp *compiler) redirs(ns []*parse.Redir) []Op {
|
|
|
|
ops := make([]Op, len(ns))
|
2016-01-23 01:05:15 +08:00
|
|
|
for i, n := range ns {
|
|
|
|
ops[i] = cp.redir(n)
|
|
|
|
}
|
|
|
|
return ops
|
|
|
|
}
|
2016-02-07 21:13:12 +08:00
|
|
|
func redirBegins(ns []*parse.Redir) []int {
|
|
|
|
begins := make([]int, len(ns))
|
|
|
|
for i, n := range ns {
|
|
|
|
begins[i] = n.Begin()
|
|
|
|
}
|
|
|
|
return begins
|
|
|
|
}
|
2016-01-23 01:05:15 +08:00
|
|
|
|
2016-02-08 06:23:16 +08:00
|
|
|
func (cp *compiler) compounds(ns []*parse.Compound) []ValuesOp {
|
|
|
|
ops := make([]ValuesOp, len(ns))
|
2016-01-23 01:05:15 +08:00
|
|
|
for i, n := range ns {
|
|
|
|
ops[i] = cp.compound(n)
|
|
|
|
}
|
|
|
|
return ops
|
|
|
|
}
|
2016-02-07 21:13:12 +08:00
|
|
|
func compoundBegins(ns []*parse.Compound) []int {
|
|
|
|
begins := make([]int, len(ns))
|
|
|
|
for i, n := range ns {
|
|
|
|
begins[i] = n.Begin()
|
|
|
|
}
|
|
|
|
return begins
|
|
|
|
}
|
2016-01-23 01:05:15 +08:00
|
|
|
|
2016-02-08 06:23:16 +08:00
|
|
|
func (cp *compiler) arrays(ns []*parse.Array) []ValuesOp {
|
|
|
|
ops := make([]ValuesOp, len(ns))
|
2016-01-23 01:05:15 +08:00
|
|
|
for i, n := range ns {
|
|
|
|
ops[i] = cp.array(n)
|
|
|
|
}
|
|
|
|
return ops
|
|
|
|
}
|
2016-02-07 21:13:12 +08:00
|
|
|
func arrayBegins(ns []*parse.Array) []int {
|
|
|
|
begins := make([]int, len(ns))
|
|
|
|
for i, n := range ns {
|
|
|
|
begins[i] = n.Begin()
|
|
|
|
}
|
|
|
|
return begins
|
|
|
|
}
|
2016-01-23 01:05:15 +08:00
|
|
|
|
2016-02-08 06:23:16 +08:00
|
|
|
func (cp *compiler) indexings(ns []*parse.Indexing) []ValuesOp {
|
|
|
|
ops := make([]ValuesOp, len(ns))
|
2016-01-23 01:05:15 +08:00
|
|
|
for i, n := range ns {
|
2016-02-03 23:36:12 +08:00
|
|
|
ops[i] = cp.indexing(n)
|
2016-01-23 01:05:15 +08:00
|
|
|
}
|
|
|
|
return ops
|
|
|
|
}
|
2016-02-07 21:13:12 +08:00
|
|
|
func indexingBegins(ns []*parse.Indexing) []int {
|
|
|
|
begins := make([]int, len(ns))
|
|
|
|
for i, n := range ns {
|
|
|
|
begins[i] = n.Begin()
|
|
|
|
}
|
|
|
|
return begins
|
|
|
|
}
|
2016-01-23 01:05:15 +08:00
|
|
|
|
2016-02-08 06:23:16 +08:00
|
|
|
func (cp *compiler) primarys(ns []*parse.Primary) []ValuesOp {
|
|
|
|
ops := make([]ValuesOp, len(ns))
|
2016-01-23 01:05:15 +08:00
|
|
|
for i, n := range ns {
|
|
|
|
ops[i] = cp.primary(n)
|
|
|
|
}
|
|
|
|
return ops
|
|
|
|
}
|
2016-02-07 21:13:12 +08:00
|
|
|
func primaryBegins(ns []*parse.Primary) []int {
|
|
|
|
begins := make([]int, len(ns))
|
|
|
|
for i, n := range ns {
|
|
|
|
begins[i] = n.Begin()
|
|
|
|
}
|
|
|
|
return begins
|
|
|
|
}
|
2016-01-23 08:34:11 +08:00
|
|
|
|
2016-02-08 06:23:16 +08:00
|
|
|
func (cp *compiler) outputCaptures(ns []*parse.Primary) []ValuesOp {
|
|
|
|
ops := make([]ValuesOp, len(ns))
|
2016-01-23 08:34:11 +08:00
|
|
|
for i, n := range ns {
|
|
|
|
ops[i] = cp.outputCapture(n)
|
|
|
|
}
|
|
|
|
return ops
|
|
|
|
}
|
2016-02-07 21:13:12 +08:00
|
|
|
func outputCaptureBegins(ns []*parse.Primary) []int {
|
|
|
|
begins := make([]int, len(ns))
|
|
|
|
for i, n := range ns {
|
|
|
|
begins[i] = n.Begin()
|
|
|
|
}
|
|
|
|
return begins
|
|
|
|
}
|
2016-01-23 08:34:11 +08:00
|
|
|
|
2016-02-08 06:23:16 +08:00
|
|
|
func (cp *compiler) lambdas(ns []*parse.Primary) []ValuesOp {
|
|
|
|
ops := make([]ValuesOp, len(ns))
|
2016-01-23 08:34:11 +08:00
|
|
|
for i, n := range ns {
|
|
|
|
ops[i] = cp.lambda(n)
|
|
|
|
}
|
|
|
|
return ops
|
|
|
|
}
|
2016-02-07 21:13:12 +08:00
|
|
|
func lambdaBegins(ns []*parse.Primary) []int {
|
|
|
|
begins := make([]int, len(ns))
|
|
|
|
for i, n := range ns {
|
|
|
|
begins[i] = n.Begin()
|
|
|
|
}
|
|
|
|
return begins
|
|
|
|
}
|
2016-01-23 08:34:11 +08:00
|
|
|
|
2016-02-08 06:23:16 +08:00
|
|
|
func (cp *compiler) map_s(ns []*parse.Primary) []ValuesOp {
|
|
|
|
ops := make([]ValuesOp, len(ns))
|
2016-01-23 08:34:11 +08:00
|
|
|
for i, n := range ns {
|
|
|
|
ops[i] = cp.map_(n)
|
|
|
|
}
|
|
|
|
return ops
|
|
|
|
}
|
2016-02-07 21:13:12 +08:00
|
|
|
func map_Begins(ns []*parse.Primary) []int {
|
|
|
|
begins := make([]int, len(ns))
|
|
|
|
for i, n := range ns {
|
|
|
|
begins[i] = n.Begin()
|
|
|
|
}
|
|
|
|
return begins
|
|
|
|
}
|
2016-01-23 08:34:11 +08:00
|
|
|
|
2016-02-08 06:23:16 +08:00
|
|
|
func (cp *compiler) braceds(ns []*parse.Primary) []ValuesOp {
|
|
|
|
ops := make([]ValuesOp, len(ns))
|
2016-01-23 08:34:11 +08:00
|
|
|
for i, n := range ns {
|
|
|
|
ops[i] = cp.braced(n)
|
|
|
|
}
|
|
|
|
return ops
|
|
|
|
}
|
2016-02-07 21:13:12 +08:00
|
|
|
func bracedBegins(ns []*parse.Primary) []int {
|
|
|
|
begins := make([]int, len(ns))
|
|
|
|
for i, n := range ns {
|
|
|
|
begins[i] = n.Begin()
|
|
|
|
}
|
|
|
|
return begins
|
|
|
|
}
|