herb 0.8.3-arm-linux-gnu → 0.8.5-arm-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 (52) hide show
  1. checksums.yaml +4 -4
  2. data/config.yml +7 -0
  3. data/ext/herb/error_helpers.c +26 -1
  4. data/ext/herb/extension_helpers.c +1 -1
  5. data/ext/herb/nodes.c +2 -2
  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/ast/helpers.rb +5 -0
  12. data/lib/herb/engine/compiler.rb +1 -0
  13. data/lib/herb/engine/debug_visitor.rb +24 -1
  14. data/lib/herb/errors.rb +53 -44
  15. data/lib/herb/version.rb +1 -1
  16. data/sig/herb/ast/helpers.rbs +3 -0
  17. data/sig/herb/engine/debug_visitor.rbs +5 -0
  18. data/sig/herb/errors.rbs +10 -0
  19. data/sig/serialized_ast_errors.rbs +3 -0
  20. data/src/analyze.c +39 -28
  21. data/src/analyze_helpers.c +179 -84
  22. data/src/analyzed_ruby.c +26 -25
  23. data/src/ast_node.c +1 -1
  24. data/src/ast_nodes.c +157 -53
  25. data/src/ast_pretty_print.c +16 -15
  26. data/src/errors.c +42 -5
  27. data/src/extract.c +4 -3
  28. data/src/herb.c +2 -2
  29. data/src/include/analyze_helpers.h +1 -0
  30. data/src/include/analyzed_ruby.h +19 -18
  31. data/src/include/errors.h +8 -0
  32. data/src/include/version.h +1 -1
  33. data/src/lexer.c +3 -3
  34. data/src/parser.c +10 -8
  35. data/src/parser_helpers.c +9 -9
  36. data/src/pretty_print.c +6 -6
  37. data/src/visitor.c +26 -26
  38. data/templates/ext/herb/error_helpers.c.erb +1 -1
  39. data/templates/ext/herb/nodes.c.erb +1 -1
  40. data/templates/java/error_helpers.c.erb +1 -1
  41. data/templates/java/nodes.c.erb +2 -2
  42. data/templates/javascript/packages/node/extension/error_helpers.cpp.erb +1 -1
  43. data/templates/javascript/packages/node/extension/nodes.cpp.erb +1 -1
  44. data/templates/lib/herb/errors.rb.erb +8 -5
  45. data/templates/rust/src/ast/nodes.rs.erb +2 -2
  46. data/templates/src/ast_nodes.c.erb +7 -3
  47. data/templates/src/ast_pretty_print.c.erb +16 -15
  48. data/templates/src/errors.c.erb +5 -5
  49. data/templates/src/visitor.c.erb +1 -1
  50. data/templates/wasm/error_helpers.cpp.erb +1 -1
  51. data/templates/wasm/nodes.cpp.erb +1 -1
  52. metadata +1 -1
data/src/analyze.c CHANGED
@@ -45,6 +45,8 @@ static analyzed_ruby_T* herb_analyze_ruby(hb_string_T source) {
45
45
  search_yield_nodes(analyzed->root, analyzed);
46
46
  search_block_closing_nodes(analyzed);
47
47
 
48
+ if (!analyzed->valid) { pm_visit_node(analyzed->root, search_unclosed_control_flows, analyzed); }
49
+
48
50
  return analyzed;
49
51
  }
50
52
 
@@ -54,12 +56,21 @@ static bool analyze_erb_content(const AST_NODE_T* node, void* data) {
54
56
 
55
57
  const char* opening = erb_content_node->tag_opening->value;
56
58
 
57
- if (strcmp(opening, "<%%") != 0 && strcmp(opening, "<%%=") != 0 && strcmp(opening, "<%#") != 0) {
59
+ if (strcmp(opening, "<%%") != 0 && strcmp(opening, "<%%=") != 0 && strcmp(opening, "<%#") != 0
60
+ && strcmp(opening, "<%graphql") != 0) {
58
61
  analyzed_ruby_T* analyzed = herb_analyze_ruby(hb_string(erb_content_node->content->value));
59
62
 
60
63
  erb_content_node->parsed = true;
61
64
  erb_content_node->valid = analyzed->valid;
62
65
  erb_content_node->analyzed_ruby = analyzed;
66
+
67
+ if (!analyzed->valid && analyzed->unclosed_control_flow_count >= 2) {
68
+ append_erb_multiple_blocks_in_tag_error(
69
+ erb_content_node->base.location.start,
70
+ erb_content_node->base.location.end,
71
+ erb_content_node->base.errors
72
+ );
73
+ }
63
74
  } else {
64
75
  erb_content_node->parsed = false;
65
76
  erb_content_node->valid = true;
@@ -287,7 +298,7 @@ static AST_NODE_T* create_control_node(
287
298
 
288
299
  if (end_node) {
289
300
  end_position = end_node->base.location.end;
290
- } else if (children && hb_array_size(children) > 0) {
301
+ } else if (children && children->size > 0) {
291
302
  AST_NODE_T* last_child = hb_array_last(children);
292
303
  end_position = last_child->location.end;
293
304
  } else if (subsequent) {
@@ -329,7 +340,7 @@ static AST_NODE_T* create_control_node(
329
340
  hb_array_T* in_conditions = hb_array_init(8);
330
341
  hb_array_T* non_when_non_in_children = hb_array_init(8);
331
342
 
332
- for (size_t i = 0; i < hb_array_size(children); i++) {
343
+ for (size_t i = 0; i < children->size; i++) {
333
344
  AST_NODE_T* child = hb_array_get(children, i);
334
345
 
335
346
  if (child && child->type == AST_ERB_WHEN_NODE) {
@@ -343,7 +354,7 @@ static AST_NODE_T* create_control_node(
343
354
 
344
355
  hb_array_free(&children);
345
356
 
346
- if (hb_array_size(in_conditions) > 0) {
357
+ if (in_conditions->size > 0) {
347
358
  hb_array_free(&when_conditions);
348
359
 
349
360
  return (AST_NODE_T*) ast_erb_case_match_node_init(
@@ -539,7 +550,7 @@ static size_t process_control_structure(
539
550
  hb_array_T* in_conditions = hb_array_init(8);
540
551
  hb_array_T* non_when_non_in_children = hb_array_init(8);
541
552
 
542
- while (index < hb_array_size(array)) {
553
+ while (index < array->size) {
543
554
  AST_NODE_T* next_node = hb_array_get(array, index);
544
555
 
545
556
  if (!next_node) { break; }
@@ -555,7 +566,7 @@ static size_t process_control_structure(
555
566
  index++;
556
567
  }
557
568
 
558
- while (index < hb_array_size(array)) {
569
+ while (index < array->size) {
559
570
  AST_NODE_T* next_node = hb_array_get(array, index);
560
571
 
561
572
  if (!next_node) { break; }
@@ -627,7 +638,7 @@ static size_t process_control_structure(
627
638
 
628
639
  AST_ERB_ELSE_NODE_T* else_clause = NULL;
629
640
 
630
- if (index < hb_array_size(array)) {
641
+ if (index < array->size) {
631
642
  AST_NODE_T* next_node = hb_array_get(array, index);
632
643
 
633
644
  if (next_node && next_node->type == AST_ERB_CONTENT_NODE) {
@@ -661,7 +672,7 @@ static size_t process_control_structure(
661
672
 
662
673
  AST_ERB_END_NODE_T* end_node = NULL;
663
674
 
664
- if (index < hb_array_size(array)) {
675
+ if (index < array->size) {
665
676
  AST_NODE_T* potential_end = hb_array_get(array, index);
666
677
 
667
678
  if (potential_end && potential_end->type == AST_ERB_CONTENT_NODE) {
@@ -694,15 +705,15 @@ static size_t process_control_structure(
694
705
  end_position = end_node->base.location.end;
695
706
  } else if (else_clause) {
696
707
  end_position = else_clause->base.location.end;
697
- } else if (hb_array_size(when_conditions) > 0) {
708
+ } else if (when_conditions->size > 0) {
698
709
  AST_NODE_T* last_when = hb_array_last(when_conditions);
699
710
  end_position = last_when->location.end;
700
- } else if (hb_array_size(in_conditions) > 0) {
711
+ } else if (in_conditions->size > 0) {
701
712
  AST_NODE_T* last_in = hb_array_last(in_conditions);
702
713
  end_position = last_in->location.end;
703
714
  }
704
715
 
705
- if (hb_array_size(in_conditions) > 0) {
716
+ if (in_conditions->size > 0) {
706
717
  hb_array_T* case_match_errors = erb_node->base.errors;
707
718
  erb_node->base.errors = NULL;
708
719
 
@@ -760,7 +771,7 @@ static size_t process_control_structure(
760
771
  AST_ERB_ELSE_NODE_T* else_clause = NULL;
761
772
  AST_ERB_ENSURE_NODE_T* ensure_clause = NULL;
762
773
 
763
- if (index < hb_array_size(array)) {
774
+ if (index < array->size) {
764
775
  AST_NODE_T* next_node = hb_array_get(array, index);
765
776
 
766
777
  if (next_node && next_node->type == AST_ERB_CONTENT_NODE) {
@@ -775,7 +786,7 @@ static size_t process_control_structure(
775
786
  }
776
787
  }
777
788
 
778
- if (index < hb_array_size(array)) {
789
+ if (index < array->size) {
779
790
  AST_NODE_T* next_node = hb_array_get(array, index);
780
791
 
781
792
  if (next_node && next_node->type == AST_ERB_CONTENT_NODE) {
@@ -807,7 +818,7 @@ static size_t process_control_structure(
807
818
  }
808
819
  }
809
820
 
810
- if (index < hb_array_size(array)) {
821
+ if (index < array->size) {
811
822
  AST_NODE_T* next_node = hb_array_get(array, index);
812
823
 
813
824
  if (next_node && next_node->type == AST_ERB_CONTENT_NODE) {
@@ -819,7 +830,7 @@ static size_t process_control_structure(
819
830
 
820
831
  index++;
821
832
 
822
- while (index < hb_array_size(array)) {
833
+ while (index < array->size) {
823
834
  AST_NODE_T* child = hb_array_get(array, index);
824
835
 
825
836
  if (!child) { break; }
@@ -855,7 +866,7 @@ static size_t process_control_structure(
855
866
 
856
867
  AST_ERB_END_NODE_T* end_node = NULL;
857
868
 
858
- if (index < hb_array_size(array)) {
869
+ if (index < array->size) {
859
870
  AST_NODE_T* potential_end = hb_array_get(array, index);
860
871
 
861
872
  if (potential_end && potential_end->type == AST_ERB_CONTENT_NODE) {
@@ -922,7 +933,7 @@ static size_t process_control_structure(
922
933
 
923
934
  AST_ERB_END_NODE_T* end_node = NULL;
924
935
 
925
- if (index < hb_array_size(array)) {
936
+ if (index < array->size) {
926
937
  AST_NODE_T* potential_close = hb_array_get(array, index);
927
938
 
928
939
  if (potential_close && potential_close->type == AST_ERB_CONTENT_NODE) {
@@ -954,7 +965,7 @@ static size_t process_control_structure(
954
965
 
955
966
  if (end_node) {
956
967
  end_position = end_node->base.location.end;
957
- } else if (children && hb_array_size(children) > 0) {
968
+ } else if (children && children->size > 0) {
958
969
  AST_NODE_T* last_child = hb_array_last(children);
959
970
  end_position = last_child->location.end;
960
971
  }
@@ -984,7 +995,7 @@ static size_t process_control_structure(
984
995
  AST_NODE_T* subsequent = NULL;
985
996
  AST_ERB_END_NODE_T* end_node = NULL;
986
997
 
987
- if (index < hb_array_size(array)) {
998
+ if (index < array->size) {
988
999
  AST_NODE_T* next_node = hb_array_get(array, index);
989
1000
 
990
1001
  if (next_node && next_node->type == AST_ERB_CONTENT_NODE) {
@@ -997,7 +1008,7 @@ static size_t process_control_structure(
997
1008
  }
998
1009
  }
999
1010
 
1000
- if (index < hb_array_size(array)) {
1011
+ if (index < array->size) {
1001
1012
  AST_NODE_T* potential_end = hb_array_get(array, index);
1002
1013
 
1003
1014
  if (potential_end && potential_end->type == AST_ERB_CONTENT_NODE) {
@@ -1059,7 +1070,7 @@ static size_t process_subsequent_block(
1059
1070
  hb_array_free(&children);
1060
1071
  }
1061
1072
 
1062
- if (index < hb_array_size(array)) {
1073
+ if (index < array->size) {
1063
1074
  AST_NODE_T* next_node = hb_array_get(array, index);
1064
1075
 
1065
1076
  if (next_node && next_node->type == AST_ERB_CONTENT_NODE) {
@@ -1117,7 +1128,7 @@ static size_t process_block_children(
1117
1128
  analyze_ruby_context_T* context,
1118
1129
  control_type_t parent_type
1119
1130
  ) {
1120
- while (index < hb_array_size(array)) {
1131
+ while (index < array->size) {
1121
1132
  AST_NODE_T* child = hb_array_get(array, index);
1122
1133
 
1123
1134
  if (!child) { break; }
@@ -1139,7 +1150,7 @@ static size_t process_block_children(
1139
1150
  hb_array_T* temp_array = hb_array_init(1);
1140
1151
  size_t new_index = process_control_structure(node, array, index, temp_array, context, child_type);
1141
1152
 
1142
- if (hb_array_size(temp_array) > 0) { hb_array_append(children_array, hb_array_first(temp_array)); }
1153
+ if (temp_array->size > 0) { hb_array_append(children_array, hb_array_first(temp_array)); }
1143
1154
 
1144
1155
  hb_array_free(&temp_array);
1145
1156
 
@@ -1155,10 +1166,10 @@ static size_t process_block_children(
1155
1166
  }
1156
1167
 
1157
1168
  hb_array_T* rewrite_node_array(AST_NODE_T* node, hb_array_T* array, analyze_ruby_context_T* context) {
1158
- hb_array_T* new_array = hb_array_init(hb_array_size(array));
1169
+ hb_array_T* new_array = hb_array_init(array->size);
1159
1170
  size_t index = 0;
1160
1171
 
1161
- while (index < hb_array_size(array)) {
1172
+ while (index < array->size) {
1162
1173
  AST_NODE_T* item = hb_array_get(array, index);
1163
1174
 
1164
1175
  if (!item) { break; }
@@ -1293,7 +1304,7 @@ static bool detect_invalid_erb_structures(const AST_NODE_T* node, void* data) {
1293
1304
  if (if_node->end_node == NULL) { check_erb_node_for_missing_end(node); }
1294
1305
 
1295
1306
  if (if_node->statements != NULL) {
1296
- for (size_t i = 0; i < hb_array_size(if_node->statements); i++) {
1307
+ for (size_t i = 0; i < if_node->statements->size; i++) {
1297
1308
  AST_NODE_T* statement = (AST_NODE_T*) hb_array_get(if_node->statements, i);
1298
1309
 
1299
1310
  if (statement != NULL) { herb_visit_node(statement, detect_invalid_erb_structures, context); }
@@ -1325,7 +1336,7 @@ static bool detect_invalid_erb_structures(const AST_NODE_T* node, void* data) {
1325
1336
  const AST_ERB_IF_NODE_T* elsif_node = (const AST_ERB_IF_NODE_T*) subsequent;
1326
1337
 
1327
1338
  if (elsif_node->statements != NULL) {
1328
- for (size_t i = 0; i < hb_array_size(elsif_node->statements); i++) {
1339
+ for (size_t i = 0; i < elsif_node->statements->size; i++) {
1329
1340
  AST_NODE_T* statement = (AST_NODE_T*) hb_array_get(elsif_node->statements, i);
1330
1341
 
1331
1342
  if (statement != NULL) { herb_visit_node(statement, detect_invalid_erb_structures, context); }
@@ -1337,7 +1348,7 @@ static bool detect_invalid_erb_structures(const AST_NODE_T* node, void* data) {
1337
1348
  const AST_ERB_ELSE_NODE_T* else_node = (const AST_ERB_ELSE_NODE_T*) subsequent;
1338
1349
 
1339
1350
  if (else_node->statements != NULL) {
1340
- for (size_t i = 0; i < hb_array_size(else_node->statements); i++) {
1351
+ for (size_t i = 0; i < else_node->statements->size; i++) {
1341
1352
  AST_NODE_T* statement = (AST_NODE_T*) hb_array_get(else_node->statements, i);
1342
1353
 
1343
1354
  if (statement != NULL) { herb_visit_node(statement, detect_invalid_erb_structures, context); }