mthom / scryer-prolog

A modern Prolog implementation written mostly in Rust.
BSD 3-Clause "New" or "Revised" License
1.93k stars 116 forks source link

Syntax error description can be improved #2400

Open triska opened 2 months ago

triska commented 2 months ago

Example:

?- T = "\y".
   error(syntax_error(missing_quote),read_term/3:0).

For comparison, with GNU Prolog:

| ?- T = "\s".
uncaught exception: error(syntax_error('user_input:1 (char:7) unknown escape sequence'),read_term/3)
UWN commented 1 month ago

Just one remark about GNU Prolog's error term. It is rather unusual to encode into the atom of syntax_error/1 the specific position as this would unnecessarily clog the atom table. Instead, many systems use here just a simple atom and relegate more complex information to the the second argument of error/2.