| OLD | NEW |
| 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 214 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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 # Don't allow a regexp to have a ) before the first ( since that's a | 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. | 234 # syntax error and it's probably just two unrelated slashes. |
| 235 slash_quoted_regexp = r"/(?:(?=\()|(?:[^()/\\]|\\.)+)(?:\([^/\\]|\\.)*/" | 235 # Also don't allow it to come after anything that can only be the |
| 236 # end of a primary expression. |
| 237 slash_quoted_regexp = r"(?<![\w$'\")\]])/(?:(?=\()|(?:[^()/\\]|\\.)+)(?:\(
[^/\\]|\\.)*/" |
| 236 # Replace multiple spaces with a single space. | 238 # Replace multiple spaces with a single space. |
| 237 line = re.sub("|".join([double_quoted_string, | 239 line = re.sub("|".join([double_quoted_string, |
| 238 single_quoted_string, | 240 single_quoted_string, |
| 239 slash_quoted_regexp, | 241 slash_quoted_regexp, |
| 240 "( )+"]), | 242 "( )+"]), |
| 241 self.RemoveSpaces, | 243 self.RemoveSpaces, |
| 242 line) | 244 line) |
| 243 # Strip single spaces unless they have an identifier character both before | 245 # Strip single spaces unless they have an identifier character both before |
| 244 # and after the space. % and $ are counted as identifier characters. | 246 # and after the space. % and $ are counted as identifier characters. |
| 245 line = re.sub("|".join([double_quoted_string, | 247 line = re.sub("|".join([double_quoted_string, |
| (...skipping 25 matching lines...) Expand all Loading... |
| 271 r"\{", # Curly braces. | 273 r"\{", # Curly braces. |
| 272 r"\}", | 274 r"\}", |
| 273 r"\bvar [\w$%,]+", # var declarations. | 275 r"\bvar [\w$%,]+", # var declarations. |
| 274 function_declaration_regexp, | 276 function_declaration_regexp, |
| 275 variable_use_regexp]), | 277 variable_use_regexp]), |
| 276 self.Declaration, | 278 self.Declaration, |
| 277 line) | 279 line) |
| 278 new_lines.append(line) | 280 new_lines.append(line) |
| 279 | 281 |
| 280 return "\n".join(new_lines) + "\n" | 282 return "\n".join(new_lines) + "\n" |
| OLD | NEW |