OLD | NEW |
1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
2 # | 2 # |
3 # Copyright 2012 the V8 project authors. All rights reserved. | 3 # Copyright 2012 the V8 project authors. All rights reserved. |
4 # Redistribution and use in source and binary forms, with or without | 4 # Redistribution and use in source and binary forms, with or without |
5 # modification, are permitted provided that the following conditions are | 5 # modification, are permitted provided that the following conditions are |
6 # met: | 6 # met: |
7 # | 7 # |
8 # * Redistributions of source code must retain the above copyright | 8 # * Redistributions of source code must retain the above copyright |
9 # notice, this list of conditions and the following disclaimer. | 9 # notice, this list of conditions and the following disclaimer. |
10 # * Redistributions in binary form must reproduce the above | 10 # * Redistributions in binary form must reproduce the above |
(...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
189 name = python_match.group(1) | 189 name = python_match.group(1) |
190 args = [match.strip() for match in python_match.group(2).split(',')] | 190 args = [match.strip() for match in python_match.group(2).split(',')] |
191 body = python_match.group(3).strip() | 191 body = python_match.group(3).strip() |
192 fun = eval("lambda " + ",".join(args) + ': ' + body) | 192 fun = eval("lambda " + ",".join(args) + ': ' + body) |
193 macros.append((re.compile("\\b%s\\(" % name), PythonMacro(args, fun))) | 193 macros.append((re.compile("\\b%s\\(" % name), PythonMacro(args, fun))) |
194 else: | 194 else: |
195 raise Error("Illegal line: " + line) | 195 raise Error("Illegal line: " + line) |
196 return (constants, macros) | 196 return (constants, macros) |
197 | 197 |
198 | 198 |
199 TEMPLATE_PATTERN = re.compile(r'^\s+T\(([A-Z][a-zA-Z]*),') | 199 TEMPLATE_PATTERN = re.compile(r'^\s+T\(([A-Z][a-zA-Z0-9]*),') |
200 | 200 |
201 def ReadMessageTemplates(lines): | 201 def ReadMessageTemplates(lines): |
202 templates = [] | 202 templates = [] |
203 index = 0 | 203 index = 0 |
204 for line in lines.split('\n'): | 204 for line in lines.split('\n'): |
205 template_match = TEMPLATE_PATTERN.match(line) | 205 template_match = TEMPLATE_PATTERN.match(line) |
206 if template_match: | 206 if template_match: |
207 name = "k%s" % template_match.group(1) | 207 name = "k%s" % template_match.group(1) |
208 value = index | 208 value = index |
209 index = index + 1 | 209 index = index + 1 |
(...skipping 382 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
592 JS2C(args[2:], | 592 JS2C(args[2:], |
593 args[0], | 593 args[0], |
594 args[1], | 594 args[1], |
595 options.raw, | 595 options.raw, |
596 options.startup_blob, | 596 options.startup_blob, |
597 options.js) | 597 options.js) |
598 | 598 |
599 | 599 |
600 if __name__ == "__main__": | 600 if __name__ == "__main__": |
601 main() | 601 main() |
OLD | NEW |