Skip to contents
  • walk() performs a depth-first traversal of the AST.

Usage

walk(
  ast,
  node = ast_root_get(ast),
  state,
  pre_op = NULL,
  post_op = NULL,
  pre_dlmtr = NULL,
  post_dlmtr = NULL,
  pre_bkt = NULL,
  post_bkt = NULL,
  pre_null = NULL,
  post_null = NULL,
  pre_lgl = NULL,
  post_lgl = NULL,
  pre_int = NULL,
  post_int = NULL,
  pre_dbl = NULL,
  post_dbl = NULL,
  pre_cpx = NULL,
  post_cpx = NULL,
  pre_chr = NULL,
  post_chr = NULL,
  pre_sym = NULL,
  post_sym = NULL,
  pre_blk = NULL,
  post_blk = NULL,
  pre_grp = NULL,
  post_grp = NULL,
  pre_nuop = NULL,
  post_nuop = NULL,
  pre_unop = NULL,
  post_unop = NULL,
  pre_binop = NULL,
  post_binop = NULL,
  pre_rlp = NULL,
  post_rlp = NULL,
  pre_wlp = NULL,
  post_wlp = NULL,
  pre_flp = NULL,
  post_flp = NULL,
  pre_icond = NULL,
  post_icond = NULL,
  pre_iecond = NULL,
  post_iecond = NULL,
  pre_fndefn = NULL,
  post_fndefn = NULL,
  pre_fncall = NULL,
  post_fncall = NULL,
  pre_sub = NULL,
  post_sub = NULL,
  pre_idx = NULL,
  post_idx = NULL,
  pre_aexpr = NULL,
  post_aexpr = NULL,
  pre_exprs = NULL,
  post_exprs = NULL,
  pre_pars = NULL,
  post_pars = NULL,
  pre_dpar = NULL,
  post_dpar = NULL,
  pre_ndpar = NULL,
  post_ndpar = NULL,
  pre_args = NULL,
  post_args = NULL,
  pre_narg = NULL,
  post_narg = NULL,
  pre_parg = NULL,
  post_parg = NULL,
  pre_cond = NULL,
  post_cond = NULL,
  pre_iter = NULL,
  post_iter = NULL,
  pre_pgm = NULL,
  post_pgm = NULL,
  pre_dlmtd = NULL,
  post_dlmtd = NULL,
  pre_msng = NULL,
  post_msng = NULL,
  pre_beg = NULL,
  post_beg = NULL,
  pre_end = NULL,
  post_end = NULL,
  pre_gap = NULL,
  post_gap = NULL,
  pre_loc = NULL,
  post_loc = NULL
)

Arguments

ast

AST object

node

starting node for traversal; defaults to AST root

state

passed to all the pre_* and post_* functions for sharing and collecting analysis information

pre_aexpr, pre_args, pre_beg, pre_binop, pre_bkt, pre_blk, pre_chr, pre_cond, pre_cpx, pre_dbl, pre_dlmtd, pre_dlmtr, pre_dpar, pre_end, pre_exprs, pre_flp, pre_fncall, pre_fndefn, pre_gap, pre_grp, pre_icond, pre_idx, pre_iecond, pre_int, pre_iter, pre_lgl, pre_loc, pre_msng, pre_narg, pre_ndpar, pre_null, pre_nuop, pre_op, pre_parg, pre_pars, pre_pgm, pre_rlp, pre_sub, pre_sym, pre_unop, pre_wlp

These functions are called before visiting the node's children

post_aexpr, post_args, post_beg, post_binop, post_bkt, post_blk, post_chr, post_cond, post_cpx, post_dbl, post_dlmtd, post_dlmtr, post_dpar, post_end, post_exprs, post_flp, post_fncall, post_fndefn, post_gap, post_grp, post_icond, post_idx, post_iecond, post_int, post_iter, post_lgl, post_msng, post_narg, post_ndpar, post_null, post_nuop, post_op, post_parg, post_pars, post_pgm, post_rlp, post_sub, post_sym, post_unop, post_wlp, post_loc

These functions are called after visiting the node's children