| OLD | NEW |
| 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 30 matching lines...) Expand all Loading... |
| 41 automaton.lex(string, rule_processor.default_action)): | 41 automaton.lex(string, rule_processor.default_action)): |
| 42 self.assertEquals(expected[i][0], action) | 42 self.assertEquals(expected[i][0], action) |
| 43 self.assertEquals(expected[i][1], string[start : stop]) | 43 self.assertEquals(expected[i][1], string[start : stop]) |
| 44 | 44 |
| 45 @staticmethod | 45 @staticmethod |
| 46 def __terminate(): | 46 def __terminate(): |
| 47 return (Action(None, ('terminate', None)), '\0') | 47 return (Action(None, ('terminate', None)), '\0') |
| 48 | 48 |
| 49 def test_simple(self): | 49 def test_simple(self): |
| 50 rules = ''' | 50 rules = ''' |
| 51 eos = [:eos:]; | |
| 52 <<default>> | 51 <<default>> |
| 53 "(" <|LBRACE|> | 52 "(" <|LBRACE|> |
| 54 ")" <|RBRACE|> | 53 ")" <|RBRACE|> |
| 55 | 54 |
| 56 "foo" <|FOO|> | 55 "foo" <|FOO|> |
| 57 eos <|terminate|>''' | 56 eos <terminate>''' |
| 58 | 57 |
| 59 string = 'foo()' | 58 string = 'foo()' |
| 60 self.__verify_action_stream(rules, string, | 59 self.__verify_action_stream(rules, string, |
| 61 [('FOO', 'foo'), ('LBRACE', '('), ('RBRACE', ')'), self.__terminate()]) | 60 [('FOO', 'foo'), ('LBRACE', '('), ('RBRACE', ')'), self.__terminate()]) |
| 62 | 61 |
| 63 def test_maximal_matching(self): | 62 def test_maximal_matching(self): |
| 64 rules = ''' | 63 rules = ''' |
| 65 eos = [:eos:]; | |
| 66 <<default>> | 64 <<default>> |
| 67 "<" <|LT|> | 65 "<" <|LT|> |
| 68 "<<" <|SHL|> | 66 "<<" <|SHL|> |
| 69 " " <|SPACE|> | 67 " " <|SPACE|> |
| 70 eos <|terminate|>''' | 68 eos <terminate>''' |
| 71 | 69 |
| 72 string = '<< <' | 70 string = '<< <' |
| 73 self.__verify_action_stream(rules, string, | 71 self.__verify_action_stream(rules, string, |
| 74 [('SHL', '<<'), ('SPACE', ' '), ('LT', '<'), self.__terminate()]) | 72 [('SHL', '<<'), ('SPACE', ' '), ('LT', '<'), self.__terminate()]) |
| 75 | 73 |
| 76 def test_consecutive_epsilon_transitions(self): | 74 def test_consecutive_epsilon_transitions(self): |
| 77 rules = ''' | 75 rules = ''' |
| 78 eos = [:eos:]; | |
| 79 digit = [0-9]; | 76 digit = [0-9]; |
| 80 number = (digit+ ("." digit+)?); | 77 number = (digit+ ("." digit+)?); |
| 81 <<default>> | 78 <<default>> |
| 82 number <|NUMBER|>''' | 79 number <|NUMBER|>''' |
| 83 | 80 |
| 84 string = '555' | 81 string = '555' |
| 85 self.__verify_action_stream(rules, string, [('NUMBER', '555')]) | 82 self.__verify_action_stream(rules, string, [('NUMBER', '555')]) |
| 86 | 83 |
| 87 def test_action_precedence(self): | 84 def test_action_precedence(self): |
| 88 rules = ''' | 85 rules = ''' |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 140 /[b-z]/ <|ID|Identifier> | 137 /[b-z]/ <|ID|Identifier> |
| 141 " " <|SPACE|> | 138 " " <|SPACE|> |
| 142 <<Identifier>> | 139 <<Identifier>> |
| 143 /[b-z]/ <|ID|continue> | 140 /[b-z]/ <|ID|continue> |
| 144 /[a]/ <|INVALID|> | 141 /[a]/ <|INVALID|> |
| 145 ''' | 142 ''' |
| 146 self.__verify_action_stream(rules, 'bc ba de', | 143 self.__verify_action_stream(rules, 'bc ba de', |
| 147 [('ID', 'bc'), ('SPACE', ' '), | 144 [('ID', 'bc'), ('SPACE', ' '), |
| 148 ('INVALID', 'ba'), ('SPACE', ' '), | 145 ('INVALID', 'ba'), ('SPACE', ' '), |
| 149 ('ID', 'de')]) | 146 ('ID', 'de')]) |
| OLD | NEW |