Skip to content

Commit

Permalink
Showing 2 changed files with 67 additions and 6 deletions.
15 changes: 14 additions & 1 deletion core/src/main/java/org/jruby/lexer/yacc/RubyLexer.java
Original file line number Diff line number Diff line change
@@ -1637,7 +1637,20 @@ private int dollar() throws IOException {
return identifierToken(Tokens.tGVAR, tokenBuffer.toString().intern());
}
}


// FIXME: I added number gvars here and they did not.
public boolean isGlobalCharPunct(int c) {
switch (c) {
case '_': case '~': case '*': case '$': case '?': case '!': case '@':
case '/': case '\\': case ';': case ',': case '.': case '=': case ':':
case '<': case '>': case '\"': case '-': case '&': case '`': case '\'':
case '+': case '1': case '2': case '3': case '4': case '5': case '6':
case '7': case '8': case '9': case '0':
return true;
}
return isIdentifierChar(c);
}

private int dot() throws IOException {
int c;

58 changes: 53 additions & 5 deletions core/src/main/java/org/jruby/lexer/yacc/StringTerm.java
Original file line number Diff line number Diff line change
@@ -109,11 +109,59 @@ public int parseString(RubyLexer lexer, LexerSource src) throws IOException {
if ((flags & RubyLexer.STR_FUNC_EXPAND) != 0 && c == '#') {
c = src.read();
switch (c) {
case '$':
case '@':
src.unread(c);
lexer.setValue("#" + c);
return Tokens.tSTRING_DVAR;
case '$': {
int c2 = src.read();

if (c2 == '-') {
int c3 = src.read();

if (c3 == RubyLexer.EOF) return RubyLexer.EOF;

if (Character.isAlphabetic(c3) || c3 == '_') {
src.unread(c3);
src.unread(c2);
src.unread(c);
lexer.setValue("#" + c2);
return Tokens.tSTRING_DVAR;
}
} else if (lexer.isGlobalCharPunct(c2)) {
lexer.setValue("#" + c2);
src.unread(c2);
src.unread(c);
return Tokens.tSTRING_DVAR;
} if (Character.isAlphabetic(c2) || c2 == '_') {
src.unread(c2);
src.unread(c);
lexer.setValue("#" + c2);
return Tokens.tSTRING_DVAR;
}
break;
}
case '@': {
int c2 = src.read();

if (c2 == '@') {
int c3 = src.read();

if (c3 == RubyLexer.EOF) return RubyLexer.EOF;

lexer.setValue("#" + c2);
src.unread(c3);
src.unread(c2);
src.unread(c);

return Tokens.tSTRING_DVAR;
}

if (Character.isAlphabetic(c2) || c2 == '_') {
src.unread(c2);
src.unread(c);
lexer.setValue("#" + c2);
return Tokens.tSTRING_DVAR;
}
break;

}
case '{':
lexer.setValue("#" + c);
return Tokens.tSTRING_DBEG;

0 comments on commit c11cb6e

Please sign in to comment.