Reviewers: dcarney,

Message:
Committed patchset #1 manually as r17619.

Description:
Experimental lexer generator: More code generation.

[email protected]
BUG=

Committed: https://code.google.com/p/v8/source/detail?r=17619

Please review this at https://codereview.chromium.org/68843002/

SVN Base: https://v8.googlecode.com/svn/branches/experimental/parser

Affected files (+16, -5 lines):
  M src/lexer/lexer_py.re
  M tools/lexer_generator/dfa.py


Index: src/lexer/lexer_py.re
diff --git a/src/lexer/lexer_py.re b/src/lexer/lexer_py.re
index 285b2c9f9b057171274debb426fc4973dbeaf4f0..37c9462c24076106929c882c10982935f5f9cbc3 100644
--- a/src/lexer/lexer_py.re
+++ b/src/lexer/lexer_py.re
@@ -100,7 +100,7 @@ number        { PUSH_TOKEN(NUMBER); }
 ","           { PUSH_TOKEN(COMMA); }

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

 "\""           <<DoubleQuoteString>>
 "'"            <<SingleQuoteString>>
@@ -197,14 +197,14 @@ eof              <<terminate>>
 /./ <<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>>
Index: tools/lexer_generator/dfa.py
diff --git a/tools/lexer_generator/dfa.py b/tools/lexer_generator/dfa.py
index 73e8eb4c26c35c1a564cd37b410e4828d8b59e27..03b9b05afd9d5607ba3cf4d258f12ec3c5feb468 100644
--- a/tools/lexer_generator/dfa.py
+++ b/tools/lexer_generator/dfa.py
@@ -59,7 +59,7 @@ class DfaState(AutomatonState):
     # 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 @@ fprintf(stderr, "state %s, char at hand is %%c\\n", c);
       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