CatchTheTornado / askql

AskQL is a query language that can express any data request
https://askql.org/
MIT License
390 stars 27 forks source link

Provide more user-friendly parser errors #358

Open czerwinskilukasz1 opened 4 years ago

czerwinskilukasz1 commented 4 years ago

Currently parser errors are neither short nor easy to read. First of all, the location should be much much shorter. Ideally, the message should be more friendly too.

A standard error looks like this:

SyntaxError: Expected " ", "(", ".", "//", ":", "[", "\n", "\r", "\t", [/], or [\-<>+*\^%=&|] but "'" found.
    Location: {
      "start": {
        "offset": 5,
        "line": 1,
        "column": 6
      },
      "end": {
        "offset": 6,
        "line": 1,
        "column": 7
      }
    }

An error when user forgot a closing brace looks like this: Program:

ask {
    a

Error:

SyntaxError: Expected " ", "(", ".", "//", ":", ";", "=", "[", "\n", "\r", "\t", "}", [/], [\-<>+*\^%=&|], or [_$a-zA-Z0-9] but end of input found.
Location: {
  "start": {
    "offset": 11,
    "line": 2,
    "column": 6
  },
  "end": {
    "offset": 11,
    "line": 2,
    "column": 6
  }
}
czerwinskilukasz1 commented 4 years ago

Some food for thought at https://github.com/pegjs/pegjs/issues/607#issuecomment-479127423 and following comments.