peg_api.c 874 B

12345678910111213141516171819202122232425262728
  1. #include "Python.h"
  2. #include "tokenizer.h"
  3. #include "pegen.h"
  4. mod_ty
  5. _PyParser_ASTFromString(const char *str, PyObject* filename, int mode,
  6. PyCompilerFlags *flags, PyArena *arena)
  7. {
  8. if (PySys_Audit("compile", "yO", str, filename) < 0) {
  9. return NULL;
  10. }
  11. mod_ty result = _PyPegen_run_parser_from_string(str, mode, filename, flags, arena);
  12. return result;
  13. }
  14. mod_ty
  15. _PyParser_ASTFromFile(FILE *fp, PyObject *filename_ob, const char *enc,
  16. int mode, const char *ps1, const char* ps2,
  17. PyCompilerFlags *flags, int *errcode, PyArena *arena)
  18. {
  19. if (PySys_Audit("compile", "OO", Py_None, filename_ob) < 0) {
  20. return NULL;
  21. }
  22. return _PyPegen_run_parser_from_file_pointer(fp, mode, filename_ob, enc, ps1, ps2,
  23. flags, errcode, arena);
  24. }