sqltoast icon indicating copy to clipboard operation
sqltoast copied to clipboard

Robustify syntax error reporting

Open jaypipes opened this issue 7 years ago • 0 comments

Due the various things, including how the lexer's cursor is moved over time, sometimes the syntax errors produced when a parsing problem happens can be confusing. Por ejemplo:

./sqltoaster/sqltoaster "SELECT NULLIF(a, b) FROM t1"
OK
statements[0]:
  <statement: SELECT
   selected columns:
     0: nullif[column-reference[a],column-reference[b]]
   referenced tables:
     0: t1>

(took 73006 nanoseconds)

If I remove the a,b arguments accidentally, I get the following parser syntax error:

./sqltoaster/sqltoaster "SELECT NULLIF() FROM t1"
Syntax error.
Expected to find one of ('*'|<< identifier >>) but found symbol[')']
SELECT NULLIF() FROM t1
             ^^^^^^^^^^
(took 78092 nanoseconds)

What should be there is a message about how a is expected as the first argument to the NULLIF() function.

jaypipes avatar Apr 18 '18 23:04 jaypipes