- git diff src/org/jruby/lexer/yacc/RubyYaccLexer.java
- diff --git a/src/org/jruby/lexer/yacc/RubyYaccLexer.java b/src/org/jruby/lexer/yacc/RubyYaccLexer.java
- index b7268b1..826ca8e 100644
- --- a/src/org/jruby/lexer/yacc/RubyYaccLexer.java
- +++ b/src/org/jruby/lexer/yacc/RubyYaccLexer.java
- @@ -39,6 +39,8 @@ import java.io.IOException;
- import java.math.BigInteger;
- import java.util.HashMap;
- +import java.util.Stack;
- +import java.util.regex.Pattern;
- import org.jcodings.Encoding;
- import org.jcodings.specific.ASCIIEncoding;
- @@ -121,6 +123,8 @@ public class RubyYaccLexer {
- }
- private Encoding encoding;
- +
- + private Stack<Keyword> backlog = new Stack<Keyword>();
- public Encoding getEncoding() {
- return encoding;
- @@ -309,6 +313,25 @@ public class RubyYaccLexer {
- }
- public int nextToken() throws IOException {
- + if (!backlog.isEmpty()) {
- + Keyword keyword = backlog.pop();
- + LexState state = lex_state; // Save state at time keyword is encountered
- +
- + setState(keyword.state);
- + if (state == LexState.EXPR_FNAME) {
- + yaccValue = new Token(keyword.name, getPosition());
- + } else {
- + yaccValue = new Token("end", getPosition());
- + }
- +
- + if (state == LexState.EXPR_BEG || (!isOneEight && state == LexState.EXPR_VALUE)) return keyword.id0;
- +
- + if (keyword.id0 != keyword.id1) setState(LexState.EXPR_BEG);
- +
- + return keyword.id1;
- + }
- +
- +
- token = yylex();
- return token == EOF ? 0 : token;
- @@ -1662,6 +1685,15 @@ public class RubyYaccLexer {
- }
- if (lex_state != LexState.EXPR_DOT) {
- + Pattern pat = Pattern.compile("en+d");
- +
- + if (pat.matcher(tempVal).matches()) {
- + int numberOfEnds = tempVal.length() - 2;
- + for (int i = 0; i < numberOfEnds - 1; i++) {
- + backlog.add(getKeyword("end"));
- + }
- + tempVal = "end";
- + }
- Keyword keyword = getKeyword(tempVal); // Is it is a keyword?
- if (keyword != null && (keyword != Keyword.__ENCODING__ || !isOneEight)) {