Closed alexschneider closed 9 years ago
I just made it return a map containing the error since your previous implementation wasn't doing anything with errors and I wanted to ensure that they were at least being generated.
Throwing exceptions is fine but I was just focusing on finishing the parser first. If you want to throw exceptions, go for the implementation :smile:
However, I think we should focus on finishing the parser before doing anything too fancy with error handling.
In our
module.exports
in ourparser.coffee
, we return a map that contains either an error or a program.This unnecessarily complicates things, and we really ought to be throwing exceptions if we have errors - this returning an error and a result pattern is only really applicable for asynchronous code.
If consistency with the scanner is a big deal, we ought to push the program parsing onto the event loop and take in a callback that has an error and result argument like our scanner.
Also, we should consider making CustomError contain a stack trace to make debugging easier.
@rachelriv, is there any reason that the parser does this?