dayton-outar/smpl

Unfriendly Syntax Error

Closed this issue · 0 comments

Screenshot from 2021-04-25 11-09-09

The above screenshot shows an exception thrown by the lexer (or parser) when it arrives at the second to last line in the SMPL script below,

/* return a newly allocated vector containing elements of v1 followed by elements of v2 */
vappend = (:v1, :v2) { [ | v1 |: i -> v1[i], | v2 |: i -> v2[i] ]; }

x = [ 2, 5, 8 ];
y = [ 7, 0, 1 ];

:> "Append arrays: [ 2, 5, 8 ] & [ 7, 0, 1 ]
:> vappend(x, y);

The syntax throwing the error is illegal because the string is not terminated the a double quote and the statement is not terminated with the semicolon. How do we throw a more graceful error message that guides the programmer to the exact point of error and gives a suggestion?