herb 0.7.3-arm64-darwin → 0.7.5-arm64-darwin

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 (49) 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.bundle +0 -0
  7. data/lib/herb/3.1/herb.bundle +0 -0
  8. data/lib/herb/3.2/herb.bundle +0 -0
  9. data/lib/herb/3.3/herb.bundle +0 -0
  10. data/lib/herb/3.4/herb.bundle +0 -0
  11. data/lib/herb/engine.rb +13 -2
  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/herb.c +2 -2
  19. data/src/include/ast_node.h +3 -3
  20. data/src/include/ast_nodes.h +32 -32
  21. data/src/include/errors.h +21 -21
  22. data/src/include/lexer_peek_helpers.h +8 -6
  23. data/src/include/lexer_struct.h +10 -9
  24. data/src/include/location.h +10 -13
  25. data/src/include/parser.h +2 -2
  26. data/src/include/parser_helpers.h +1 -1
  27. data/src/include/position.h +3 -14
  28. data/src/include/pretty_print.h +1 -1
  29. data/src/include/prism_helpers.h +1 -1
  30. data/src/include/range.h +4 -13
  31. data/src/include/token.h +0 -3
  32. data/src/include/token_struct.h +2 -2
  33. data/src/include/version.h +1 -1
  34. data/src/lexer.c +3 -2
  35. data/src/lexer_peek_helpers.c +10 -4
  36. data/src/location.c +9 -37
  37. data/src/parser.c +100 -121
  38. data/src/parser_helpers.c +15 -15
  39. data/src/pretty_print.c +7 -12
  40. data/src/prism_helpers.c +7 -7
  41. data/src/range.c +2 -35
  42. data/src/token.c +25 -29
  43. data/templates/javascript/packages/core/src/visitor.ts.erb +29 -1
  44. data/templates/src/ast_nodes.c.erb +1 -3
  45. data/templates/src/errors.c.erb +5 -7
  46. data/templates/src/include/ast_nodes.h.erb +2 -2
  47. data/templates/src/include/errors.h.erb +3 -3
  48. metadata +2 -3
  49. data/src/position.c +0 -33
@@ -51,7 +51,7 @@ typedef enum {
51
51
 
52
52
  typedef struct AST_NODE_STRUCT {
53
53
  ast_node_type_T type;
54
- location_T* location;
54
+ location_T location;
55
55
  // maybe a range too?
56
56
  array_T* errors;
57
57
  } AST_NODE_T;
@@ -307,37 +307,37 @@ typedef struct AST_ERB_IN_NODE_STRUCT {
307
307
  array_T* statements;
308
308
  } AST_ERB_IN_NODE_T;
309
309
 
310
- AST_DOCUMENT_NODE_T* ast_document_node_init(array_T* children, position_T* start_position, position_T* end_position, array_T* errors);
311
- AST_LITERAL_NODE_T* ast_literal_node_init(const char* content, position_T* start_position, position_T* end_position, array_T* errors);
312
- AST_HTML_OPEN_TAG_NODE_T* ast_html_open_tag_node_init(token_T* tag_opening, token_T* tag_name, token_T* tag_closing, array_T* children, bool is_void, position_T* start_position, position_T* end_position, array_T* errors);
313
- AST_HTML_CLOSE_TAG_NODE_T* ast_html_close_tag_node_init(token_T* tag_opening, token_T* tag_name, array_T* children, token_T* tag_closing, position_T* start_position, position_T* end_position, array_T* errors);
314
- AST_HTML_ELEMENT_NODE_T* ast_html_element_node_init(struct AST_HTML_OPEN_TAG_NODE_STRUCT* open_tag, token_T* tag_name, array_T* body, struct AST_HTML_CLOSE_TAG_NODE_STRUCT* close_tag, bool is_void, element_source_t source, position_T* start_position, position_T* end_position, array_T* errors);
315
- AST_HTML_ATTRIBUTE_VALUE_NODE_T* ast_html_attribute_value_node_init(token_T* open_quote, array_T* children, token_T* close_quote, bool quoted, position_T* start_position, position_T* end_position, array_T* errors);
316
- AST_HTML_ATTRIBUTE_NAME_NODE_T* ast_html_attribute_name_node_init(array_T* children, position_T* start_position, position_T* end_position, array_T* errors);
317
- AST_HTML_ATTRIBUTE_NODE_T* ast_html_attribute_node_init(struct AST_HTML_ATTRIBUTE_NAME_NODE_STRUCT* name, token_T* equals, struct AST_HTML_ATTRIBUTE_VALUE_NODE_STRUCT* value, position_T* start_position, position_T* end_position, array_T* errors);
318
- AST_HTML_TEXT_NODE_T* ast_html_text_node_init(const char* content, position_T* start_position, position_T* end_position, array_T* errors);
319
- AST_HTML_COMMENT_NODE_T* ast_html_comment_node_init(token_T* comment_start, array_T* children, token_T* comment_end, position_T* start_position, position_T* end_position, array_T* errors);
320
- AST_HTML_DOCTYPE_NODE_T* ast_html_doctype_node_init(token_T* tag_opening, array_T* children, token_T* tag_closing, position_T* start_position, position_T* end_position, array_T* errors);
321
- AST_XML_DECLARATION_NODE_T* ast_xml_declaration_node_init(token_T* tag_opening, array_T* children, token_T* tag_closing, position_T* start_position, position_T* end_position, array_T* errors);
322
- AST_CDATA_NODE_T* ast_cdata_node_init(token_T* tag_opening, array_T* children, token_T* tag_closing, position_T* start_position, position_T* end_position, array_T* errors);
323
- AST_WHITESPACE_NODE_T* ast_whitespace_node_init(token_T* value, position_T* start_position, position_T* end_position, array_T* errors);
324
- AST_ERB_CONTENT_NODE_T* ast_erb_content_node_init(token_T* tag_opening, token_T* content, token_T* tag_closing, analyzed_ruby_T* analyzed_ruby, bool parsed, bool valid, position_T* start_position, position_T* end_position, array_T* errors);
325
- 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, array_T* errors);
326
- AST_ERB_ELSE_NODE_T* ast_erb_else_node_init(token_T* tag_opening, token_T* content, token_T* tag_closing, array_T* statements, position_T* start_position, position_T* end_position, array_T* errors);
327
- AST_ERB_IF_NODE_T* ast_erb_if_node_init(token_T* tag_opening, token_T* content, token_T* tag_closing, array_T* statements, struct AST_NODE_STRUCT* subsequent, struct AST_ERB_END_NODE_STRUCT* end_node, position_T* start_position, position_T* end_position, array_T* errors);
328
- AST_ERB_BLOCK_NODE_T* ast_erb_block_node_init(token_T* tag_opening, token_T* content, token_T* tag_closing, array_T* body, struct AST_ERB_END_NODE_STRUCT* end_node, position_T* start_position, position_T* end_position, array_T* errors);
329
- AST_ERB_WHEN_NODE_T* ast_erb_when_node_init(token_T* tag_opening, token_T* content, token_T* tag_closing, array_T* statements, position_T* start_position, position_T* end_position, array_T* errors);
330
- AST_ERB_CASE_NODE_T* ast_erb_case_node_init(token_T* tag_opening, token_T* content, token_T* tag_closing, array_T* children, 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, array_T* errors);
331
- AST_ERB_CASE_MATCH_NODE_T* ast_erb_case_match_node_init(token_T* tag_opening, token_T* content, token_T* tag_closing, array_T* children, 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, array_T* errors);
332
- AST_ERB_WHILE_NODE_T* ast_erb_while_node_init(token_T* tag_opening, token_T* content, token_T* tag_closing, array_T* statements, struct AST_ERB_END_NODE_STRUCT* end_node, position_T* start_position, position_T* end_position, array_T* errors);
333
- AST_ERB_UNTIL_NODE_T* ast_erb_until_node_init(token_T* tag_opening, token_T* content, token_T* tag_closing, array_T* statements, struct AST_ERB_END_NODE_STRUCT* end_node, position_T* start_position, position_T* end_position, array_T* errors);
334
- AST_ERB_FOR_NODE_T* ast_erb_for_node_init(token_T* tag_opening, token_T* content, token_T* tag_closing, array_T* statements, struct AST_ERB_END_NODE_STRUCT* end_node, position_T* start_position, position_T* end_position, array_T* errors);
335
- AST_ERB_RESCUE_NODE_T* ast_erb_rescue_node_init(token_T* tag_opening, token_T* content, token_T* tag_closing, array_T* statements, struct AST_ERB_RESCUE_NODE_STRUCT* subsequent, position_T* start_position, position_T* end_position, array_T* errors);
336
- AST_ERB_ENSURE_NODE_T* ast_erb_ensure_node_init(token_T* tag_opening, token_T* content, token_T* tag_closing, array_T* statements, position_T* start_position, position_T* end_position, array_T* errors);
337
- AST_ERB_BEGIN_NODE_T* ast_erb_begin_node_init(token_T* tag_opening, token_T* content, token_T* tag_closing, array_T* statements, 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, array_T* errors);
338
- AST_ERB_UNLESS_NODE_T* ast_erb_unless_node_init(token_T* tag_opening, token_T* content, token_T* tag_closing, 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, array_T* errors);
339
- 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, array_T* errors);
340
- AST_ERB_IN_NODE_T* ast_erb_in_node_init(token_T* tag_opening, token_T* content, token_T* tag_closing, array_T* statements, position_T* start_position, position_T* end_position, array_T* errors);
310
+ AST_DOCUMENT_NODE_T* ast_document_node_init(array_T* children, position_T start_position, position_T end_position, array_T* errors);
311
+ AST_LITERAL_NODE_T* ast_literal_node_init(const char* content, position_T start_position, position_T end_position, array_T* errors);
312
+ AST_HTML_OPEN_TAG_NODE_T* ast_html_open_tag_node_init(token_T* tag_opening, token_T* tag_name, token_T* tag_closing, array_T* children, bool is_void, position_T start_position, position_T end_position, array_T* errors);
313
+ AST_HTML_CLOSE_TAG_NODE_T* ast_html_close_tag_node_init(token_T* tag_opening, token_T* tag_name, array_T* children, token_T* tag_closing, position_T start_position, position_T end_position, array_T* errors);
314
+ AST_HTML_ELEMENT_NODE_T* ast_html_element_node_init(struct AST_HTML_OPEN_TAG_NODE_STRUCT* open_tag, token_T* tag_name, array_T* body, struct AST_HTML_CLOSE_TAG_NODE_STRUCT* close_tag, bool is_void, element_source_t source, position_T start_position, position_T end_position, array_T* errors);
315
+ AST_HTML_ATTRIBUTE_VALUE_NODE_T* ast_html_attribute_value_node_init(token_T* open_quote, array_T* children, token_T* close_quote, bool quoted, position_T start_position, position_T end_position, array_T* errors);
316
+ AST_HTML_ATTRIBUTE_NAME_NODE_T* ast_html_attribute_name_node_init(array_T* children, position_T start_position, position_T end_position, array_T* errors);
317
+ AST_HTML_ATTRIBUTE_NODE_T* ast_html_attribute_node_init(struct AST_HTML_ATTRIBUTE_NAME_NODE_STRUCT* name, token_T* equals, struct AST_HTML_ATTRIBUTE_VALUE_NODE_STRUCT* value, position_T start_position, position_T end_position, array_T* errors);
318
+ AST_HTML_TEXT_NODE_T* ast_html_text_node_init(const char* content, position_T start_position, position_T end_position, array_T* errors);
319
+ AST_HTML_COMMENT_NODE_T* ast_html_comment_node_init(token_T* comment_start, array_T* children, token_T* comment_end, position_T start_position, position_T end_position, array_T* errors);
320
+ AST_HTML_DOCTYPE_NODE_T* ast_html_doctype_node_init(token_T* tag_opening, array_T* children, token_T* tag_closing, position_T start_position, position_T end_position, array_T* errors);
321
+ AST_XML_DECLARATION_NODE_T* ast_xml_declaration_node_init(token_T* tag_opening, array_T* children, token_T* tag_closing, position_T start_position, position_T end_position, array_T* errors);
322
+ AST_CDATA_NODE_T* ast_cdata_node_init(token_T* tag_opening, array_T* children, token_T* tag_closing, position_T start_position, position_T end_position, array_T* errors);
323
+ AST_WHITESPACE_NODE_T* ast_whitespace_node_init(token_T* value, position_T start_position, position_T end_position, array_T* errors);
324
+ AST_ERB_CONTENT_NODE_T* ast_erb_content_node_init(token_T* tag_opening, token_T* content, token_T* tag_closing, analyzed_ruby_T* analyzed_ruby, bool parsed, bool valid, position_T start_position, position_T end_position, array_T* errors);
325
+ 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, array_T* errors);
326
+ AST_ERB_ELSE_NODE_T* ast_erb_else_node_init(token_T* tag_opening, token_T* content, token_T* tag_closing, array_T* statements, position_T start_position, position_T end_position, array_T* errors);
327
+ AST_ERB_IF_NODE_T* ast_erb_if_node_init(token_T* tag_opening, token_T* content, token_T* tag_closing, array_T* statements, struct AST_NODE_STRUCT* subsequent, struct AST_ERB_END_NODE_STRUCT* end_node, position_T start_position, position_T end_position, array_T* errors);
328
+ AST_ERB_BLOCK_NODE_T* ast_erb_block_node_init(token_T* tag_opening, token_T* content, token_T* tag_closing, array_T* body, struct AST_ERB_END_NODE_STRUCT* end_node, position_T start_position, position_T end_position, array_T* errors);
329
+ AST_ERB_WHEN_NODE_T* ast_erb_when_node_init(token_T* tag_opening, token_T* content, token_T* tag_closing, array_T* statements, position_T start_position, position_T end_position, array_T* errors);
330
+ AST_ERB_CASE_NODE_T* ast_erb_case_node_init(token_T* tag_opening, token_T* content, token_T* tag_closing, array_T* children, 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, array_T* errors);
331
+ AST_ERB_CASE_MATCH_NODE_T* ast_erb_case_match_node_init(token_T* tag_opening, token_T* content, token_T* tag_closing, array_T* children, 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, array_T* errors);
332
+ AST_ERB_WHILE_NODE_T* ast_erb_while_node_init(token_T* tag_opening, token_T* content, token_T* tag_closing, array_T* statements, struct AST_ERB_END_NODE_STRUCT* end_node, position_T start_position, position_T end_position, array_T* errors);
333
+ AST_ERB_UNTIL_NODE_T* ast_erb_until_node_init(token_T* tag_opening, token_T* content, token_T* tag_closing, array_T* statements, struct AST_ERB_END_NODE_STRUCT* end_node, position_T start_position, position_T end_position, array_T* errors);
334
+ AST_ERB_FOR_NODE_T* ast_erb_for_node_init(token_T* tag_opening, token_T* content, token_T* tag_closing, array_T* statements, struct AST_ERB_END_NODE_STRUCT* end_node, position_T start_position, position_T end_position, array_T* errors);
335
+ AST_ERB_RESCUE_NODE_T* ast_erb_rescue_node_init(token_T* tag_opening, token_T* content, token_T* tag_closing, array_T* statements, struct AST_ERB_RESCUE_NODE_STRUCT* subsequent, position_T start_position, position_T end_position, array_T* errors);
336
+ AST_ERB_ENSURE_NODE_T* ast_erb_ensure_node_init(token_T* tag_opening, token_T* content, token_T* tag_closing, array_T* statements, position_T start_position, position_T end_position, array_T* errors);
337
+ AST_ERB_BEGIN_NODE_T* ast_erb_begin_node_init(token_T* tag_opening, token_T* content, token_T* tag_closing, array_T* statements, 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, array_T* errors);
338
+ AST_ERB_UNLESS_NODE_T* ast_erb_unless_node_init(token_T* tag_opening, token_T* content, token_T* tag_closing, 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, array_T* errors);
339
+ 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, array_T* errors);
340
+ AST_ERB_IN_NODE_T* ast_erb_in_node_init(token_T* tag_opening, token_T* content, token_T* tag_closing, array_T* statements, position_T start_position, position_T end_position, array_T* errors);
341
341
 
342
342
  const char* ast_node_type_to_string(AST_NODE_T* node);
343
343
  const char* ast_node_human_type(AST_NODE_T* node);
data/src/include/errors.h CHANGED
@@ -25,7 +25,7 @@ typedef enum {
25
25
 
26
26
  typedef struct ERROR_STRUCT {
27
27
  error_type_T type;
28
- location_T* location;
28
+ location_T location;
29
29
  char* message;
30
30
  } ERROR_T;
31
31
 
@@ -84,26 +84,26 @@ typedef struct {
84
84
  const char* level;
85
85
  } RUBY_PARSE_ERROR_T;
86
86
 
87
- UNEXPECTED_ERROR_T* unexpected_error_init(const char* description, const char* expected, const char* found, position_T* start, position_T* end);
88
- void append_unexpected_error(const char* description, const char* expected, const char* found, position_T* start, position_T* end, array_T* errors);
89
- UNEXPECTED_TOKEN_ERROR_T* unexpected_token_error_init(token_type_T expected_type, token_T* found, position_T* start, position_T* end);
90
- void append_unexpected_token_error(token_type_T expected_type, token_T* found, position_T* start, position_T* end, array_T* errors);
91
- MISSING_OPENING_TAG_ERROR_T* missing_opening_tag_error_init(token_T* closing_tag, position_T* start, position_T* end);
92
- void append_missing_opening_tag_error(token_T* closing_tag, position_T* start, position_T* end, array_T* errors);
93
- MISSING_CLOSING_TAG_ERROR_T* missing_closing_tag_error_init(token_T* opening_tag, position_T* start, position_T* end);
94
- void append_missing_closing_tag_error(token_T* opening_tag, position_T* start, position_T* end, array_T* errors);
95
- TAG_NAMES_MISMATCH_ERROR_T* tag_names_mismatch_error_init(token_T* opening_tag, token_T* closing_tag, position_T* start, position_T* end);
96
- void append_tag_names_mismatch_error(token_T* opening_tag, token_T* closing_tag, position_T* start, position_T* end, array_T* errors);
97
- QUOTES_MISMATCH_ERROR_T* quotes_mismatch_error_init(token_T* opening_quote, token_T* closing_quote, position_T* start, position_T* end);
98
- void append_quotes_mismatch_error(token_T* opening_quote, token_T* closing_quote, position_T* start, position_T* end, array_T* errors);
99
- VOID_ELEMENT_CLOSING_TAG_ERROR_T* void_element_closing_tag_error_init(token_T* tag_name, const char* expected, const char* found, position_T* start, position_T* end);
100
- void append_void_element_closing_tag_error(token_T* tag_name, const char* expected, const char* found, position_T* start, position_T* end, array_T* errors);
101
- UNCLOSED_ELEMENT_ERROR_T* unclosed_element_error_init(token_T* opening_tag, position_T* start, position_T* end);
102
- void append_unclosed_element_error(token_T* opening_tag, position_T* start, position_T* end, array_T* errors);
103
- RUBY_PARSE_ERROR_T* ruby_parse_error_init(const char* error_message, const char* diagnostic_id, const char* level, position_T* start, position_T* end);
104
- void append_ruby_parse_error(const char* error_message, const char* diagnostic_id, const char* level, position_T* start, position_T* end, array_T* errors);
105
-
106
- void error_init(ERROR_T* error, error_type_T type, position_T* start, position_T* end);
87
+ UNEXPECTED_ERROR_T* unexpected_error_init(const char* description, const char* expected, const char* found, position_T start, position_T end);
88
+ void append_unexpected_error(const char* description, const char* expected, const char* found, position_T start, position_T end, array_T* errors);
89
+ UNEXPECTED_TOKEN_ERROR_T* unexpected_token_error_init(token_type_T expected_type, token_T* found, position_T start, position_T end);
90
+ void append_unexpected_token_error(token_type_T expected_type, token_T* found, position_T start, position_T end, array_T* errors);
91
+ MISSING_OPENING_TAG_ERROR_T* missing_opening_tag_error_init(token_T* closing_tag, position_T start, position_T end);
92
+ void append_missing_opening_tag_error(token_T* closing_tag, position_T start, position_T end, array_T* errors);
93
+ MISSING_CLOSING_TAG_ERROR_T* missing_closing_tag_error_init(token_T* opening_tag, position_T start, position_T end);
94
+ void append_missing_closing_tag_error(token_T* opening_tag, position_T start, position_T end, array_T* errors);
95
+ TAG_NAMES_MISMATCH_ERROR_T* tag_names_mismatch_error_init(token_T* opening_tag, token_T* closing_tag, position_T start, position_T end);
96
+ void append_tag_names_mismatch_error(token_T* opening_tag, token_T* closing_tag, position_T start, position_T end, array_T* errors);
97
+ QUOTES_MISMATCH_ERROR_T* quotes_mismatch_error_init(token_T* opening_quote, token_T* closing_quote, position_T start, position_T end);
98
+ void append_quotes_mismatch_error(token_T* opening_quote, token_T* closing_quote, position_T start, position_T end, array_T* errors);
99
+ VOID_ELEMENT_CLOSING_TAG_ERROR_T* void_element_closing_tag_error_init(token_T* tag_name, const char* expected, const char* found, position_T start, position_T end);
100
+ void append_void_element_closing_tag_error(token_T* tag_name, const char* expected, const char* found, position_T start, position_T end, array_T* errors);
101
+ UNCLOSED_ELEMENT_ERROR_T* unclosed_element_error_init(token_T* opening_tag, position_T start, position_T end);
102
+ void append_unclosed_element_error(token_T* opening_tag, position_T start, position_T end, array_T* errors);
103
+ RUBY_PARSE_ERROR_T* ruby_parse_error_init(const char* error_message, const char* diagnostic_id, const char* level, position_T start, position_T end);
104
+ void append_ruby_parse_error(const char* error_message, const char* diagnostic_id, const char* level, position_T start, position_T end, array_T* errors);
105
+
106
+ void error_init(ERROR_T* error, error_type_T type, position_T start, position_T end);
107
107
 
108
108
  size_t error_sizeof(void);
109
109
  error_type_T error_type(ERROR_T* error);
@@ -5,16 +5,17 @@
5
5
  #include "token_struct.h"
6
6
 
7
7
  #include <stdbool.h>
8
+ #include <stdint.h>
8
9
  #include <stdio.h>
9
10
  #include <stdlib.h>
10
11
 
11
12
  typedef struct {
12
- size_t position;
13
- size_t line;
14
- size_t column;
15
- size_t previous_position;
16
- size_t previous_line;
17
- size_t previous_column;
13
+ uint32_t position;
14
+ uint32_t line;
15
+ uint32_t column;
16
+ uint32_t previous_position;
17
+ uint32_t previous_line;
18
+ uint32_t previous_column;
18
19
  char current_character;
19
20
  lexer_state_T state;
20
21
  } lexer_state_snapshot_T;
@@ -31,6 +32,7 @@ bool lexer_peek_for_html_comment_end(const lexer_T* lexer, int offset);
31
32
  bool lexer_peek_erb_close_tag(const lexer_T* lexer, int offset);
32
33
  bool lexer_peek_erb_dash_close_tag(const lexer_T* lexer, int offset);
33
34
  bool lexer_peek_erb_percent_close_tag(const lexer_T* lexer, int offset);
35
+ bool lexer_peek_erb_equals_close_tag(const lexer_T* lexer, int offset);
34
36
  bool lexer_peek_erb_end(const lexer_T* lexer, int offset);
35
37
 
36
38
  char lexer_backtrack(const lexer_T* lexer, int offset);
@@ -2,6 +2,7 @@
2
2
  #define HERB_LEXER_STRUCT_H
3
3
 
4
4
  #include <stdbool.h>
5
+ #include <stdint.h>
5
6
  #include <stdlib.h>
6
7
 
7
8
  typedef enum {
@@ -12,20 +13,20 @@ typedef enum {
12
13
 
13
14
  typedef struct LEXER_STRUCT {
14
15
  const char* source;
15
- size_t source_length;
16
+ uint32_t source_length;
16
17
 
17
- size_t current_line;
18
- size_t current_column;
19
- size_t current_position;
18
+ uint32_t current_line;
19
+ uint32_t current_column;
20
+ uint32_t current_position;
20
21
 
21
- size_t previous_line;
22
- size_t previous_column;
23
- size_t previous_position;
22
+ uint32_t previous_line;
23
+ uint32_t previous_column;
24
+ uint32_t previous_position;
24
25
 
25
26
  char current_character;
26
27
  lexer_state_T state;
27
- size_t stall_counter;
28
- size_t last_position;
28
+ uint32_t stall_counter;
29
+ uint32_t last_position;
29
30
  bool stalled;
30
31
  } lexer_T;
31
32
 
@@ -1,25 +1,22 @@
1
1
  #ifndef HERB_LOCATION_H
2
2
  #define HERB_LOCATION_H
3
3
 
4
+ #include <stdint.h>
4
5
  #include <stdlib.h>
5
6
 
6
7
  #include "position.h"
7
8
 
8
9
  typedef struct LOCATION_STRUCT {
9
- position_T* start;
10
- position_T* end;
10
+ position_T start;
11
+ position_T end;
11
12
  } location_T;
12
13
 
13
- location_T* location_init(position_T* start, position_T* end);
14
- location_T* location_from(size_t start_line, size_t start_column, size_t end_line, size_t end_column);
15
-
16
- position_T* location_start(location_T* location);
17
- position_T* location_end_(location_T* location);
18
-
19
- size_t location_sizeof(void);
20
-
21
- location_T* location_copy(location_T* location);
22
-
23
- void location_free(location_T* location);
14
+ void location_from(
15
+ location_T* location,
16
+ uint32_t start_line,
17
+ uint32_t start_column,
18
+ uint32_t end_line,
19
+ uint32_t end_column
20
+ );
24
21
 
25
22
  #endif
data/src/include/parser.h CHANGED
@@ -28,9 +28,9 @@ typedef struct PARSER_STRUCT {
28
28
  parser_options_T* options;
29
29
  } parser_T;
30
30
 
31
- parser_T* parser_init(lexer_T* lexer, parser_options_T* options);
31
+ parser_T* herb_parser_init(lexer_T* lexer, parser_options_T* options);
32
32
 
33
- AST_DOCUMENT_NODE_T* parser_parse(parser_T* parser);
33
+ AST_DOCUMENT_NODE_T* herb_parser_parse(parser_T* parser);
34
34
 
35
35
  size_t parser_sizeof(void);
36
36
 
@@ -19,7 +19,7 @@ void parser_append_literal_node_from_buffer(
19
19
  const parser_T* parser,
20
20
  buffer_T* buffer,
21
21
  array_T* children,
22
- position_T* start
22
+ position_T start
23
23
  );
24
24
 
25
25
  bool parser_in_svg_context(const parser_T* parser);
@@ -1,22 +1,11 @@
1
1
  #ifndef HERB_POSITION_H
2
2
  #define HERB_POSITION_H
3
3
 
4
- #include <stdlib.h>
4
+ #include <stdint.h>
5
5
 
6
6
  typedef struct POSITION_STRUCT {
7
- size_t line;
8
- size_t column;
7
+ uint32_t line;
8
+ uint32_t column;
9
9
  } position_T;
10
10
 
11
- position_T* position_init(size_t line, size_t column);
12
-
13
- size_t position_line(const position_T* position);
14
- size_t position_column(const position_T* position);
15
-
16
- size_t position_sizeof(void);
17
-
18
- position_T* position_copy(position_T* position);
19
-
20
- void position_free(position_T* position);
21
-
22
11
  #endif
@@ -21,7 +21,7 @@ void pretty_print_position_property(
21
21
  buffer_T* buffer
22
22
  );
23
23
 
24
- void pretty_print_location(location_T* location, buffer_T* buffer);
24
+ void pretty_print_location(location_T location, buffer_T* buffer);
25
25
 
26
26
  void pretty_print_property(
27
27
  const char* name,
@@ -16,6 +16,6 @@ RUBY_PARSE_ERROR_T* ruby_parse_error_from_prism_error(
16
16
  pm_parser_t* parser
17
17
  );
18
18
 
19
- position_T* position_from_source_with_offset(const char* source, size_t offset);
19
+ position_T position_from_source_with_offset(const char* source, size_t offset);
20
20
 
21
21
  #endif
data/src/include/range.h CHANGED
@@ -1,23 +1,14 @@
1
1
  #ifndef HERB_RANGE_H
2
2
  #define HERB_RANGE_H
3
3
 
4
+ #include <stdint.h>
4
5
  #include <stdlib.h>
5
6
 
6
7
  typedef struct RANGE_STRUCT {
7
- size_t from;
8
- size_t to;
8
+ uint32_t from;
9
+ uint32_t to;
9
10
  } range_T;
10
11
 
11
- range_T* range_init(size_t from, size_t to);
12
-
13
- size_t range_from(const range_T* range);
14
- size_t range_to(const range_T* range);
15
- size_t range_length(range_T* range);
16
-
17
- range_T* range_copy(range_T* range);
18
-
19
- size_t range_sizeof(void);
20
-
21
- void range_free(range_T* range);
12
+ uint32_t range_length(range_T range);
22
13
 
23
14
  #endif
data/src/include/token.h CHANGED
@@ -13,9 +13,6 @@ const char* token_type_to_string(token_type_T type);
13
13
  char* token_value(const token_T* token);
14
14
  int token_type(const token_T* token);
15
15
 
16
- position_T* token_start_position(token_T* token);
17
- position_T* token_end_position(token_T* token);
18
-
19
16
  size_t token_sizeof(void);
20
17
 
21
18
  token_T* token_copy(token_T* token);
@@ -50,8 +50,8 @@ typedef enum {
50
50
 
51
51
  typedef struct TOKEN_STRUCT {
52
52
  char* value;
53
- range_T* range;
54
- location_T* location;
53
+ range_T range;
54
+ location_T location;
55
55
  token_type_T type;
56
56
  } token_T;
57
57
 
@@ -1,6 +1,6 @@
1
1
  #ifndef HERB_VERSION_H
2
2
  #define HERB_VERSION_H
3
3
 
4
- #define HERB_VERSION "0.7.3"
4
+ #define HERB_VERSION "0.7.5"
5
5
 
6
6
  #endif
data/src/lexer.c CHANGED
@@ -42,7 +42,7 @@ lexer_T* lexer_init(const char* source) {
42
42
  lexer->state = STATE_DATA;
43
43
 
44
44
  lexer->source = source;
45
- lexer->source_length = strlen(source);
45
+ lexer->source_length = (uint32_t) strlen(source);
46
46
  lexer->current_character = source[0];
47
47
 
48
48
  lexer->current_line = 1;
@@ -66,7 +66,7 @@ token_T* lexer_error(lexer_T* lexer, const char* message) {
66
66
  snprintf(
67
67
  error_message,
68
68
  sizeof(error_message),
69
- "[Lexer] Error: %s (character '%c', line %zu, col %zu)\n",
69
+ "[Lexer] Error: %s (character '%c', line %u, col %u)\n",
70
70
  message,
71
71
  lexer->current_character,
72
72
  lexer->current_line,
@@ -256,6 +256,7 @@ static token_T* lexer_parse_erb_close(lexer_T* lexer) {
256
256
  lexer->state = STATE_DATA;
257
257
 
258
258
  if (lexer_peek_erb_percent_close_tag(lexer, 0)) { return lexer_advance_with(lexer, "%%>", TOKEN_ERB_END); }
259
+ if (lexer_peek_erb_equals_close_tag(lexer, 0)) { return lexer_advance_with(lexer, "=%>", TOKEN_ERB_END); }
259
260
  if (lexer_peek_erb_dash_close_tag(lexer, 0)) { return lexer_advance_with(lexer, "-%>", TOKEN_ERB_END); }
260
261
 
261
262
  return lexer_advance_with(lexer, "%>", TOKEN_ERB_END);
@@ -65,18 +65,23 @@ bool lexer_peek_erb_percent_close_tag(const lexer_T* lexer, const int offset) {
65
65
  return lexer_peek_for(lexer, offset, "%%>", false);
66
66
  }
67
67
 
68
+ bool lexer_peek_erb_equals_close_tag(const lexer_T* lexer, const int offset) {
69
+ return lexer_peek_for(lexer, offset, "=%>", false);
70
+ }
71
+
68
72
  bool lexer_peek_erb_end(const lexer_T* lexer, const int offset) {
69
73
  return (
70
74
  lexer_peek_erb_close_tag(lexer, offset) || lexer_peek_erb_dash_close_tag(lexer, offset)
71
- || lexer_peek_erb_percent_close_tag(lexer, offset)
75
+ || lexer_peek_erb_percent_close_tag(lexer, offset) || lexer_peek_erb_equals_close_tag(lexer, offset)
72
76
  );
73
77
  }
74
78
 
75
79
  bool lexer_peek_for_token_type_after_whitespace(lexer_T* lexer, token_type_T token_type) {
76
- size_t saved_position = lexer->current_position;
77
- size_t saved_line = lexer->current_line;
78
- size_t saved_column = lexer->current_column;
80
+ uint32_t saved_position = lexer->current_position;
81
+ uint32_t saved_line = lexer->current_line;
82
+ uint32_t saved_column = lexer->current_column;
79
83
  char saved_character = lexer->current_character;
84
+ lexer_state_T saved_state = lexer->state;
80
85
 
81
86
  token_T* token = lexer_next_token(lexer);
82
87
 
@@ -93,6 +98,7 @@ bool lexer_peek_for_token_type_after_whitespace(lexer_T* lexer, token_type_T tok
93
98
  lexer->current_line = saved_line;
94
99
  lexer->current_column = saved_column;
95
100
  lexer->current_character = saved_character;
101
+ lexer->state = saved_state;
96
102
 
97
103
  return result;
98
104
  }
data/src/location.c CHANGED
@@ -1,41 +1,13 @@
1
1
  #include "include/location.h"
2
- #include "include/memory.h"
3
2
  #include "include/position.h"
4
3
 
5
- size_t location_sizeof(void) {
6
- return sizeof(location_T);
7
- }
8
-
9
- location_T* location_init(position_T* start, position_T* end) {
10
- location_T* location = safe_malloc(location_sizeof());
11
-
12
- location->start = start;
13
- location->end = end;
14
-
15
- return location;
16
- }
17
-
18
- location_T* location_from(size_t start_line, size_t start_column, size_t end_line, size_t end_column) {
19
- return location_init(position_init(start_line, start_column), position_init(end_line, end_column));
20
- }
21
-
22
- position_T* location_start(location_T* location) {
23
- return location->start;
24
- }
25
-
26
- position_T* location_end(location_T* location) {
27
- return location->end;
28
- }
29
-
30
- location_T* location_copy(location_T* location) {
31
- if (location == NULL) { return NULL; }
32
-
33
- return location_init(position_copy(location->start), position_copy(location->end));
34
- }
35
-
36
- void location_free(location_T* location) {
37
- if (location->start != NULL) { position_free(location->start); }
38
- if (location->end != NULL) { position_free(location->end); }
39
-
40
- free(location);
4
+ void location_from(
5
+ location_T* location,
6
+ uint32_t start_line,
7
+ uint32_t start_column,
8
+ uint32_t end_line,
9
+ uint32_t end_column
10
+ ) {
11
+ location->start = (position_T) { .line = start_line, .column = start_column };
12
+ location->end = (position_T) { .line = end_line, .column = end_column };
41
13
  }