herb 0.8.5-x86-linux-gnu → 0.8.7-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 (60) hide show
  1. checksums.yaml +4 -4
  2. data/ext/herb/error_helpers.c +1 -1
  3. data/ext/herb/extension_helpers.c +1 -1
  4. data/ext/herb/nodes.c +2 -2
  5. data/lib/herb/3.0/herb.so +0 -0
  6. data/lib/herb/3.1/herb.so +0 -0
  7. data/lib/herb/3.2/herb.so +0 -0
  8. data/lib/herb/3.3/herb.so +0 -0
  9. data/lib/herb/3.4/herb.so +0 -0
  10. data/lib/herb/4.0/herb.so +0 -0
  11. data/lib/herb/version.rb +1 -1
  12. data/src/analyze.c +40 -30
  13. data/src/ast_node.c +1 -1
  14. data/src/ast_nodes.c +53 -157
  15. data/src/errors.c +5 -5
  16. data/src/extract.c +2 -2
  17. data/src/herb.c +2 -2
  18. data/src/include/util/hb_narray.h +30 -0
  19. data/src/include/version.h +1 -1
  20. data/src/parser.c +9 -9
  21. data/src/parser_helpers.c +4 -4
  22. data/src/pretty_print.c +6 -6
  23. data/src/util/hb_array.c +1 -0
  24. data/src/util/hb_narray.c +81 -0
  25. data/src/visitor.c +26 -26
  26. data/templates/ext/herb/error_helpers.c.erb +1 -1
  27. data/templates/ext/herb/nodes.c.erb +1 -1
  28. data/templates/java/error_helpers.c.erb +1 -1
  29. data/templates/java/nodes.c.erb +2 -2
  30. data/templates/javascript/packages/node/extension/error_helpers.cpp.erb +1 -1
  31. data/templates/javascript/packages/node/extension/nodes.cpp.erb +1 -1
  32. data/templates/rust/src/ast/nodes.rs.erb +2 -2
  33. data/templates/src/ast_nodes.c.erb +3 -7
  34. data/templates/src/errors.c.erb +5 -5
  35. data/templates/src/visitor.c.erb +1 -1
  36. data/templates/wasm/error_helpers.cpp.erb +1 -1
  37. data/templates/wasm/nodes.cpp.erb +1 -1
  38. data/vendor/prism/config.yml +28 -3
  39. data/vendor/prism/include/prism/ast.h +54 -20
  40. data/vendor/prism/include/prism/diagnostic.h +2 -0
  41. data/vendor/prism/include/prism/options.h +8 -2
  42. data/vendor/prism/include/prism/parser.h +3 -0
  43. data/vendor/prism/include/prism/version.h +2 -2
  44. data/vendor/prism/include/prism.h +1 -1
  45. data/vendor/prism/src/diagnostic.c +5 -1
  46. data/vendor/prism/src/encoding.c +172 -67
  47. data/vendor/prism/src/node.c +9 -0
  48. data/vendor/prism/src/options.c +17 -7
  49. data/vendor/prism/src/prettyprint.c +16 -0
  50. data/vendor/prism/src/prism.c +1192 -1895
  51. data/vendor/prism/src/serialize.c +7 -1
  52. data/vendor/prism/src/token_type.c +2 -2
  53. data/vendor/prism/src/util/pm_constant_pool.c +1 -1
  54. data/vendor/prism/templates/include/prism/ast.h.erb +26 -16
  55. data/vendor/prism/templates/java/org/prism/Loader.java.erb +1 -1
  56. data/vendor/prism/templates/javascript/src/deserialize.js.erb +1 -1
  57. data/vendor/prism/templates/lib/prism/serialize.rb.erb +1 -1
  58. data/vendor/prism/templates/src/diagnostic.c.erb +2 -0
  59. data/vendor/prism/templates/src/serialize.c.erb +1 -1
  60. metadata +6 -3
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 60339fc8673ae3d005154369f8de1f27d559fef8ef64ee1ff4ad15ba01fa891d
4
- data.tar.gz: f73c89656dfeff57e1620925453ee11f98c4ce928dd105e320a5eda52b521156
3
+ metadata.gz: fe158d868675617e21efedbe101da31f5865e1d0d4a259d1a78b4ab154b36a6a
4
+ data.tar.gz: 415352c5c6c674d15c20f210c31ffd6253f2d3877cd3e153d929d7086948422e
5
5
  SHA512:
6
- metadata.gz: a09d71a6cff9ffd8ec85c60f889bc507663dd962abf8b6c033be9f928a7b6b49eac236498508f7839b7c4c7e7c6f08d0f590693ad7df5d815e4ef8ca01d09af7
7
- data.tar.gz: 4f789772832dca54c525ca29240ed7f9a033cd69d0a835c414cbdbcd85644e02742b11957a189017f0431070dc8b6e398a0e2c0d1530a564f38ded6aa9ff927f
6
+ metadata.gz: 439a2fd32794fdf5c96aea5c5ca7d959c2897d83ec79cd07022d6c84e1411c4546649f12534744233b6fa36c9b165e3ca225e301a02aba09c5b976ae19666b0f
7
+ data.tar.gz: ece6b3363022dcb6dee45a901d7311b779109189a6772dc271ac61cc4c9ad140ceea2afc70659910cdafbf280f5ae2887f5989895c77924f92e75e9114d2c40b
@@ -367,7 +367,7 @@ VALUE rb_errors_array_from_c_array(hb_array_T* array) {
367
367
  VALUE rb_array = rb_ary_new();
368
368
 
369
369
  if (array) {
370
- for (size_t i = 0; i < array->size; i++) {
370
+ for (size_t i = 0; i < hb_array_size(array); i++) {
371
371
  ERROR_T* child_node = (ERROR_T*) hb_array_get(array, i);
372
372
 
373
373
  if (child_node) {
@@ -63,7 +63,7 @@ VALUE create_lex_result(hb_array_T* tokens, VALUE source) {
63
63
  VALUE warnings = rb_ary_new();
64
64
  VALUE errors = rb_ary_new();
65
65
 
66
- for (size_t i = 0; i < tokens->size; i++) {
66
+ for (size_t i = 0; i < hb_array_size(tokens); i++) {
67
67
  token_T* token = hb_array_get(tokens, i);
68
68
  if (token != NULL) { rb_ary_push(value, rb_token_from_c_struct(token)); }
69
69
  }
data/ext/herb/nodes.c CHANGED
@@ -464,7 +464,7 @@ static VALUE rb_erb_content_node_from_c_struct(AST_ERB_CONTENT_NODE_T* erb_conte
464
464
  VALUE erb_content_node_tag_opening = rb_token_from_c_struct(erb_content_node->tag_opening);
465
465
  VALUE erb_content_node_content = rb_token_from_c_struct(erb_content_node->content);
466
466
  VALUE erb_content_node_tag_closing = rb_token_from_c_struct(erb_content_node->tag_closing);
467
- /* #<Herb::Template::AnalyzedRubyField:0x00007f77e1751740 @name="analyzed_ruby", @options={kind: nil}> */
467
+ /* #<Herb::Template::AnalyzedRubyField:0x00007fa5568cfde0 @name="analyzed_ruby", @options={kind: nil}> */
468
468
  VALUE erb_content_node_analyzed_ruby = Qnil;
469
469
  VALUE erb_content_node_parsed = (erb_content_node->parsed) ? Qtrue : Qfalse;
470
470
  VALUE erb_content_node_valid = (erb_content_node->valid) ? Qtrue : Qfalse;
@@ -1091,7 +1091,7 @@ static VALUE rb_nodes_array_from_c_array(hb_array_T* array) {
1091
1091
  VALUE rb_array = rb_ary_new();
1092
1092
 
1093
1093
  if (array) {
1094
- for (size_t i = 0; i < array->size; i++) {
1094
+ for (size_t i = 0; i < hb_array_size(array); i++) {
1095
1095
  AST_NODE_T* child_node = (AST_NODE_T*) hb_array_get(array, i);
1096
1096
 
1097
1097
  if (child_node) {
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
Binary file
data/lib/herb/version.rb CHANGED
@@ -2,5 +2,5 @@
2
2
  # typed: true
3
3
 
4
4
  module Herb
5
- VERSION = "0.8.5"
5
+ VERSION = "0.8.7"
6
6
  end
data/src/analyze.c CHANGED
@@ -192,9 +192,19 @@ static bool find_earliest_control_keyword_walker(const pm_node_t* node, void* da
192
192
  case PM_CALL_NODE: {
193
193
  pm_call_node_t* call = (pm_call_node_t*) node;
194
194
 
195
- if (call->block != NULL) {
196
- current_type = CONTROL_TYPE_BLOCK;
197
- keyword_offset = (uint32_t) (node->location.start - context->source_start);
195
+ if (call->block != NULL && call->block->type == PM_BLOCK_NODE) {
196
+ pm_block_node_t* block_node = (pm_block_node_t*) call->block;
197
+ size_t opening_length = block_node->opening_loc.end - block_node->opening_loc.start;
198
+ bool has_do_opening =
199
+ opening_length == 2 && block_node->opening_loc.start[0] == 'd' && block_node->opening_loc.start[1] == 'o';
200
+ bool has_brace_opening = opening_length == 1 && block_node->opening_loc.start[0] == '{';
201
+ bool has_closing_location = block_node->closing_loc.start != NULL && block_node->closing_loc.end != NULL
202
+ && (block_node->closing_loc.end - block_node->closing_loc.start) > 0;
203
+
204
+ if (has_do_opening || (has_brace_opening && !has_closing_location)) {
205
+ current_type = CONTROL_TYPE_BLOCK;
206
+ keyword_offset = (uint32_t) (node->location.start - context->source_start);
207
+ }
198
208
  }
199
209
  break;
200
210
  }
@@ -298,7 +308,7 @@ static AST_NODE_T* create_control_node(
298
308
 
299
309
  if (end_node) {
300
310
  end_position = end_node->base.location.end;
301
- } else if (children && children->size > 0) {
311
+ } else if (hb_array_size(children) > 0) {
302
312
  AST_NODE_T* last_child = hb_array_last(children);
303
313
  end_position = last_child->location.end;
304
314
  } else if (subsequent) {
@@ -340,7 +350,7 @@ static AST_NODE_T* create_control_node(
340
350
  hb_array_T* in_conditions = hb_array_init(8);
341
351
  hb_array_T* non_when_non_in_children = hb_array_init(8);
342
352
 
343
- for (size_t i = 0; i < children->size; i++) {
353
+ for (size_t i = 0; i < hb_array_size(children); i++) {
344
354
  AST_NODE_T* child = hb_array_get(children, i);
345
355
 
346
356
  if (child && child->type == AST_ERB_WHEN_NODE) {
@@ -354,7 +364,7 @@ static AST_NODE_T* create_control_node(
354
364
 
355
365
  hb_array_free(&children);
356
366
 
357
- if (in_conditions->size > 0) {
367
+ if (hb_array_size(in_conditions) > 0) {
358
368
  hb_array_free(&when_conditions);
359
369
 
360
370
  return (AST_NODE_T*) ast_erb_case_match_node_init(
@@ -550,7 +560,7 @@ static size_t process_control_structure(
550
560
  hb_array_T* in_conditions = hb_array_init(8);
551
561
  hb_array_T* non_when_non_in_children = hb_array_init(8);
552
562
 
553
- while (index < array->size) {
563
+ while (index < hb_array_size(array)) {
554
564
  AST_NODE_T* next_node = hb_array_get(array, index);
555
565
 
556
566
  if (!next_node) { break; }
@@ -566,7 +576,7 @@ static size_t process_control_structure(
566
576
  index++;
567
577
  }
568
578
 
569
- while (index < array->size) {
579
+ while (index < hb_array_size(array)) {
570
580
  AST_NODE_T* next_node = hb_array_get(array, index);
571
581
 
572
582
  if (!next_node) { break; }
@@ -638,7 +648,7 @@ static size_t process_control_structure(
638
648
 
639
649
  AST_ERB_ELSE_NODE_T* else_clause = NULL;
640
650
 
641
- if (index < array->size) {
651
+ if (index < hb_array_size(array)) {
642
652
  AST_NODE_T* next_node = hb_array_get(array, index);
643
653
 
644
654
  if (next_node && next_node->type == AST_ERB_CONTENT_NODE) {
@@ -672,7 +682,7 @@ static size_t process_control_structure(
672
682
 
673
683
  AST_ERB_END_NODE_T* end_node = NULL;
674
684
 
675
- if (index < array->size) {
685
+ if (index < hb_array_size(array)) {
676
686
  AST_NODE_T* potential_end = hb_array_get(array, index);
677
687
 
678
688
  if (potential_end && potential_end->type == AST_ERB_CONTENT_NODE) {
@@ -705,15 +715,15 @@ static size_t process_control_structure(
705
715
  end_position = end_node->base.location.end;
706
716
  } else if (else_clause) {
707
717
  end_position = else_clause->base.location.end;
708
- } else if (when_conditions->size > 0) {
718
+ } else if (hb_array_size(when_conditions) > 0) {
709
719
  AST_NODE_T* last_when = hb_array_last(when_conditions);
710
720
  end_position = last_when->location.end;
711
- } else if (in_conditions->size > 0) {
721
+ } else if (hb_array_size(in_conditions) > 0) {
712
722
  AST_NODE_T* last_in = hb_array_last(in_conditions);
713
723
  end_position = last_in->location.end;
714
724
  }
715
725
 
716
- if (in_conditions->size > 0) {
726
+ if (hb_array_size(in_conditions) > 0) {
717
727
  hb_array_T* case_match_errors = erb_node->base.errors;
718
728
  erb_node->base.errors = NULL;
719
729
 
@@ -771,7 +781,7 @@ static size_t process_control_structure(
771
781
  AST_ERB_ELSE_NODE_T* else_clause = NULL;
772
782
  AST_ERB_ENSURE_NODE_T* ensure_clause = NULL;
773
783
 
774
- if (index < array->size) {
784
+ if (index < hb_array_size(array)) {
775
785
  AST_NODE_T* next_node = hb_array_get(array, index);
776
786
 
777
787
  if (next_node && next_node->type == AST_ERB_CONTENT_NODE) {
@@ -786,7 +796,7 @@ static size_t process_control_structure(
786
796
  }
787
797
  }
788
798
 
789
- if (index < array->size) {
799
+ if (index < hb_array_size(array)) {
790
800
  AST_NODE_T* next_node = hb_array_get(array, index);
791
801
 
792
802
  if (next_node && next_node->type == AST_ERB_CONTENT_NODE) {
@@ -818,7 +828,7 @@ static size_t process_control_structure(
818
828
  }
819
829
  }
820
830
 
821
- if (index < array->size) {
831
+ if (index < hb_array_size(array)) {
822
832
  AST_NODE_T* next_node = hb_array_get(array, index);
823
833
 
824
834
  if (next_node && next_node->type == AST_ERB_CONTENT_NODE) {
@@ -830,7 +840,7 @@ static size_t process_control_structure(
830
840
 
831
841
  index++;
832
842
 
833
- while (index < array->size) {
843
+ while (index < hb_array_size(array)) {
834
844
  AST_NODE_T* child = hb_array_get(array, index);
835
845
 
836
846
  if (!child) { break; }
@@ -866,7 +876,7 @@ static size_t process_control_structure(
866
876
 
867
877
  AST_ERB_END_NODE_T* end_node = NULL;
868
878
 
869
- if (index < array->size) {
879
+ if (index < hb_array_size(array)) {
870
880
  AST_NODE_T* potential_end = hb_array_get(array, index);
871
881
 
872
882
  if (potential_end && potential_end->type == AST_ERB_CONTENT_NODE) {
@@ -933,7 +943,7 @@ static size_t process_control_structure(
933
943
 
934
944
  AST_ERB_END_NODE_T* end_node = NULL;
935
945
 
936
- if (index < array->size) {
946
+ if (index < hb_array_size(array)) {
937
947
  AST_NODE_T* potential_close = hb_array_get(array, index);
938
948
 
939
949
  if (potential_close && potential_close->type == AST_ERB_CONTENT_NODE) {
@@ -965,7 +975,7 @@ static size_t process_control_structure(
965
975
 
966
976
  if (end_node) {
967
977
  end_position = end_node->base.location.end;
968
- } else if (children && children->size > 0) {
978
+ } else if (hb_array_size(children) > 0) {
969
979
  AST_NODE_T* last_child = hb_array_last(children);
970
980
  end_position = last_child->location.end;
971
981
  }
@@ -995,7 +1005,7 @@ static size_t process_control_structure(
995
1005
  AST_NODE_T* subsequent = NULL;
996
1006
  AST_ERB_END_NODE_T* end_node = NULL;
997
1007
 
998
- if (index < array->size) {
1008
+ if (index < hb_array_size(array)) {
999
1009
  AST_NODE_T* next_node = hb_array_get(array, index);
1000
1010
 
1001
1011
  if (next_node && next_node->type == AST_ERB_CONTENT_NODE) {
@@ -1008,7 +1018,7 @@ static size_t process_control_structure(
1008
1018
  }
1009
1019
  }
1010
1020
 
1011
- if (index < array->size) {
1021
+ if (index < hb_array_size(array)) {
1012
1022
  AST_NODE_T* potential_end = hb_array_get(array, index);
1013
1023
 
1014
1024
  if (potential_end && potential_end->type == AST_ERB_CONTENT_NODE) {
@@ -1070,7 +1080,7 @@ static size_t process_subsequent_block(
1070
1080
  hb_array_free(&children);
1071
1081
  }
1072
1082
 
1073
- if (index < array->size) {
1083
+ if (index < hb_array_size(array)) {
1074
1084
  AST_NODE_T* next_node = hb_array_get(array, index);
1075
1085
 
1076
1086
  if (next_node && next_node->type == AST_ERB_CONTENT_NODE) {
@@ -1128,7 +1138,7 @@ static size_t process_block_children(
1128
1138
  analyze_ruby_context_T* context,
1129
1139
  control_type_t parent_type
1130
1140
  ) {
1131
- while (index < array->size) {
1141
+ while (index < hb_array_size(array)) {
1132
1142
  AST_NODE_T* child = hb_array_get(array, index);
1133
1143
 
1134
1144
  if (!child) { break; }
@@ -1150,7 +1160,7 @@ static size_t process_block_children(
1150
1160
  hb_array_T* temp_array = hb_array_init(1);
1151
1161
  size_t new_index = process_control_structure(node, array, index, temp_array, context, child_type);
1152
1162
 
1153
- if (temp_array->size > 0) { hb_array_append(children_array, hb_array_first(temp_array)); }
1163
+ if (hb_array_size(temp_array) > 0) { hb_array_append(children_array, hb_array_first(temp_array)); }
1154
1164
 
1155
1165
  hb_array_free(&temp_array);
1156
1166
 
@@ -1166,10 +1176,10 @@ static size_t process_block_children(
1166
1176
  }
1167
1177
 
1168
1178
  hb_array_T* rewrite_node_array(AST_NODE_T* node, hb_array_T* array, analyze_ruby_context_T* context) {
1169
- hb_array_T* new_array = hb_array_init(array->size);
1179
+ hb_array_T* new_array = hb_array_init(hb_array_size(array));
1170
1180
  size_t index = 0;
1171
1181
 
1172
- while (index < array->size) {
1182
+ while (index < hb_array_size(array)) {
1173
1183
  AST_NODE_T* item = hb_array_get(array, index);
1174
1184
 
1175
1185
  if (!item) { break; }
@@ -1304,7 +1314,7 @@ static bool detect_invalid_erb_structures(const AST_NODE_T* node, void* data) {
1304
1314
  if (if_node->end_node == NULL) { check_erb_node_for_missing_end(node); }
1305
1315
 
1306
1316
  if (if_node->statements != NULL) {
1307
- for (size_t i = 0; i < if_node->statements->size; i++) {
1317
+ for (size_t i = 0; i < hb_array_size(if_node->statements); i++) {
1308
1318
  AST_NODE_T* statement = (AST_NODE_T*) hb_array_get(if_node->statements, i);
1309
1319
 
1310
1320
  if (statement != NULL) { herb_visit_node(statement, detect_invalid_erb_structures, context); }
@@ -1336,7 +1346,7 @@ static bool detect_invalid_erb_structures(const AST_NODE_T* node, void* data) {
1336
1346
  const AST_ERB_IF_NODE_T* elsif_node = (const AST_ERB_IF_NODE_T*) subsequent;
1337
1347
 
1338
1348
  if (elsif_node->statements != NULL) {
1339
- for (size_t i = 0; i < elsif_node->statements->size; i++) {
1349
+ for (size_t i = 0; i < hb_array_size(elsif_node->statements); i++) {
1340
1350
  AST_NODE_T* statement = (AST_NODE_T*) hb_array_get(elsif_node->statements, i);
1341
1351
 
1342
1352
  if (statement != NULL) { herb_visit_node(statement, detect_invalid_erb_structures, context); }
@@ -1348,7 +1358,7 @@ static bool detect_invalid_erb_structures(const AST_NODE_T* node, void* data) {
1348
1358
  const AST_ERB_ELSE_NODE_T* else_node = (const AST_ERB_ELSE_NODE_T*) subsequent;
1349
1359
 
1350
1360
  if (else_node->statements != NULL) {
1351
- for (size_t i = 0; i < else_node->statements->size; i++) {
1361
+ for (size_t i = 0; i < hb_array_size(else_node->statements); i++) {
1352
1362
  AST_NODE_T* statement = (AST_NODE_T*) hb_array_get(else_node->statements, i);
1353
1363
 
1354
1364
  if (statement != NULL) { herb_visit_node(statement, detect_invalid_erb_structures, context); }
data/src/ast_node.c CHANGED
@@ -43,7 +43,7 @@ ast_node_type_T ast_node_type(const AST_NODE_T* node) {
43
43
  }
44
44
 
45
45
  size_t ast_node_errors_count(const AST_NODE_T* node) {
46
- return node->errors->size;
46
+ return hb_array_size(node->errors);
47
47
  }
48
48
 
49
49
  hb_array_T* ast_node_errors(const AST_NODE_T* node) {