Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: jruby/jruby
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: a67ade80e733
Choose a base ref
...
head repository: jruby/jruby
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 70e7046d1be7
Choose a head ref
  • 2 commits
  • 2 files changed
  • 1 contributor

Commits on Feb 29, 2016

  1. Copy the full SHA
    b47bc93 View commit details
  2. Fixes another issue with yard where it expects a bom to be prefixed t…

    …o a kw as part of the value. MRI does this and we are just following the same somewhat broken behavior (see FIXME in commit for more details)
    enebo committed Feb 29, 2016
    Copy the full SHA
    70e7046 View commit details
Showing with 19 additions and 9 deletions.
  1. +11 −5 core/src/main/java/org/jruby/ext/ripper/RipperLexer.java
  2. +8 −4 core/src/main/java/org/jruby/lexer/LexingCommon.java
16 changes: 11 additions & 5 deletions core/src/main/java/org/jruby/ext/ripper/RipperLexer.java
Original file line number Diff line number Diff line change
@@ -1585,14 +1585,20 @@ private int greaterThan() throws IOException {
return Tokens.tGT;
}
}

private int identifier(int c, boolean commandState) throws IOException {
if (!isIdentifierChar(c)) {
String badChar = "\\" + Integer.toOctalString(c & 0xff);
compile_error("Invalid char `" + badChar + "' ('" + (char) c + "') in expression");
}
// FIXME: on_kw: will return BOM as part of the ident string "\xfeffclass" on MRI and Yard also seems
// to need this to properly parse. So I record where token should really start so I can extract as
// a proper ident for keyword check but createTempValue below will end up creating the bom + kw. This feels like
// an MRI bug but it is well baked into libraries at this point??? newtok+tokadd is still different from MRI
// and does not construct a temp buf. Once I convert that to be the same I think I can do exactly what MRI does
// and this hack can disappear.
int whereKeywordShouldStart = lex_p - 1;

//newtok(true); MRI does this but we don't so BOM + keyword will return goofy offset instead of logical one (yard seems to rely on this too).
int first = c;
do {
if (!tokadd_mbchar(c)) return EOF;
@@ -1653,14 +1659,14 @@ private int identifier(int c, boolean commandState) throws IOException {
}

if (lex_state != EXPR_DOT) {
Keyword keyword = getKeyword(tempVal); // Is it is a keyword?
Keyword keyword = getKeyword(createTokenString(whereKeywordShouldStart)); // Is it is a keyword?

if (keyword != null) {
int state = lex_state; // Save state at time keyword is encountered
setState(keyword.state);

if (isLexState(state, EXPR_FNAME)) {
identValue = keyword.name;
identValue = tempVal;
return keyword.id0;
}

@@ -2255,7 +2261,7 @@ private int parseNumber(int c) throws IOException {
default :
pushback(c);
numberBuffer.append('0');
return setIntegerLiteral(numberBuffer.toString(), 10);
return setIntegerLiteral(numberBuffer.toString(), numberLiteralSuffix(SUFFIX_ALL));
}
}

12 changes: 8 additions & 4 deletions core/src/main/java/org/jruby/lexer/LexingCommon.java
Original file line number Diff line number Diff line change
@@ -98,7 +98,7 @@ public ByteList createTokenByteList() {
return new ByteList(lexb.unsafeBytes(), lexb.begin() + tokp, lex_p - tokp, getEncoding(), false);
}

public String createTokenString() {
public String createTokenString(int start) {
byte[] bytes = lexb.getUnsafeBytes();
int begin = lexb.begin();
Charset charset;
@@ -108,15 +108,19 @@ public String createTokenString() {
charset = getEncoding().getCharset();
if (charset != null) {
if (charset == RubyEncoding.UTF8) {
return RubyEncoding.decodeUTF8(bytes, begin + tokp, lex_p - tokp);
return RubyEncoding.decodeUTF8(bytes, begin + start, lex_p - start);
} else {
return new String(bytes, begin + tokp, lex_p - tokp, charset);
return new String(bytes, begin + start, lex_p - start, charset);
}
}
} catch (UnsupportedCharsetException e) {}


return new String(bytes, begin + tokp, lex_p - tokp);
return new String(bytes, begin + start, lex_p - start);
}

public String createTokenString() {
return createTokenString(tokp);
}

protected int dedent_string(ByteList string, int width) {