Revision: 17698
Author:   [email protected]
Date:     Wed Nov 13 15:03:03 2013 UTC
Log:      Experimental lexer generator: fix MultiLineComment ending.

Dfaing was confused since after */ we can be in so many states!

BUG=
[email protected]

Review URL: https://codereview.chromium.org/70083007
http://code.google.com/p/v8/source/detail?r=17698

Modified:
 /branches/experimental/parser/src/lexer/even-more-experimental-scanner.h
 /branches/experimental/parser/src/lexer/lexer_py.re
 /branches/experimental/parser/tools/lexer_generator/code_generator.py

=======================================
--- /branches/experimental/parser/src/lexer/even-more-experimental-scanner.h Wed Nov 13 12:12:08 2013 UTC +++ /branches/experimental/parser/src/lexer/even-more-experimental-scanner.h Wed Nov 13 15:03:03 2013 UTC
@@ -36,6 +36,7 @@

 #define PUSH_TOKEN(T) { send(T); start_ = cursor_; }
 #define PUSH_LINE_TERMINATOR(s) { start_ = cursor_; }
+#define BACK() { yych = *(--cursor_); }
 #define SKIP() { start_ = cursor_; }

 namespace v8 {
=======================================
--- /branches/experimental/parser/src/lexer/lexer_py.re Tue Nov 12 15:31:00 2013 UTC +++ /branches/experimental/parser/src/lexer/lexer_py.re Wed Nov 13 15:03:03 2013 UTC
@@ -195,8 +195,8 @@
 catch_all <<continue>>

 <MultiLineComment>
-"*/"             { SKIP(); }
-/\*./             <<continue>>
+"*/"             { SKIP(); BACK(); goto code_start;}
+/\*[^\057]/      <<continue>>
 # need to force action
 line_terminator+ { PUSH_LINE_TERMINATOR(); } <<continue>>
 eof              <<terminate>>
=======================================
--- /branches/experimental/parser/tools/lexer_generator/code_generator.py Wed Nov 13 13:34:33 2013 UTC +++ /branches/experimental/parser/tools/lexer_generator/code_generator.py Wed Nov 13 15:03:03 2013 UTC
@@ -56,18 +56,24 @@
     # FIXME: add different check types (if, switch, lookup table)
     # FIXME: add action + break / continue
     # FIXME: add default action
-    code = '''
+    code = ''
+    if start_node_number == state.node_number():
+      code += '''
+code_start:
+'''
+    code += '''
 code_%s:
-    //fprintf(stderr, "state %s\\n");''' % (state.node_number(),
-                                          state.node_number())
+    //fprintf(stderr, "state %s\\n");
+''' % (state.node_number(),
+       state.node_number())

     action = state.action()
     if action:
       if action.type() == 'terminate':
-        code += 'return 0;'
+        code += 'PUSH_TOKEN(Token::EOS); return 0;'
         return code
       elif action.type() == 'terminate_illegal':
-        code += 'return 1;'
+        code += 'PUSH_TOKEN(Token::ILLEGAL); return 1;'
         return code

     code += '''
@@ -82,7 +88,7 @@
 ''' % s.node_number()

     if action:
-      code += '%s\nyych = *(--cursor_);\ngoto code_%s;\n' % (action.data(),
+      code += '%s\nBACK();\ngoto code_%s;\n' % (action.data(),
start_node_number)
     else:
       code += 'goto default_action;'
@@ -108,8 +114,9 @@
     code += '''
   CHECK(false);
 default_action:
+  //fprintf(stderr, "default action\\n");
   %s
-  yych = *(--cursor_);
+  BACK();
   goto code_%s;
   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