@@ -6651,7 +6651,7 @@ class BodyVisitor : public CommonVisitor<BodyVisitor> {
66516651 /*
66526652 String Validation Methods i.e all "is" based functions are handled here
66536653 */
6654- std::vector<std::string> validation_methods{" lower" , " upper" , " decimal" , " ascii" }; // Database of validation methods supported
6654+ std::vector<std::string> validation_methods{" lower" , " upper" , " decimal" , " ascii" , " space " }; // Database of validation methods supported
66556655 std::string method_name = attr_name.substr (2 );
66566656
66576657 if (std::find (validation_methods.begin (),validation_methods.end (), method_name) == validation_methods.end ()) {
@@ -6919,7 +6919,7 @@ class BodyVisitor : public CommonVisitor<BodyVisitor> {
69196919 * islower() method is limited to English Alphabets currently
69206920 * TODO: We can support other characters from Unicode Library
69216921 */
6922- std::vector<std::string> validation_methods{" lower" , " upper" , " decimal" , " ascii" }; // Database of validation methods supported
6922+ std::vector<std::string> validation_methods{" lower" , " upper" , " decimal" , " ascii" , " space " }; // Database of validation methods supported
69236923 std::string method_name = attr_name.substr (2 );
69246924 if (std::find (validation_methods.begin (),validation_methods.end (), method_name) == validation_methods.end ()) {
69256925 throw SemanticError (" String method not implemented: " + attr_name, loc);
@@ -6999,6 +6999,22 @@ class BodyVisitor : public CommonVisitor<BodyVisitor> {
69996999 tmp = ASR::make_LogicalConstant_t (al, loc, is_ascii,
70007000 ASRUtils::TYPE (ASR::make_Logical_t (al, loc, 4 )));
70017001 return ;
7002+ } else if (attr_name == " isspace" ) {
7003+ /*
7004+ * Specification:
7005+ Return true if all characters in the input string are considered whitespace characters,
7006+ as defined by the std::isspace function. Return false otherwise.
7007+ */
7008+ bool is_space = true ;
7009+ for (char i : s_var) {
7010+ if (!std::isspace (static_cast <unsigned char >(i))) {
7011+ is_space = false ;
7012+ break ;
7013+ }
7014+ }
7015+ tmp = ASR::make_LogicalConstant_t (al, loc, is_space,
7016+ ASRUtils::TYPE (ASR::make_Logical_t (al, loc, 4 )));
7017+ return ;
70027018 } else {
70037019 throw SemanticError (" 'str' object has no attribute '" + attr_name + " '" , loc);
70047020 }
0 commit comments