Skip to content

Transform regular expressions into finite state machines and output Go source code

License

Notifications You must be signed in to change notification settings

roger2000hk/re2dfa

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

61 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

re2dfa License Build Status

re2dfa transforms regular expressions into deterministic finite state machines and outputs Go source code containing the matching function.

Installation

go get github.com/opennota/re2dfa

Usage

re2dfa ^a+$ main.matchAPlus string

Benchmarks

Regular expression:

^(?:
    <[A-Za-z][A-Za-z0-9\-]*(?:\s+[a-zA-Z_:][a-zA-Z0-9:._-]*(?:\s*=\s*(?:[^"'=<>`\x00-\x20]+|'[^']*'|"[^"]*"))?)*\s*\/?> |

    <\/[A-Za-z][A-Za-z0-9\-]*\s*> |

    <!----> |

    <!--(?:-?[^>-])(?:-?[^-])*--> |

    <[?].*?[?]> |

    <![A-Z]+\s+[^>]*> |

    <!\[CDATA\[[\s\S]*?\]\]>
)

Benchmark results (Intel(R) Core(TM) i5-2400 CPU @ 3.10GHz):

BenchmarkFSM1          300000         4049 ns/op          0 B/op        0 allocs/op
BenchmarkRegexp1        30000        48303 ns/op        112 B/op        7 allocs/op

About

Transform regular expressions into finite state machines and output Go source code

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages