Skip to content

Commit

Permalink
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
Original file line number Diff line number Diff line change
@@ -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;
@@ -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;

0 comments on commit bb85d42

Please sign in to comment.