Skip to content

Commit

Permalink
Character#isAlphabetic is from Java 7, so duplicate logic here.
Browse files Browse the repository at this point in the history
  • Loading branch information
headius committed Nov 4, 2014
1 parent 6505ecf commit bb85d42
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion core/src/main/java/org/jruby/lexer/yacc/StringTerm.java
Expand Up @@ -140,7 +140,7 @@ private int parsePeekVariableName(RubyYaccLexer lexer, LexerSource src) throws I
return 0;
}

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

// Character#isAlphabetic is a 1.7 feature, so we duplicate the logic here
private static boolean isAlphabetic(int codePoint) {
return (((((1 << Character.UPPERCASE_LETTER) |
(1 << Character.LOWERCASE_LETTER) |
(1 << Character.TITLECASE_LETTER) |
(1 << Character.MODIFIER_LETTER) |
(1 << Character.OTHER_LETTER) |
(1 << Character.LETTER_NUMBER)) >> Character.getType(codePoint)) & 1) != 0);
}

public int parseString(RubyYaccLexer lexer, LexerSource src) throws IOException {
boolean spaceSeen = false;
int c;
Expand Down

0 comments on commit bb85d42

Please sign in to comment.