mirror of
https://github.com/mruby/mruby
synced 2026-06-08 16:11:16 +00:00
mruby-compiler: add one-line pattern matching
add support for one-line pattern matching syntax: - 'expr in pattern' returns true/false - 'expr => pattern' raises NoMatchingPatternError on mismatch add NODE_MATCH_PAT node type for both forms, distinguished by raise_on_fail flag. grammar rules placed at expr level to avoid conflict with rescue clause's exception variable syntax. Co-authored-by: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -920,6 +920,7 @@ mrb_init_exception(mrb_state *mrb)
|
||||
mrb_define_class_id(mrb, MRB_SYM(SyntaxError), script_error); /* 15.2.38 */
|
||||
struct RClass *index_error = mrb_define_class_id(mrb, MRB_SYM(IndexError), E_STANDARD_ERROR); /* 15.2.33 */
|
||||
mrb_define_class_id(mrb, MRB_SYM(KeyError), index_error);
|
||||
mrb_define_class_id(mrb, MRB_SYM(NoMatchingPatternError), E_STANDARD_ERROR); /* pattern matching */
|
||||
struct RClass *stack_error = mrb_define_class_id(mrb, MRB_SYM(SystemStackError), exception);
|
||||
mrb->stack_err = mrb_obj_ptr(mrb_exc_new_lit(mrb, stack_error, "stack level too deep"));
|
||||
|
||||
|
||||
Reference in New Issue
Block a user