Sha256: e06c3e17796e1b0d1ade7a0a34db8a3a168df36b24429b206aa101a9c67dad1e

Contents?: true

Size: 1.66 KB

Versions: 51

Compression:

Stored size: 1.66 KB

Contents

#ifndef _BEL_AST_H
#define _BEL_AST_H

typedef enum {
    BEL_TOKEN,
    BEL_VALUE
} bel_ast_node_type;

typedef enum {
    BEL_TOKEN_STATEMENT,
    BEL_TOKEN_SUBJECT,
    BEL_TOKEN_OBJECT,
    BEL_TOKEN_REL,
    BEL_TOKEN_TERM,
    BEL_TOKEN_ARG,
    BEL_TOKEN_NV
} bel_ast_token_type;

typedef enum {
    BEL_VALUE_FX,
    BEL_VALUE_REL,
    BEL_VALUE_PFX,
    BEL_VALUE_VAL
} bel_ast_value_type;

typedef struct {
    bel_ast_node_type type;
    union {
    bel_ast_token_type ttype;
    bel_ast_value_type vtype;
    };
} bel_ast_node_type_info;

typedef struct bel_ast_node_token bel_ast_node_token;
typedef struct bel_ast_node_value bel_ast_node_value;

typedef struct {
    union {
        bel_ast_node_type_info* type_info;
        bel_ast_node_token*    token;
        bel_ast_node_value*    value;
    };
} bel_ast_node;

struct bel_ast_node_token {
    bel_ast_node_type  type;
    bel_ast_token_type ttype;
    bel_ast_node*      left;
    bel_ast_node*      right;
};

struct bel_ast_node_value {
    bel_ast_node_type  type;
    bel_ast_value_type vtype;
    char*              value;
};

typedef struct {
    bel_ast_node* root;
} bel_ast;

bel_ast_node* bel_new_ast_node_token(bel_ast_token_type type);

bel_ast_node* bel_new_ast_node_value(bel_ast_value_type type, char* value);

bel_ast_node* bel_copy_ast_node(bel_ast_node* node);

bel_ast_node* bel_set_value(bel_ast_node* node, char* value);

bel_ast* bel_new_ast();

void bel_free_ast_node(bel_ast_node* node);

void bel_free_ast(bel_ast* ast);

void bel_print_ast_node(bel_ast_node* node, char* tree_flat_string);

void bel_print_ast(bel_ast* ast);

char* bel_ast_as_string(bel_ast* ast);

#endif /* not defined _BEL_AST_H */

Version data entries

51 entries across 51 versions & 1 rubygems

Version Path
bel-1.1.2 ext/mri/bel-ast.h
bel-1.1.1 ext/mri/bel-ast.h
bel-1.1.0 ext/mri/bel-ast.h
bel-1.0.1 ext/mri/bel-ast.h
bel-1.0.0 ext/mri/bel-ast.h
bel-0.7.0 ext/mri/bel-ast.h
bel-0.6.0 ext/mri/bel-ast.h
bel-0.5.0 ext/mri/bel-ast.h
bel-0.4.2 ext/mri/bel-ast.h
bel-0.4.1 ext/mri/bel-ast.h
bel-0.4.0 ext/mri/bel-ast.h
bel-0.4.0.beta.13 ext/mri/bel-ast.h
bel-0.4.0.beta.12 ext/mri/bel-ast.h
bel-0.4.0.beta.11 ext/mri/bel-ast.h
bel-0.4.0.beta.10 ext/mri/bel-ast.h
bel-0.4.0.beta.9 ext/mri/bel-ast.h
bel-0.4.0.beta.8 ext/mri/bel-ast.h
bel-0.4.0.beta.7 ext/mri/bel-ast.h
bel-0.4.0.beta.5 ext/mri/bel-ast.h
bel-0.4.0.beta.4 ext/mri/bel-ast.h