const char *reg_parse(t_reg *reg, const char *pattern) { *reg = (t_reg){0, 1, 1, 0, NULL}; if (*pattern == '!' && pattern++) reg->flags |= FLAG_R_NOT; if (*pattern == 'i' && pattern++) reg->flags |= FLAG_R_CASE; if (ft_isdigit(*pattern)) pattern = parse_reg_n(reg, pattern); else if (*pattern == '*' && pattern++) { reg->from = 0; reg->to = -1; } else if (*pattern == '?' && pattern++) { reg->from = 0; reg->to = 1; } else if (*pattern == '+' && pattern++) { reg->from = 1; reg->to = -1; } return (parse_reg_r(reg, pattern)); }
InstructionModel Parser::parse(TokenisedInstruction instruction) { InstructionModel model; model.s = parse_s(instruction); model.code = parse_operation_code(instruction); model.cond = parse_condition_code(instruction); model.reg_d = parse_reg_d(instruction); model.reg_n = parse_reg_n(instruction); parse_arg_c(instruction, &model); return model; }