summaryrefslogtreecommitdiff
path: root/parse.y
diff options
context:
space:
mode:
authorS-H-GAMELINKS <gamelinks007@gmail.com>2023-07-09 13:25:45 +0900
committerYuichiro Kaneko <spiketeika@gmail.com>2023-07-09 15:00:52 +0900
commitacd9c208d5ab8619b6102116f48fcfc06f47cb7e (patch)
tree802983e022b1c0c0f9866736aaef288a81f9c4a2 /parse.y
parentb2bccf053befd331553e9443b1f1c86b7aaf1296 (diff)
Move some macro for universal parser
Notes
Notes: Merged: https://github.com/ruby/ruby/pull/8044
Diffstat (limited to 'parse.y')
-rw-r--r--parse.y92
1 files changed, 81 insertions, 11 deletions
diff --git a/parse.y b/parse.y
index c2f6683166..f17002a311 100644
--- a/parse.y
+++ b/parse.y
@@ -201,6 +201,87 @@ new_strterm(VALUE v1, VALUE v2, VALUE v3, VALUE v0, int heredoc)
}
#endif /* !UNIVERSAL_PARSER */
+static inline int
+parse_isascii(int c)
+{
+ return '\0' <= c && c <= '\x7f';
+}
+
+#undef ISASCII
+#define ISASCII parse_isascii
+
+static inline int
+parse_isspace(int c)
+{
+ return c == ' ' || ('\t' <= c && c <= '\r');
+}
+
+#undef ISSPACE
+#define ISSPACE parse_isspace
+
+static inline int
+parse_iscntrl(int c)
+{
+ return ('\0' <= c && c < ' ') || c == '\x7f';
+}
+
+#undef ISCNTRL
+#define ISCNTRL(c) parse_iscntrl(c)
+
+static inline int
+parse_isupper(int c)
+{
+ return 'A' <= c && c <= 'Z';
+}
+
+static inline int
+parse_islower(int c)
+{
+ return 'a' <= c && c <= 'z';
+}
+
+static inline int
+parse_isalpha(int c)
+{
+ return parse_isupper(c) || parse_islower(c);
+}
+
+#undef ISALPHA
+#define ISALPHA(c) parse_isalpha(c)
+
+static inline int
+parse_isdigit(int c)
+{
+ return '0' <= c && c <= '9';
+}
+
+#undef ISDIGIT
+#define ISDIGIT(c) parse_isdigit(c)
+
+static inline int
+parse_isalnum(int c)
+{
+ return parse_isalpha(c) || parse_isdigit(c);
+}
+
+#undef ISALNUM
+#define ISALNUM(c) parse_isalnum(c)
+
+static inline int
+parse_isxdigit(int c)
+{
+ return parse_isdigit(c) || ('A' <= c && c <= 'F') || ('a' <= c && c <= 'f');
+}
+
+#undef ISXDIGIT
+#define ISXDIGIT(c) parse_isxdigit(c)
+
+#undef STRCASECMP
+#define STRCASECMP st_locale_insensitive_strcasecmp
+
+#undef STRNCASECMP
+#define STRNCASECMP st_locale_insensitive_strncasecmp
+
#ifdef RIPPER
#include "ripper_init.h"
#endif
@@ -6352,17 +6433,6 @@ ripper_dispatch_delayed_token(struct parser_params *p, enum yytokentype t)
#endif /* RIPPER */
static inline int
-parse_isascii(int c)
-{
- return '\0' <= c && c <= '\x7f';
-}
-
-#ifdef ISASCII
-#undef ISASCII
-#define ISASCII parse_isascii
-#endif
-
-static inline int
is_identchar(struct parser_params *p, const char *ptr, const char *MAYBE_UNUSED(ptr_end), rb_encoding *enc)
{
return rb_enc_isalnum((unsigned char)*ptr, enc) || *ptr == '_' || !ISASCII(*ptr);