func Re_replace_by(vm *gelo.VM, args *gelo.List, ac uint) gelo.Word { if ac != 3 { gelo.ArgumentError(vm, "replace-all", "regexp string replace-cmd", args) } r := ReOrElse(vm, args.Value) src := args.Next.Value.Ser().Bytes() repl := args.Next.Next.Value return gelo.BytesToSym(r.ReplaceAllFunc(src, func(s []byte) []byte { args := gelo.NewList(gelo.BytesToSym(s)) return vm.API.InvokeCmdOrElse(repl, args).Ser().Bytes() })) }
func Re_replace(vm *gelo.VM, args *gelo.List, ac uint) gelo.Word { if ac != 3 { gelo.ArgumentError(vm, "replace-all", "regexp string replace", args) } r := ReOrElse(vm, args.Value) src := args.Next.Value.Ser().Bytes() repl := args.Next.Next.Value.Ser().Bytes() return gelo.BytesToSym(r.ReplaceAll(src, repl)) }
func (c *couple) Ser() gelo.Symbol { //Couple{p_in p_out} or Couple{} if closed var buf bytes.Buffer buf.WriteString("Couple{") for _, p := range *c { buf.Write(p.Ser().Bytes()) } buf.WriteByte('}') return gelo.BytesToSym(buf.Bytes()) }
func (t *tee) Ser() gelo.Symbol { //Tee{p0 p1 ... pN} var buf bytes.Buffer buf.WriteString("Tee{") for _, p := range *t { buf.Write(p.Ser().Bytes()) } buf.WriteByte('}') return gelo.BytesToSym(buf.Bytes()) }
func Re_matches(vm *gelo.VM, args *gelo.List, ac uint) gelo.Word { if ac != 2 { gelo.ArgumentError(vm, "matches", "regexp string", args) } r := ReOrElse(vm, args.Value) s := args.Next.Value.Ser().Bytes() list := extensions.ListBuilder() for _, v := range r.FindSubmatch(s) { list.Push(gelo.BytesToSym(v)) } return list.List() }
func (s *_stdio) Recv() gelo.Word { line, _ := s.Reader.ReadBytes('\n') return gelo.BytesToSym(line[0 : len(line)-1]) }