[hack] Make lowering fail more gracefully for non-well-formed programs
[hack] Make lowering fail more gracefully for non-well-formed programs

Summary:
The lowerer assumes it receives syntactically well-formed programs. This is why
it throws exceptions when it doesn't. For IDE applications, etc, we need to be
able to deal with incomplete programs and/or typos, yet still produce a (best
effort) AST.

We introduce the flag `fail_open`. When set, failure in case of parse errors
is more graceful than breaking out with an exception.  We may want to be more
precise in future (add special casing for specific `missing_syntax` instances),
but for now, we define special cases for missing expressions and statements,
catching any further errors at either the class element or top level and continue.

Reviewed By: dabek

Differential Revision: D7023896

fbshipit-source-id: 92a0c003859d2d315002f04e2fcb413ad26c62e2

facebook/flow,gabelevi/flow,mroch/flow,facebook/flow,samwgoldman/flow,samwgoldman/flow,jamesgpearce/flow,JonathanUsername/flow,samwgoldman/flow,JonathanUsername/flow,mroch/flow,JonathanUsername/flow,samwgoldman/flow,jamesgpearce/flow,JonathanUsername/flow,popham/flow,claudiopro/flow,popham/flow,samwgoldman/flow,mroch/flow,popham/flow,claudiopro/flow,AgentME/flow,facebook/flow,nmote/flow,facebook/flow,nmote/flow,mroch/flow,AgentME/flow,samwgoldman/flow,claudiopro/flow,nmote/flow,jamesgpearce/flow,popham/flow,nmote/flow,jamesgpearce/flow,gabelevi/flow,popham/flow,mroch/flow,gabelevi/flow,gabelevi/flow,facebook/flow,gabelevi/flow,facebook/flow,nmote/flow,nmote/flow,gabelevi/flow,mroch/flow,mroch/flow,jamesgpearce/flow,AgentME/flow,AgentME/flow,claudiopro/flow,facebook/flow,claudiopro/flow,popham/flow,samwgoldman/flow,AgentME/flow,JonathanUsername/flow,JonathanUsername/flow,JonathanUsername/flow,nmote/flow,popham/flow,gabelevi/flow,jamesgpearce/flow,jamesgpearce/flow