https://github.com/go-toolsmith/strparse
Package strparse provides convenience wrappers around `go/parser` for simple expr/stmt/decl parsing from string.
https://github.com/go-toolsmith/strparse
ast go golang parse string-parsing
Last synced: 5 months ago
JSON representation
Package strparse provides convenience wrappers around `go/parser` for simple expr/stmt/decl parsing from string.
- Host: GitHub
- URL: https://github.com/go-toolsmith/strparse
- Owner: go-toolsmith
- License: mit
- Created: 2018-06-12T11:48:50.000Z (about 8 years ago)
- Default Branch: master
- Last Pushed: 2024-01-07T09:53:12.000Z (over 2 years ago)
- Last Synced: 2024-06-19T17:50:59.173Z (almost 2 years ago)
- Topics: ast, go, golang, parse, string-parsing
- Language: Go
- Homepage:
- Size: 16.6 KB
- Stars: 1
- Watchers: 4
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# strparse
[![build-img]][build-url]
[![pkg-img]][pkg-url]
[![reportcard-img]][reportcard-url]
[![version-img]][version-url]
Package `strparse` provides convenience wrappers around `go/parser` for simple
expression, statement and declaretion parsing from string.
## Installation
Go version 1.16+
```bash
go get github.com/go-toolsmith/strparse
```
## Example
```go
package main
import (
"github.com/go-toolsmith/astequal"
"github.com/go-toolsmith/strparse"
)
func main() {
// Comparing AST strings for equallity (note different spacing):
x := strparse.Expr(`1 + f(v[0].X)`)
y := strparse.Expr(` 1+f( v[0].X ) `)
fmt.Println(astequal.Expr(x, y)) // => true
}
```
## License
[MIT License](LICENSE).
[build-img]: https://github.com/go-toolsmith/strparse/workflows/build/badge.svg
[build-url]: https://github.com/go-toolsmith/strparse/actions
[pkg-img]: https://pkg.go.dev/badge/go-toolsmith/strparse
[pkg-url]: https://pkg.go.dev/github.com/go-toolsmith/strparse
[reportcard-img]: https://goreportcard.com/badge/go-toolsmith/strparse
[reportcard-url]: https://goreportcard.com/report/go-toolsmith/strparse
[version-img]: https://img.shields.io/github/v/release/go-toolsmith/strparse
[version-url]: https://github.com/go-toolsmith/strparse/releases