Given a string and a formal grammar I would like to determine wether a string is a valid prefix of another string that is accepted by that grammar.
For example, say I was looking for valid JSON prefixes, I would like to determine that [1, 2, 3
is a valid prefix of a JSON document however [1, 2, ]
is not.
I've done some research to find a parser generator that supports this but I can't seem to find any good resources.
I've tried looking at parser generators like tree sitter which support incremental parsing however it doesn't seem to distinguish between errors which show up for valid prefixes and ones for invalid ones.