| 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 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 128 | 128 |
| 129 def p_maybe_class_content(self, p): | 129 def p_maybe_class_content(self, p): |
| 130 '''maybe_class_content : class_content | 130 '''maybe_class_content : class_content |
| 131 | empty''' | 131 | empty''' |
| 132 p[0] = p[1] | 132 p[0] = p[1] |
| 133 | 133 |
| 134 def p_empty(self, p): | 134 def p_empty(self, p): |
| 135 'empty :' | 135 'empty :' |
| 136 | 136 |
| 137 def p_error(self, p): | 137 def p_error(self, p): |
| 138 raise Exception("Syntax error in input '%s'" % p) | 138 raise Exception("Syntax error in input '%s'" % str(p)) |
| 139 | 139 |
| 140 @staticmethod | 140 @staticmethod |
| 141 def __cat(left, right): | 141 def __cat(left, right): |
| 142 if right == None: | 142 if right == None: |
| 143 return left | 143 return left |
| 144 return ('CAT', left, right) | 144 return ('CAT', left, right) |
| 145 | 145 |
| 146 def build(self, **kwargs): | 146 def build(self, **kwargs): |
| 147 self.parser = yacc.yacc(module=self, debug=0, write_tables=0, **kwargs) | 147 self.parser = yacc.yacc(module=self, debug=0, write_tables=0, **kwargs) |
| 148 self.lexer = RegexLexer() | 148 self.lexer = RegexLexer() |
| 149 self.lexer.build(**kwargs) | 149 self.lexer.build(**kwargs) |
| 150 | 150 |
| 151 __static_instance = None | 151 __static_instance = None |
| 152 @staticmethod | 152 @staticmethod |
| 153 def parse(data): | 153 def parse(data): |
| 154 parser = RegexParser.__static_instance | 154 parser = RegexParser.__static_instance |
| 155 if not parser: | 155 if not parser: |
| 156 parser = RegexParser() | 156 parser = RegexParser() |
| 157 parser.build() | 157 parser.build() |
| 158 RegexParser.__static_instance = parser | 158 RegexParser.__static_instance = parser |
| 159 return parser.parser.parse(data, lexer=parser.lexer.lexer) | 159 try: |
| 160 return parser.parser.parse(data, lexer=parser.lexer.lexer) |
| 161 except Exception as e: |
| 162 RegexParser.__static_instance = None |
| 163 raise e |
| OLD | NEW |