cpython/Python/ast.c

/*
 * This file exposes PyAST_Validate interface to check the integrity
 * of the given abstract syntax tree (potentially constructed manually).
 */
#include "Python.h"
#include "pycore_ast.h"           // asdl_stmt_seq
#include "pycore_pystate.h"       // _PyThreadState_GET()

#include <assert.h>
#include <stdbool.h>

struct validator {};

#define ENTER_RECURSIVE(ST)

#define LEAVE_RECURSIVE(ST)

static int validate_stmts(struct validator *, asdl_stmt_seq *);
static int validate_exprs(struct validator *, asdl_expr_seq *, expr_context_ty, int);
static int validate_patterns(struct validator *, asdl_pattern_seq *, int);
static int validate_type_params(struct validator *, asdl_type_param_seq *);
static int _validate_nonempty_seq(asdl_seq *, const char *, const char *);
static int validate_stmt(struct validator *, stmt_ty);
static int validate_expr(struct validator *, expr_ty, expr_context_ty);
static int validate_pattern(struct validator *, pattern_ty, int);
static int validate_typeparam(struct validator *, type_param_ty);

#define VALIDATE_POSITIONS(node)

static int
validate_name(PyObject *name)
{}

static int
validate_comprehension(struct validator *state, asdl_comprehension_seq *gens)
{}

static int
validate_keywords(struct validator *state, asdl_keyword_seq *keywords)
{}

static int
validate_args(struct validator *state, asdl_arg_seq *args)
{}

static const char *
expr_context_name(expr_context_ty ctx)
{}

static int
validate_arguments(struct validator *state, arguments_ty args)
{}

static int
validate_constant(struct validator *state, PyObject *value)
{}

static int
validate_expr(struct validator *state, expr_ty exp, expr_context_ty ctx)
{}


// Note: the ensure_literal_* functions are only used to validate a restricted
//       set of non-recursive literals that have already been checked with
//       validate_expr, so they don't accept the validator state
static int
ensure_literal_number(expr_ty exp, bool allow_real, bool allow_imaginary)
{}

static int
ensure_literal_negative(expr_ty exp, bool allow_real, bool allow_imaginary)
{}

static int
ensure_literal_complex(expr_ty exp)
{}

static int
validate_pattern_match_value(struct validator *state, expr_ty exp)
{}

static int
validate_capture(PyObject *name)
{}

static int
validate_pattern(struct validator *state, pattern_ty p, int star_ok)
{}

static int
_validate_nonempty_seq(asdl_seq *seq, const char *what, const char *owner)
{}
#define validate_nonempty_seq(seq, what, owner)

static int
validate_assignlist(struct validator *state, asdl_expr_seq *targets, expr_context_ty ctx)
{}

static int
validate_body(struct validator *state, asdl_stmt_seq *body, const char *owner)
{}

static int
validate_stmt(struct validator *state, stmt_ty stmt)
{}

static int
validate_stmts(struct validator *state, asdl_stmt_seq *seq)
{}

static int
validate_exprs(struct validator *state, asdl_expr_seq *exprs, expr_context_ty ctx, int null_ok)
{}

static int
validate_patterns(struct validator *state, asdl_pattern_seq *patterns, int star_ok)
{}

static int
validate_typeparam(struct validator *state, type_param_ty tp)
{}

static int
validate_type_params(struct validator *state, asdl_type_param_seq *tps)
{}

int
_PyAST_Validate(mod_ty mod)
{}

PyObject *
_PyAST_GetDocString(asdl_stmt_seq *body)
{}