libsnobol4 1.0.2
High-performance SNOBOL4-style pattern matching library
Loading...
Searching...
No Matches
ast_node Struct Reference

#include <ast.h>

Collaboration diagram for ast_node:

Public Attributes

ast_type_t type
uint32_t depth
bool arena_allocated
union { 
   struct { 
      char *   text 
      size_t   len 
   }   literal
   struct { 
      ast_node_t **   parts 
      size_t   count 
   }   concat
   struct { 
      ast_node_t *   left 
      ast_node_t *   right 
   }   alt
   struct { 
      ast_node_t *   sub 
      int32_t   min 
      int32_t   max 
   }   repetition
   struct { 
      char *   set 
      size_t   len 
   }   charclass
   struct { 
      ast_node_t *   sub 
   }   arbno
   struct { 
      int   reg 
      ast_node_t *   sub 
   }   cap
   struct { 
      int   var 
      int   reg 
   }   assign
   struct { 
      int32_t   n 
   }   len
   struct { 
      int   fn 
      int   reg 
   }   eval
   struct { 
      ast_node_t *   expr 
   }   dynamic_eval
   struct { 
      anchor_type_t   atype 
   }   anchor
   struct { 
      char *   text 
      size_t   len 
      int   reg 
   }   emit
   struct { 
      char *   name 
      ast_node_t *   target 
   }   label
   struct { 
      char *   label 
   }   goto_stmt
   struct { 
      char *   table 
      ast_node_t *   key 
   }   table_access
   struct { 
      char *   table 
      ast_node_t *   key 
      ast_node_t *   value 
      uint8_t   value_reg 
   }   table_update
   struct { 
      char *   set 
      size_t   len 
   }   breakx
   struct { 
      uint32_t   open_cp 
      uint32_t   close_cp 
   }   bal
   struct { 
      int32_t   n 
   }   rpos_rtab
   struct { 
      int   reg 
   }   reg_ref
} data

Detailed Description

AST node - tagged union representation

Memory layout:

  • type: identifies which union member is active
  • data: union of node-specific data
  • Children are owned by parent (freed recursively)

Definition at line 139 of file ast.h.

Member Data Documentation

◆ [struct]

struct { ... } ast_node::alt

◆ [struct]

struct { ... } ast_node::anchor

◆ [struct]

struct { ... } ast_node::arbno

◆ arena_allocated

bool ast_node::arena_allocated

True when this node's storage was bump-allocated from the thread-local AST arena (see snobol_ast_set_arena). Such nodes must not be passed to free(); the owning arena is reset by the caller instead. Sub-allocations owned by the node (strings, concat part arrays) are always heap-allocated and freed individually by snobol_ast_free().

Definition at line 157 of file ast.h.

◆ [struct]

struct { ... } ast_node::assign

◆ atype

anchor_type_t ast_node::atype

Definition at line 226 of file ast.h.

◆ [struct]

struct { ... } ast_node::bal

◆ [struct]

struct { ... } ast_node::breakx

◆ [struct]

struct { ... } ast_node::cap

◆ [struct]

struct { ... } ast_node::charclass

◆ close_cp

uint32_t ast_node::close_cp

Definition at line 271 of file ast.h.

◆ [struct]

struct { ... } ast_node::concat

◆ count

size_t ast_node::count

Definition at line 169 of file ast.h.

◆ [union]

union { ... } ast_node::data

◆ depth

uint32_t ast_node::depth

Height of this node's subtree, in nodes (a leaf is 1). Maintained in O(1) by the snobol_ast_create_*() factories and snobol_ast_clone(); the parser uses it to reject patterns whose nesting would exhaust the recursive AST walkers (see SNOBOL_PARSER_MAX_DEPTH).

Definition at line 148 of file ast.h.

◆ [struct]

struct { ... } ast_node::dynamic_eval

◆ [struct]

struct { ... } ast_node::emit

◆ [struct]

struct { ... } ast_node::eval

◆ expr

ast_node_t* ast_node::expr

Definition at line 221 of file ast.h.

◆ fn

int ast_node::fn

Definition at line 215 of file ast.h.

◆ [struct]

struct { ... } ast_node::goto_stmt

◆ key

ast_node_t* ast_node::key

Definition at line 250 of file ast.h.

◆ label [1/2]

char* ast_node::label

Definition at line 244 of file ast.h.

◆ [struct] [2/2]

struct { ... } ast_node::label

◆ left

ast_node_t* ast_node::left

Definition at line 174 of file ast.h.

◆ [struct] [1/2]

struct { ... } ast_node::len

◆ len [2/2]

size_t ast_node::len

Definition at line 163 of file ast.h.

◆ [struct]

struct { ... } ast_node::literal

◆ max

int32_t ast_node::max

Definition at line 182 of file ast.h.

◆ min

int32_t ast_node::min

Definition at line 181 of file ast.h.

◆ n

int32_t ast_node::n

Definition at line 210 of file ast.h.

◆ name

char* ast_node::name

Definition at line 238 of file ast.h.

◆ open_cp

uint32_t ast_node::open_cp

Definition at line 270 of file ast.h.

◆ parts

ast_node_t** ast_node::parts

Definition at line 168 of file ast.h.

◆ reg

int ast_node::reg

Definition at line 198 of file ast.h.

◆ [struct]

struct { ... } ast_node::reg_ref

◆ [struct]

struct { ... } ast_node::repetition

◆ right

ast_node_t* ast_node::right

Definition at line 175 of file ast.h.

◆ [struct]

struct { ... } ast_node::rpos_rtab

◆ set

char* ast_node::set

Definition at line 187 of file ast.h.

◆ sub

ast_node_t* ast_node::sub

Definition at line 180 of file ast.h.

◆ table

char* ast_node::table

Definition at line 249 of file ast.h.

◆ [struct]

struct { ... } ast_node::table_access

◆ [struct]

struct { ... } ast_node::table_update

◆ target

ast_node_t* ast_node::target

Definition at line 239 of file ast.h.

◆ text

char* ast_node::text

Definition at line 162 of file ast.h.

◆ type

ast_type_t ast_node::type

Definition at line 140 of file ast.h.

◆ value

ast_node_t* ast_node::value

Definition at line 257 of file ast.h.

◆ value_reg

uint8_t ast_node::value_reg

Definition at line 258 of file ast.h.

◆ var

int ast_node::var

Definition at line 204 of file ast.h.


The documentation for this struct was generated from the following file:
  • core/include/snobol/ast.h