Revision: 17619
Author:   [email protected]
Date:     Mon Nov 11 14:46:29 2013 UTC
Log:      Experimental lexer generator: More code generation.

[email protected]
BUG=

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

Modified:
 /branches/experimental/parser/src/lexer/lexer_py.re
 /branches/experimental/parser/tools/lexer_generator/dfa.py

=======================================
--- /branches/experimental/parser/src/lexer/lexer_py.re Mon Nov 11 07:52:15 2013 UTC +++ /branches/experimental/parser/src/lexer/lexer_py.re Mon Nov 11 14:46:29 2013 UTC
@@ -100,7 +100,7 @@
 ","           { PUSH_TOKEN(COMMA); }

 line_terminator+  { PUSH_LINE_TERMINATOR(); }
-whitespace     { SKIP } # TODO implement skip
+whitespace     { SKIP(); } # TODO implement skip

 "\""           <<DoubleQuoteString>>
 "'"            <<SingleQuoteString>>
@@ -197,14 +197,14 @@
 /./ <<continue>>

 <MultiLineComment>
-"*/"             { SKIP }
+"*/"             { SKIP(); }
 # need to force action
 line_terminator+ { PUSH_LINE_TERMINATOR(); } <<continue>>
 eof              <<terminate>>
 /./ <<continue>>

 <HtmlComment>
-"-->"            { SKIP }
+"-->"            { SKIP(); }
 # need to force action
 line_terminator+ { PUSH_LINE_TERMINATOR(); } <<continue>>
 eof              <<terminate>>
=======================================
--- /branches/experimental/parser/tools/lexer_generator/dfa.py Mon Nov 11 14:22:00 2013 UTC +++ /branches/experimental/parser/tools/lexer_generator/dfa.py Mon Nov 11 14:46:29 2013 UTC
@@ -59,7 +59,7 @@
     # FIXME: add default action
     code = '''
 code_%s:
-fprintf(stderr, "state %s, char at hand is %%c\\n", c);
+fprintf(stderr, "state %s, char at hand is %%c (%%d)\\n", c, c);
 ''' % (self.node_number(), self.node_number())

     for key, state in self.__transitions.items():
@@ -67,7 +67,18 @@
       code += ''' {
   c = *(++cursor);
   goto code_%s;
-}''' % state.node_number()
+}
+''' % state.node_number()
+
+    action = self.action()
+    if action:
+      if action[1] == 'terminate':
+        code += 'return 0;'
+      elif action[1] == 'terminate_illegal':
+        code += 'return 1;'
+      else:
+        code += self.action()[1];
+
     return code

 class Dfa(Automaton):

--
--
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