Introduce find pattern [Feature #16828]

This commit is contained in:
Kazuki Tsujimoto 2020-06-14 09:24:36 +09:00
parent f7906a7e31
commit ddded1157a
No known key found for this signature in database
GPG key ID: BCEA306C49B81CD7
10 changed files with 450 additions and 11 deletions

11
node.h
View file

@ -123,6 +123,7 @@ enum node_type {
NODE_LAMBDA,
NODE_ARYPTN,
NODE_HSHPTN,
NODE_FNDPTN,
NODE_LAST
};
@ -166,6 +167,7 @@ typedef struct RNode {
struct rb_global_entry *entry;
struct rb_args_info *args;
struct rb_ary_pattern_info *apinfo;
struct rb_fnd_pattern_info *fpinfo;
VALUE value;
} u3;
rb_code_location_t nd_loc;
@ -278,6 +280,8 @@ typedef struct RNode {
#define nd_apinfo u3.apinfo
#define nd_fpinfo u3.fpinfo
#define NEW_NODE(t,a0,a1,a2,loc) rb_node_newnode((t),(VALUE)(a0),(VALUE)(a1),(VALUE)(a2),loc)
#define NEW_NODE_WITH_LOCALS(t,a1,a2,loc) node_newnode_with_locals(p, (t),(VALUE)(a1),(VALUE)(a2),loc)
@ -456,6 +460,13 @@ struct rb_ary_pattern_info {
VALUE imemo;
};
struct rb_fnd_pattern_info {
NODE *pre_rest_arg;
NODE *args;
NODE *post_rest_arg;
VALUE imemo;
};
struct parser_params;
void *rb_parser_malloc(struct parser_params *, size_t);
void *rb_parser_realloc(struct parser_params *, void *, size_t);