This will improve the debug experience if something fails in the produced AST. Previously, errors in the produced AST can be felt much later like in the garbage collector or the compiler, making debugging them much more difficult.
#include "pegen.h"
#include "string_parser.h"
+#include "ast.h"
PyObject *
_PyPegen_new_type_comment(Parser *p, char *s)
return RAISE_SYNTAX_ERROR("multiple statements found while compiling a single statement");
}
+#if defined(Py_DEBUG) && defined(Py_BUILD_CORE)
+ if (p->start_rule == Py_single_input ||
+ p->start_rule == Py_file_input ||
+ p->start_rule == Py_eval_input)
+ {
+ assert(PyAST_Validate(res));
+ }
+#endif
return res;
}