ekzhang / percival

📝 Web-based, reactive Datalog notebooks for data analysis and visualization

Home Page:https://percival.ink

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Better error messages with a lexical grammar

ekzhang opened this issue · comments

Right now, the Percival compiler simply parses inputs as a character stream with parser combinators. Although this is simple and was sufficient for the purposes of the basic language, some error messages are a little bit suspect, especially ones that mention "expected ... in input." For example, the error below is misleading. It should suggest either an import, rule, or end-of-file.

image

By switching to a two-phase lexical and syntactic analysis step on a stream of tokens, rather than characters, the parser will be much more flexible, while also having clearer error messages.