-
-
Notifications
You must be signed in to change notification settings - Fork 5.8k
Description
Issue originally reported by @thejameskyle in babel/babylon#347
Right now whenever Babylon comes across a syntax error it immediately throws an error and tosses out the AST. While this is okay for a compiler pipeline where we want don't want to attempt transforming a broken AST, it's not okay for other types of tooling.
For example, there's plenty of tooling that needs to run in your editor while you are typing. If you are in the middle of typing code, you often have a half-finished/invalid program. But this is when editor tooling is most useful because a lot of it's there to help finish what you're typing.
I think the best way to approach this would be to start by removing all the throw-s from the parser code and replace them by pushing to an errors array. Then we can start to identify all the places where we'll have to make a decision on how to continue building the AST.