alecthomas / alecthomas/participle
Request for feature: partial parsing
- Dominant language
- Go
- Stars
- 3.9k
- Forks
- 213
- PR merge metrics
- No merged PRs in 30d
Description
Description:
A new method that starts the parser as usual, but returns:
- (State, Resumption, Error)
State is either "Incomplete" (the structure isn't fully parsed) or "Complete" (the structure is fully parsed).
Resumption is something that will allow you to resume parsing with more tokens if State == Incomplete.
If it hits EOF while in the middle of parsing a structure, it pauses, returning something to allow you to resume the parsing from where it left off with new input instead of erroring.
Usecase:
REPLs.
Something like:
```go
document := &ast{}
line := readline()
state, resumption, error := parser.ParsePartial(&document, line)
for {
if err != nil {
// input is malformed
}
if state == Complete {
// evaluate code
} else if state == Incomplete {
line = readline()
state, resumption, err = resumption.Resume(line)
}
}
```
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.