All pastes #955989 Raw Edit

Stuff

public text v1 · immutable
#955989 ·published 2008-03-24 23:22 UTC
rendered paste body
/* struct.h */                                                                                                                                                                                                      
#ifndef _STRUCT_H                                                                                                                                                                                                   
#define _STRUCT_H                                                                                                                                                                                                   
                                                                                                                                                                                                                    
#define MAX_NODES 100           /* essentially, the number of atoms a s-exp can have */                                                                                                                             
                                                                                                                                                                                                                    
enum exp_state { INIT, B_NODE, L_NODE };                                                                                                                                                                            
struct exp                                                                                                                                                                                                          
{                                                                                                                                                                                                                   
    enum exp_state s;                                                                                                                                                                                               
    union                                                                                                                                                                                                           
    {                                                                                                                                                                                                               
        char* s;                                                                                                                                                                                                    
        struct exp* n[MAX_NODES];                                                                                                                                                                                   
    } v;                                                                                                                                                                                                            
    int depth;                                                                                                                                                                                                      
};                                                                                                                                                                                                                  
                                                                                                                                                                                                                    
int set_vexp( struct exp*, char* );                                                                                                                                                                                 
int add_node_exp( struct exp*, struct exp* );                                                                                                                                                                       
void init_exp( struct exp* );                                                                                                                                                                                       
void destroy_exp( struct exp* );                                                                                                                                                                                    
                                                                                                                                                                                                                    
#endif