https://github.com/losinggeneration/pego
PEG library in Go based on LPeg
https://github.com/losinggeneration/pego
Last synced: about 1 year ago
JSON representation
PEG library in Go based on LPeg
- Host: GitHub
- URL: https://github.com/losinggeneration/pego
- Owner: losinggeneration
- License: mit
- Created: 2013-06-21T21:27:33.000Z (almost 13 years ago)
- Default Branch: master
- Last Pushed: 2017-03-23T23:45:14.000Z (about 9 years ago)
- Last Synced: 2025-04-15T01:54:15.079Z (about 1 year ago)
- Language: Go
- Size: 45.9 KB
- Stars: 20
- Watchers: 1
- Forks: 4
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: COPYING
Awesome Lists containing this project
README
pego
====
This is a pattern matching library for Go. It is based on lpeg, which uses a flavor of PEG.
This is the official continuation of the project of the same name started by Markus Jarderot.
He wrote the implementation and I've updated the project to work with newer Go versions.
The original project page is located here: https://code.google.com/p/pego/
## Example
```go
pat := Grm("S", map[string]*Pattern{
"S": Ref("A").Clist(),
"A": Seq(
NegSet("()").Rep(0, -1),
Seq(
Ref("B"),
NegSet("()").Rep(0, -1),
).Rep(0, -1)).Csimple(),
"B": Seq(
"(", Ref("A"), ")"),
})
```
## More information
* [LPeg - Parsing Expression Grammars For Lua](http://www.inf.puc-rio.br/~roberto/lpeg/lpeg.html) - Source of inspiration
* [A Text Pattern-Matching Tool based on Parsing Expression Grammars](http://www.inf.puc-rio.br/~roberto/docs/peg.pdf) - Paper on the implementation of LPeg.