@herb-tools/node 0.5.0 → 0.6.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/herb-node.esm.js +1 -1
- package/dist/herb-node.esm.js.map +1 -1
- package/dist/types/util.d.ts +2 -0
- package/extension/error_helpers.cpp +1 -1
- package/extension/error_helpers.h +1 -1
- package/extension/herb.cpp +29 -4
- package/extension/libherb/ast_nodes.c +80 -37
- package/extension/libherb/ast_nodes.h +25 -17
- package/extension/libherb/ast_pretty_print.c +21 -13
- package/extension/libherb/ast_pretty_print.h +1 -1
- package/extension/libherb/errors.c +1 -1
- package/extension/libherb/errors.h +1 -1
- package/extension/libherb/herb.c +2 -2
- package/extension/libherb/herb.h +2 -1
- package/extension/libherb/include/ast_nodes.h +25 -17
- package/extension/libherb/include/ast_pretty_print.h +1 -1
- package/extension/libherb/include/errors.h +1 -1
- package/extension/libherb/include/herb.h +2 -1
- package/extension/libherb/include/lexer_peek_helpers.h +21 -0
- package/extension/libherb/include/parser.h +6 -1
- package/extension/libherb/include/token_struct.h +6 -1
- package/extension/libherb/include/version.h +1 -1
- package/extension/libherb/lexer.c +20 -1
- package/extension/libherb/lexer_peek_helpers.c +77 -0
- package/extension/libherb/lexer_peek_helpers.h +21 -0
- package/extension/libherb/main.c +2 -2
- package/extension/libherb/parser.c +435 -122
- package/extension/libherb/parser.h +6 -1
- package/extension/libherb/token.c +5 -0
- package/extension/libherb/token_struct.h +6 -1
- package/extension/libherb/version.h +1 -1
- package/extension/libherb/visitor.c +39 -6
- package/extension/nodes.cpp +74 -44
- package/extension/nodes.h +3 -2
- package/package.json +2 -2
package/dist/herb-node.esm.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"herb-node.esm.js","sources":["../src/node-backend.ts","../src/index-esm.mts"],"sourcesContent":["import packageJSON from \"../package.json\" with { type: \"json\" }\n\nimport { HerbBackend } from \"@herb-tools/core\"\n\nexport class HerbBackendNode extends HerbBackend {\n backendVersion(): string {\n return `${packageJSON.name}@${packageJSON.version}`\n }\n}\n","export * from \"@herb-tools/core\"\n\nimport path from \"path\"\nimport binary from \"@mapbox/node-pre-gyp\"\n\nimport { createRequire } from \"module\"\nimport { fileURLToPath } from \"url\"\n\nconst __filename = fileURLToPath(import.meta.url)\nconst __dirname = path.dirname(__filename)\nconst require = createRequire(import.meta.url)\n\nconst packagePath = path.resolve(__dirname, \"../package.json\")\nconst libherbPath = binary.find(packagePath)\n\nconst libHerbBinary = require(libherbPath)\n\nimport { HerbBackendNode } from \"./node-backend.js\"\n\n/**\n * An instance of the `Herb` class using a Node.js backend.\n * This loads `libherb` in a Node.js C++ native extension.\n */\nconst Herb = new HerbBackendNode(\n () => new Promise((resolve, _reject) => resolve(libHerbBinary)),\n)\n\nexport { Herb, HerbBackendNode }\n"],"names":[],"mappings":";;;;;;;;;;;;;AAIM,MAAO,eAAgB,SAAQ,WAAW,CAAA;IAC9C,cAAc,GAAA;QACZ,OAAO,CAAA,EAAG,WAAW,CAAC,IAAI,IAAI,WAAW,CAAC,OAAO,CAAA,CAAE;;
|
|
1
|
+
{"version":3,"file":"herb-node.esm.js","sources":["../src/node-backend.ts","../src/index-esm.mts"],"sourcesContent":["import packageJSON from \"../package.json\" with { type: \"json\" }\n\nimport { HerbBackend } from \"@herb-tools/core\"\n\nexport class HerbBackendNode extends HerbBackend {\n backendVersion(): string {\n return `${packageJSON.name}@${packageJSON.version}`\n }\n}\n","export * from \"@herb-tools/core\"\n\nimport path from \"path\"\nimport binary from \"@mapbox/node-pre-gyp\"\n\nimport { createRequire } from \"module\"\nimport { fileURLToPath } from \"url\"\n\nconst __filename = fileURLToPath(import.meta.url)\nconst __dirname = path.dirname(__filename)\nconst require = createRequire(import.meta.url)\n\nconst packagePath = path.resolve(__dirname, \"../package.json\")\nconst libherbPath = binary.find(packagePath)\n\nconst libHerbBinary = require(libherbPath)\n\nimport { HerbBackendNode } from \"./node-backend.js\"\n\n/**\n * An instance of the `Herb` class using a Node.js backend.\n * This loads `libherb` in a Node.js C++ native extension.\n */\nconst Herb = new HerbBackendNode(\n () => new Promise((resolve, _reject) => resolve(libHerbBinary)),\n)\n\nexport { Herb, HerbBackendNode }\n"],"names":[],"mappings":";;;;;;;;;;;;;AAIM,MAAO,eAAgB,SAAQ,WAAW,CAAA;IAC9C,cAAc,GAAA;QACZ,OAAO,CAAA,EAAG,WAAW,CAAC,IAAI,IAAI,WAAW,CAAC,OAAO,CAAA,CAAE;IACrD;AACD;;ACAD,MAAM,UAAU,GAAG,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC;AACjD,MAAM,SAAS,GAAG,IAAI,CAAC,OAAO,CAAC,UAAU,CAAC;AAC1C,MAAM,OAAO,GAAG,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC;AAE9C,MAAM,WAAW,GAAG,IAAI,CAAC,OAAO,CAAC,SAAS,EAAE,iBAAiB,CAAC;AAC9D,MAAM,WAAW,GAAG,MAAM,CAAC,IAAI,CAAC,WAAW,CAAC;AAE5C,MAAM,aAAa,GAAG,OAAO,CAAC,WAAW,CAAC;AAI1C;;;AAGG;AACH,MAAM,IAAI,GAAG,IAAI,eAAe,CAC9B,MAAM,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,OAAO,KAAK,OAAO,CAAC,aAAa,CAAC,CAAC;;;;"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// NOTE: This file is generated by the templates/template.rb script and should not
|
|
2
|
-
// be modified manually. See /Users/marcoroth/Development/herb-release-0.
|
|
2
|
+
// be modified manually. See /Users/marcoroth/Development/herb-release-0.6.1/templates/javascript/packages/node/extension/error_helpers.cpp.erb
|
|
3
3
|
|
|
4
4
|
#include <node_api.h>
|
|
5
5
|
#include "error_helpers.h"
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// NOTE: This file is generated by the templates/template.rb script and should not
|
|
2
|
-
// be modified manually. See /Users/marcoroth/Development/herb-release-0.
|
|
2
|
+
// be modified manually. See /Users/marcoroth/Development/herb-release-0.6.1/templates/javascript/packages/node/extension/error_helpers.h.erb
|
|
3
3
|
|
|
4
4
|
#ifndef HERB_EXTENSION_ERRORS_H
|
|
5
5
|
#define HERB_EXTENSION_ERRORS_H
|
package/extension/herb.cpp
CHANGED
|
@@ -64,8 +64,8 @@ napi_value Herb_lex_file(napi_env env, napi_callback_info info) {
|
|
|
64
64
|
}
|
|
65
65
|
|
|
66
66
|
napi_value Herb_parse(napi_env env, napi_callback_info info) {
|
|
67
|
-
size_t argc =
|
|
68
|
-
napi_value args[
|
|
67
|
+
size_t argc = 2;
|
|
68
|
+
napi_value args[2];
|
|
69
69
|
napi_get_cb_info(env, info, &argc, args, nullptr, nullptr);
|
|
70
70
|
|
|
71
71
|
if (argc < 1) {
|
|
@@ -76,7 +76,32 @@ napi_value Herb_parse(napi_env env, napi_callback_info info) {
|
|
|
76
76
|
char* string = CheckString(env, args[0]);
|
|
77
77
|
if (!string) { return nullptr; }
|
|
78
78
|
|
|
79
|
-
|
|
79
|
+
parser_options_T* parser_options = nullptr;
|
|
80
|
+
parser_options_T opts = {0};
|
|
81
|
+
|
|
82
|
+
if (argc >= 2) {
|
|
83
|
+
napi_valuetype valuetype;
|
|
84
|
+
napi_typeof(env, args[1], &valuetype);
|
|
85
|
+
|
|
86
|
+
if (valuetype == napi_object) {
|
|
87
|
+
napi_value track_whitespace_prop;
|
|
88
|
+
bool has_prop;
|
|
89
|
+
napi_has_named_property(env, args[1], "track_whitespace", &has_prop);
|
|
90
|
+
|
|
91
|
+
if (has_prop) {
|
|
92
|
+
napi_get_named_property(env, args[1], "track_whitespace", &track_whitespace_prop);
|
|
93
|
+
bool track_whitespace_value;
|
|
94
|
+
napi_get_value_bool(env, track_whitespace_prop, &track_whitespace_value);
|
|
95
|
+
|
|
96
|
+
if (track_whitespace_value) {
|
|
97
|
+
opts.track_whitespace = true;
|
|
98
|
+
parser_options = &opts;
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
AST_DOCUMENT_NODE_T* root = herb_parse(string, parser_options);
|
|
80
105
|
herb_analyze_parse_tree(root, string);
|
|
81
106
|
napi_value result = CreateParseResult(env, root, args[0]);
|
|
82
107
|
|
|
@@ -107,7 +132,7 @@ napi_value Herb_parse_file(napi_env env, napi_callback_info info) {
|
|
|
107
132
|
return nullptr;
|
|
108
133
|
}
|
|
109
134
|
|
|
110
|
-
AST_DOCUMENT_NODE_T* root = herb_parse(string);
|
|
135
|
+
AST_DOCUMENT_NODE_T* root = herb_parse(string, nullptr);
|
|
111
136
|
napi_value result = CreateParseResult(env, root, source_value);
|
|
112
137
|
|
|
113
138
|
ast_node_free((AST_NODE_T *) root);
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// NOTE: This file is generated by the templates/template.rb script and should not
|
|
2
|
-
// be modified manually. See /Users/marcoroth/Development/herb-release-0.
|
|
2
|
+
// be modified manually. See /Users/marcoroth/Development/herb-release-0.6.1/templates/src/ast_nodes.c.erb
|
|
3
3
|
|
|
4
4
|
#include <stdio.h>
|
|
5
5
|
#include <stdbool.h>
|
|
@@ -49,32 +49,19 @@ AST_HTML_OPEN_TAG_NODE_T* ast_html_open_tag_node_init(token_T* tag_opening, toke
|
|
|
49
49
|
return html_open_tag_node;
|
|
50
50
|
}
|
|
51
51
|
|
|
52
|
-
AST_HTML_CLOSE_TAG_NODE_T* ast_html_close_tag_node_init(token_T* tag_opening, token_T* tag_name, token_T* tag_closing, position_T* start_position, position_T* end_position, array_T* errors) {
|
|
52
|
+
AST_HTML_CLOSE_TAG_NODE_T* ast_html_close_tag_node_init(token_T* tag_opening, token_T* tag_name, array_T* children, token_T* tag_closing, position_T* start_position, position_T* end_position, array_T* errors) {
|
|
53
53
|
AST_HTML_CLOSE_TAG_NODE_T* html_close_tag_node = malloc(sizeof(AST_HTML_CLOSE_TAG_NODE_T));
|
|
54
54
|
|
|
55
55
|
ast_node_init(&html_close_tag_node->base, AST_HTML_CLOSE_TAG_NODE, start_position, end_position, errors);
|
|
56
56
|
|
|
57
57
|
html_close_tag_node->tag_opening = token_copy(tag_opening);
|
|
58
58
|
html_close_tag_node->tag_name = token_copy(tag_name);
|
|
59
|
+
html_close_tag_node->children = children;
|
|
59
60
|
html_close_tag_node->tag_closing = token_copy(tag_closing);
|
|
60
61
|
|
|
61
62
|
return html_close_tag_node;
|
|
62
63
|
}
|
|
63
64
|
|
|
64
|
-
AST_HTML_SELF_CLOSE_TAG_NODE_T* ast_html_self_close_tag_node_init(token_T* tag_opening, token_T* tag_name, array_T* attributes, token_T* tag_closing, bool is_void, position_T* start_position, position_T* end_position, array_T* errors) {
|
|
65
|
-
AST_HTML_SELF_CLOSE_TAG_NODE_T* html_self_close_tag_node = malloc(sizeof(AST_HTML_SELF_CLOSE_TAG_NODE_T));
|
|
66
|
-
|
|
67
|
-
ast_node_init(&html_self_close_tag_node->base, AST_HTML_SELF_CLOSE_TAG_NODE, start_position, end_position, errors);
|
|
68
|
-
|
|
69
|
-
html_self_close_tag_node->tag_opening = token_copy(tag_opening);
|
|
70
|
-
html_self_close_tag_node->tag_name = token_copy(tag_name);
|
|
71
|
-
html_self_close_tag_node->attributes = attributes;
|
|
72
|
-
html_self_close_tag_node->tag_closing = token_copy(tag_closing);
|
|
73
|
-
html_self_close_tag_node->is_void = is_void;
|
|
74
|
-
|
|
75
|
-
return html_self_close_tag_node;
|
|
76
|
-
}
|
|
77
|
-
|
|
78
65
|
AST_HTML_ELEMENT_NODE_T* ast_html_element_node_init(struct AST_HTML_OPEN_TAG_NODE_STRUCT* open_tag, token_T* tag_name, array_T* body, struct AST_HTML_CLOSE_TAG_NODE_STRUCT* close_tag, bool is_void, position_T* start_position, position_T* end_position, array_T* errors) {
|
|
79
66
|
AST_HTML_ELEMENT_NODE_T* html_element_node = malloc(sizeof(AST_HTML_ELEMENT_NODE_T));
|
|
80
67
|
|
|
@@ -102,12 +89,12 @@ AST_HTML_ATTRIBUTE_VALUE_NODE_T* ast_html_attribute_value_node_init(token_T* ope
|
|
|
102
89
|
return html_attribute_value_node;
|
|
103
90
|
}
|
|
104
91
|
|
|
105
|
-
AST_HTML_ATTRIBUTE_NAME_NODE_T* ast_html_attribute_name_node_init(
|
|
92
|
+
AST_HTML_ATTRIBUTE_NAME_NODE_T* ast_html_attribute_name_node_init(array_T* children, position_T* start_position, position_T* end_position, array_T* errors) {
|
|
106
93
|
AST_HTML_ATTRIBUTE_NAME_NODE_T* html_attribute_name_node = malloc(sizeof(AST_HTML_ATTRIBUTE_NAME_NODE_T));
|
|
107
94
|
|
|
108
95
|
ast_node_init(&html_attribute_name_node->base, AST_HTML_ATTRIBUTE_NAME_NODE, start_position, end_position, errors);
|
|
109
96
|
|
|
110
|
-
html_attribute_name_node->
|
|
97
|
+
html_attribute_name_node->children = children;
|
|
111
98
|
|
|
112
99
|
return html_attribute_name_node;
|
|
113
100
|
}
|
|
@@ -158,6 +145,30 @@ AST_HTML_DOCTYPE_NODE_T* ast_html_doctype_node_init(token_T* tag_opening, array_
|
|
|
158
145
|
return html_doctype_node;
|
|
159
146
|
}
|
|
160
147
|
|
|
148
|
+
AST_XML_DECLARATION_NODE_T* ast_xml_declaration_node_init(token_T* tag_opening, array_T* children, token_T* tag_closing, position_T* start_position, position_T* end_position, array_T* errors) {
|
|
149
|
+
AST_XML_DECLARATION_NODE_T* xml_declaration_node = malloc(sizeof(AST_XML_DECLARATION_NODE_T));
|
|
150
|
+
|
|
151
|
+
ast_node_init(&xml_declaration_node->base, AST_XML_DECLARATION_NODE, start_position, end_position, errors);
|
|
152
|
+
|
|
153
|
+
xml_declaration_node->tag_opening = token_copy(tag_opening);
|
|
154
|
+
xml_declaration_node->children = children;
|
|
155
|
+
xml_declaration_node->tag_closing = token_copy(tag_closing);
|
|
156
|
+
|
|
157
|
+
return xml_declaration_node;
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
AST_CDATA_NODE_T* ast_cdata_node_init(token_T* tag_opening, array_T* children, token_T* tag_closing, position_T* start_position, position_T* end_position, array_T* errors) {
|
|
161
|
+
AST_CDATA_NODE_T* cdata_node = malloc(sizeof(AST_CDATA_NODE_T));
|
|
162
|
+
|
|
163
|
+
ast_node_init(&cdata_node->base, AST_CDATA_NODE, start_position, end_position, errors);
|
|
164
|
+
|
|
165
|
+
cdata_node->tag_opening = token_copy(tag_opening);
|
|
166
|
+
cdata_node->children = children;
|
|
167
|
+
cdata_node->tag_closing = token_copy(tag_closing);
|
|
168
|
+
|
|
169
|
+
return cdata_node;
|
|
170
|
+
}
|
|
171
|
+
|
|
161
172
|
AST_WHITESPACE_NODE_T* ast_whitespace_node_init(token_T* value, position_T* start_position, position_T* end_position, array_T* errors) {
|
|
162
173
|
AST_WHITESPACE_NODE_T* whitespace_node = malloc(sizeof(AST_WHITESPACE_NODE_T));
|
|
163
174
|
|
|
@@ -208,7 +219,7 @@ AST_ERB_ELSE_NODE_T* ast_erb_else_node_init(token_T* tag_opening, token_T* conte
|
|
|
208
219
|
return erb_else_node;
|
|
209
220
|
}
|
|
210
221
|
|
|
211
|
-
AST_ERB_IF_NODE_T* ast_erb_if_node_init(token_T* tag_opening, token_T* content, token_T* tag_closing, array_T* statements,
|
|
222
|
+
AST_ERB_IF_NODE_T* ast_erb_if_node_init(token_T* tag_opening, token_T* content, token_T* tag_closing, array_T* statements, struct AST_NODE_STRUCT* subsequent, struct AST_ERB_END_NODE_STRUCT* end_node, position_T* start_position, position_T* end_position, array_T* errors) {
|
|
212
223
|
AST_ERB_IF_NODE_T* erb_if_node = malloc(sizeof(AST_ERB_IF_NODE_T));
|
|
213
224
|
|
|
214
225
|
ast_node_init(&erb_if_node->base, AST_ERB_IF_NODE, start_position, end_position, errors);
|
|
@@ -414,7 +425,6 @@ const char* ast_node_type_to_string(AST_NODE_T* node) {
|
|
|
414
425
|
case AST_LITERAL_NODE: return "AST_LITERAL_NODE";
|
|
415
426
|
case AST_HTML_OPEN_TAG_NODE: return "AST_HTML_OPEN_TAG_NODE";
|
|
416
427
|
case AST_HTML_CLOSE_TAG_NODE: return "AST_HTML_CLOSE_TAG_NODE";
|
|
417
|
-
case AST_HTML_SELF_CLOSE_TAG_NODE: return "AST_HTML_SELF_CLOSE_TAG_NODE";
|
|
418
428
|
case AST_HTML_ELEMENT_NODE: return "AST_HTML_ELEMENT_NODE";
|
|
419
429
|
case AST_HTML_ATTRIBUTE_VALUE_NODE: return "AST_HTML_ATTRIBUTE_VALUE_NODE";
|
|
420
430
|
case AST_HTML_ATTRIBUTE_NAME_NODE: return "AST_HTML_ATTRIBUTE_NAME_NODE";
|
|
@@ -422,6 +432,8 @@ const char* ast_node_type_to_string(AST_NODE_T* node) {
|
|
|
422
432
|
case AST_HTML_TEXT_NODE: return "AST_HTML_TEXT_NODE";
|
|
423
433
|
case AST_HTML_COMMENT_NODE: return "AST_HTML_COMMENT_NODE";
|
|
424
434
|
case AST_HTML_DOCTYPE_NODE: return "AST_HTML_DOCTYPE_NODE";
|
|
435
|
+
case AST_XML_DECLARATION_NODE: return "AST_XML_DECLARATION_NODE";
|
|
436
|
+
case AST_CDATA_NODE: return "AST_CDATA_NODE";
|
|
425
437
|
case AST_WHITESPACE_NODE: return "AST_WHITESPACE_NODE";
|
|
426
438
|
case AST_ERB_CONTENT_NODE: return "AST_ERB_CONTENT_NODE";
|
|
427
439
|
case AST_ERB_END_NODE: return "AST_ERB_END_NODE";
|
|
@@ -451,7 +463,6 @@ const char* ast_node_human_type(AST_NODE_T* node) {
|
|
|
451
463
|
case AST_LITERAL_NODE: return "LiteralNode";
|
|
452
464
|
case AST_HTML_OPEN_TAG_NODE: return "HTMLOpenTagNode";
|
|
453
465
|
case AST_HTML_CLOSE_TAG_NODE: return "HTMLCloseTagNode";
|
|
454
|
-
case AST_HTML_SELF_CLOSE_TAG_NODE: return "HTMLSelfCloseTagNode";
|
|
455
466
|
case AST_HTML_ELEMENT_NODE: return "HTMLElementNode";
|
|
456
467
|
case AST_HTML_ATTRIBUTE_VALUE_NODE: return "HTMLAttributeValueNode";
|
|
457
468
|
case AST_HTML_ATTRIBUTE_NAME_NODE: return "HTMLAttributeNameNode";
|
|
@@ -459,6 +470,8 @@ const char* ast_node_human_type(AST_NODE_T* node) {
|
|
|
459
470
|
case AST_HTML_TEXT_NODE: return "HTMLTextNode";
|
|
460
471
|
case AST_HTML_COMMENT_NODE: return "HTMLCommentNode";
|
|
461
472
|
case AST_HTML_DOCTYPE_NODE: return "HTMLDoctypeNode";
|
|
473
|
+
case AST_XML_DECLARATION_NODE: return "XMLDeclarationNode";
|
|
474
|
+
case AST_CDATA_NODE: return "CDATANode";
|
|
462
475
|
case AST_WHITESPACE_NODE: return "WhitespaceNode";
|
|
463
476
|
case AST_ERB_CONTENT_NODE: return "ERBContentNode";
|
|
464
477
|
case AST_ERB_END_NODE: return "ERBEndNode";
|
|
@@ -538,25 +551,17 @@ static void ast_free_html_open_tag_node(AST_HTML_OPEN_TAG_NODE_T* html_open_tag_
|
|
|
538
551
|
static void ast_free_html_close_tag_node(AST_HTML_CLOSE_TAG_NODE_T* html_close_tag_node) {
|
|
539
552
|
if (html_close_tag_node->tag_opening != NULL) { token_free(html_close_tag_node->tag_opening); }
|
|
540
553
|
if (html_close_tag_node->tag_name != NULL) { token_free(html_close_tag_node->tag_name); }
|
|
541
|
-
if (html_close_tag_node->
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
}
|
|
545
|
-
|
|
546
|
-
static void ast_free_html_self_close_tag_node(AST_HTML_SELF_CLOSE_TAG_NODE_T* html_self_close_tag_node) {
|
|
547
|
-
if (html_self_close_tag_node->tag_opening != NULL) { token_free(html_self_close_tag_node->tag_opening); }
|
|
548
|
-
if (html_self_close_tag_node->tag_name != NULL) { token_free(html_self_close_tag_node->tag_name); }
|
|
549
|
-
if (html_self_close_tag_node->attributes != NULL) {
|
|
550
|
-
for (size_t i = 0; i < array_size(html_self_close_tag_node->attributes); i++) {
|
|
551
|
-
AST_NODE_T* child = array_get(html_self_close_tag_node->attributes, i);
|
|
554
|
+
if (html_close_tag_node->children != NULL) {
|
|
555
|
+
for (size_t i = 0; i < array_size(html_close_tag_node->children); i++) {
|
|
556
|
+
AST_NODE_T* child = array_get(html_close_tag_node->children, i);
|
|
552
557
|
if (child) { ast_node_free(child); }
|
|
553
558
|
}
|
|
554
559
|
|
|
555
|
-
array_free(&
|
|
560
|
+
array_free(&html_close_tag_node->children);
|
|
556
561
|
}
|
|
557
|
-
if (
|
|
562
|
+
if (html_close_tag_node->tag_closing != NULL) { token_free(html_close_tag_node->tag_closing); }
|
|
558
563
|
|
|
559
|
-
ast_free_base_node(&
|
|
564
|
+
ast_free_base_node(&html_close_tag_node->base);
|
|
560
565
|
}
|
|
561
566
|
|
|
562
567
|
static void ast_free_html_element_node(AST_HTML_ELEMENT_NODE_T* html_element_node) {
|
|
@@ -591,7 +596,14 @@ static void ast_free_html_attribute_value_node(AST_HTML_ATTRIBUTE_VALUE_NODE_T*
|
|
|
591
596
|
}
|
|
592
597
|
|
|
593
598
|
static void ast_free_html_attribute_name_node(AST_HTML_ATTRIBUTE_NAME_NODE_T* html_attribute_name_node) {
|
|
594
|
-
if (html_attribute_name_node->
|
|
599
|
+
if (html_attribute_name_node->children != NULL) {
|
|
600
|
+
for (size_t i = 0; i < array_size(html_attribute_name_node->children); i++) {
|
|
601
|
+
AST_NODE_T* child = array_get(html_attribute_name_node->children, i);
|
|
602
|
+
if (child) { ast_node_free(child); }
|
|
603
|
+
}
|
|
604
|
+
|
|
605
|
+
array_free(&html_attribute_name_node->children);
|
|
606
|
+
}
|
|
595
607
|
|
|
596
608
|
ast_free_base_node(&html_attribute_name_node->base);
|
|
597
609
|
}
|
|
@@ -640,6 +652,36 @@ static void ast_free_html_doctype_node(AST_HTML_DOCTYPE_NODE_T* html_doctype_nod
|
|
|
640
652
|
ast_free_base_node(&html_doctype_node->base);
|
|
641
653
|
}
|
|
642
654
|
|
|
655
|
+
static void ast_free_xml_declaration_node(AST_XML_DECLARATION_NODE_T* xml_declaration_node) {
|
|
656
|
+
if (xml_declaration_node->tag_opening != NULL) { token_free(xml_declaration_node->tag_opening); }
|
|
657
|
+
if (xml_declaration_node->children != NULL) {
|
|
658
|
+
for (size_t i = 0; i < array_size(xml_declaration_node->children); i++) {
|
|
659
|
+
AST_NODE_T* child = array_get(xml_declaration_node->children, i);
|
|
660
|
+
if (child) { ast_node_free(child); }
|
|
661
|
+
}
|
|
662
|
+
|
|
663
|
+
array_free(&xml_declaration_node->children);
|
|
664
|
+
}
|
|
665
|
+
if (xml_declaration_node->tag_closing != NULL) { token_free(xml_declaration_node->tag_closing); }
|
|
666
|
+
|
|
667
|
+
ast_free_base_node(&xml_declaration_node->base);
|
|
668
|
+
}
|
|
669
|
+
|
|
670
|
+
static void ast_free_cdata_node(AST_CDATA_NODE_T* cdata_node) {
|
|
671
|
+
if (cdata_node->tag_opening != NULL) { token_free(cdata_node->tag_opening); }
|
|
672
|
+
if (cdata_node->children != NULL) {
|
|
673
|
+
for (size_t i = 0; i < array_size(cdata_node->children); i++) {
|
|
674
|
+
AST_NODE_T* child = array_get(cdata_node->children, i);
|
|
675
|
+
if (child) { ast_node_free(child); }
|
|
676
|
+
}
|
|
677
|
+
|
|
678
|
+
array_free(&cdata_node->children);
|
|
679
|
+
}
|
|
680
|
+
if (cdata_node->tag_closing != NULL) { token_free(cdata_node->tag_closing); }
|
|
681
|
+
|
|
682
|
+
ast_free_base_node(&cdata_node->base);
|
|
683
|
+
}
|
|
684
|
+
|
|
643
685
|
static void ast_free_whitespace_node(AST_WHITESPACE_NODE_T* whitespace_node) {
|
|
644
686
|
if (whitespace_node->value != NULL) { token_free(whitespace_node->value); }
|
|
645
687
|
|
|
@@ -938,7 +980,6 @@ void ast_node_free(AST_NODE_T* node) {
|
|
|
938
980
|
case AST_LITERAL_NODE: ast_free_literal_node((AST_LITERAL_NODE_T*) node); break;
|
|
939
981
|
case AST_HTML_OPEN_TAG_NODE: ast_free_html_open_tag_node((AST_HTML_OPEN_TAG_NODE_T*) node); break;
|
|
940
982
|
case AST_HTML_CLOSE_TAG_NODE: ast_free_html_close_tag_node((AST_HTML_CLOSE_TAG_NODE_T*) node); break;
|
|
941
|
-
case AST_HTML_SELF_CLOSE_TAG_NODE: ast_free_html_self_close_tag_node((AST_HTML_SELF_CLOSE_TAG_NODE_T*) node); break;
|
|
942
983
|
case AST_HTML_ELEMENT_NODE: ast_free_html_element_node((AST_HTML_ELEMENT_NODE_T*) node); break;
|
|
943
984
|
case AST_HTML_ATTRIBUTE_VALUE_NODE: ast_free_html_attribute_value_node((AST_HTML_ATTRIBUTE_VALUE_NODE_T*) node); break;
|
|
944
985
|
case AST_HTML_ATTRIBUTE_NAME_NODE: ast_free_html_attribute_name_node((AST_HTML_ATTRIBUTE_NAME_NODE_T*) node); break;
|
|
@@ -946,6 +987,8 @@ void ast_node_free(AST_NODE_T* node) {
|
|
|
946
987
|
case AST_HTML_TEXT_NODE: ast_free_html_text_node((AST_HTML_TEXT_NODE_T*) node); break;
|
|
947
988
|
case AST_HTML_COMMENT_NODE: ast_free_html_comment_node((AST_HTML_COMMENT_NODE_T*) node); break;
|
|
948
989
|
case AST_HTML_DOCTYPE_NODE: ast_free_html_doctype_node((AST_HTML_DOCTYPE_NODE_T*) node); break;
|
|
990
|
+
case AST_XML_DECLARATION_NODE: ast_free_xml_declaration_node((AST_XML_DECLARATION_NODE_T*) node); break;
|
|
991
|
+
case AST_CDATA_NODE: ast_free_cdata_node((AST_CDATA_NODE_T*) node); break;
|
|
949
992
|
case AST_WHITESPACE_NODE: ast_free_whitespace_node((AST_WHITESPACE_NODE_T*) node); break;
|
|
950
993
|
case AST_ERB_CONTENT_NODE: ast_free_erb_content_node((AST_ERB_CONTENT_NODE_T*) node); break;
|
|
951
994
|
case AST_ERB_END_NODE: ast_free_erb_end_node((AST_ERB_END_NODE_T*) node); break;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// NOTE: This file is generated by the templates/template.rb script and should not
|
|
2
|
-
// be modified manually. See /Users/marcoroth/Development/herb-release-0.
|
|
2
|
+
// be modified manually. See /Users/marcoroth/Development/herb-release-0.6.1/templates/src/include/ast_nodes.h.erb
|
|
3
3
|
|
|
4
4
|
#ifndef HERB_AST_NODES_H
|
|
5
5
|
#define HERB_AST_NODES_H
|
|
@@ -19,7 +19,6 @@ typedef enum {
|
|
|
19
19
|
AST_LITERAL_NODE,
|
|
20
20
|
AST_HTML_OPEN_TAG_NODE,
|
|
21
21
|
AST_HTML_CLOSE_TAG_NODE,
|
|
22
|
-
AST_HTML_SELF_CLOSE_TAG_NODE,
|
|
23
22
|
AST_HTML_ELEMENT_NODE,
|
|
24
23
|
AST_HTML_ATTRIBUTE_VALUE_NODE,
|
|
25
24
|
AST_HTML_ATTRIBUTE_NAME_NODE,
|
|
@@ -27,6 +26,8 @@ typedef enum {
|
|
|
27
26
|
AST_HTML_TEXT_NODE,
|
|
28
27
|
AST_HTML_COMMENT_NODE,
|
|
29
28
|
AST_HTML_DOCTYPE_NODE,
|
|
29
|
+
AST_XML_DECLARATION_NODE,
|
|
30
|
+
AST_CDATA_NODE,
|
|
30
31
|
AST_WHITESPACE_NODE,
|
|
31
32
|
AST_ERB_CONTENT_NODE,
|
|
32
33
|
AST_ERB_END_NODE,
|
|
@@ -78,18 +79,10 @@ typedef struct AST_HTML_CLOSE_TAG_NODE_STRUCT {
|
|
|
78
79
|
AST_NODE_T base;
|
|
79
80
|
token_T* tag_opening;
|
|
80
81
|
token_T* tag_name;
|
|
82
|
+
array_T* children;
|
|
81
83
|
token_T* tag_closing;
|
|
82
84
|
} AST_HTML_CLOSE_TAG_NODE_T;
|
|
83
85
|
|
|
84
|
-
typedef struct AST_HTML_SELF_CLOSE_TAG_NODE_STRUCT {
|
|
85
|
-
AST_NODE_T base;
|
|
86
|
-
token_T* tag_opening;
|
|
87
|
-
token_T* tag_name;
|
|
88
|
-
array_T* attributes;
|
|
89
|
-
token_T* tag_closing;
|
|
90
|
-
bool is_void;
|
|
91
|
-
} AST_HTML_SELF_CLOSE_TAG_NODE_T;
|
|
92
|
-
|
|
93
86
|
typedef struct AST_HTML_ELEMENT_NODE_STRUCT {
|
|
94
87
|
AST_NODE_T base;
|
|
95
88
|
struct AST_HTML_OPEN_TAG_NODE_STRUCT* open_tag;
|
|
@@ -109,7 +102,7 @@ typedef struct AST_HTML_ATTRIBUTE_VALUE_NODE_STRUCT {
|
|
|
109
102
|
|
|
110
103
|
typedef struct AST_HTML_ATTRIBUTE_NAME_NODE_STRUCT {
|
|
111
104
|
AST_NODE_T base;
|
|
112
|
-
|
|
105
|
+
array_T* children;
|
|
113
106
|
} AST_HTML_ATTRIBUTE_NAME_NODE_T;
|
|
114
107
|
|
|
115
108
|
typedef struct AST_HTML_ATTRIBUTE_NODE_STRUCT {
|
|
@@ -138,6 +131,20 @@ typedef struct AST_HTML_DOCTYPE_NODE_STRUCT {
|
|
|
138
131
|
token_T* tag_closing;
|
|
139
132
|
} AST_HTML_DOCTYPE_NODE_T;
|
|
140
133
|
|
|
134
|
+
typedef struct AST_XML_DECLARATION_NODE_STRUCT {
|
|
135
|
+
AST_NODE_T base;
|
|
136
|
+
token_T* tag_opening;
|
|
137
|
+
array_T* children;
|
|
138
|
+
token_T* tag_closing;
|
|
139
|
+
} AST_XML_DECLARATION_NODE_T;
|
|
140
|
+
|
|
141
|
+
typedef struct AST_CDATA_NODE_STRUCT {
|
|
142
|
+
AST_NODE_T base;
|
|
143
|
+
token_T* tag_opening;
|
|
144
|
+
array_T* children;
|
|
145
|
+
token_T* tag_closing;
|
|
146
|
+
} AST_CDATA_NODE_T;
|
|
147
|
+
|
|
141
148
|
typedef struct AST_WHITESPACE_NODE_STRUCT {
|
|
142
149
|
AST_NODE_T base;
|
|
143
150
|
token_T* value;
|
|
@@ -174,7 +181,7 @@ typedef struct AST_ERB_IF_NODE_STRUCT {
|
|
|
174
181
|
token_T* content;
|
|
175
182
|
token_T* tag_closing;
|
|
176
183
|
array_T* statements;
|
|
177
|
-
|
|
184
|
+
struct AST_NODE_STRUCT* subsequent;
|
|
178
185
|
struct AST_ERB_END_NODE_STRUCT* end_node;
|
|
179
186
|
} AST_ERB_IF_NODE_T;
|
|
180
187
|
|
|
@@ -301,20 +308,21 @@ typedef struct AST_ERB_IN_NODE_STRUCT {
|
|
|
301
308
|
AST_DOCUMENT_NODE_T* ast_document_node_init(array_T* children, position_T* start_position, position_T* end_position, array_T* errors);
|
|
302
309
|
AST_LITERAL_NODE_T* ast_literal_node_init(const char* content, position_T* start_position, position_T* end_position, array_T* errors);
|
|
303
310
|
AST_HTML_OPEN_TAG_NODE_T* ast_html_open_tag_node_init(token_T* tag_opening, token_T* tag_name, token_T* tag_closing, array_T* children, bool is_void, position_T* start_position, position_T* end_position, array_T* errors);
|
|
304
|
-
AST_HTML_CLOSE_TAG_NODE_T* ast_html_close_tag_node_init(token_T* tag_opening, token_T* tag_name, token_T* tag_closing, position_T* start_position, position_T* end_position, array_T* errors);
|
|
305
|
-
AST_HTML_SELF_CLOSE_TAG_NODE_T* ast_html_self_close_tag_node_init(token_T* tag_opening, token_T* tag_name, array_T* attributes, token_T* tag_closing, bool is_void, position_T* start_position, position_T* end_position, array_T* errors);
|
|
311
|
+
AST_HTML_CLOSE_TAG_NODE_T* ast_html_close_tag_node_init(token_T* tag_opening, token_T* tag_name, array_T* children, token_T* tag_closing, position_T* start_position, position_T* end_position, array_T* errors);
|
|
306
312
|
AST_HTML_ELEMENT_NODE_T* ast_html_element_node_init(struct AST_HTML_OPEN_TAG_NODE_STRUCT* open_tag, token_T* tag_name, array_T* body, struct AST_HTML_CLOSE_TAG_NODE_STRUCT* close_tag, bool is_void, position_T* start_position, position_T* end_position, array_T* errors);
|
|
307
313
|
AST_HTML_ATTRIBUTE_VALUE_NODE_T* ast_html_attribute_value_node_init(token_T* open_quote, array_T* children, token_T* close_quote, bool quoted, position_T* start_position, position_T* end_position, array_T* errors);
|
|
308
|
-
AST_HTML_ATTRIBUTE_NAME_NODE_T* ast_html_attribute_name_node_init(
|
|
314
|
+
AST_HTML_ATTRIBUTE_NAME_NODE_T* ast_html_attribute_name_node_init(array_T* children, position_T* start_position, position_T* end_position, array_T* errors);
|
|
309
315
|
AST_HTML_ATTRIBUTE_NODE_T* ast_html_attribute_node_init(struct AST_HTML_ATTRIBUTE_NAME_NODE_STRUCT* name, token_T* equals, struct AST_HTML_ATTRIBUTE_VALUE_NODE_STRUCT* value, position_T* start_position, position_T* end_position, array_T* errors);
|
|
310
316
|
AST_HTML_TEXT_NODE_T* ast_html_text_node_init(const char* content, position_T* start_position, position_T* end_position, array_T* errors);
|
|
311
317
|
AST_HTML_COMMENT_NODE_T* ast_html_comment_node_init(token_T* comment_start, array_T* children, token_T* comment_end, position_T* start_position, position_T* end_position, array_T* errors);
|
|
312
318
|
AST_HTML_DOCTYPE_NODE_T* ast_html_doctype_node_init(token_T* tag_opening, array_T* children, token_T* tag_closing, position_T* start_position, position_T* end_position, array_T* errors);
|
|
319
|
+
AST_XML_DECLARATION_NODE_T* ast_xml_declaration_node_init(token_T* tag_opening, array_T* children, token_T* tag_closing, position_T* start_position, position_T* end_position, array_T* errors);
|
|
320
|
+
AST_CDATA_NODE_T* ast_cdata_node_init(token_T* tag_opening, array_T* children, token_T* tag_closing, position_T* start_position, position_T* end_position, array_T* errors);
|
|
313
321
|
AST_WHITESPACE_NODE_T* ast_whitespace_node_init(token_T* value, position_T* start_position, position_T* end_position, array_T* errors);
|
|
314
322
|
AST_ERB_CONTENT_NODE_T* ast_erb_content_node_init(token_T* tag_opening, token_T* content, token_T* tag_closing, analyzed_ruby_T* analyzed_ruby, bool parsed, bool valid, position_T* start_position, position_T* end_position, array_T* errors);
|
|
315
323
|
AST_ERB_END_NODE_T* ast_erb_end_node_init(token_T* tag_opening, token_T* content, token_T* tag_closing, position_T* start_position, position_T* end_position, array_T* errors);
|
|
316
324
|
AST_ERB_ELSE_NODE_T* ast_erb_else_node_init(token_T* tag_opening, token_T* content, token_T* tag_closing, array_T* statements, position_T* start_position, position_T* end_position, array_T* errors);
|
|
317
|
-
AST_ERB_IF_NODE_T* ast_erb_if_node_init(token_T* tag_opening, token_T* content, token_T* tag_closing, array_T* statements,
|
|
325
|
+
AST_ERB_IF_NODE_T* ast_erb_if_node_init(token_T* tag_opening, token_T* content, token_T* tag_closing, array_T* statements, struct AST_NODE_STRUCT* subsequent, struct AST_ERB_END_NODE_STRUCT* end_node, position_T* start_position, position_T* end_position, array_T* errors);
|
|
318
326
|
AST_ERB_BLOCK_NODE_T* ast_erb_block_node_init(token_T* tag_opening, token_T* content, token_T* tag_closing, array_T* body, struct AST_ERB_END_NODE_STRUCT* end_node, position_T* start_position, position_T* end_position, array_T* errors);
|
|
319
327
|
AST_ERB_WHEN_NODE_T* ast_erb_when_node_init(token_T* tag_opening, token_T* content, token_T* tag_closing, array_T* statements, position_T* start_position, position_T* end_position, array_T* errors);
|
|
320
328
|
AST_ERB_CASE_NODE_T* ast_erb_case_node_init(token_T* tag_opening, token_T* content, token_T* tag_closing, array_T* children, array_T* conditions, struct AST_ERB_ELSE_NODE_STRUCT* else_clause, struct AST_ERB_END_NODE_STRUCT* end_node, position_T* start_position, position_T* end_position, array_T* errors);
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// NOTE: This file is generated by the templates/template.rb script and should not
|
|
2
|
-
// be modified manually. See /Users/marcoroth/Development/herb-release-0.
|
|
2
|
+
// be modified manually. See /Users/marcoroth/Development/herb-release-0.6.1/templates/src/ast_pretty_print.c.erb
|
|
3
3
|
|
|
4
4
|
#include "include/ast_node.h"
|
|
5
5
|
#include "include/ast_nodes.h"
|
|
@@ -58,20 +58,10 @@ void ast_pretty_print_node(AST_NODE_T* node, const size_t indent, const size_t r
|
|
|
58
58
|
pretty_print_errors(node, indent, relative_indent, false, buffer);
|
|
59
59
|
pretty_print_token_property(html_close_tag_node->tag_opening, "tag_opening", indent, relative_indent, false, buffer);
|
|
60
60
|
pretty_print_token_property(html_close_tag_node->tag_name, "tag_name", indent, relative_indent, false, buffer);
|
|
61
|
+
pretty_print_array("children", html_close_tag_node->children, indent, relative_indent, false, buffer);
|
|
61
62
|
pretty_print_token_property(html_close_tag_node->tag_closing, "tag_closing", indent, relative_indent, true, buffer);
|
|
62
63
|
} break;
|
|
63
64
|
|
|
64
|
-
case AST_HTML_SELF_CLOSE_TAG_NODE: {
|
|
65
|
-
const AST_HTML_SELF_CLOSE_TAG_NODE_T* html_self_close_tag_node = (AST_HTML_SELF_CLOSE_TAG_NODE_T*) node;
|
|
66
|
-
|
|
67
|
-
pretty_print_errors(node, indent, relative_indent, false, buffer);
|
|
68
|
-
pretty_print_token_property(html_self_close_tag_node->tag_opening, "tag_opening", indent, relative_indent, false, buffer);
|
|
69
|
-
pretty_print_token_property(html_self_close_tag_node->tag_name, "tag_name", indent, relative_indent, false, buffer);
|
|
70
|
-
pretty_print_array("attributes", html_self_close_tag_node->attributes, indent, relative_indent, false, buffer);
|
|
71
|
-
pretty_print_token_property(html_self_close_tag_node->tag_closing, "tag_closing", indent, relative_indent, false, buffer);
|
|
72
|
-
pretty_print_boolean_property("is_void", html_self_close_tag_node->is_void, indent, relative_indent, true, buffer);
|
|
73
|
-
} break;
|
|
74
|
-
|
|
75
65
|
case AST_HTML_ELEMENT_NODE: {
|
|
76
66
|
const AST_HTML_ELEMENT_NODE_T* html_element_node = (AST_HTML_ELEMENT_NODE_T*) node;
|
|
77
67
|
|
|
@@ -125,7 +115,7 @@ void ast_pretty_print_node(AST_NODE_T* node, const size_t indent, const size_t r
|
|
|
125
115
|
const AST_HTML_ATTRIBUTE_NAME_NODE_T* html_attribute_name_node = (AST_HTML_ATTRIBUTE_NAME_NODE_T*) node;
|
|
126
116
|
|
|
127
117
|
pretty_print_errors(node, indent, relative_indent, false, buffer);
|
|
128
|
-
|
|
118
|
+
pretty_print_array("children", html_attribute_name_node->children, indent, relative_indent, true, buffer);
|
|
129
119
|
} break;
|
|
130
120
|
|
|
131
121
|
case AST_HTML_ATTRIBUTE_NODE: {
|
|
@@ -190,6 +180,24 @@ void ast_pretty_print_node(AST_NODE_T* node, const size_t indent, const size_t r
|
|
|
190
180
|
pretty_print_token_property(html_doctype_node->tag_closing, "tag_closing", indent, relative_indent, true, buffer);
|
|
191
181
|
} break;
|
|
192
182
|
|
|
183
|
+
case AST_XML_DECLARATION_NODE: {
|
|
184
|
+
const AST_XML_DECLARATION_NODE_T* xml_declaration_node = (AST_XML_DECLARATION_NODE_T*) node;
|
|
185
|
+
|
|
186
|
+
pretty_print_errors(node, indent, relative_indent, false, buffer);
|
|
187
|
+
pretty_print_token_property(xml_declaration_node->tag_opening, "tag_opening", indent, relative_indent, false, buffer);
|
|
188
|
+
pretty_print_array("children", xml_declaration_node->children, indent, relative_indent, false, buffer);
|
|
189
|
+
pretty_print_token_property(xml_declaration_node->tag_closing, "tag_closing", indent, relative_indent, true, buffer);
|
|
190
|
+
} break;
|
|
191
|
+
|
|
192
|
+
case AST_CDATA_NODE: {
|
|
193
|
+
const AST_CDATA_NODE_T* cdata_node = (AST_CDATA_NODE_T*) node;
|
|
194
|
+
|
|
195
|
+
pretty_print_errors(node, indent, relative_indent, false, buffer);
|
|
196
|
+
pretty_print_token_property(cdata_node->tag_opening, "tag_opening", indent, relative_indent, false, buffer);
|
|
197
|
+
pretty_print_array("children", cdata_node->children, indent, relative_indent, false, buffer);
|
|
198
|
+
pretty_print_token_property(cdata_node->tag_closing, "tag_closing", indent, relative_indent, true, buffer);
|
|
199
|
+
} break;
|
|
200
|
+
|
|
193
201
|
case AST_WHITESPACE_NODE: {
|
|
194
202
|
const AST_WHITESPACE_NODE_T* whitespace_node = (AST_WHITESPACE_NODE_T*) node;
|
|
195
203
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// NOTE: This file is generated by the templates/template.rb script and should not
|
|
2
|
-
// be modified manually. See /Users/marcoroth/Development/herb-release-0.
|
|
2
|
+
// be modified manually. See /Users/marcoroth/Development/herb-release-0.6.1/templates/src/include/ast_pretty_print.h.erb
|
|
3
3
|
|
|
4
4
|
#ifndef HERB_AST_PRETTY_PRINT_H
|
|
5
5
|
#define HERB_AST_PRETTY_PRINT_H
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// NOTE: This file is generated by the templates/template.rb script and should not
|
|
2
|
-
// be modified manually. See /Users/marcoroth/Development/herb-release-0.
|
|
2
|
+
// be modified manually. See /Users/marcoroth/Development/herb-release-0.6.1/templates/src/errors.c.erb
|
|
3
3
|
|
|
4
4
|
#include "include/array.h"
|
|
5
5
|
#include "include/errors.h"
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// NOTE: This file is generated by the templates/template.rb script and should not
|
|
2
|
-
// be modified manually. See /Users/marcoroth/Development/herb-release-0.
|
|
2
|
+
// be modified manually. See /Users/marcoroth/Development/herb-release-0.6.1/templates/src/include/errors.h.erb
|
|
3
3
|
|
|
4
4
|
#ifndef HERB_ERRORS_H
|
|
5
5
|
#define HERB_ERRORS_H
|
package/extension/libherb/herb.c
CHANGED
|
@@ -27,9 +27,9 @@ array_T* herb_lex(const char* source) {
|
|
|
27
27
|
return tokens;
|
|
28
28
|
}
|
|
29
29
|
|
|
30
|
-
AST_DOCUMENT_NODE_T* herb_parse(const char* source) {
|
|
30
|
+
AST_DOCUMENT_NODE_T* herb_parse(const char* source, parser_options_T* options) {
|
|
31
31
|
lexer_T* lexer = lexer_init(source);
|
|
32
|
-
parser_T* parser = parser_init(lexer);
|
|
32
|
+
parser_T* parser = parser_init(lexer, options);
|
|
33
33
|
|
|
34
34
|
AST_DOCUMENT_NODE_T* document = parser_parse(parser);
|
|
35
35
|
|
package/extension/libherb/herb.h
CHANGED
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
#include "ast_node.h"
|
|
6
6
|
#include "buffer.h"
|
|
7
7
|
#include "extract.h"
|
|
8
|
+
#include "parser.h"
|
|
8
9
|
|
|
9
10
|
#include <stdint.h>
|
|
10
11
|
|
|
@@ -18,7 +19,7 @@ void herb_lex_json_to_buffer(const char* source, buffer_T* output);
|
|
|
18
19
|
array_T* herb_lex(const char* source);
|
|
19
20
|
array_T* herb_lex_file(const char* path);
|
|
20
21
|
|
|
21
|
-
AST_DOCUMENT_NODE_T* herb_parse(const char* source);
|
|
22
|
+
AST_DOCUMENT_NODE_T* herb_parse(const char* source, parser_options_T* options);
|
|
22
23
|
|
|
23
24
|
const char* herb_version(void);
|
|
24
25
|
const char* herb_prism_version(void);
|