Coder Social home page Coder Social logo

as / edit Goto Github PK

View Code? Open in Web Editor NEW
32.0 3.0 2.0 42 KB

A stand-alone implementation of the Acme text editor's command language.

License: BSD 3-Clause "New" or "Revised" License

Go 100.00%
acme edit sam command language structural regular-expression

edit's Introduction

edit

Edit is an implementation of the Acme/Sam command language

usage

ed, _ := text.Open(text.NewBuffer())
ed.Insert([]byte("Removing vowels isnt the best way to name things"), 0)

cmd, _ := edit.Compile(",x,[aeiou],d")
cmd.Run(ed)

fmt.Printf("%s\n", ed.Bytes())
// Rmvng vwls snt th bst wy t nm thngs

example

See example/example.go

reference

Rob Pike pioneered structural regular expressions in the 1980s. The original implementations can be found in his Sam and Acme text editors.

http://doc.cat-v.org/bell_labs/structural_regexps/

http://doc.cat-v.org/bell_labs/sam_lang_tutorial/

Go Report Card

appendix

This implementation now runs 10-1000 times faster

Benchmark before coalescing (2017.09.17)

goos: windows
goarch: amd64
BenchmarkChange128KBto64KB-4             	       1	3531749200 ns/op
BenchmarkChange128KBto128KB-4            	       1	3784740700 ns/op
BenchmarkChange128KBto128KBNest4x2x1-4   	       1	3642752800 ns/op
BenchmarkChange128KBto128KBx16x4x1-4     	       1	3589181900 ns/op

After coalescing (current)

goos: windows
goarch: amd64
pkg: github.com/as/edit
BenchmarkChange128KBto64KB-4                           2         530753100 ns/op
BenchmarkChange128KBto128KB-4                        200           6529711 ns/op
BenchmarkChange128KBto128KBNest4x2x1-4               200           6450888 ns/op
BenchmarkChange128KBto128KBx16x4x1-4                 200           6333687 ns/op
BenchmarkDelete128KB-4                            200000             11720 ns/op
BenchmarkDelete128KBx64-4                             20          93447760 ns/op
BenchmarkDelete128KBx8-4                              20          68008640 ns/op
BenchmarkDelete128KBx1-4                               5         263001000 ns/op
BenchmarkDelete256KBx1-4                               2         519648200 ns/op
BenchmarkDelete512KBx1-4                               1        1032597800 ns/op

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.