Herb C Reference
Loading...
Searching...
No Matches
prism_context.h
Go to the documentation of this file.
1#ifndef HERB_PRISM_CONTEXT_H
2#define HERB_PRISM_CONTEXT_H
3
4#include "util/hb_allocator.h"
5#include "util/hb_buffer.h"
6#include <prism.h>
7#include <stdbool.h>
8
9typedef struct {
10 pm_parser_t parser;
11 pm_options_t pm_opts;
12 pm_node_t* root;
13 hb_buffer_T ruby_buf;
14
16 pm_parser_t structural_parser;
17 pm_options_t structural_pm_opts;
18 pm_node_t* structural_root;
19 hb_buffer_T structural_buf;
20
21 hb_allocator_T* allocator;
23
24static inline void herb_prism_context_free(herb_prism_context_T* context) {
25 if (!context) { return; }
26
27 if (context->root) { pm_node_destroy(&context->parser, context->root); }
28
29 pm_parser_free(&context->parser);
30 pm_options_free(&context->pm_opts);
31 hb_buffer_free(&context->ruby_buf);
32
33 if (context->has_structural) {
34 if (context->structural_root) { pm_node_destroy(&context->structural_parser, context->structural_root); }
35
36 pm_parser_free(&context->structural_parser);
37 pm_options_free(&context->structural_pm_opts);
38
39 if (context->structural_buf.value) { hb_buffer_free(&context->structural_buf); }
40 }
41
42 hb_allocator_dealloc(context->allocator, context);
43}
44
45#endif
static void herb_prism_context_free(herb_prism_context_T *context)
Definition prism_context.h:24
Definition prism_context.h:9
hb_buffer_T structural_buf
Definition prism_context.h:19
hb_allocator_T * allocator
Definition prism_context.h:21
pm_options_t pm_opts
Definition prism_context.h:11
pm_node_t * structural_root
Definition prism_context.h:18
pm_options_t structural_pm_opts
Definition prism_context.h:17
bool has_structural
Definition prism_context.h:15
hb_buffer_T ruby_buf
Definition prism_context.h:13
pm_parser_t structural_parser
Definition prism_context.h:16
pm_parser_t parser
Definition prism_context.h:10
pm_node_t * root
Definition prism_context.h:12