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

Side by Side Diff: tools/js2c.py

Issue 1324103003: Adding js2c.py "Too many arguments" for Macros Error (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: use os.linesep Created 5 years, 3 months 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
101 # Scan over the arguments 101 # Scan over the arguments
102 height = 1 102 height = 1
103 start = pattern_match.start() 103 start = pattern_match.start()
104 end = pattern_match.end() 104 end = pattern_match.end()
105 assert lines[end - 1] == '(' 105 assert lines[end - 1] == '('
106 last_match = end 106 last_match = end
107 arg_index = [0] # Wrap state into array, to work around Python "scoping" 107 arg_index = [0] # Wrap state into array, to work around Python "scoping"
108 mapping = { } 108 mapping = { }
109 def add_arg(str): 109 def add_arg(str):
110 # Remember to expand recursively in the arguments 110 # Remember to expand recursively in the arguments
111 if arg_index[0] >= len(macro.args):
112 lineno = lines.count(os.linesep, 0, start) + 1
113 raise Error('line %s: Too many arguments for macro "%s"' % (lineno, name _pattern.pattern))
111 replacement = expander(str.strip()) 114 replacement = expander(str.strip())
112 mapping[macro.args[arg_index[0]]] = replacement 115 mapping[macro.args[arg_index[0]]] = replacement
113 arg_index[0] += 1 116 arg_index[0] += 1
114 while end < len(lines) and height > 0: 117 while end < len(lines) and height > 0:
115 # We don't count commas at higher nesting levels. 118 # We don't count commas at higher nesting levels.
116 if lines[end] == ',' and height == 1: 119 if lines[end] == ',' and height == 1:
117 add_arg(lines[last_match:end]) 120 add_arg(lines[last_match:end])
118 last_match = end + 1 121 last_match = end + 1
119 elif lines[end] in ['(', '{', '[']: 122 elif lines[end] in ['(', '{', '[']:
120 height = height + 1 123 height = height + 1
(...skipping 471 matching lines...) Expand 10 before | Expand all | Expand 10 after
592 JS2C(args[2:], 595 JS2C(args[2:],
593 args[0], 596 args[0],
594 args[1], 597 args[1],
595 options.raw, 598 options.raw,
596 options.startup_blob, 599 options.startup_blob,
597 options.js) 600 options.js)
598 601
599 602
600 if __name__ == "__main__": 603 if __name__ == "__main__":
601 main() 604 main()
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698