This is for JRUBY-1855, where we would quietly ignore the first EOF character seen immediately after a newline. In order to compress the AST a bit, we spun in the lexer until the first non-newline character, so we'd only have a single newline node for sequences of blank lines. Unfortunately this resulted in unreading an EOF, which doesn't appear to allow it back out again. My fix is to immediately return EOF from the lexer if we encounter EOF during that spinning, so it can be handled properly. I think this is safe, but I'd like a second opinion.

-------- Original Message --------
Subject:        [jruby-scm] [jruby] [8988]
trunk/jruby/src/org/jruby/lexer/yacc/RubyYaccLexer.java: Fix for
JRUBY-1855: EOF handling in case of reading program from standard input
Date:   Wed, 04 Feb 2009 01:24:23 -0600 (CST)
From:   [email protected]
Reply-To:       [email protected]
To:     [email protected]



Revision
    8988 <http://fisheye.codehaus.org/changelog/jruby/?cs=8988>
Author
    headius
Date
    2009-02-04 01:24:22 -0600 (Wed, 04 Feb 2009)


      Log Message

Fix for JRUBY-1855 <http://jira.codehaus.org/secure/ViewIssue.jspa?key=JRUBY-1855>: EOF handling in case of reading program from standard input


      Modified Paths

    * trunk/jruby/src/org/jruby/lexer/yacc/RubyYaccLexer.java
      <#trunkjrubysrcorgjrubylexeryaccRubyYaccLexerjava>


      Diff


        Modified:
        trunk/jruby/src/org/jruby/lexer/yacc/RubyYaccLexer.java (8987 =>
        8988)

--- trunk/jruby/src/org/jruby/lexer/yacc/RubyYaccLexer.java 2009-02-04 07:10:18 UTC (rev 8987) +++ trunk/jruby/src/org/jruby/lexer/yacc/RubyYaccLexer.java 2009-02-04 07:24:22 UTC (rev 8988)
@@ -880,6 +880,8 @@
                     }
                 }

+                if (c == -1) return EOF;
+
                 src.unread(c);
                 getPosition();


------------------------------------------------------------------------

To unsubscribe from this list please visit:

http://xircles.codehaus.org/manage_email


---------------------------------------------------------------------
To unsubscribe from this list, please visit:

   http://xircles.codehaus.org/manage_email


Reply via email to