From ae7e12538850b16e60af70325027a7c2c2bcec62 Mon Sep 17 00:00:00 2001 From: "Yukihiro \"Matz\" Matsumoto" Date: Wed, 20 Aug 2025 07:44:18 +0900 Subject: [PATCH] mruby-compiler: encapsulate string and heredoc types Move STR_FUNC_* macros, enum mrb_string_type, and struct mrb_parser_heredoc_info from include/mruby/compile.h to mrbgems/mruby-compiler/core/node.h. These types are internal to the mruby compiler gem and are used by both parse.y and codegen.c. Moving them to node.h encapsulates them within the compiler gem, cleaning up the public mruby/compile.h header. Co-authored-by: Gemini --- include/mruby/compile.h | 36 ------------------------------ mrbgems/mruby-compiler/core/node.h | 36 ++++++++++++++++++++++++++++++ 2 files changed, 36 insertions(+), 36 deletions(-) diff --git a/include/mruby/compile.h b/include/mruby/compile.h index 40ee8139c..74cd8fb64 100644 --- a/include/mruby/compile.h +++ b/include/mruby/compile.h @@ -81,42 +81,6 @@ struct mrb_parser_message { char* message; }; -#define STR_FUNC_PARSING 0x01 -#define STR_FUNC_EXPAND 0x02 -#define STR_FUNC_REGEXP 0x04 -#define STR_FUNC_WORD 0x08 -#define STR_FUNC_SYMBOL 0x10 -#define STR_FUNC_ARRAY 0x20 -#define STR_FUNC_HEREDOC 0x40 -#define STR_FUNC_XQUOTE 0x80 - -enum mrb_string_type { - str_not_parsing = (0), - str_squote = (STR_FUNC_PARSING), - str_dquote = (STR_FUNC_PARSING|STR_FUNC_EXPAND), - str_regexp = (STR_FUNC_PARSING|STR_FUNC_REGEXP|STR_FUNC_EXPAND), - str_sword = (STR_FUNC_PARSING|STR_FUNC_WORD|STR_FUNC_ARRAY), - str_dword = (STR_FUNC_PARSING|STR_FUNC_WORD|STR_FUNC_ARRAY|STR_FUNC_EXPAND), - str_ssym = (STR_FUNC_PARSING|STR_FUNC_SYMBOL), - str_ssymbols = (STR_FUNC_PARSING|STR_FUNC_SYMBOL|STR_FUNC_ARRAY), - str_dsymbols = (STR_FUNC_PARSING|STR_FUNC_SYMBOL|STR_FUNC_ARRAY|STR_FUNC_EXPAND), - str_heredoc = (STR_FUNC_PARSING|STR_FUNC_HEREDOC), - str_xquote = (STR_FUNC_PARSING|STR_FUNC_XQUOTE|STR_FUNC_EXPAND), -}; - -/* heredoc structure */ -struct mrb_parser_heredoc_info { - mrb_bool allow_indent:1; - mrb_bool remove_indent:1; - mrb_bool line_head:1; - size_t indent; - mrb_ast_node *indented; - enum mrb_string_type type; - const char *term; - int term_len; - mrb_ast_node *doc; -}; - #define MRB_PARSER_TOKBUF_MAX (UINT16_MAX-1) #define MRB_PARSER_TOKBUF_SIZE 256 diff --git a/mrbgems/mruby-compiler/core/node.h b/mrbgems/mruby-compiler/core/node.h index ddcb29d50..f95f7eebd 100644 --- a/mrbgems/mruby-compiler/core/node.h +++ b/mrbgems/mruby-compiler/core/node.h @@ -103,4 +103,40 @@ enum node_type { NODE_LAST }; +#define STR_FUNC_PARSING 0x01 +#define STR_FUNC_EXPAND 0x02 +#define STR_FUNC_REGEXP 0x04 +#define STR_FUNC_WORD 0x08 +#define STR_FUNC_SYMBOL 0x10 +#define STR_FUNC_ARRAY 0x20 +#define STR_FUNC_HEREDOC 0x40 +#define STR_FUNC_XQUOTE 0x80 + +enum mrb_string_type { + str_not_parsing = (0), + str_squote = (STR_FUNC_PARSING), + str_dquote = (STR_FUNC_PARSING|STR_FUNC_EXPAND), + str_regexp = (STR_FUNC_PARSING|STR_FUNC_REGEXP|STR_FUNC_EXPAND), + str_sword = (STR_FUNC_PARSING|STR_FUNC_WORD|STR_FUNC_ARRAY), + str_dword = (STR_FUNC_PARSING|STR_FUNC_WORD|STR_FUNC_ARRAY|STR_FUNC_EXPAND), + str_ssym = (STR_FUNC_PARSING|STR_FUNC_SYMBOL), + str_ssymbols = (STR_FUNC_PARSING|STR_FUNC_SYMBOL|STR_FUNC_ARRAY), + str_dsymbols = (STR_FUNC_PARSING|STR_FUNC_SYMBOL|STR_FUNC_ARRAY|STR_FUNC_EXPAND), + str_heredoc = (STR_FUNC_PARSING|STR_FUNC_HEREDOC), + str_xquote = (STR_FUNC_PARSING|STR_FUNC_XQUOTE|STR_FUNC_EXPAND), +}; + +/* heredoc structure */ +struct mrb_parser_heredoc_info { + mrb_bool allow_indent:1; + mrb_bool remove_indent:1; + mrb_bool line_head:1; + size_t indent; + mrb_ast_node *indented; + enum mrb_string_type type; + const char *term; + int term_len; + mrb_ast_node *doc; +}; + #endif /* MRUBY_COMPILER_NODE_H */