husk-scheme icon indicating copy to clipboard operation
husk-scheme copied to clipboard

Extraneous trailing parentheses are allowed

Open ryantrinkle opened this issue 9 years ago • 2 comments

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

ryantrinkle avatar Oct 09 '15 18:10 ryantrinkle

I solved this by doing

parse (mainParser <* eof) ""

So, I'm not sure if the eof should be built into mainParser or not.

ryantrinkle avatar Oct 09 '15 19:10 ryantrinkle

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.

justinethier avatar Oct 09 '15 20:10 justinethier