| 391 | return Result() + _model_compilers[type(atom)](self, atom) |
| 392 | |
| 393 | def compile(self, tree): |
| 394 | if tree is None: |
| 395 | return Result() |
| 396 | try: |
| 397 | ret = self.compile_atom(tree) |
| 398 | return ret |
| 399 | except HyCompileError: |
| 400 | # compile calls compile, so we're going to have multiple raise |
| 401 | # nested; so let's re-raise this exception, let's not wrap it in |
| 402 | # another HyCompileError! |
| 403 | raise |
| 404 | except HyLanguageError as e: |
| 405 | # These are expected errors that should be passed to the user. |
| 406 | raise e |
| 407 | except Exception as e: |
| 408 | # These are unexpected errors that will--hopefully--never be seen |
| 409 | # by the user. |
| 410 | f_exc = traceback.format_exc() |
| 411 | exc_msg = "Internal Compiler Bug\n {}".format(f_exc) |
| 412 | raise HyCompileError(exc_msg) |
| 413 | |
| 414 | def _syntax_error(self, expr, message): |
| 415 | raise HySyntaxError(message, expr, self.filename, self.source) |