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

Side by Side Diff: tools/jsmin.py

Issue 521057: Inline a number of simple date computations.... (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: '' Created 10 years, 11 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 | Annotate | Revision Log
« no previous file with comments | « src/macros.py ('k') | 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/python2.4 1 #!/usr/bin/python2.4
2 2
3 # Copyright 2009 the V8 project authors. All rights reserved. 3 # Copyright 2009 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 212 matching lines...) Expand 10 before | Expand all | Expand 10 after
223 # Strip leading and trailing spaces. 223 # Strip leading and trailing spaces.
224 line = re.sub(r"^ +", "", line) 224 line = re.sub(r"^ +", "", line)
225 line = re.sub(r" +$", "", line) 225 line = re.sub(r" +$", "", line)
226 # A regexp that matches a literal string surrounded by "double quotes". 226 # A regexp that matches a literal string surrounded by "double quotes".
227 # This regexp can handle embedded backslash-escaped characters including 227 # This regexp can handle embedded backslash-escaped characters including
228 # embedded backslash-escaped double quotes. 228 # embedded backslash-escaped double quotes.
229 double_quoted_string = r'"(?:[^"\\]|\\.)*"' 229 double_quoted_string = r'"(?:[^"\\]|\\.)*"'
230 # A regexp that matches a literal string surrounded by 'double quotes'. 230 # A regexp that matches a literal string surrounded by 'double quotes'.
231 single_quoted_string = r"'(?:[^'\\]|\\.)*'" 231 single_quoted_string = r"'(?:[^'\\]|\\.)*'"
232 # A regexp that matches a regexp literal surrounded by /slashes/. 232 # A regexp that matches a regexp literal surrounded by /slashes/.
233 slash_quoted_regexp = r"/(?:[^/\\]|\\.)+/" 233 # Don't allow a regexp to have a ) before the first ( since that's a
234 # syntax error and it's probably just two unrelated slashes.
235 slash_quoted_regexp = r"/(?:(?=\()|(?:[^()/\\]|\\.)+)(?:\([^/\\]|\\.)*/"
234 # Replace multiple spaces with a single space. 236 # Replace multiple spaces with a single space.
235 line = re.sub("|".join([double_quoted_string, 237 line = re.sub("|".join([double_quoted_string,
236 single_quoted_string, 238 single_quoted_string,
237 slash_quoted_regexp, 239 slash_quoted_regexp,
238 "( )+"]), 240 "( )+"]),
239 self.RemoveSpaces, 241 self.RemoveSpaces,
240 line) 242 line)
241 # Strip single spaces unless they have an identifier character both before 243 # Strip single spaces unless they have an identifier character both before
242 # and after the space. % and $ are counted as identifier characters. 244 # and after the space. % and $ are counted as identifier characters.
243 line = re.sub("|".join([double_quoted_string, 245 line = re.sub("|".join([double_quoted_string,
(...skipping 25 matching lines...) Expand all
269 r"\{", # Curly braces. 271 r"\{", # Curly braces.
270 r"\}", 272 r"\}",
271 r"\bvar [\w$%,]+", # var declarations. 273 r"\bvar [\w$%,]+", # var declarations.
272 function_declaration_regexp, 274 function_declaration_regexp,
273 variable_use_regexp]), 275 variable_use_regexp]),
274 self.Declaration, 276 self.Declaration,
275 line) 277 line)
276 new_lines.append(line) 278 new_lines.append(line)
277 279
278 return "\n".join(new_lines) + "\n" 280 return "\n".join(new_lines) + "\n"
OLDNEW
« no previous file with comments | « src/macros.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698