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: 652d8a2a134c
Choose a base ref
...
head repository: jruby/jruby
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 2bc13c5a1792
Choose a head ref
  • 3 commits
  • 13 files changed
  • 1 contributor

Commits on Mar 22, 2018

  1. Update lexer + parser a bit more to match Ruby 2.5. I missed some sig…

    …nificant
    
    changes to string/heredoc/regexp parsing from the previous update (although
    it is unclear these changes actually changed anything.  I think these were
    mostly done in regards to ripper (which we do not share the same grammar file
    but...).
    enebo committed Mar 22, 2018

    Verified

    This commit was signed with the committer’s verified signature. The key has expired.
    nomadium Miguel Landaeta
    Copy the full SHA
    4fa77db View commit details
  2. Copy the full SHA
    5ed7280 View commit details
  3. Catch up ripper to parser. Error counts did not change but 7 more ass…

    …erts pass!!!! Still missing some smaller changes. Up next.
    enebo committed Mar 22, 2018
    Copy the full SHA
    2bc13c5 View commit details
6 changes: 4 additions & 2 deletions core/src/main/java/org/jruby/ext/ripper/HeredocTerm.java
Original file line number Diff line number Diff line change
@@ -99,9 +99,9 @@ protected int error(RipperLexer lexer, int len, ByteList str, ByteList eos) {

protected int restore(RipperLexer lexer) {
lexer.heredoc_restore(this);
lexer.setStrTerm(null);
lexer.setStrTerm(new StringTerm(flags | STR_FUNC_TERM, 0, 0)); // Weird way of ending

return EOF;
return RubyParser.tSTRING_CONTENT;
}

@Override
@@ -118,6 +118,8 @@ public int parseString(RipperLexer lexer, LexerSource src) throws java.io.IOExce
if (lexer.was_bol() && lexer.whole_match_p(nd_lit, indent)) {
lexer.dispatchHeredocEnd();
lexer.heredoc_restore(this);
lexer.setStrTerm(null);
lexer.setState(EXPR_END);
return RubyParser.tSTRING_END;
}

37 changes: 5 additions & 32 deletions core/src/main/java/org/jruby/ext/ripper/RipperLexer.java
Original file line number Diff line number Diff line change
@@ -522,15 +522,11 @@ private int parseQuote(int c) throws IOException {
return RipperParser.tSTRING_BEG;

case 'W':
lex_strterm = new StringTerm(str_dquote | STR_FUNC_QWORDS, begin, end);
do {c = nextc();} while (Character.isWhitespace(c));
pushback(c);
lex_strterm = new StringTerm(str_dword, begin, end);
return RipperParser.tWORDS_BEG;

case 'w':
lex_strterm = new StringTerm(/* str_squote | */ STR_FUNC_QWORDS, begin, end);
do {c = nextc();} while (Character.isWhitespace(c));
pushback(c);
lex_strterm = new StringTerm(str_sword, begin, end);
return RipperParser.tQWORDS_BEG;

case 'x':
@@ -547,15 +543,11 @@ private int parseQuote(int c) throws IOException {
return RipperParser.tSYMBEG;

case 'I':
lex_strterm = new StringTerm(str_dquote | STR_FUNC_QWORDS, begin, end);
do {c = nextc();} while (Character.isWhitespace(c));
pushback(c);
lex_strterm = new StringTerm(str_dquote, begin, end);
return RipperParser.tSYMBOLS_BEG;

case 'i':
lex_strterm = new StringTerm(/* str_squote | */STR_FUNC_QWORDS, begin, end);
do {c = nextc();} while (Character.isWhitespace(c));
pushback(c);
lex_strterm = new StringTerm(str_sword, begin, end);
return RipperParser.tQSYMBOLS_BEG;
default:
compile_error("Unknown type of %string. Expected 'Q', 'q', 'w', 'x', 'r' or any non letter character, but found '" + c + "'.");
@@ -949,27 +941,8 @@ private int yylex() throws IOException {
boolean spaceSeen = false;
boolean commandState;
boolean tokenSeen = this.tokenSeen;

if (lex_strterm != null) {
int tok = lex_strterm.parseString(this, src);

if (tok == RipperParser.tSTRING_END && (lex_strterm.getFlags() & STR_FUNC_LABEL) != 0) {
if ((isLexState(lex_state, EXPR_BEG|EXPR_ENDFN) && !conditionState.isInState() ||
isARG()) && isLabelSuffix()) {
nextc();
tok = RipperParser.tLABEL_END;
setState(EXPR_BEG|EXPR_LABEL);
lex_strterm = null;
}
}

if (tok == RipperParser.tSTRING_END || tok == RipperParser.tREGEXP_END) {
lex_strterm = null;
setState(EXPR_END|EXPR_ENDARG);
}

return tok;
}
if (lex_strterm != null) return lex_strterm.parseString(this, src);

commandState = commandStart;
commandStart = false;
Loading