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.
Files changed (47) hide show
  1. checksums.yaml +4 -4
  2. data/config.yml +14 -14
  3. data/ext/herb/extension_helpers.c +9 -15
  4. data/ext/herb/extension_helpers.h +3 -3
  5. data/ext/herb/nodes.c +1 -1
  6. data/lib/herb/3.0/herb.so +0 -0
  7. data/lib/herb/3.1/herb.so +0 -0
  8. data/lib/herb/3.2/herb.so +0 -0
  9. data/lib/herb/3.3/herb.so +0 -0
  10. data/lib/herb/3.4/herb.so +0 -0
  11. data/lib/herb/engine.rb +10 -6
  12. data/lib/herb/version.rb +1 -1
  13. data/src/analyze.c +43 -80
  14. data/src/ast_node.c +10 -13
  15. data/src/ast_nodes.c +31 -33
  16. data/src/buffer.c +10 -1
  17. data/src/errors.c +35 -35
  18. data/src/include/ast_node.h +3 -3
  19. data/src/include/ast_nodes.h +32 -32
  20. data/src/include/errors.h +21 -21
  21. data/src/include/lexer_peek_helpers.h +8 -6
  22. data/src/include/lexer_struct.h +10 -9
  23. data/src/include/location.h +10 -13
  24. data/src/include/parser_helpers.h +1 -1
  25. data/src/include/position.h +3 -14
  26. data/src/include/pretty_print.h +1 -1
  27. data/src/include/prism_helpers.h +1 -1
  28. data/src/include/range.h +4 -13
  29. data/src/include/token.h +0 -3
  30. data/src/include/token_struct.h +2 -2
  31. data/src/include/version.h +1 -1
  32. data/src/lexer.c +3 -2
  33. data/src/lexer_peek_helpers.c +10 -4
  34. data/src/location.c +9 -37
  35. data/src/parser.c +98 -119
  36. data/src/parser_helpers.c +15 -15
  37. data/src/pretty_print.c +7 -12
  38. data/src/prism_helpers.c +7 -7
  39. data/src/range.c +2 -35
  40. data/src/token.c +25 -29
  41. data/templates/javascript/packages/core/src/visitor.ts.erb +29 -1
  42. data/templates/src/ast_nodes.c.erb +1 -3
  43. data/templates/src/errors.c.erb +5 -7
  44. data/templates/src/include/ast_nodes.h.erb +2 -2
  45. data/templates/src/include/errors.h.erb +3 -3
  46. metadata +2 -3
  47. data/src/position.c +0 -33
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e5686adc013e239cbb9ceda550da801ff75c8cde4ac3a9fd316317de517fa708
4
- data.tar.gz: b748f6ef34c932ece85f1931cbd8f81570f19f31fd7e93730308a7f4347730ca
3
+ metadata.gz: 71ad6c6d788139d98397fc010ed14607fea675ff70b3180489f988f3c414d307
4
+ data.tar.gz: bd8aedaf8adf48873703bbf9b1d6a6b4962612ec1af4885c11758b93b66b65ff
5
5
  SHA512:
6
- metadata.gz: 2d974fdb21ccba9767d354de219ca55ec8280ec4cd6ddefa69827b46625a556e29681e762b47376a4c4f80b734111fe440031c7d33e582e498bf5fc4aefe3e1f
7
- data.tar.gz: e40994555945a3bca80dc7f40c77f144dc5cac517e32c6e94727a88c0b42d54d80d785c9f6bba70268b36292d86e09b74b610de823979154f81bcca4cb883460
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->start->line
38
- - found->location->start->column
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->start->line
53
- - closing_tag->location->start->column
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->start->line
65
- - opening_tag->location->start->column
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->start->line
78
- - opening_tag->location->start->column
77
+ - opening_tag->location.start.line
78
+ - opening_tag->location.start.column
79
79
  - closing_tag->value
80
- - closing_tag->location->start->line
81
- - closing_tag->location->start->column
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->start->line
97
- - closing_quote->location->start->column
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->start->line
131
- - opening_tag->location->start->column
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* position) {
24
- if (!position) { return Qnil; }
25
-
23
+ VALUE rb_position_from_c_struct(position_T position) {
26
24
  VALUE args[2];
27
- args[0] = SIZET2NUM(position->line);
28
- args[1] = SIZET2NUM(position->column);
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* location) {
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->start);
38
- args[1] = rb_position_from_c_struct(location->end);
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* range) {
44
- if (!range) { return Qnil; }
45
-
39
+ VALUE rb_range_from_c_struct(range_T range) {
46
40
  VALUE args[2];
47
- args[0] = SIZET2NUM(range->from);
48
- args[1] = SIZET2NUM(range->to);
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* position);
16
- VALUE rb_location_from_c_struct(location_T* location);
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* range);
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:0x00007f64bd63b388 @name="analyzed_ruby", @options={kind: nil}> */
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
- @src << " " << code
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 << ";" unless code[-1] == "\n"
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
@@ -2,5 +2,5 @@
2
2
  # typed: true
3
3
 
4
4
  module Herb
5
- VERSION = "0.7.4"
5
+ VERSION = "0.7.5"
6
6
  end
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* start_position = erb_node->tag_opening->location->start;
162
- position_T* end_position = erb_node->tag_closing->location->end;
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->end;
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->end;
165
+ end_position = last_child->location.end;
169
166
  } else if (subsequent) {
170
- end_position = subsequent->location->end;
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
- while (index < array_size(array)) {
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->start,
463
- erb_content->tag_closing->location->end,
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
- while (index < array_size(array)) {
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->start,
499
- erb_content->tag_closing->location->end,
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->start,
550
- next_erb->tag_closing->location->end,
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->start,
571
- end_erb->tag_closing->location->end,
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* start_position = erb_node->tag_opening->location->start;
581
- position_T* end_position = erb_node->tag_closing->location->end;
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->end;
547
+ end_position = end_node->base.location.end;
585
548
  } else if (else_clause) {
586
- end_position = else_clause->base.location->end;
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->end;
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->end;
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->start,
686
- next_erb->tag_closing->location->end,
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->start,
727
- next_erb->tag_closing->location->end,
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->start,
748
- end_erb->tag_closing->location->end,
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* start_position = erb_node->tag_opening->location->start;
758
- position_T* end_position = erb_node->tag_closing->location->end;
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->end;
724
+ end_position = end_node->base.location.end;
762
725
  } else if (ensure_clause) {
763
- end_position = ensure_clause->base.location->end;
726
+ end_position = ensure_clause->base.location.end;
764
727
  } else if (else_clause) {
765
- end_position = else_clause->base.location->end;
728
+ end_position = else_clause->base.location.end;
766
729
  } else if (rescue_clause) {
767
- end_position = rescue_clause->base.location->end;
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->start,
806
- close_erb->tag_closing->location->end,
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* start_position = erb_node->tag_opening->location->start;
816
- position_T* end_position = erb_node->tag_closing->location->end;
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->end;
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->end;
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->start,
870
- end_erb->tag_closing->location->end,
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* start, position_T* end, array_T* errors) {
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 = location_init(position_copy(start), position_copy(end));
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->start, token->location->end, NULL);
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* position) {
55
- if (node->location->start != NULL) { position_free(node->location->start); }
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* position) {
61
- if (node->location->end != NULL) { position_free(node->location->end); }
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->start);
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->end);
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) {