Custom language parser autocomplete

Our frontend is implementing a custom language for users to query data (simpler than SQL). I am wondering if any parsing libraries exist that could help me provide “autocomplete” like functionality.

For example, a user types if points and then an autocomplete would pop-up with a list of next possible tokens such as [">", "<", "="] .

I’ve looked at NimbleParsec and leex/yacc but can’t seem to find anything for getting the next possible tokens.

I think the solution here is to write a hand-rolled parser that on partial parse returns the next expected token. You might be able to extract this information from parser generator’s error, but that depends on the tool.