Skip to content

Commit bb85d42

Browse files
committed
Character#isAlphabetic is from Java 7, so duplicate logic here.
1 parent 6505ecf commit bb85d42

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

core/src/main/java/org/jruby/lexer/yacc/StringTerm.java

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ private int parsePeekVariableName(RubyYaccLexer lexer, LexerSource src) throws I
140140
return 0;
141141
}
142142

143-
if (significant != -1 && Character.isAlphabetic(significant) || significant == '_') {
143+
if (significant != -1 && isAlphabetic(significant) || significant == '_') {
144144
src.unread(c);
145145
lexer.setValue(new Token("#" + significant, lexer.getPosition()));
146146
return Tokens.tSTRING_DVAR;
@@ -149,6 +149,16 @@ private int parsePeekVariableName(RubyYaccLexer lexer, LexerSource src) throws I
149149
return 0;
150150
}
151151

152+
// Character#isAlphabetic is a 1.7 feature, so we duplicate the logic here
153+
private static boolean isAlphabetic(int codePoint) {
154+
return (((((1 << Character.UPPERCASE_LETTER) |
155+
(1 << Character.LOWERCASE_LETTER) |
156+
(1 << Character.TITLECASE_LETTER) |
157+
(1 << Character.MODIFIER_LETTER) |
158+
(1 << Character.OTHER_LETTER) |
159+
(1 << Character.LETTER_NUMBER)) >> Character.getType(codePoint)) & 1) != 0);
160+
}
161+
152162
public int parseString(RubyYaccLexer lexer, LexerSource src) throws IOException {
153163
boolean spaceSeen = false;
154164
int c;

0 commit comments

Comments
 (0)