Skip to content

Commit 4932393

Browse files
committedMar 25, 2018
lol. Accidentally using main line parser token values for ripper token values.
In theory they should be ordered the same but apparently are a little off towards the end (no doubt to ripper specific tokens mainline does not have).
1 parent 957d0f2 commit 4932393

File tree

2 files changed

+15
-17
lines changed

2 files changed

+15
-17
lines changed
 

Diff for: ‎core/src/main/java/org/jruby/ext/ripper/HeredocTerm.java

+8-9
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@
3131

3232
import org.jcodings.Encoding;
3333
import org.jruby.lexer.LexerSource;
34-
import org.jruby.parser.RubyParser;
3534
import org.jruby.util.ByteList;
3635

3736
import static org.jruby.lexer.LexingCommon.*;
@@ -80,7 +79,7 @@ protected int error(RipperLexer lexer, int len, ByteList str, ByteList eos) {
8079
lexer.compile_error("can't find string \"" + eos.toString() + "\" anywhere before EOF");
8180

8281
if (lexer.delayed == null) {
83-
lexer.dispatchScanEvent(RubyParser.tSTRING_CONTENT);
82+
lexer.dispatchScanEvent(RipperParser.tSTRING_CONTENT);
8483
} else {
8584
if (str != null) {
8685
lexer.delayed.append(str);
@@ -90,7 +89,7 @@ protected int error(RipperLexer lexer, int len, ByteList str, ByteList eos) {
9089
lexer.delayed.append(lexer.lexb.makeShared(lexer.tokp, len));
9190
}
9291
}
93-
lexer.dispatchDelayedToken(RubyParser.tSTRING_CONTENT);
92+
lexer.dispatchDelayedToken(RipperParser.tSTRING_CONTENT);
9493
}
9594
lexer.lex_goto_eol();
9695

@@ -101,7 +100,7 @@ protected int restore(RipperLexer lexer) {
101100
lexer.heredoc_restore(this);
102101
lexer.setStrTerm(new StringTerm(flags | STR_FUNC_TERM, 0, 0)); // Weird way of ending
103102

104-
return RubyParser.tSTRING_CONTENT;
103+
return RipperParser.tSTRING_CONTENT;
105104
}
106105

107106
@Override
@@ -120,7 +119,7 @@ public int parseString(RipperLexer lexer, LexerSource src) throws java.io.IOExce
120119
lexer.heredoc_restore(this);
121120
lexer.setStrTerm(null);
122121
lexer.setState(EXPR_END);
123-
return RubyParser.tSTRING_END;
122+
return RipperParser.tSTRING_END;
124123
}
125124

126125
if ((flags & STR_FUNC_EXPAND) == 0) {
@@ -159,7 +158,7 @@ public int parseString(RipperLexer lexer, LexerSource src) throws java.io.IOExce
159158

160159
if (lexer.getHeredocIndent() > 0) {
161160
lexer.setValue(lexer.createStr(str, 0));
162-
return RubyParser.tSTRING_CONTENT;
161+
return RipperParser.tSTRING_CONTENT;
163162
}
164163
// MRI null checks str in this case but it is unconditionally non-null?
165164
if (lexer.nextc() == -1) return error(lexer, len, null, eos);
@@ -192,15 +191,15 @@ public int parseString(RipperLexer lexer, LexerSource src) throws java.io.IOExce
192191
if (c != '\n') {
193192
lexer.setValue(lexer.createStr(tok, 0));
194193
lexer.flush_string_content(enc[0]);
195-
return RubyParser.tSTRING_CONTENT;
194+
return RipperParser.tSTRING_CONTENT;
196195
}
197196
tok.append(lexer.nextc());
198197

199198
if (lexer.getHeredocIndent() > 0) {
200199
lexer.lex_goto_eol();
201200
lexer.setValue(lexer.createStr(tok, 0));
202201
lexer.flush_string_content(enc[0]);
203-
return RubyParser.tSTRING_CONTENT;
202+
return RipperParser.tSTRING_CONTENT;
204203
}
205204

206205
if ((c = lexer.nextc()) == EOF) return error(lexer, len, str, eos);
@@ -211,6 +210,6 @@ public int parseString(RipperLexer lexer, LexerSource src) throws java.io.IOExce
211210
lexer.pushback(c);
212211
lexer.setValue(lexer.createStr(str, 0));
213212
lexer.flush_string_content(lexer.getEncoding());
214-
return RubyParser.tSTRING_CONTENT;
213+
return RipperParser.tSTRING_CONTENT;
215214
}
216215
}

Diff for: ‎core/src/main/java/org/jruby/ext/ripper/StringTerm.java

+7-8
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@
3333
import org.jcodings.Encoding;
3434
import org.jruby.Ruby;
3535
import org.jruby.lexer.LexerSource;
36-
import org.jruby.parser.RubyParser;
3736
import org.jruby.util.ByteList;
3837
import org.jruby.util.RegexpOptions;
3938

@@ -84,19 +83,19 @@ private int endFound(RipperLexer lexer) throws IOException {
8483

8584
if ((flags & STR_FUNC_REGEXP) != 0) {
8685
validateRegexp(lexer);
87-
lexer.dispatchScanEvent(RubyParser.tREGEXP_END);
86+
lexer.dispatchScanEvent(RipperParser.tREGEXP_END);
8887
lexer.setState(EXPR_END | EXPR_ENDARG);
89-
return RubyParser.tREGEXP_END;
88+
return RipperParser.tREGEXP_END;
9089
}
9190

9291
if ((flags & STR_FUNC_LABEL) != 0 && lexer.isLabelSuffix()) {
9392
lexer.nextc();
9493
lexer.setState(EXPR_BEG | EXPR_LABEL);
95-
return RubyParser.tLABEL_END;
94+
return RipperParser.tLABEL_END;
9695
}
9796

9897
lexer.setState(EXPR_END | EXPR_ENDARG);
99-
return RubyParser.tSTRING_END;
98+
return RipperParser.tSTRING_END;
10099
}
101100

102101
private void validateRegexp(RipperLexer lexer) throws IOException {
@@ -121,7 +120,7 @@ public int parseString(RipperLexer lexer, LexerSource src) throws IOException {
121120
if ((flags & STR_FUNC_QWORDS) != 0) lexer.nextc(); // delayed terminator char
122121
lexer.ignoreNextScanEvent = true;
123122
lexer.setStrTerm(null);
124-
return ((flags & STR_FUNC_REGEXP) != 0) ? RubyParser.tREGEXP_END : RubyParser.tSTRING_END;
123+
return ((flags & STR_FUNC_REGEXP) != 0) ? RipperParser.tREGEXP_END : RipperParser.tSTRING_END;
125124
}
126125

127126
ByteList buffer = createByteList(lexer);
@@ -150,7 +149,7 @@ public int parseString(RipperLexer lexer, LexerSource src) throws IOException {
150149
}
151150

152151
if ((flags & STR_FUNC_EXPAND) != 0 && c == '#') {
153-
int token = lexer.peekVariableName(RubyParser.tSTRING_DVAR, RubyParser.tSTRING_DBEG);
152+
int token = lexer.peekVariableName(RipperParser.tSTRING_DVAR, RipperParser.tSTRING_DBEG);
154153

155154
if (token != 0) {
156155
if ((flags & STR_FUNC_REGEXP) != 0) {
@@ -180,7 +179,7 @@ public int parseString(RipperLexer lexer, LexerSource src) throws IOException {
180179
regexpFragments.add(buffer);
181180
}
182181
lexer.flush_string_content(enc[0]);
183-
return RubyParser.tSTRING_CONTENT;
182+
return RipperParser.tSTRING_CONTENT;
184183
}
185184

186185
private void mixedEscape(RipperLexer lexer, Encoding foundEncoding, Encoding parserEncoding) {

0 commit comments

Comments
 (0)
Please sign in to comment.