alecthomas / alecthomas/participle

Request for feature: partial parsing

Abierto
#192 4 comentarios 3 reacciones 0 asignados Ver en GitHub
enhancement
Lenguaje dominante
Go
Estrellas
3.9k
Forks
213
Métricas de merge de PR
Sin PR fusionados en 30 d

Descripción

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)
}
}
```

Guía de contribución

No hay ninguna guía de contribución indexada para este repositorio

Evaluación

Este issue todavía no se ha evaluado.

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.