husk-scheme
husk-scheme copied to clipboard
Extraneous trailing parentheses are allowed
When parsing an expression, extra closing parentheses are allowed; I would expect to receive an error:
parse mainParser "" "())"
produces Right ()
I would expect it to produce a Left value
I solved this by doing
parse (mainParser <* eof) ""
So, I'm not sure if the eof should be built into mainParser or not.
Thanks for the report. Yes, right now the parser only reads the first expression and discards any trailing characters in the input:
huski> (+ 1 2))
3
huski> 1 2 3
1
It probably should throw an error if an extra parenthesis is found, and it would be nice if, at a higher level, more expressions were parsed.