s-webber / projog

Prolog programming for the Java platform.
Apache License 2.0
37 stars 9 forks source link

improve error messages when fail to parse prolog syntax #222

Closed s-webber closed 1 year ago

s-webber commented 1 year ago

Make the error messages more informative when an error is encountered while parsing Prolog syntax.

Examples of how errors should be reported:

?- X = [1, 2, 3).

Error parsing query:
No matching ] for [
X = [1, 2, 3).
    ^

?- X = [1, 2, 3 | 4 | 5].

Error parsing query:
Expected ]
X = [1, 2, 3 | 4 | 5].
                 ^

?- X = p(a, b, c, d e f, g).

Error parsing query:
No suitable operands
X = p(a, b, c, d e f, g).
                   ^

?- X = p(a, b, c,).

Error parsing query:
No arguments to parse
X = p(a, b, c,).
             ^

?- X = p(a, b, c,.

Error parsing query:
No matching ) for (
X = p(a, b, c,.