https://github.com/tvanriel/go-parser
https://github.com/tvanriel/go-parser
Last synced: 6 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/tvanriel/go-parser
- Owner: tvanriel
- License: mit
- Created: 2022-05-28T00:05:12.000Z (about 4 years ago)
- Default Branch: master
- Last Pushed: 2022-06-19T07:28:03.000Z (about 4 years ago)
- Last Synced: 2024-05-17T00:37:48.027Z (about 2 years ago)
- Language: Go
- Size: 3.91 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# go-parser
A simple parser helper written in go with the [go-lexer](https://github.com/bbuck/go-lexer/) in mind.
## Usage
```go
import(
lex "github.com/bbuck/go-lexer"
)
func Parse(tokens []*lex.Token) (*parse.AST, error) {
p := &parse.Parser{
Tokens: tokens,
Cur: 0,
AST: &parse.AST{},
}
for p.Continue() {
ParseTextOrDirective(p)
}
if p.Err() != nil {
return nil, p.Err()
}
return p.AST, nil
}
```