herb 0.9.2-arm-linux-gnu → 0.9.4-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 (171) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +2 -0
  3. data/config.yml +125 -0
  4. data/ext/herb/error_helpers.c +172 -2
  5. data/ext/herb/extconf.rb +6 -0
  6. data/ext/herb/extension.c +16 -2
  7. data/ext/herb/extension_helpers.c +6 -5
  8. data/ext/herb/extension_helpers.h +4 -4
  9. data/ext/herb/nodes.c +89 -3
  10. data/lib/herb/3.0/herb.so +0 -0
  11. data/lib/herb/3.1/herb.so +0 -0
  12. data/lib/herb/3.2/herb.so +0 -0
  13. data/lib/herb/3.3/herb.so +0 -0
  14. data/lib/herb/3.4/herb.so +0 -0
  15. data/lib/herb/4.0/herb.so +0 -0
  16. data/lib/herb/ast/erb_content_node.rb +32 -0
  17. data/lib/herb/ast/nodes.rb +244 -3
  18. data/lib/herb/cli.rb +12 -2
  19. data/lib/herb/engine/compiler.rb +166 -75
  20. data/lib/herb/engine/validators/security_validator.rb +40 -0
  21. data/lib/herb/engine.rb +3 -0
  22. data/lib/herb/errors.rb +268 -0
  23. data/lib/herb/parser_options.rb +7 -2
  24. data/lib/herb/project.rb +58 -17
  25. data/lib/herb/version.rb +1 -1
  26. data/lib/herb/visitor.rb +82 -0
  27. data/lib/herb.rb +1 -0
  28. data/sig/herb/ast/erb_content_node.rbs +13 -0
  29. data/sig/herb/ast/nodes.rbs +98 -2
  30. data/sig/herb/engine/compiler.rbs +31 -2
  31. data/sig/herb/engine/validators/security_validator.rbs +4 -0
  32. data/sig/herb/engine.rbs +3 -0
  33. data/sig/herb/errors.rbs +122 -0
  34. data/sig/herb/parser_options.rbs +6 -2
  35. data/sig/herb/visitor.rbs +12 -0
  36. data/sig/serialized_ast_errors.rbs +29 -0
  37. data/sig/serialized_ast_nodes.rbs +19 -0
  38. data/src/analyze/action_view/attribute_extraction_helpers.c +420 -91
  39. data/src/analyze/action_view/image_tag.c +87 -0
  40. data/src/analyze/action_view/javascript_include_tag.c +22 -12
  41. data/src/analyze/action_view/registry.c +6 -3
  42. data/src/analyze/action_view/tag.c +19 -2
  43. data/src/analyze/action_view/tag_helper_node_builders.c +105 -36
  44. data/src/analyze/action_view/tag_helpers.c +792 -44
  45. data/src/analyze/analyze.c +167 -13
  46. data/src/analyze/{helpers.c → analyze_helpers.c} +1 -1
  47. data/src/analyze/analyzed_ruby.c +1 -1
  48. data/src/analyze/builders.c +11 -8
  49. data/src/analyze/conditional_elements.c +6 -7
  50. data/src/analyze/conditional_open_tags.c +6 -7
  51. data/src/analyze/control_type.c +4 -2
  52. data/src/analyze/invalid_structures.c +5 -5
  53. data/src/analyze/missing_end.c +2 -2
  54. data/src/analyze/parse_errors.c +47 -6
  55. data/src/analyze/prism_annotate.c +7 -7
  56. data/src/analyze/render_nodes.c +6 -26
  57. data/src/analyze/strict_locals.c +651 -0
  58. data/src/analyze/transform.c +7 -0
  59. data/src/{ast_node.c → ast/ast_node.c} +8 -8
  60. data/src/{ast_nodes.c → ast/ast_nodes.c} +82 -11
  61. data/src/{ast_pretty_print.c → ast/ast_pretty_print.c} +113 -9
  62. data/src/{pretty_print.c → ast/pretty_print.c} +9 -9
  63. data/src/errors.c +398 -8
  64. data/src/extract.c +5 -5
  65. data/src/herb.c +15 -5
  66. data/src/include/analyze/action_view/attribute_extraction_helpers.h +3 -1
  67. data/src/include/analyze/action_view/tag_helper_handler.h +3 -3
  68. data/src/include/analyze/action_view/tag_helper_node_builders.h +34 -5
  69. data/src/include/analyze/action_view/tag_helpers.h +4 -3
  70. data/src/include/analyze/analyze.h +12 -5
  71. data/src/include/analyze/analyzed_ruby.h +2 -2
  72. data/src/include/analyze/builders.h +4 -4
  73. data/src/include/analyze/conditional_elements.h +2 -2
  74. data/src/include/analyze/conditional_open_tags.h +2 -2
  75. data/src/include/analyze/control_type.h +1 -1
  76. data/src/include/analyze/helpers.h +2 -2
  77. data/src/include/analyze/invalid_structures.h +1 -1
  78. data/src/include/analyze/prism_annotate.h +2 -2
  79. data/src/include/analyze/render_nodes.h +1 -1
  80. data/src/include/analyze/strict_locals.h +11 -0
  81. data/src/include/{ast_node.h → ast/ast_node.h} +4 -4
  82. data/src/include/{ast_nodes.h → ast/ast_nodes.h} +38 -14
  83. data/src/include/{ast_pretty_print.h → ast/ast_pretty_print.h} +3 -3
  84. data/src/include/{pretty_print.h → ast/pretty_print.h} +4 -4
  85. data/src/include/errors.h +65 -7
  86. data/src/include/extract.h +2 -2
  87. data/src/include/herb.h +5 -5
  88. data/src/include/{lex_helpers.h → lexer/lex_helpers.h} +5 -5
  89. data/src/include/{lexer.h → lexer/lexer.h} +1 -1
  90. data/src/include/{lexer_peek_helpers.h → lexer/lexer_peek_helpers.h} +2 -2
  91. data/src/include/{lexer_struct.h → lexer/lexer_struct.h} +2 -2
  92. data/src/include/{token.h → lexer/token.h} +3 -3
  93. data/src/include/{token_matchers.h → lexer/token_matchers.h} +1 -1
  94. data/src/include/{token_struct.h → lexer/token_struct.h} +3 -3
  95. data/src/include/{util → lib}/hb_foreach.h +1 -1
  96. data/src/include/{util → lib}/hb_string.h +5 -1
  97. data/src/include/{location.h → location/location.h} +1 -1
  98. data/src/include/parser/dot_notation.h +12 -0
  99. data/src/include/{parser.h → parser/parser.h} +11 -4
  100. data/src/include/{parser_helpers.h → parser/parser_helpers.h} +6 -6
  101. data/src/include/{prism_context.h → prism/prism_context.h} +2 -2
  102. data/src/include/{prism_helpers.h → prism/prism_helpers.h} +6 -6
  103. data/src/include/{html_util.h → util/html_util.h} +1 -1
  104. data/src/include/util/ruby_util.h +9 -0
  105. data/src/include/{utf8.h → util/utf8.h} +1 -1
  106. data/src/include/{util.h → util/util.h} +1 -1
  107. data/src/include/version.h +1 -1
  108. data/src/include/visitor.h +3 -3
  109. data/src/{lexer_peek_helpers.c → lexer/lexer_peek_helpers.c} +3 -3
  110. data/src/{token.c → lexer/token.c} +8 -8
  111. data/src/{token_matchers.c → lexer/token_matchers.c} +2 -2
  112. data/src/lexer.c +6 -6
  113. data/src/{util → lib}/hb_allocator.c +2 -2
  114. data/src/{util → lib}/hb_arena.c +1 -1
  115. data/src/{util → lib}/hb_arena_debug.c +2 -2
  116. data/src/{util → lib}/hb_array.c +2 -2
  117. data/src/{util → lib}/hb_buffer.c +2 -2
  118. data/src/{util → lib}/hb_narray.c +1 -1
  119. data/src/{util → lib}/hb_string.c +2 -2
  120. data/src/{location.c → location/location.c} +2 -2
  121. data/src/{position.c → location/position.c} +2 -2
  122. data/src/{range.c → location/range.c} +1 -1
  123. data/src/main.c +11 -11
  124. data/src/parser/dot_notation.c +100 -0
  125. data/src/{parser_match_tags.c → parser/match_tags.c} +34 -5
  126. data/src/{parser_helpers.c → parser/parser_helpers.c} +10 -10
  127. data/src/parser.c +68 -32
  128. data/src/{prism_helpers.c → prism/prism_helpers.c} +7 -7
  129. data/src/{ruby_parser.c → prism/ruby_parser.c} +1 -1
  130. data/src/{html_util.c → util/html_util.c} +4 -4
  131. data/src/{io.c → util/io.c} +3 -3
  132. data/src/util/ruby_util.c +42 -0
  133. data/src/{utf8.c → util/utf8.c} +2 -2
  134. data/src/{util.c → util/util.c} +4 -4
  135. data/src/visitor.c +35 -3
  136. data/templates/ext/herb/error_helpers.c.erb +2 -2
  137. data/templates/ext/herb/nodes.c.erb +1 -1
  138. data/templates/java/error_helpers.c.erb +1 -1
  139. data/templates/java/error_helpers.h.erb +2 -2
  140. data/templates/java/nodes.c.erb +4 -4
  141. data/templates/java/nodes.h.erb +1 -1
  142. data/templates/javascript/packages/node/extension/error_helpers.cpp.erb +4 -4
  143. data/templates/javascript/packages/node/extension/nodes.cpp.erb +4 -4
  144. data/templates/lib/herb/visitor.rb.erb +14 -0
  145. data/templates/src/analyze/missing_end.c.erb +2 -2
  146. data/templates/src/{ast_nodes.c.erb → ast/ast_nodes.c.erb} +9 -9
  147. data/templates/src/{ast_pretty_print.c.erb → ast/ast_pretty_print.c.erb} +8 -8
  148. data/templates/src/errors.c.erb +8 -8
  149. data/templates/src/include/{ast_nodes.h.erb → ast/ast_nodes.h.erb} +11 -12
  150. data/templates/src/include/{ast_pretty_print.h.erb → ast/ast_pretty_print.h.erb} +2 -2
  151. data/templates/src/include/errors.h.erb +7 -7
  152. data/templates/src/{parser_match_tags.c.erb → parser/match_tags.c.erb} +4 -4
  153. data/templates/src/visitor.c.erb +3 -3
  154. data/templates/wasm/error_helpers.cpp.erb +4 -4
  155. data/templates/wasm/nodes.cpp.erb +5 -5
  156. metadata +76 -68
  157. data/src/include/element_source.h +0 -10
  158. /data/src/include/{util → lib}/hb_allocator.h +0 -0
  159. /data/src/include/{util → lib}/hb_arena.h +0 -0
  160. /data/src/include/{util → lib}/hb_arena_debug.h +0 -0
  161. /data/src/include/{util → lib}/hb_array.h +0 -0
  162. /data/src/include/{util → lib}/hb_buffer.h +0 -0
  163. /data/src/include/{util → lib}/hb_narray.h +0 -0
  164. /data/src/include/{util → lib}/string.h +0 -0
  165. /data/src/include/{position.h → location/position.h} +0 -0
  166. /data/src/include/{range.h → location/range.h} +0 -0
  167. /data/src/include/{herb_prism_node.h → prism/herb_prism_node.h} +0 -0
  168. /data/src/include/{prism_serialized.h → prism/prism_serialized.h} +0 -0
  169. /data/src/include/{ruby_parser.h → prism/ruby_parser.h} +0 -0
  170. /data/src/include/{io.h → util/io.h} +0 -0
  171. /data/templates/src/include/{util → lib}/hb_foreach.h.erb +0 -0
@@ -1,8 +1,8 @@
1
1
  #ifndef HERB_ANALYZED_RUBY_H
2
2
  #define HERB_ANALYZED_RUBY_H
3
3
 
4
- #include "../util/hb_array.h"
5
- #include "../util/hb_string.h"
4
+ #include "../lib/hb_array.h"
5
+ #include "../lib/hb_string.h"
6
6
 
7
7
  #include <prism.h>
8
8
 
@@ -1,10 +1,10 @@
1
1
  #ifndef HERB_ANALYZE_BUILDERS_H
2
2
  #define HERB_ANALYZE_BUILDERS_H
3
3
 
4
- #include "../ast_nodes.h"
5
- #include "../location.h"
6
- #include "../position.h"
7
- #include "../util/hb_allocator.h"
4
+ #include "../ast/ast_nodes.h"
5
+ #include "../lib/hb_allocator.h"
6
+ #include "../location/location.h"
7
+ #include "../location/position.h"
8
8
  #include "analyze.h"
9
9
 
10
10
  position_T erb_content_end_position(const AST_ERB_CONTENT_NODE_T* erb_node);
@@ -1,8 +1,8 @@
1
1
  #ifndef HERB_ANALYZE_CONDITIONAL_ELEMENTS_H
2
2
  #define HERB_ANALYZE_CONDITIONAL_ELEMENTS_H
3
3
 
4
- #include "../ast_nodes.h"
5
- #include "../util/hb_allocator.h"
4
+ #include "../ast/ast_nodes.h"
5
+ #include "../lib/hb_allocator.h"
6
6
 
7
7
  void herb_transform_conditional_elements(AST_DOCUMENT_NODE_T* document, hb_allocator_T* allocator);
8
8
 
@@ -1,8 +1,8 @@
1
1
  #ifndef HERB_ANALYZE_CONDITIONAL_OPEN_TAGS_H
2
2
  #define HERB_ANALYZE_CONDITIONAL_OPEN_TAGS_H
3
3
 
4
- #include "../ast_nodes.h"
5
- #include "../util/hb_allocator.h"
4
+ #include "../ast/ast_nodes.h"
5
+ #include "../lib/hb_allocator.h"
6
6
 
7
7
  void herb_transform_conditional_open_tags(AST_DOCUMENT_NODE_T* document, hb_allocator_T* allocator);
8
8
 
@@ -1,7 +1,7 @@
1
1
  #ifndef HERB_ANALYZE_CONTROL_TYPE_H
2
2
  #define HERB_ANALYZE_CONTROL_TYPE_H
3
3
 
4
- #include "../ast_nodes.h"
4
+ #include "../ast/ast_nodes.h"
5
5
  #include "analyze.h"
6
6
 
7
7
  #include <stdbool.h>
@@ -4,8 +4,8 @@
4
4
  #include <prism.h>
5
5
  #include <stdbool.h>
6
6
 
7
- #include "../ast_node.h"
8
- #include "../util/hb_allocator.h"
7
+ #include "../ast/ast_node.h"
8
+ #include "../lib/hb_allocator.h"
9
9
  #include "analyzed_ruby.h"
10
10
 
11
11
  bool has_if_node(analyzed_ruby_T* analyzed);
@@ -1,7 +1,7 @@
1
1
  #ifndef HERB_ANALYZE_INVALID_STRUCTURES_H
2
2
  #define HERB_ANALYZE_INVALID_STRUCTURES_H
3
3
 
4
- #include "../ast_node.h"
4
+ #include "../ast/ast_node.h"
5
5
  #include "analyze.h"
6
6
 
7
7
  #include <stdbool.h>
@@ -1,8 +1,8 @@
1
1
  #ifndef HERB_PRISM_ANNOTATE_H
2
2
  #define HERB_PRISM_ANNOTATE_H
3
3
 
4
- #include "../ast_nodes.h"
5
- #include "../util/hb_allocator.h"
4
+ #include "../ast/ast_nodes.h"
5
+ #include "../lib/hb_allocator.h"
6
6
 
7
7
  void herb_annotate_prism_nodes(
8
8
  AST_DOCUMENT_NODE_T* document,
@@ -1,7 +1,7 @@
1
1
  #ifndef HERB_ANALYZE_RENDER_NODES_H
2
2
  #define HERB_ANALYZE_RENDER_NODES_H
3
3
 
4
- #include "../ast_nodes.h"
4
+ #include "../ast/ast_nodes.h"
5
5
  #include "analyze.h"
6
6
 
7
7
  #include <stdbool.h>
@@ -0,0 +1,11 @@
1
+ #ifndef HERB_ANALYZE_STRICT_LOCALS_H
2
+ #define HERB_ANALYZE_STRICT_LOCALS_H
3
+
4
+ #include "../ast/ast_nodes.h"
5
+ #include "analyze.h"
6
+
7
+ #include <stdbool.h>
8
+
9
+ bool transform_strict_locals_nodes(const AST_NODE_T* node, void* data);
10
+
11
+ #endif
@@ -1,11 +1,11 @@
1
1
  #ifndef HERB_AST_H
2
2
  #define HERB_AST_H
3
3
 
4
+ #include "../errors.h"
5
+ #include "../lexer/token_struct.h"
6
+ #include "../lib/hb_allocator.h"
7
+ #include "../location/position.h"
4
8
  #include "ast_nodes.h"
5
- #include "errors.h"
6
- #include "position.h"
7
- #include "token_struct.h"
8
- #include "util/hb_allocator.h"
9
9
 
10
10
  void ast_node_init(
11
11
  AST_NODE_T* node,
@@ -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 /home/runner/work/herb/herb/templates/src/include/ast_nodes.h.erb
2
+ // be modified manually. See /home/runner/work/herb/herb/templates/src/include/ast/ast_nodes.h.erb
3
3
 
4
4
  #ifndef HERB_AST_NODES_H
5
5
  #define HERB_AST_NODES_H
@@ -7,18 +7,17 @@
7
7
  #include <stdbool.h>
8
8
  #include <prism.h>
9
9
 
10
- #include "analyze/analyzed_ruby.h"
11
- #include "element_source.h"
12
- #include "herb_prism_node.h"
13
- #include "prism_context.h"
14
- #include "prism_serialized.h"
15
- #include "location.h"
16
- #include "position.h"
17
- #include "token_struct.h"
18
- #include "util/hb_allocator.h"
19
- #include "util/hb_array.h"
20
- #include "util/hb_buffer.h"
21
- #include "util/hb_string.h"
10
+ #include "../analyze/analyzed_ruby.h"
11
+ #include "../prism/herb_prism_node.h"
12
+ #include "../prism/prism_context.h"
13
+ #include "../prism/prism_serialized.h"
14
+ #include "../location/location.h"
15
+ #include "../location/position.h"
16
+ #include "../lexer/token_struct.h"
17
+ #include "../lib/hb_allocator.h"
18
+ #include "../lib/hb_array.h"
19
+ #include "../lib/hb_buffer.h"
20
+ #include "../lib/hb_string.h"
22
21
 
23
22
  typedef enum {
24
23
  AST_DOCUMENT_NODE,
@@ -59,6 +58,8 @@ typedef enum {
59
58
  AST_ERB_UNLESS_NODE,
60
59
  AST_RUBY_RENDER_LOCAL_NODE,
61
60
  AST_ERB_RENDER_NODE,
61
+ AST_RUBY_STRICT_LOCAL_NODE,
62
+ AST_ERB_STRICT_LOCALS_NODE,
62
63
  AST_ERB_YIELD_NODE,
63
64
  AST_ERB_IN_NODE,
64
65
  } ast_node_type_T;
@@ -262,6 +263,9 @@ typedef struct AST_ERB_BLOCK_NODE_STRUCT {
262
263
  token_T* tag_closing;
263
264
  herb_prism_node_T prism_node;
264
265
  hb_array_T* body;
266
+ struct AST_ERB_RESCUE_NODE_STRUCT* rescue_clause;
267
+ struct AST_ERB_ELSE_NODE_STRUCT* else_clause;
268
+ struct AST_ERB_ENSURE_NODE_STRUCT* ensure_clause;
265
269
  struct AST_ERB_END_NODE_STRUCT* end_node;
266
270
  } AST_ERB_BLOCK_NODE_T;
267
271
 
@@ -403,6 +407,24 @@ typedef struct AST_ERB_RENDER_NODE_STRUCT {
403
407
  hb_array_T* locals;
404
408
  } AST_ERB_RENDER_NODE_T;
405
409
 
410
+ typedef struct AST_RUBY_STRICT_LOCAL_NODE_STRUCT {
411
+ AST_NODE_T base;
412
+ token_T* name;
413
+ struct AST_RUBY_LITERAL_NODE_STRUCT* default_value;
414
+ bool required;
415
+ bool double_splat;
416
+ } AST_RUBY_STRICT_LOCAL_NODE_T;
417
+
418
+ typedef struct AST_ERB_STRICT_LOCALS_NODE_STRUCT {
419
+ AST_NODE_T base;
420
+ token_T* tag_opening;
421
+ token_T* content;
422
+ token_T* tag_closing;
423
+ analyzed_ruby_T* analyzed_ruby;
424
+ herb_prism_node_T prism_node;
425
+ hb_array_T* locals;
426
+ } AST_ERB_STRICT_LOCALS_NODE_T;
427
+
406
428
  typedef struct AST_ERB_YIELD_NODE_STRUCT {
407
429
  AST_NODE_T base;
408
430
  token_T* tag_opening;
@@ -444,7 +466,7 @@ AST_ERB_CONTENT_NODE_T* ast_erb_content_node_init(token_T* tag_opening, token_T*
444
466
  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, hb_array_T* errors, hb_allocator_T* allocator);
445
467
  AST_ERB_ELSE_NODE_T* ast_erb_else_node_init(token_T* tag_opening, token_T* content, token_T* tag_closing, hb_array_T* statements, position_T start_position, position_T end_position, hb_array_T* errors, hb_allocator_T* allocator);
446
468
  AST_ERB_IF_NODE_T* ast_erb_if_node_init(token_T* tag_opening, token_T* content, token_T* tag_closing, location_T* then_keyword, herb_prism_node_T prism_node, hb_array_T* statements, AST_NODE_T* subsequent, struct AST_ERB_END_NODE_STRUCT* end_node, position_T start_position, position_T end_position, hb_array_T* errors, hb_allocator_T* allocator);
447
- AST_ERB_BLOCK_NODE_T* ast_erb_block_node_init(token_T* tag_opening, token_T* content, token_T* tag_closing, herb_prism_node_T prism_node, hb_array_T* body, struct AST_ERB_END_NODE_STRUCT* end_node, position_T start_position, position_T end_position, hb_array_T* errors, hb_allocator_T* allocator);
469
+ AST_ERB_BLOCK_NODE_T* ast_erb_block_node_init(token_T* tag_opening, token_T* content, token_T* tag_closing, herb_prism_node_T prism_node, hb_array_T* body, struct AST_ERB_RESCUE_NODE_STRUCT* rescue_clause, struct AST_ERB_ELSE_NODE_STRUCT* else_clause, struct AST_ERB_ENSURE_NODE_STRUCT* ensure_clause, struct AST_ERB_END_NODE_STRUCT* end_node, position_T start_position, position_T end_position, hb_array_T* errors, hb_allocator_T* allocator);
448
470
  AST_ERB_WHEN_NODE_T* ast_erb_when_node_init(token_T* tag_opening, token_T* content, token_T* tag_closing, location_T* then_keyword, hb_array_T* statements, position_T start_position, position_T end_position, hb_array_T* errors, hb_allocator_T* allocator);
449
471
  AST_ERB_CASE_NODE_T* ast_erb_case_node_init(token_T* tag_opening, token_T* content, token_T* tag_closing, hb_array_T* children, herb_prism_node_T prism_node, hb_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, hb_array_T* errors, hb_allocator_T* allocator);
450
472
  AST_ERB_CASE_MATCH_NODE_T* ast_erb_case_match_node_init(token_T* tag_opening, token_T* content, token_T* tag_closing, hb_array_T* children, herb_prism_node_T prism_node, hb_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, hb_array_T* errors, hb_allocator_T* allocator);
@@ -457,6 +479,8 @@ AST_ERB_BEGIN_NODE_T* ast_erb_begin_node_init(token_T* tag_opening, token_T* con
457
479
  AST_ERB_UNLESS_NODE_T* ast_erb_unless_node_init(token_T* tag_opening, token_T* content, token_T* tag_closing, location_T* then_keyword, herb_prism_node_T prism_node, hb_array_T* statements, struct AST_ERB_ELSE_NODE_STRUCT* else_clause, struct AST_ERB_END_NODE_STRUCT* end_node, position_T start_position, position_T end_position, hb_array_T* errors, hb_allocator_T* allocator);
458
480
  AST_RUBY_RENDER_LOCAL_NODE_T* ast_ruby_render_local_node_init(token_T* name, struct AST_RUBY_LITERAL_NODE_STRUCT* value, position_T start_position, position_T end_position, hb_array_T* errors, hb_allocator_T* allocator);
459
481
  AST_ERB_RENDER_NODE_T* ast_erb_render_node_init(token_T* tag_opening, token_T* content, token_T* tag_closing, analyzed_ruby_T* analyzed_ruby, herb_prism_node_T prism_node, token_T* partial, token_T* template_path, token_T* layout, token_T* file, token_T* inline_template, token_T* body, token_T* plain, token_T* html, token_T* renderable, token_T* collection, token_T* object, token_T* as_name, token_T* spacer_template, token_T* formats, token_T* variants, token_T* handlers, token_T* content_type, hb_array_T* locals, position_T start_position, position_T end_position, hb_array_T* errors, hb_allocator_T* allocator);
482
+ AST_RUBY_STRICT_LOCAL_NODE_T* ast_ruby_strict_local_node_init(token_T* name, struct AST_RUBY_LITERAL_NODE_STRUCT* default_value, bool required, bool double_splat, position_T start_position, position_T end_position, hb_array_T* errors, hb_allocator_T* allocator);
483
+ AST_ERB_STRICT_LOCALS_NODE_T* ast_erb_strict_locals_node_init(token_T* tag_opening, token_T* content, token_T* tag_closing, analyzed_ruby_T* analyzed_ruby, herb_prism_node_T prism_node, hb_array_T* locals, position_T start_position, position_T end_position, hb_array_T* errors, hb_allocator_T* allocator);
460
484
  AST_ERB_YIELD_NODE_T* ast_erb_yield_node_init(token_T* tag_opening, token_T* content, token_T* tag_closing, position_T start_position, position_T end_position, hb_array_T* errors, hb_allocator_T* allocator);
461
485
  AST_ERB_IN_NODE_T* ast_erb_in_node_init(token_T* tag_opening, token_T* content, token_T* tag_closing, location_T* then_keyword, hb_array_T* statements, position_T start_position, position_T end_position, hb_array_T* errors, hb_allocator_T* allocator);
462
486
 
@@ -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 /home/runner/work/herb/herb/templates/src/include/ast_pretty_print.h.erb
2
+ // be modified manually. See /home/runner/work/herb/herb/templates/src/include/ast/ast_pretty_print.h.erb
3
3
 
4
4
  #ifndef HERB_AST_PRETTY_PRINT_H
5
5
  #define HERB_AST_PRETTY_PRINT_H
@@ -8,8 +8,8 @@
8
8
  // Pretty print support excluded
9
9
  #else
10
10
 
11
- #include "ast_nodes.h"
12
- #include "util/hb_buffer.h"
11
+ #include "../ast/ast_nodes.h"
12
+ #include "../lib/hb_buffer.h"
13
13
 
14
14
  void ast_pretty_print_node(
15
15
  AST_NODE_T* node,
@@ -5,10 +5,10 @@
5
5
  // Pretty print support excluded
6
6
  #else
7
7
 
8
- # include "analyze/analyzed_ruby.h"
9
- # include "ast_nodes.h"
10
- # include "location.h"
11
- # include "util/hb_buffer.h"
8
+ # include "../analyze/analyzed_ruby.h"
9
+ # include "../ast/ast_nodes.h"
10
+ # include "../lib/hb_buffer.h"
11
+ # include "../location/location.h"
12
12
 
13
13
  # include <stdbool.h>
14
14
 
data/src/include/errors.h CHANGED
@@ -5,13 +5,13 @@
5
5
  #define HERB_ERRORS_H
6
6
 
7
7
  #include "errors.h"
8
- #include "location.h"
9
- #include "position.h"
10
- #include "token.h"
11
- #include "util/hb_allocator.h"
12
- #include "util/hb_array.h"
13
- #include "util/hb_buffer.h"
14
- #include "util/hb_string.h"
8
+ #include "location/location.h"
9
+ #include "location/position.h"
10
+ #include "lexer/token.h"
11
+ #include "lib/hb_allocator.h"
12
+ #include "lib/hb_array.h"
13
+ #include "lib/hb_buffer.h"
14
+ #include "lib/hb_string.h"
15
15
 
16
16
  typedef enum {
17
17
  UNEXPECTED_ERROR,
@@ -44,6 +44,13 @@ typedef enum {
44
44
  RENDER_INVALID_AS_OPTION_ERROR,
45
45
  RENDER_OBJECT_AND_COLLECTION_ERROR,
46
46
  RENDER_LAYOUT_WITHOUT_BLOCK_ERROR,
47
+ STRICT_LOCALS_POSITIONAL_ARGUMENT_ERROR,
48
+ STRICT_LOCALS_BLOCK_ARGUMENT_ERROR,
49
+ STRICT_LOCALS_SPLAT_ARGUMENT_ERROR,
50
+ STRICT_LOCALS_MISSING_PARENTHESIS_ERROR,
51
+ STRICT_LOCALS_DUPLICATE_DECLARATION_ERROR,
52
+ VOID_ELEMENT_CONTENT_ERROR,
53
+ DOT_NOTATION_CASING_ERROR,
47
54
  } error_type_T;
48
55
 
49
56
  typedef struct ERROR_STRUCT {
@@ -223,6 +230,43 @@ typedef struct {
223
230
  hb_string_T layout;
224
231
  } RENDER_LAYOUT_WITHOUT_BLOCK_ERROR_T;
225
232
 
233
+ typedef struct {
234
+ ERROR_T base;
235
+ hb_string_T name;
236
+ } STRICT_LOCALS_POSITIONAL_ARGUMENT_ERROR_T;
237
+
238
+ typedef struct {
239
+ ERROR_T base;
240
+ hb_string_T name;
241
+ } STRICT_LOCALS_BLOCK_ARGUMENT_ERROR_T;
242
+
243
+ typedef struct {
244
+ ERROR_T base;
245
+ hb_string_T name;
246
+ } STRICT_LOCALS_SPLAT_ARGUMENT_ERROR_T;
247
+
248
+ typedef struct {
249
+ ERROR_T base;
250
+ hb_string_T rest;
251
+ } STRICT_LOCALS_MISSING_PARENTHESIS_ERROR_T;
252
+
253
+ typedef struct {
254
+ ERROR_T base;
255
+ /* no additional fields */
256
+ } STRICT_LOCALS_DUPLICATE_DECLARATION_ERROR_T;
257
+
258
+ typedef struct {
259
+ ERROR_T base;
260
+ token_T* tag_name;
261
+ hb_string_T helper_name;
262
+ hb_string_T content_type;
263
+ } VOID_ELEMENT_CONTENT_ERROR_T;
264
+
265
+ typedef struct {
266
+ ERROR_T base;
267
+ token_T* segment;
268
+ } DOT_NOTATION_CASING_ERROR_T;
269
+
226
270
  UNEXPECTED_ERROR_T* unexpected_error_init(hb_string_T description, hb_string_T expected, hb_string_T found, position_T start, position_T end, hb_allocator_T* allocator);
227
271
  void append_unexpected_error(hb_string_T description, hb_string_T expected, hb_string_T found, position_T start, position_T end, hb_allocator_T* allocator, hb_array_T* errors);
228
272
  UNEXPECTED_TOKEN_ERROR_T* unexpected_token_error_init(token_type_T expected_type, token_T* found, position_T start, position_T end, hb_allocator_T* allocator);
@@ -283,6 +327,20 @@ RENDER_OBJECT_AND_COLLECTION_ERROR_T* render_object_and_collection_error_init(po
283
327
  void append_render_object_and_collection_error(position_T start, position_T end, hb_allocator_T* allocator, hb_array_T* errors);
284
328
  RENDER_LAYOUT_WITHOUT_BLOCK_ERROR_T* render_layout_without_block_error_init(hb_string_T layout, position_T start, position_T end, hb_allocator_T* allocator);
285
329
  void append_render_layout_without_block_error(hb_string_T layout, position_T start, position_T end, hb_allocator_T* allocator, hb_array_T* errors);
330
+ STRICT_LOCALS_POSITIONAL_ARGUMENT_ERROR_T* strict_locals_positional_argument_error_init(hb_string_T name, position_T start, position_T end, hb_allocator_T* allocator);
331
+ void append_strict_locals_positional_argument_error(hb_string_T name, position_T start, position_T end, hb_allocator_T* allocator, hb_array_T* errors);
332
+ STRICT_LOCALS_BLOCK_ARGUMENT_ERROR_T* strict_locals_block_argument_error_init(hb_string_T name, position_T start, position_T end, hb_allocator_T* allocator);
333
+ void append_strict_locals_block_argument_error(hb_string_T name, position_T start, position_T end, hb_allocator_T* allocator, hb_array_T* errors);
334
+ STRICT_LOCALS_SPLAT_ARGUMENT_ERROR_T* strict_locals_splat_argument_error_init(hb_string_T name, position_T start, position_T end, hb_allocator_T* allocator);
335
+ void append_strict_locals_splat_argument_error(hb_string_T name, position_T start, position_T end, hb_allocator_T* allocator, hb_array_T* errors);
336
+ STRICT_LOCALS_MISSING_PARENTHESIS_ERROR_T* strict_locals_missing_parenthesis_error_init(hb_string_T rest, position_T start, position_T end, hb_allocator_T* allocator);
337
+ void append_strict_locals_missing_parenthesis_error(hb_string_T rest, position_T start, position_T end, hb_allocator_T* allocator, hb_array_T* errors);
338
+ STRICT_LOCALS_DUPLICATE_DECLARATION_ERROR_T* strict_locals_duplicate_declaration_error_init(position_T start, position_T end, hb_allocator_T* allocator);
339
+ void append_strict_locals_duplicate_declaration_error(position_T start, position_T end, hb_allocator_T* allocator, hb_array_T* errors);
340
+ VOID_ELEMENT_CONTENT_ERROR_T* void_element_content_error_init(token_T* tag_name, hb_string_T helper_name, hb_string_T content_type, position_T start, position_T end, hb_allocator_T* allocator);
341
+ void append_void_element_content_error(token_T* tag_name, hb_string_T helper_name, hb_string_T content_type, position_T start, position_T end, hb_allocator_T* allocator, hb_array_T* errors);
342
+ DOT_NOTATION_CASING_ERROR_T* dot_notation_casing_error_init(token_T* segment, position_T start, position_T end, hb_allocator_T* allocator);
343
+ void append_dot_notation_casing_error(token_T* segment, position_T start, position_T end, hb_allocator_T* allocator, hb_array_T* errors);
286
344
 
287
345
  void error_init(ERROR_T* error, error_type_T type, position_T start, position_T end);
288
346
 
@@ -1,8 +1,8 @@
1
1
  #ifndef HERB_EXTRACT_H
2
2
  #define HERB_EXTRACT_H
3
3
 
4
- #include "util/hb_allocator.h"
5
- #include "util/hb_buffer.h"
4
+ #include "lib/hb_allocator.h"
5
+ #include "lib/hb_buffer.h"
6
6
 
7
7
  #include <stdbool.h>
8
8
 
data/src/include/herb.h CHANGED
@@ -1,13 +1,13 @@
1
1
  #ifndef HERB_H
2
2
  #define HERB_H
3
3
 
4
- #include "ast_node.h"
4
+ #include "ast/ast_node.h"
5
5
  #include "extract.h"
6
+ #include "lib/hb_allocator.h"
7
+ #include "lib/hb_array.h"
8
+ #include "lib/hb_buffer.h"
6
9
  #include "macros.h"
7
- #include "parser.h"
8
- #include "util/hb_allocator.h"
9
- #include "util/hb_array.h"
10
- #include "util/hb_buffer.h"
10
+ #include "parser/parser.h"
11
11
 
12
12
  #include <prism.h>
13
13
  #include <stdbool.h>
@@ -1,12 +1,12 @@
1
1
  #ifndef HERB_LEX_HELPERS_H
2
2
  #define HERB_LEX_HELPERS_H
3
3
 
4
- #include "herb.h"
4
+ #include "../herb.h"
5
+ #include "../lib/hb_allocator.h"
6
+ #include "../lib/hb_array.h"
7
+ #include "../lib/hb_buffer.h"
8
+ #include "../lib/hb_string.h"
5
9
  #include "token.h"
6
- #include "util/hb_allocator.h"
7
- #include "util/hb_array.h"
8
- #include "util/hb_buffer.h"
9
- #include "util/hb_string.h"
10
10
 
11
11
  #include <stdlib.h>
12
12
 
@@ -1,8 +1,8 @@
1
1
  #ifndef HERB_LEXER_H
2
2
  #define HERB_LEXER_H
3
3
 
4
+ #include "../lexer/token_struct.h"
4
5
  #include "lexer_struct.h"
5
- #include "token_struct.h"
6
6
 
7
7
  void lexer_init(lexer_T* lexer, const char* source, hb_allocator_T* allocator);
8
8
  token_T* lexer_next_token(lexer_T* lexer);
@@ -1,10 +1,10 @@
1
1
  #ifndef HERB_LEXER_PEEK_HELPERS_H
2
2
  #define HERB_LEXER_PEEK_HELPERS_H
3
3
 
4
+ #include "../lib/hb_string.h"
5
+ #include "../macros.h"
4
6
  #include "lexer_struct.h"
5
- #include "macros.h"
6
7
  #include "token_struct.h"
7
- #include "util/hb_string.h"
8
8
 
9
9
  #include <ctype.h>
10
10
  #include <stdbool.h>
@@ -1,8 +1,8 @@
1
1
  #ifndef HERB_LEXER_STRUCT_H
2
2
  #define HERB_LEXER_STRUCT_H
3
3
 
4
- #include "util/hb_allocator.h"
5
- #include "util/hb_string.h"
4
+ #include "../lib/hb_allocator.h"
5
+ #include "../lib/hb_string.h"
6
6
 
7
7
  #include <stdbool.h>
8
8
  #include <stdint.h>
@@ -1,11 +1,11 @@
1
1
  #ifndef HERB_TOKEN_H
2
2
  #define HERB_TOKEN_H
3
3
 
4
+ #include "../lib/hb_allocator.h"
5
+ #include "../lib/hb_string.h"
6
+ #include "../location/position.h"
4
7
  #include "lexer_struct.h"
5
- #include "position.h"
6
8
  #include "token_struct.h"
7
- #include "util/hb_allocator.h"
8
- #include "util/hb_string.h"
9
9
 
10
10
  #include <stdarg.h>
11
11
 
@@ -1,7 +1,7 @@
1
1
  #ifndef HERB_TOKEN_MATCHERS_H
2
2
  #define HERB_TOKEN_MATCHERS_H
3
3
 
4
- #include "parser.h"
4
+ #include "../parser/parser.h"
5
5
  #include "token.h"
6
6
 
7
7
  #include <stdarg.h>
@@ -3,9 +3,9 @@
3
3
 
4
4
  #include <stdbool.h>
5
5
 
6
- #include "location.h"
7
- #include "range.h"
8
- #include "util/hb_string.h"
6
+ #include "../lib/hb_string.h"
7
+ #include "../location/location.h"
8
+ #include "../location/range.h"
9
9
 
10
10
  typedef enum {
11
11
  TOKEN_WHITESPACE, // ' '
@@ -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 /home/runner/work/herb/herb/templates/src/include/util/hb_foreach.h.erb
2
+ // be modified manually. See /home/runner/work/herb/herb/templates/src/include/lib/hb_foreach.h.erb
3
3
 
4
4
  #ifndef HB_FOREACH_H
5
5
  #define HB_FOREACH_H
@@ -15,7 +15,7 @@ typedef struct HB_STRING_STRUCT {
15
15
  uint32_t length;
16
16
  } hb_string_T;
17
17
 
18
- #define HB_STRING_EMPTY ((hb_string_T) { .data = "", .length = 0 })
18
+ #define HB_STRING_EMPTY ((hb_string_T) { .data = (char*) "", .length = 0 })
19
19
  #define HB_STRING_NULL ((hb_string_T) { .data = NULL, .length = 0 })
20
20
 
21
21
  #define HB_STRING_LITERAL(string) { .data = (char*) (string), .length = (uint32_t) (sizeof(string) - 1) }
@@ -29,6 +29,10 @@ typedef struct HB_STRING_STRUCT {
29
29
 
30
30
  hb_string_T hb_string_from_c_string(const char* null_terminated_c_string);
31
31
 
32
+ static inline hb_string_T hb_string_from_data(const char* data, size_t length) {
33
+ return (hb_string_T) { .data = (char*) data, .length = (uint32_t) length };
34
+ }
35
+
32
36
  static inline bool hb_string_is_null(hb_string_T string) {
33
37
  return string.data == NULL;
34
38
  }
@@ -4,8 +4,8 @@
4
4
  #include <stdint.h>
5
5
  #include <stdlib.h>
6
6
 
7
+ #include "../lib/hb_allocator.h"
7
8
  #include "position.h"
8
- #include "util/hb_allocator.h"
9
9
 
10
10
  typedef struct LOCATION_STRUCT {
11
11
  position_T start;
@@ -0,0 +1,12 @@
1
+ #ifndef HERB_PARSER_DOT_NOTATION_H
2
+ #define HERB_PARSER_DOT_NOTATION_H
3
+
4
+ #include <stdbool.h>
5
+
6
+ #include "../lib/hb_array.h"
7
+ #include "parser.h"
8
+
9
+ bool parser_lookahead_is_valid_dot_notation_open_tag(parser_T* parser);
10
+ void parser_consume_dot_notation_segments(parser_T* parser, token_T* tag_name, hb_array_T* errors);
11
+
12
+ #endif
@@ -1,10 +1,12 @@
1
1
  #ifndef HERB_PARSER_H
2
2
  #define HERB_PARSER_H
3
3
 
4
- #include "ast_node.h"
5
- #include "lexer.h"
6
- #include "util/hb_allocator.h"
7
- #include "util/hb_array.h"
4
+ #include "../ast/ast_node.h"
5
+ #include "../lexer/lexer.h"
6
+ #include "../lib/hb_allocator.h"
7
+ #include "../lib/hb_array.h"
8
+
9
+ #include <stdint.h>
8
10
 
9
11
  typedef enum {
10
12
  FOREIGN_CONTENT_UNKNOWN = 0,
@@ -22,9 +24,14 @@ typedef struct PARSER_OPTIONS_STRUCT {
22
24
  bool strict;
23
25
  bool action_view_helpers;
24
26
  bool render_nodes;
27
+ bool strict_locals;
25
28
  bool prism_program;
26
29
  bool prism_nodes;
27
30
  bool prism_nodes_deep;
31
+ bool dot_notation_tags;
32
+ bool html;
33
+ uint32_t start_line;
34
+ uint32_t start_column;
28
35
  } parser_options_T;
29
36
 
30
37
  typedef struct MATCH_TAGS_CONTEXT_STRUCT {
@@ -1,13 +1,13 @@
1
1
  #ifndef HERB_PARSER_HELPERS_H
2
2
  #define HERB_PARSER_HELPERS_H
3
3
 
4
- #include "ast_nodes.h"
5
- #include "errors.h"
4
+ #include "../ast/ast_nodes.h"
5
+ #include "../errors.h"
6
+ #include "../lexer/token.h"
7
+ #include "../lib/hb_array.h"
8
+ #include "../lib/hb_buffer.h"
9
+ #include "../lib/hb_string.h"
6
10
  #include "parser.h"
7
- #include "token.h"
8
- #include "util/hb_array.h"
9
- #include "util/hb_buffer.h"
10
- #include "util/hb_string.h"
11
11
 
12
12
  void parser_push_open_tag(const parser_T* parser, token_T* tag_name);
13
13
  bool parser_check_matching_tag(const parser_T* parser, hb_string_T tag_name);
@@ -1,8 +1,8 @@
1
1
  #ifndef HERB_PRISM_CONTEXT_H
2
2
  #define HERB_PRISM_CONTEXT_H
3
3
 
4
- #include "util/hb_allocator.h"
5
- #include "util/hb_buffer.h"
4
+ #include "../lib/hb_allocator.h"
5
+ #include "../lib/hb_buffer.h"
6
6
  #include <prism.h>
7
7
  #include <stdbool.h>
8
8
 
@@ -1,12 +1,12 @@
1
1
  #ifndef HERB_PRISM_HELPERS_H
2
2
  #define HERB_PRISM_HELPERS_H
3
3
 
4
- #include "analyze/analyzed_ruby.h"
5
- #include "ast_nodes.h"
6
- #include "errors.h"
7
- #include "location.h"
8
- #include "position.h"
9
- #include "util/hb_allocator.h"
4
+ #include "../analyze/analyzed_ruby.h"
5
+ #include "../ast/ast_nodes.h"
6
+ #include "../errors.h"
7
+ #include "../lib/hb_allocator.h"
8
+ #include "../location/location.h"
9
+ #include "../location/position.h"
10
10
 
11
11
  #include <prism.h>
12
12
 
@@ -1,7 +1,7 @@
1
1
  #ifndef HERB_HTML_UTIL_H
2
2
  #define HERB_HTML_UTIL_H
3
3
 
4
- #include "util/hb_string.h"
4
+ #include "../lib/hb_string.h"
5
5
  #include <stdbool.h>
6
6
 
7
7
  struct hb_allocator;