Revision: 17233
Author:   [email protected]
Date:     Wed Oct 16 09:06:56 2013 UTC
Log:      Add early exit on EOS to lexer.

BUG=
[email protected]

Review URL: https://chromiumcodereview.appspot.com/27347002
http://code.google.com/p/v8/source/detail?r=17233

Modified:
 /branches/experimental/parser/Makefile
 /branches/experimental/parser/src/lexer/lexer.gyp
 /branches/experimental/parser/src/lexer/lexer.re

=======================================
--- /branches/experimental/parser/Makefile      Mon Oct 14 11:35:31 2013 UTC
+++ /branches/experimental/parser/Makefile      Wed Oct 16 09:06:56 2013 UTC
@@ -38,7 +38,6 @@
 ANDROID_TOOLCHAIN ?=
 ANDROID_V8 ?= /data/local/tmp/v8
 NACL_SDK_ROOT ?=
-RE2C ?= re2c

 # Special build flags. Use them like this: "make library=shared"

=======================================
--- /branches/experimental/parser/src/lexer/lexer.gyp Mon Oct 14 14:35:38 2013 UTC +++ /branches/experimental/parser/src/lexer/lexer.gyp Wed Oct 16 09:06:56 2013 UTC
@@ -66,7 +66,7 @@
             '<(SHARED_INTERMEDIATE_DIR)/lexer.cc',
           ],
           'action': [
-            '$(RE2C)',
+            're2c',
             '-f',
             '-c',
             '--output',
=======================================
--- /branches/experimental/parser/src/lexer/lexer.re Tue Oct 15 10:43:48 2013 UTC +++ /branches/experimental/parser/src/lexer/lexer.re Wed Oct 16 09:06:56 2013 UTC
@@ -48,6 +48,7 @@

 #define PUSH_TOKEN(T) { send(T); SKIP(); }
 #define PUSH_TOKEN_LOOKAHEAD(T) { --cursor_; send(T); SKIP(); }
+#define PUSH_EOF_AND_RETURN() { send(Token::EOS); eof_ = true; return 1;}
 #define PUSH_LINE_TERMINATOR() { SKIP(); }
 #define TERMINATE_ILLEGAL() { return 1; }

@@ -125,7 +126,7 @@
     size_t allocated = buffer_end_ - buffer_;
     if(allocated < needed) {
       size_t limit__offset = limit_ - buffer_;
-      size_t start__offset = start_ - buffer_;
+      size_t start_offset = start_ - buffer_;
       size_t marker__offset = marker_ - buffer_;
       size_t cursor__offset = cursor_ - buffer_;

@@ -134,7 +135,7 @@

       marker_ = marker__offset + buffer_;
       cursor_ = cursor__offset + buffer_;
-      start_ = buffer_ + start__offset;
+      start_ = buffer_ + start_offset;
       limit_ = limit__offset + buffer_;
     }
     memcpy(limit_, input, input_size);
@@ -293,7 +294,7 @@

     <Normal> identifier_start_    :=> Identifier

-    <Normal> eof           { PUSH_TOKEN(Token::EOS); return 1; }
+    <Normal> eof           { PUSH_EOF_AND_RETURN();}
     <Normal> any           { TERMINATE_ILLEGAL(); }

     <DoubleQuoteString> "\\\""  { goto yy0; }
@@ -321,7 +322,7 @@
     */

  fill:
-    int unfinished_size = cursor_-start_;
+    int unfinished_size = cursor_ - start_;
     if (FLAG_trace_lexer) {
       printf(
         "scanner needs a refill. Exiting for now with:\n"
@@ -332,7 +333,7 @@
       );
       if(0 < unfinished_size && start_ < limit_) {
         printf("  unfinished token is: ");
-        fwrite(start_, 1, cursor_-start_, stdout);
+        fwrite(start_, 1, cursor_ - start_, stdout);
         putchar('\n');
       }
       putchar('\n');
@@ -344,13 +345,13 @@
     //  everything before start_ and after limit_.

     if (buffer_ < start_) {
-      size_t start__offset = start_ - buffer_;
+      size_t start_offset = start_ - buffer_;
       memmove(buffer_, start_, limit_ - start_);
-      marker_ -= start__offset;
-      cursor_ -= start__offset;
-      limit_ -= start__offset;
-      start_ -= start__offset;
-      real_start_ += start__offset;
+      marker_ -= start_offset;
+      cursor_ -= start_offset;
+      limit_ -= start_offset;
+      start_ -= start_offset;
+      real_start_ += start_offset;
     }
     return 0;
   }

--
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev
--- You received this message because you are subscribed to the Google Groups "v8-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to