Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(361)

Side by Side Diff: tools/lexer_generator/automata_test.py

Issue 69293005: Experimental parser: add catch all rule (Closed) Base URL: https://v8.googlecode.com/svn/branches/experimental/parser
Patch Set: Created 7 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 # Copyright 2013 the V8 project authors. All rights reserved. 1 # Copyright 2013 the V8 project authors. All rights reserved.
2 # Redistribution and use in source and binary forms, with or without 2 # Redistribution and use in source and binary forms, with or without
3 # modification, are permitted provided that the following conditions are 3 # modification, are permitted provided that the following conditions are
4 # met: 4 # met:
5 # 5 #
6 # * Redistributions of source code must retain the above copyright 6 # * Redistributions of source code must retain the above copyright
7 # notice, this list of conditions and the following disclaimer. 7 # notice, this list of conditions and the following disclaimer.
8 # * Redistributions in binary form must reproduce the above 8 # * Redistributions in binary form must reproduce the above
9 # copyright notice, this list of conditions and the following 9 # copyright notice, this list of conditions and the following
10 # disclaimer in the documentation and/or other materials provided 10 # disclaimer in the documentation and/or other materials provided
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
97 def verify_miss(string, expected): 97 def verify_miss(string, expected):
98 verify(string, expected + [('MISS',)]) 98 verify(string, expected + [('MISS',)])
99 def verify_hit(string, expected): 99 def verify_hit(string, expected):
100 verify(string, expected + [('TERMINATE',)]) 100 verify(string, expected + [('TERMINATE',)])
101 (l, r) = left_action, right_action 101 (l, r) = left_action, right_action
102 verify_hit("left", [l]) 102 verify_hit("left", [l])
103 verify_miss("lefta", [l]) 103 verify_miss("lefta", [l])
104 verify_hit("leftrightleftright", [l, r, l, r]) 104 verify_hit("leftrightleftright", [l, r, l, r])
105 verify_miss("leftrightleftrightx", [l, r, l, r]) 105 verify_miss("leftrightleftrightx", [l, r, l, r])
106 106
107 def test_continue(self): 107 def test_minimization(self):
108 graph = NfaBuilder.cat_graphs([ 108 for (regex, matches, not_matches) in self.__test_data:
109 NfaBuilder.cat_graphs([ 109 (nfa, dfa) = build_automata(regex)
110 RegexParser.parse("ab"), 110 dfa.minimize()
111 NfaBuilder.add_continue(RegexParser.parse("cd"))]), 111
112 RegexParser.parse("ef")]) 112
113 nfa = NfaBuilder().nfa(graph)
114 self.assertFalse(nfa.matches(""))
115 self.assertTrue(nfa.matches("abcdef"))
116 self.assertTrue(nfa.matches("abcdabcdef"))
OLDNEW
« src/lexer/lexer_py.re ('K') | « src/lexer/lexer_py.re ('k') | tools/lexer_generator/dfa.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698