You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Partial parsing and exposing the next expected tokens #173
I was wondering if there's a recommended way to handle failed parses, to get a partial result and enumerate the next valid rules that would have been expected. My motivation is to build an auto-complete feature for a small language. I've been struggling to grok the internals of the Peg struct being created. Am I missing something obvious that allows what I'm looking for, or should something change in the implementation to expose the information required to implement such a functionality?
Parse does return an error type that has the "deepest" parse. In a typical peg grammar the parser attempts to parse the input in several different ways, so the correct next token is not clear.
Activity
pointlander commentedon Apr 16, 2025
Parse does return an error type that has the "deepest" parse. In a typical peg grammar the parser attempts to parse the input in several different ways, so the correct next token is not clear.
pointlander commentedon Apr 16, 2025
You could use peg to define your own parsing language, and your parser could use levenshtein distance for parsing.