Revision: 17581
Author:   [email protected]
Date:     Fri Nov  8 10:28:35 2013 UTC
Log: Experimental lexer generator: fix dfa generation when there are epsilon transitions with actions.

[email protected]
BUG=

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

Modified:
 /branches/experimental/parser/tools/lexer_generator/lexer_test.py
 /branches/experimental/parser/tools/lexer_generator/nfa.py

=======================================
--- /branches/experimental/parser/tools/lexer_generator/lexer_test.py Thu Nov 7 15:42:57 2013 UTC +++ /branches/experimental/parser/tools/lexer_generator/lexer_test.py Fri Nov 8 10:28:35 2013 UTC
@@ -65,3 +65,22 @@
     self.__verify_action_stream(
         lexer.lex(string),
         [('SHL', '<<'), ('SPACE', ' '), ('LT', '<')])
+
+
+  def test_consecutive_epsilon_transitions(self):
+ # This rule set will create a NFA where we first have an epsilon transition, + # then following that, an epsilon transition with an action. This will test
+    # that the action is correctly pulled forward when creating the dfa.
+    rules = '''
+    digit = [0-9];
+    number = (digit+ ("." digit+)?);
+    <default>
+    number        { NUMBER }
+    eof           <<terminate>>'''
+
+    lexer = Lexer(rules)
+
+    string = '555\0'
+    self.__verify_action_stream(
+        lexer.lex(string),
+        [('NUMBER', '555')])
=======================================
--- /branches/experimental/parser/tools/lexer_generator/nfa.py Fri Nov 8 07:29:01 2013 UTC +++ /branches/experimental/parser/tools/lexer_generator/nfa.py Fri Nov 8 10:28:35 2013 UTC
@@ -399,6 +399,11 @@
           for e_trans in state.transitions()[e]:
             if e_trans[1]:
               actions.append(e_trans[1])
+        for s in state.epsilon_closure():
+          if e in s.transitions():
+            for e_trans in s.transitions()[e]:
+              if e_trans[1]:
+                actions.append(e_trans[1])

       assert len(match_states) == len(transitions)

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