Introduce NODE_REGX to manage regexp literal

This commit is contained in:
yui-knk 2024-02-10 10:05:18 +09:00 committed by Yuichiro Kaneko
parent 97d4363d3b
commit e7ab5d891c
10 changed files with 283 additions and 52 deletions

View file

@ -1,5 +1,6 @@
/* This is a wrapper for parse.y */
#include "internal/re.h"
#include "internal/ruby_parser.h"
#include "node.h"
@ -1010,6 +1011,16 @@ rb_node_dregx_string_val(const NODE *node)
return rb_str_new_parser_string(str);
}
VALUE
rb_node_regx_string_val(const NODE *node)
{
rb_node_regx_t *node_reg = RNODE_REGX(node);
rb_parser_string_t *string = node_reg->string;
VALUE str = rb_enc_str_new(string->ptr, string->len, string->enc);
return rb_reg_compile(str, node_reg->options, NULL, 0);
}
VALUE
rb_node_line_lineno_val(const NODE *node)
{