herb 0.7.4-x86-linux-gnu → 0.7.5-x86-linux-gnu
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.
- checksums.yaml +4 -4
- data/config.yml +14 -14
- data/ext/herb/extension_helpers.c +9 -15
- data/ext/herb/extension_helpers.h +3 -3
- data/ext/herb/nodes.c +1 -1
- data/lib/herb/3.0/herb.so +0 -0
- data/lib/herb/3.1/herb.so +0 -0
- data/lib/herb/3.2/herb.so +0 -0
- data/lib/herb/3.3/herb.so +0 -0
- data/lib/herb/3.4/herb.so +0 -0
- data/lib/herb/engine.rb +10 -6
- data/lib/herb/version.rb +1 -1
- data/src/analyze.c +43 -80
- data/src/ast_node.c +10 -13
- data/src/ast_nodes.c +31 -33
- data/src/buffer.c +10 -1
- data/src/errors.c +35 -35
- data/src/include/ast_node.h +3 -3
- data/src/include/ast_nodes.h +32 -32
- data/src/include/errors.h +21 -21
- data/src/include/lexer_peek_helpers.h +8 -6
- data/src/include/lexer_struct.h +10 -9
- data/src/include/location.h +10 -13
- data/src/include/parser_helpers.h +1 -1
- data/src/include/position.h +3 -14
- data/src/include/pretty_print.h +1 -1
- data/src/include/prism_helpers.h +1 -1
- data/src/include/range.h +4 -13
- data/src/include/token.h +0 -3
- data/src/include/token_struct.h +2 -2
- data/src/include/version.h +1 -1
- data/src/lexer.c +3 -2
- data/src/lexer_peek_helpers.c +10 -4
- data/src/location.c +9 -37
- data/src/parser.c +98 -119
- data/src/parser_helpers.c +15 -15
- data/src/pretty_print.c +7 -12
- data/src/prism_helpers.c +7 -7
- data/src/range.c +2 -35
- data/src/token.c +25 -29
- data/templates/javascript/packages/core/src/visitor.ts.erb +29 -1
- data/templates/src/ast_nodes.c.erb +1 -3
- data/templates/src/errors.c.erb +5 -7
- data/templates/src/include/ast_nodes.h.erb +2 -2
- data/templates/src/include/errors.h.erb +3 -3
- metadata +2 -3
- data/src/position.c +0 -33
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 71ad6c6d788139d98397fc010ed14607fea675ff70b3180489f988f3c414d307
|
4
|
+
data.tar.gz: bd8aedaf8adf48873703bbf9b1d6a6b4962612ec1af4885c11758b93b66b65ff
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a120fd92055db187dc57864552caebd84cc802459fb7b8f24fd7eaef748996772c567c82aeeb4472c5c00390f223ce5fd5002efb3b666dce72e25cedd6f279b2
|
7
|
+
data.tar.gz: 386c42e813e0103d1fc3136634276badaae0f1455fa0ca27e8f879d3a6887088e5f49f0a955a028f9243da065304818f4a682650a77693ef6ce66912f0e60b61
|
data/config.yml
CHANGED
@@ -34,8 +34,8 @@ errors:
|
|
34
34
|
arguments:
|
35
35
|
- token_type_to_string(found->type)
|
36
36
|
- token_type_to_string(expected_type)
|
37
|
-
- found->location
|
38
|
-
- found->location
|
37
|
+
- found->location.start.line
|
38
|
+
- found->location.start.column
|
39
39
|
|
40
40
|
fields:
|
41
41
|
- name: expected_type
|
@@ -49,8 +49,8 @@ errors:
|
|
49
49
|
template: "Found closing tag `</%s>` at (%zu:%zu) without a matching opening tag."
|
50
50
|
arguments:
|
51
51
|
- closing_tag->value
|
52
|
-
- closing_tag->location
|
53
|
-
- closing_tag->location
|
52
|
+
- closing_tag->location.start.line
|
53
|
+
- closing_tag->location.start.column
|
54
54
|
|
55
55
|
fields:
|
56
56
|
- name: closing_tag
|
@@ -61,8 +61,8 @@ errors:
|
|
61
61
|
template: "Opening tag `<%s>` at (%zu:%zu) doesn't have a matching closing tag `</%s>`."
|
62
62
|
arguments:
|
63
63
|
- opening_tag->value
|
64
|
-
- opening_tag->location
|
65
|
-
- opening_tag->location
|
64
|
+
- opening_tag->location.start.line
|
65
|
+
- opening_tag->location.start.column
|
66
66
|
- opening_tag->value
|
67
67
|
|
68
68
|
fields:
|
@@ -74,11 +74,11 @@ errors:
|
|
74
74
|
template: "Opening tag `<%s>` at (%zu:%zu) closed with `</%s>` at (%zu:%zu)."
|
75
75
|
arguments:
|
76
76
|
- opening_tag->value
|
77
|
-
- opening_tag->location
|
78
|
-
- opening_tag->location
|
77
|
+
- opening_tag->location.start.line
|
78
|
+
- opening_tag->location.start.column
|
79
79
|
- closing_tag->value
|
80
|
-
- closing_tag->location
|
81
|
-
- closing_tag->location
|
80
|
+
- closing_tag->location.start.line
|
81
|
+
- closing_tag->location.start.column
|
82
82
|
|
83
83
|
fields:
|
84
84
|
- name: opening_tag
|
@@ -93,8 +93,8 @@ errors:
|
|
93
93
|
arguments:
|
94
94
|
- opening_quote->value
|
95
95
|
- closing_quote->value
|
96
|
-
- closing_quote->location
|
97
|
-
- closing_quote->location
|
96
|
+
- closing_quote->location.start.line
|
97
|
+
- closing_quote->location.start.column
|
98
98
|
|
99
99
|
fields:
|
100
100
|
- name: opening_quote
|
@@ -127,8 +127,8 @@ errors:
|
|
127
127
|
template: "Tag `<%s>` opened at (%zu:%zu) was never closed before the end of document."
|
128
128
|
arguments:
|
129
129
|
- opening_tag->value
|
130
|
-
- opening_tag->location
|
131
|
-
- opening_tag->location
|
130
|
+
- opening_tag->location.start.line
|
131
|
+
- opening_tag->location.start.column
|
132
132
|
|
133
133
|
fields:
|
134
134
|
- name: opening_tag
|
@@ -20,32 +20,26 @@ const char* check_string(VALUE value) {
|
|
20
20
|
return RSTRING_PTR(value);
|
21
21
|
}
|
22
22
|
|
23
|
-
VALUE rb_position_from_c_struct(position_T
|
24
|
-
if (!position) { return Qnil; }
|
25
|
-
|
23
|
+
VALUE rb_position_from_c_struct(position_T position) {
|
26
24
|
VALUE args[2];
|
27
|
-
args[0] =
|
28
|
-
args[1] =
|
25
|
+
args[0] = UINT2NUM(position.line);
|
26
|
+
args[1] = UINT2NUM(position.column);
|
29
27
|
|
30
28
|
return rb_class_new_instance(2, args, cPosition);
|
31
29
|
}
|
32
30
|
|
33
|
-
VALUE rb_location_from_c_struct(location_T
|
34
|
-
if (!location) { return Qnil; }
|
35
|
-
|
31
|
+
VALUE rb_location_from_c_struct(location_T location) {
|
36
32
|
VALUE args[2];
|
37
|
-
args[0] = rb_position_from_c_struct(location
|
38
|
-
args[1] = rb_position_from_c_struct(location
|
33
|
+
args[0] = rb_position_from_c_struct(location.start);
|
34
|
+
args[1] = rb_position_from_c_struct(location.end);
|
39
35
|
|
40
36
|
return rb_class_new_instance(2, args, cLocation);
|
41
37
|
}
|
42
38
|
|
43
|
-
VALUE rb_range_from_c_struct(range_T
|
44
|
-
if (!range) { return Qnil; }
|
45
|
-
|
39
|
+
VALUE rb_range_from_c_struct(range_T range) {
|
46
40
|
VALUE args[2];
|
47
|
-
args[0] =
|
48
|
-
args[1] =
|
41
|
+
args[0] = UINT2NUM(range.from);
|
42
|
+
args[1] = UINT2NUM(range.to);
|
49
43
|
|
50
44
|
return rb_class_new_instance(2, args, cRange);
|
51
45
|
}
|
@@ -12,11 +12,11 @@
|
|
12
12
|
const char* check_string(VALUE value);
|
13
13
|
VALUE read_file_to_ruby_string(const char* file_path);
|
14
14
|
|
15
|
-
VALUE rb_position_from_c_struct(position_T
|
16
|
-
VALUE rb_location_from_c_struct(location_T
|
15
|
+
VALUE rb_position_from_c_struct(position_T position);
|
16
|
+
VALUE rb_location_from_c_struct(location_T location);
|
17
17
|
|
18
18
|
VALUE rb_token_from_c_struct(token_T* token);
|
19
|
-
VALUE rb_range_from_c_struct(range_T
|
19
|
+
VALUE rb_range_from_c_struct(range_T range);
|
20
20
|
|
21
21
|
VALUE create_lex_result(array_T* tokens, VALUE source);
|
22
22
|
VALUE create_parse_result(AST_DOCUMENT_NODE_T* root, VALUE source);
|
data/ext/herb/nodes.c
CHANGED
@@ -445,7 +445,7 @@ static VALUE rb_erb_content_node_from_c_struct(AST_ERB_CONTENT_NODE_T* erb_conte
|
|
445
445
|
VALUE erb_content_node_tag_opening = rb_token_from_c_struct(erb_content_node->tag_opening);
|
446
446
|
VALUE erb_content_node_content = rb_token_from_c_struct(erb_content_node->content);
|
447
447
|
VALUE erb_content_node_tag_closing = rb_token_from_c_struct(erb_content_node->tag_closing);
|
448
|
-
/* #<Herb::Template::AnalyzedRubyField:
|
448
|
+
/* #<Herb::Template::AnalyzedRubyField:0x00007f952d549150 @name="analyzed_ruby", @options={kind: nil}> */
|
449
449
|
VALUE erb_content_node_analyzed_ruby = Qnil;
|
450
450
|
VALUE erb_content_node_parsed = (erb_content_node->parsed) ? Qtrue : Qfalse;
|
451
451
|
VALUE erb_content_node_valid = (erb_content_node->valid) ? Qtrue : Qfalse;
|
data/lib/herb/3.0/herb.so
CHANGED
Binary file
|
data/lib/herb/3.1/herb.so
CHANGED
Binary file
|
data/lib/herb/3.2/herb.so
CHANGED
Binary file
|
data/lib/herb/3.3/herb.so
CHANGED
Binary file
|
data/lib/herb/3.4/herb.so
CHANGED
Binary file
|
data/lib/herb/engine.rb
CHANGED
@@ -193,13 +193,17 @@ module Herb
|
|
193
193
|
def add_code(code)
|
194
194
|
terminate_expression
|
195
195
|
|
196
|
-
|
197
|
-
|
198
|
-
# TODO: rework and check for Prism::InlineComment as soon as we expose the Prism Nodes in the Herb AST
|
199
|
-
if code.include?("#")
|
200
|
-
@src << "\n"
|
196
|
+
if code.include?("=begin") || code.include?("=end")
|
197
|
+
@src << "\n" << code << "\n"
|
201
198
|
else
|
202
|
-
@src << "
|
199
|
+
@src << " " << code
|
200
|
+
|
201
|
+
# TODO: rework and check for Prism::InlineComment as soon as we expose the Prism Nodes in the Herb AST
|
202
|
+
if code.include?("#")
|
203
|
+
@src << "\n"
|
204
|
+
else
|
205
|
+
@src << ";" unless code[-1] == "\n"
|
206
|
+
end
|
203
207
|
end
|
204
208
|
|
205
209
|
@buffer_on_stack = false
|
data/lib/herb/version.rb
CHANGED
data/src/analyze.c
CHANGED
@@ -96,12 +96,8 @@ static control_type_t detect_control_type(AST_ERB_CONTENT_NODE_T* erb_node) {
|
|
96
96
|
|
97
97
|
if (!ruby) { return CONTROL_TYPE_UNKNOWN; }
|
98
98
|
|
99
|
-
if (ruby->valid) {
|
100
|
-
if (has_yield_node(ruby)) { return CONTROL_TYPE_YIELD; }
|
101
|
-
return CONTROL_TYPE_UNKNOWN;
|
102
|
-
}
|
99
|
+
if (ruby->valid) { return CONTROL_TYPE_UNKNOWN; }
|
103
100
|
|
104
|
-
if (has_yield_node(ruby)) { return CONTROL_TYPE_YIELD; }
|
105
101
|
if (has_block_node(ruby)) { return CONTROL_TYPE_BLOCK; }
|
106
102
|
if (has_if_node(ruby)) { return CONTROL_TYPE_IF; }
|
107
103
|
if (has_elsif_node(ruby)) { return CONTROL_TYPE_ELSIF; }
|
@@ -119,6 +115,7 @@ static control_type_t detect_control_type(AST_ERB_CONTENT_NODE_T* erb_node) {
|
|
119
115
|
if (has_until_node(ruby)) { return CONTROL_TYPE_UNTIL; }
|
120
116
|
if (has_for_node(ruby)) { return CONTROL_TYPE_FOR; }
|
121
117
|
if (has_block_closing(ruby)) { return CONTROL_TYPE_BLOCK_CLOSE; }
|
118
|
+
if (has_yield_node(ruby)) { return CONTROL_TYPE_YIELD; }
|
122
119
|
|
123
120
|
return CONTROL_TYPE_UNKNOWN;
|
124
121
|
}
|
@@ -158,16 +155,16 @@ static AST_NODE_T* create_control_node(
|
|
158
155
|
control_type_t control_type
|
159
156
|
) {
|
160
157
|
array_T* errors = array_init(8);
|
161
|
-
position_T
|
162
|
-
position_T
|
158
|
+
position_T start_position = erb_node->tag_opening->location.start;
|
159
|
+
position_T end_position = erb_node->tag_closing->location.end;
|
163
160
|
|
164
161
|
if (end_node) {
|
165
|
-
end_position = end_node->base.location
|
162
|
+
end_position = end_node->base.location.end;
|
166
163
|
} else if (children && array_size(children) > 0) {
|
167
164
|
AST_NODE_T* last_child = array_get(children, array_size(children) - 1);
|
168
|
-
end_position = last_child->location
|
165
|
+
end_position = last_child->location.end;
|
169
166
|
} else if (subsequent) {
|
170
|
-
end_position = subsequent->location
|
167
|
+
end_position = subsequent->location.end;
|
171
168
|
}
|
172
169
|
|
173
170
|
token_T* tag_opening = erb_node->tag_opening;
|
@@ -435,32 +432,15 @@ static size_t process_control_structure(
|
|
435
432
|
array_T* when_statements = array_init(8);
|
436
433
|
index++;
|
437
434
|
|
438
|
-
|
439
|
-
AST_NODE_T* child = array_get(array, index);
|
440
|
-
|
441
|
-
if (!child) { break; }
|
442
|
-
|
443
|
-
if (child->type == AST_ERB_CONTENT_NODE) {
|
444
|
-
AST_ERB_CONTENT_NODE_T* child_erb = (AST_ERB_CONTENT_NODE_T*) child;
|
445
|
-
control_type_t child_type = detect_control_type(child_erb);
|
446
|
-
|
447
|
-
if (child_type == CONTROL_TYPE_WHEN || child_type == CONTROL_TYPE_IN || child_type == CONTROL_TYPE_ELSE
|
448
|
-
|| child_type == CONTROL_TYPE_END) {
|
449
|
-
break;
|
450
|
-
}
|
451
|
-
}
|
452
|
-
|
453
|
-
array_append(when_statements, child);
|
454
|
-
index++;
|
455
|
-
}
|
435
|
+
index = process_block_children(node, array, index, when_statements, context, CONTROL_TYPE_WHEN);
|
456
436
|
|
457
437
|
AST_ERB_WHEN_NODE_T* when_node = ast_erb_when_node_init(
|
458
438
|
erb_content->tag_opening,
|
459
439
|
erb_content->content,
|
460
440
|
erb_content->tag_closing,
|
461
441
|
when_statements,
|
462
|
-
erb_content->tag_opening->location
|
463
|
-
erb_content->tag_closing->location
|
442
|
+
erb_content->tag_opening->location.start,
|
443
|
+
erb_content->tag_closing->location.end,
|
464
444
|
array_init(8)
|
465
445
|
);
|
466
446
|
|
@@ -471,32 +451,15 @@ static size_t process_control_structure(
|
|
471
451
|
array_T* in_statements = array_init(8);
|
472
452
|
index++;
|
473
453
|
|
474
|
-
|
475
|
-
AST_NODE_T* child = array_get(array, index);
|
476
|
-
|
477
|
-
if (!child) { break; }
|
478
|
-
|
479
|
-
if (child->type == AST_ERB_CONTENT_NODE) {
|
480
|
-
AST_ERB_CONTENT_NODE_T* child_erb = (AST_ERB_CONTENT_NODE_T*) child;
|
481
|
-
control_type_t child_type = detect_control_type(child_erb);
|
482
|
-
|
483
|
-
if (child_type == CONTROL_TYPE_IN || child_type == CONTROL_TYPE_WHEN || child_type == CONTROL_TYPE_ELSE
|
484
|
-
|| child_type == CONTROL_TYPE_END) {
|
485
|
-
break;
|
486
|
-
}
|
487
|
-
}
|
488
|
-
|
489
|
-
array_append(in_statements, child);
|
490
|
-
index++;
|
491
|
-
}
|
454
|
+
index = process_block_children(node, array, index, in_statements, context, CONTROL_TYPE_IN);
|
492
455
|
|
493
456
|
AST_ERB_IN_NODE_T* in_node = ast_erb_in_node_init(
|
494
457
|
erb_content->tag_opening,
|
495
458
|
erb_content->content,
|
496
459
|
erb_content->tag_closing,
|
497
460
|
in_statements,
|
498
|
-
erb_content->tag_opening->location
|
499
|
-
erb_content->tag_closing->location
|
461
|
+
erb_content->tag_opening->location.start,
|
462
|
+
erb_content->tag_closing->location.end,
|
500
463
|
array_init(8)
|
501
464
|
);
|
502
465
|
|
@@ -546,8 +509,8 @@ static size_t process_control_structure(
|
|
546
509
|
next_erb->content,
|
547
510
|
next_erb->tag_closing,
|
548
511
|
else_children,
|
549
|
-
next_erb->tag_opening->location
|
550
|
-
next_erb->tag_closing->location
|
512
|
+
next_erb->tag_opening->location.start,
|
513
|
+
next_erb->tag_closing->location.end,
|
551
514
|
array_init(8)
|
552
515
|
);
|
553
516
|
}
|
@@ -567,8 +530,8 @@ static size_t process_control_structure(
|
|
567
530
|
end_erb->tag_opening,
|
568
531
|
end_erb->content,
|
569
532
|
end_erb->tag_closing,
|
570
|
-
end_erb->tag_opening->location
|
571
|
-
end_erb->tag_closing->location
|
533
|
+
end_erb->tag_opening->location.start,
|
534
|
+
end_erb->tag_closing->location.end,
|
572
535
|
end_erb->base.errors
|
573
536
|
);
|
574
537
|
|
@@ -577,19 +540,19 @@ static size_t process_control_structure(
|
|
577
540
|
}
|
578
541
|
}
|
579
542
|
|
580
|
-
position_T
|
581
|
-
position_T
|
543
|
+
position_T start_position = erb_node->tag_opening->location.start;
|
544
|
+
position_T end_position = erb_node->tag_closing->location.end;
|
582
545
|
|
583
546
|
if (end_node) {
|
584
|
-
end_position = end_node->base.location
|
547
|
+
end_position = end_node->base.location.end;
|
585
548
|
} else if (else_clause) {
|
586
|
-
end_position = else_clause->base.location
|
549
|
+
end_position = else_clause->base.location.end;
|
587
550
|
} else if (array_size(when_conditions) > 0) {
|
588
551
|
AST_NODE_T* last_when = array_get(when_conditions, array_size(when_conditions) - 1);
|
589
|
-
end_position = last_when->location
|
552
|
+
end_position = last_when->location.end;
|
590
553
|
} else if (array_size(in_conditions) > 0) {
|
591
554
|
AST_NODE_T* last_in = array_get(in_conditions, array_size(in_conditions) - 1);
|
592
|
-
end_position = last_in->location
|
555
|
+
end_position = last_in->location.end;
|
593
556
|
}
|
594
557
|
|
595
558
|
if (array_size(in_conditions) > 0) {
|
@@ -682,8 +645,8 @@ static size_t process_control_structure(
|
|
682
645
|
next_erb->content,
|
683
646
|
next_erb->tag_closing,
|
684
647
|
else_children,
|
685
|
-
next_erb->tag_opening->location
|
686
|
-
next_erb->tag_closing->location
|
648
|
+
next_erb->tag_opening->location.start,
|
649
|
+
next_erb->tag_closing->location.end,
|
687
650
|
array_init(8)
|
688
651
|
);
|
689
652
|
}
|
@@ -723,8 +686,8 @@ static size_t process_control_structure(
|
|
723
686
|
next_erb->content,
|
724
687
|
next_erb->tag_closing,
|
725
688
|
ensure_children,
|
726
|
-
next_erb->tag_opening->location
|
727
|
-
next_erb->tag_closing->location
|
689
|
+
next_erb->tag_opening->location.start,
|
690
|
+
next_erb->tag_closing->location.end,
|
728
691
|
array_init(8)
|
729
692
|
);
|
730
693
|
}
|
@@ -744,8 +707,8 @@ static size_t process_control_structure(
|
|
744
707
|
end_erb->tag_opening,
|
745
708
|
end_erb->content,
|
746
709
|
end_erb->tag_closing,
|
747
|
-
end_erb->tag_opening->location
|
748
|
-
end_erb->tag_closing->location
|
710
|
+
end_erb->tag_opening->location.start,
|
711
|
+
end_erb->tag_closing->location.end,
|
749
712
|
end_erb->base.errors
|
750
713
|
);
|
751
714
|
|
@@ -754,17 +717,17 @@ static size_t process_control_structure(
|
|
754
717
|
}
|
755
718
|
}
|
756
719
|
|
757
|
-
position_T
|
758
|
-
position_T
|
720
|
+
position_T start_position = erb_node->tag_opening->location.start;
|
721
|
+
position_T end_position = erb_node->tag_closing->location.end;
|
759
722
|
|
760
723
|
if (end_node) {
|
761
|
-
end_position = end_node->base.location
|
724
|
+
end_position = end_node->base.location.end;
|
762
725
|
} else if (ensure_clause) {
|
763
|
-
end_position = ensure_clause->base.location
|
726
|
+
end_position = ensure_clause->base.location.end;
|
764
727
|
} else if (else_clause) {
|
765
|
-
end_position = else_clause->base.location
|
728
|
+
end_position = else_clause->base.location.end;
|
766
729
|
} else if (rescue_clause) {
|
767
|
-
end_position = rescue_clause->base.location
|
730
|
+
end_position = rescue_clause->base.location.end;
|
768
731
|
}
|
769
732
|
|
770
733
|
AST_ERB_BEGIN_NODE_T* begin_node = ast_erb_begin_node_init(
|
@@ -802,8 +765,8 @@ static size_t process_control_structure(
|
|
802
765
|
close_erb->tag_opening,
|
803
766
|
close_erb->content,
|
804
767
|
close_erb->tag_closing,
|
805
|
-
close_erb->tag_opening->location
|
806
|
-
close_erb->tag_closing->location
|
768
|
+
close_erb->tag_opening->location.start,
|
769
|
+
close_erb->tag_closing->location.end,
|
807
770
|
close_erb->base.errors
|
808
771
|
);
|
809
772
|
|
@@ -812,14 +775,14 @@ static size_t process_control_structure(
|
|
812
775
|
}
|
813
776
|
}
|
814
777
|
|
815
|
-
position_T
|
816
|
-
position_T
|
778
|
+
position_T start_position = erb_node->tag_opening->location.start;
|
779
|
+
position_T end_position = erb_node->tag_closing->location.end;
|
817
780
|
|
818
781
|
if (end_node) {
|
819
|
-
end_position = end_node->base.location
|
782
|
+
end_position = end_node->base.location.end;
|
820
783
|
} else if (children && array_size(children) > 0) {
|
821
784
|
AST_NODE_T* last_child = array_get(children, array_size(children) - 1);
|
822
|
-
end_position = last_child->location
|
785
|
+
end_position = last_child->location.end;
|
823
786
|
}
|
824
787
|
|
825
788
|
AST_ERB_BLOCK_NODE_T* block_node = ast_erb_block_node_init(
|
@@ -866,8 +829,8 @@ static size_t process_control_structure(
|
|
866
829
|
end_erb->tag_opening,
|
867
830
|
end_erb->content,
|
868
831
|
end_erb->tag_closing,
|
869
|
-
end_erb->tag_opening->location
|
870
|
-
end_erb->tag_closing->location
|
832
|
+
end_erb->tag_opening->location.start,
|
833
|
+
end_erb->tag_closing->location.end,
|
871
834
|
end_erb->base.errors
|
872
835
|
);
|
873
836
|
|
data/src/ast_node.c
CHANGED
@@ -12,11 +12,12 @@ size_t ast_node_sizeof(void) {
|
|
12
12
|
return sizeof(struct AST_NODE_STRUCT);
|
13
13
|
}
|
14
14
|
|
15
|
-
void ast_node_init(AST_NODE_T* node, const ast_node_type_T type, position_T
|
15
|
+
void ast_node_init(AST_NODE_T* node, const ast_node_type_T type, position_T start, position_T end, array_T* errors) {
|
16
16
|
if (!node) { return; }
|
17
17
|
|
18
18
|
node->type = type;
|
19
|
-
node->location =
|
19
|
+
node->location.start = start;
|
20
|
+
node->location.end = end;
|
20
21
|
|
21
22
|
if (errors == NULL) {
|
22
23
|
node->errors = array_init(8);
|
@@ -28,7 +29,7 @@ void ast_node_init(AST_NODE_T* node, const ast_node_type_T type, position_T* sta
|
|
28
29
|
AST_LITERAL_NODE_T* ast_literal_node_init_from_token(const token_T* token) {
|
29
30
|
AST_LITERAL_NODE_T* literal = malloc(sizeof(AST_LITERAL_NODE_T));
|
30
31
|
|
31
|
-
ast_node_init(&literal->base, AST_LITERAL_NODE, token->location
|
32
|
+
ast_node_init(&literal->base, AST_LITERAL_NODE, token->location.start, token->location.end, NULL);
|
32
33
|
|
33
34
|
literal->content = herb_strdup(token->value);
|
34
35
|
|
@@ -51,24 +52,20 @@ void ast_node_append_error(const AST_NODE_T* node, ERROR_T* error) {
|
|
51
52
|
array_append(node->errors, error);
|
52
53
|
}
|
53
54
|
|
54
|
-
void ast_node_set_start(AST_NODE_T* node, position_T
|
55
|
-
|
56
|
-
|
57
|
-
node->location->start = position_copy(position);
|
55
|
+
void ast_node_set_start(AST_NODE_T* node, position_T position) {
|
56
|
+
node->location.start = position;
|
58
57
|
}
|
59
58
|
|
60
|
-
void ast_node_set_end(AST_NODE_T* node, position_T
|
61
|
-
|
62
|
-
|
63
|
-
node->location->end = position_copy(position);
|
59
|
+
void ast_node_set_end(AST_NODE_T* node, position_T position) {
|
60
|
+
node->location.end = position;
|
64
61
|
}
|
65
62
|
|
66
63
|
void ast_node_set_start_from_token(AST_NODE_T* node, const token_T* token) {
|
67
|
-
ast_node_set_start(node, token->location
|
64
|
+
ast_node_set_start(node, token->location.start);
|
68
65
|
}
|
69
66
|
|
70
67
|
void ast_node_set_end_from_token(AST_NODE_T* node, const token_T* token) {
|
71
|
-
ast_node_set_end(node, token->location
|
68
|
+
ast_node_set_end(node, token->location.end);
|
72
69
|
}
|
73
70
|
|
74
71
|
void ast_node_set_positions_from_token(AST_NODE_T* node, const token_T* token) {
|