Separated the implementation of to_val and value_from_str_add.