| 219 | ) |
| 220 | |
| 221 | def parse_external(self, code): |
| 222 | res = (None, None) |
| 223 | try: |
| 224 | return self.ast_dispatcher.parse(code) |
| 225 | except IndentationError as e: |
| 226 | e.filename = "script.py" |
| 227 | # no line info for now |
| 228 | self.report( |
| 229 | "Your code could not be parsed due to an error in the indentation:<br>`%s.`" |
| 230 | % str(e) |
| 231 | ) |
| 232 | |
| 233 | except SyntaxError as e: |
| 234 | e.filename = "script.py" |
| 235 | # no line info for now |
| 236 | self.report( |
| 237 | "Your code can not be executed due to a syntax error:<br>`%s.`" % str(e) |
| 238 | ) |
| 239 | |
| 240 | # Can happen, can't catch this earlier because we can't differentiate between |
| 241 | # TypeError in parsing or TypeError within code (at runtime). |
| 242 | except: |
| 243 | self.report("Something went wrong while parsing your code.") |
| 244 | |
| 245 | return res |
| 246 | |
| 247 | def parse_internal(self, code): |
| 248 | try: |