| OLD | NEW |
| 1 // Copyright 2006-2008 the V8 project authors. All rights reserved. | 1 // Copyright 2006-2008 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 316 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 327 TestCharacterClassEscapes('.', Dot); | 327 TestCharacterClassEscapes('.', Dot); |
| 328 TestCharacterClassEscapes('d', IsDigit); | 328 TestCharacterClassEscapes('d', IsDigit); |
| 329 TestCharacterClassEscapes('D', NotDigit); | 329 TestCharacterClassEscapes('D', NotDigit); |
| 330 TestCharacterClassEscapes('s', IsWhiteSpace); | 330 TestCharacterClassEscapes('s', IsWhiteSpace); |
| 331 TestCharacterClassEscapes('S', NotWhiteSpace); | 331 TestCharacterClassEscapes('S', NotWhiteSpace); |
| 332 TestCharacterClassEscapes('w', IsWord); | 332 TestCharacterClassEscapes('w', IsWord); |
| 333 TestCharacterClassEscapes('W', NotWord); | 333 TestCharacterClassEscapes('W', NotWord); |
| 334 } | 334 } |
| 335 | 335 |
| 336 | 336 |
| 337 static RegExpNode* Compile(const char* input) { |
| 338 unibrow::Utf8InputBuffer<> buffer(input, strlen(input)); |
| 339 RegExpParseResult result; |
| 340 if (!v8::internal::ParseRegExp(&buffer, &result)) |
| 341 return NULL; |
| 342 RegExpNode* node = NULL; |
| 343 RegExpEngine::Compile(&result, &node, false); |
| 344 return node; |
| 345 } |
| 346 |
| 347 |
| 337 static void Execute(const char* input, | 348 static void Execute(const char* input, |
| 338 const char* str, | 349 const char* str, |
| 339 bool dot_output = false) { | 350 bool dot_output = false) { |
| 340 v8::HandleScope scope; | 351 v8::HandleScope scope; |
| 341 unibrow::Utf8InputBuffer<> buffer(input, strlen(input)); | |
| 342 ZoneScope zone_scope(DELETE_ON_EXIT); | 352 ZoneScope zone_scope(DELETE_ON_EXIT); |
| 343 RegExpParseResult result; | 353 RegExpNode* node = Compile(input); |
| 344 if (!v8::internal::ParseRegExp(&buffer, &result)) | |
| 345 return; | |
| 346 RegExpNode* node = NULL; | |
| 347 RegExpEngine::Compile(&result, &node, false); | |
| 348 USE(node); | 354 USE(node); |
| 349 #ifdef DEBUG | 355 #ifdef DEBUG |
| 350 if (dot_output) { | 356 if (dot_output) { |
| 351 RegExpEngine::DotPrint(input, node); | 357 RegExpEngine::DotPrint(input, node); |
| 352 exit(0); | 358 exit(0); |
| 353 } | 359 } |
| 354 #endif // DEBUG | 360 #endif // DEBUG |
| 355 } | 361 } |
| 356 | 362 |
| 357 | 363 |
| (...skipping 390 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 748 uc32 u = upper[0]; | 754 uc32 u = upper[0]; |
| 749 if (length > 1 || (c >= 128 && u < 128)) | 755 if (length > 1 || (c >= 128 && u < 128)) |
| 750 u = c; | 756 u = c; |
| 751 if (u != canonicalize(c)) | 757 if (u != canonicalize(c)) |
| 752 printf("%x\n", c); | 758 printf("%x\n", c); |
| 753 CHECK_EQ(u, canonicalize(c)); | 759 CHECK_EQ(u, canonicalize(c)); |
| 754 } | 760 } |
| 755 } | 761 } |
| 756 | 762 |
| 757 | 763 |
| 764 TEST(SimplePropagation) { |
| 765 v8::HandleScope scope; |
| 766 ZoneScope zone_scope(DELETE_ON_EXIT); |
| 767 RegExpNode* node = Compile("(a|^b|c)"); |
| 768 CHECK(node->info()->determine_start); |
| 769 } |
| 770 |
| 771 |
| 758 TEST(Graph) { | 772 TEST(Graph) { |
| 759 Execute("fo[ob]ar|[ba]z|x[yz]*", "", true); | 773 Execute("(a|^b|c)", "", true); |
| 760 } | 774 } |
| OLD | NEW |