Commit 254d73e
Feature/regular expression metafunction (#904)
* Missing trailing '...' in variadic template arguments.
* Regular expressions initial setup.
* Current working status.
* Handling of groups.
* Handling of alternatives.
* Refactor to position based matching.
* Added regular expression class.
* Added class matching.
* Add line start and end match.
* Compatibility fixes.
* Added test file for regular expressions.
* Basic state machine for range matchers.
* Proper range printing and group invalidation on alternatives.
* State management for ranges. No longer invalid groups if last match fails.
* Range check in class_matcher and restore of groups in ranges_matcher.
* Fix for list matcher and state for alternatives.
* Improved handling of empty matches and ranges.
* Bugfix for missing semaphore in typed template parameters.
* Support for posix character classes.
* Fix for missing escape of '\'.
* Missing group clear in alternate matcher.
* Whitespace errors from cppfront.
* Include regular expressions in cpp2utils.hpp.
* Update for tests.
* Remove initialization from context.
* Basic char matching.
* Removed need of end logic.
* Basic group matching.
* Added alternative.
* Added range matcher logic.
* Added remaining regex patterns.
* Fixes for range matcher.
* Improved group handling.
* Proper reset of ranges.
* Refactor.
* Moved begin and end to context.
* Removed Iter as template argument.
* Refactor.
* Refactor of parser.
* Regular expression update.
* Update of test and header files.
* Addressed review comments.
In addition:
- Removed TODO in reflect.h2.
- Reworked name handling in regex_gen.
* Review updates.
- Moved 'source/regex.h' to '../include/cpp2regex.h'.
- Created 'source/cpp2regex.h'
- Added a utility function for 'is_escaped'.
* Removed static annotation.
* Added greedy matching for alternatives.
* Greedy version of alternative regex.
* Helpers in match return and first shorthand character class.
* Proper error handling.
* Escaped characters from perl.
* Group escapes and named group handling.
* Named group access in regex result.
* Case insensitive matching flag.
* Added modifiers to regular expressions.
* Fixing bugs in implementation.
* Non-greedy and possessive matching.
* Added horizontal and vertical white spaces.
* Additional handling of excapes.
* Update of tests.
* Make regex generation public.
* Performance fixes for greedy matching.
* Added modifiers to matching logic.
* Added (?<mod>) notation.
* Added (?:) notation.
* Added m and s modifiers.
* Bugfix for wrong none-greedy parsing.
* Fixes for regex results.
* Update for tests.
* Added support for 'n' modifier.
* Added perquisites for per syntax parsing.
* Remove direkt position handling from parser.
* Added named groups with '.
* Escape of space in character classes.
* Proper handliing of x and xx modifier switches.
* Added parsing for comment groups.
* Aded branch reset support.
* Update of tests and header.
* Added support for \x.
* Added \000 and \o{000} handles.
* Added lookahead matchers.
* Addes statefull match tail.
* Helper functions for match_return creation.
* Refactor of matcher naming and helpers.
* Cleanup of to_string.
* Matcher cleanup.
* Parser refactor.
* Header update and tests update.
* Fix for greedy range matching.
Greedy ranges matching is now a recursive call which no longer discards
the state of previous iterations of M. This enables the regex to try all
alternatives over the bounds of the greedy method.
* Better template arguments for range matchers.
* Update for regex tests.
* Changes for new analysis.
* Remove <format> dependency, get warning-clean build
Header `<format>` requires newer (2022/2023) compilers, so I'll try to remove depending on it to keep cppfront's own build working to ~2019 compilers
* Create pure2-regex-partial.cpp2
Feel free to drop this file again:
I just added it to show the results of trying to comment out all the cases that cause the metafunction to report an error, in an attempt to get an executable file. After commenting these ones, cppfront completes
I still get strange errors from the Cpp1 compiler, which I've narrowed down to this short repro:
#define CPP2_IMPORT_STD Yes
#include "cpp2util.h"
If the macro is commented out, things compile fine. So there's something about the "import std" path that's going wrong, it seems on both MSVC and GCC 10. I haven't been able to diagnose the problem further than that though.
* Fix for compile time degradation.
The change for the stateful tail increased the compile time. The tail is
now stateless again and we have an extra argument for the end function
call.
* Added first conversion to matcher generator.
* Basic generation of char matchers.
* Basic code generation via regegx tokens.
* Moved and renamed char token matcher.
* Parsing of ranges.
* Moved code generation to generation context.
* Generation of statefull matcher.
* Cleanup of ranger matcher implementation.
* Added special range matching.
* Removed old range parsers.
* Moved parse_until into parser context.
* Added to_string output.
* Added group handling.
* Added logic for alternative.
* Added '.' regex expression.
* Added group reference matchers.
* Added anchor matchers.
* Added class matchers.
* Added full group matcher parsing.
* Added basic character escapes.
* Added word boundary matchers.
* Added named start and end line matchers.
* Added named class matchers.
* Added \K token.
* Added hexadicimal token and octal token.
* Added lookahead parsing and matching.
* Group gathering is now done in a set.
* Added modifier handling.
* Removal of unused funtionality and proper parsing of global modifiers.
* Moved name group lookup creation.
* Fixes for generation.
* Bugfix for nonconst has in generated flag_enums.
* Removed modifiers from arguments and fixed a few wanrings.
* Removed templates for regular arguments.
* Agglomeration of character matchers.
* Refactored function generation to do .. while loop.
* Removed UFCS calls.
* Fixes for new cppfront analysis.
* Fixes for new char matcher logic.
* Added handling of raw strings and using raw strings.
* Escape adaptions for to_string and other to_string fixes.
* General refactor.
* Continuation of cleanup.
* Added namespace ot string_util.h.
* Fixes for compiler warnings.
* Added new tests.
* Changes for regression tests.
* Fixes for regex and non-regex tests.
* Remove UFCS from regex and more non-regex test fixes.
* Update for TODOs.
* Update for generated header files.
* Update of generated header files.
* Updates for regression tests.
* Enable modules build on MSVC by removing #includes when using modules
Also, silence two narrowing errors MSVC reports by adding unsafe_narrow
* Updates for regression tests.
* Changes for regression-tests.
* Updates for regression tests.
* Updates for regression tests.
* Update for \e escape.
* CI update tests
* Update for tests.
* Update for test results.
* Update for regression tests.
* Reran regressions on my box - whitespace changes only
Probably line-ends
Plus an MSVC minor version update
Committing this just-whitespace update to clear the diff list before I make any review changes/renames...
* Move & rename source/regex.h2 to include/cpp2regex.h2
In this project I'm trying to build *.h2 files in the same directory as the *.h they generate, and keep the same name
In /include, "cpp2util.h" is named that way because it really is the Cpp2 run-time library... For regex, we could name it regex.h(2) or cpp2regex.h(2)... the argument for using "cpp2" is because it really does include additional run-time support for what will now be one of the Cpp2-built-in metafunctions... anyway we can always revisit that in the future...
* Merge string_util.h into cpp2util.h
Minus a couple of functions that aren't used
And minor touchups, mainly int_to_string using more if-constexpr
* Review pass through cpp2regex.h2
Up to line ~1600
Looking good, mainly formatting tweaks to follow the repo's style
* Finish tweaking pass through cpp2regex.h2
From line 1600 onward
---------
Signed-off-by: Max Sagebaum <[email protected]>
Signed-off-by: Herb Sutter <[email protected]>
Co-authored-by: Herb Sutter <[email protected]>
Co-authored-by: jarzec <[email protected]>1 parent e45eae5 commit 254d73e
File tree
542 files changed
+122033
-300
lines changed- include
- regression-tests
- test-results
- apple-clang-14-c++2b
- apple-clang-15-c++2b
- clang-12-c++20
- clang-15-c++20-libcpp
- clang-15-c++20
- clang-18-c++20
- clang-18-c++23-libcpp
- gcc-10-c++20
- gcc-13-c++2b
- gcc-14-c++2b
- msvc-2022-c++20
- msvc-2022-c++latest
- source
Some content is hidden
Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
542 files changed
+122033
-300
lines changedLarge diffs are not rendered by default.
Large diffs are not rendered by default.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
36 | 36 | | |
37 | 37 | | |
38 | 38 | | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
39 | 45 | | |
40 | 46 | | |
41 | | - | |
42 | | - | |
| 47 | + | |
| 48 | + | |
43 | 49 | | |
44 | 50 | | |
45 | 51 | | |
| |||
269 | 275 | | |
270 | 276 | | |
271 | 277 | | |
| 278 | + | |
272 | 279 | | |
273 | 280 | | |
274 | 281 | | |
275 | 282 | | |
276 | 283 | | |
277 | 284 | | |
278 | 285 | | |
| 286 | + | |
279 | 287 | | |
| 288 | + | |
280 | 289 | | |
281 | 290 | | |
282 | 291 | | |
| |||
320 | 329 | | |
321 | 330 | | |
322 | 331 | | |
323 | | - | |
324 | 332 | | |
325 | 333 | | |
326 | 334 | | |
| |||
360 | 368 | | |
361 | 369 | | |
362 | 370 | | |
| 371 | + | |
| 372 | + | |
| 373 | + | |
| 374 | + | |
| 375 | + | |
| 376 | + | |
| 377 | + | |
| 378 | + | |
| 379 | + | |
| 380 | + | |
| 381 | + | |
| 382 | + | |
| 383 | + | |
| 384 | + | |
| 385 | + | |
| 386 | + | |
| 387 | + | |
| 388 | + | |
| 389 | + | |
| 390 | + | |
| 391 | + | |
| 392 | + | |
| 393 | + | |
| 394 | + | |
| 395 | + | |
| 396 | + | |
| 397 | + | |
| 398 | + | |
| 399 | + | |
| 400 | + | |
| 401 | + | |
| 402 | + | |
| 403 | + | |
| 404 | + | |
| 405 | + | |
| 406 | + | |
| 407 | + | |
| 408 | + | |
| 409 | + | |
| 410 | + | |
| 411 | + | |
| 412 | + | |
| 413 | + | |
| 414 | + | |
| 415 | + | |
| 416 | + | |
| 417 | + | |
| 418 | + | |
| 419 | + | |
| 420 | + | |
| 421 | + | |
| 422 | + | |
| 423 | + | |
| 424 | + | |
| 425 | + | |
| 426 | + | |
| 427 | + | |
| 428 | + | |
| 429 | + | |
| 430 | + | |
| 431 | + | |
| 432 | + | |
| 433 | + | |
| 434 | + | |
| 435 | + | |
| 436 | + | |
| 437 | + | |
| 438 | + | |
| 439 | + | |
| 440 | + | |
| 441 | + | |
| 442 | + | |
| 443 | + | |
| 444 | + | |
| 445 | + | |
| 446 | + | |
| 447 | + | |
| 448 | + | |
| 449 | + | |
| 450 | + | |
| 451 | + | |
| 452 | + | |
| 453 | + | |
| 454 | + | |
| 455 | + | |
| 456 | + | |
| 457 | + | |
| 458 | + | |
| 459 | + | |
| 460 | + | |
| 461 | + | |
| 462 | + | |
| 463 | + | |
| 464 | + | |
| 465 | + | |
| 466 | + | |
| 467 | + | |
| 468 | + | |
| 469 | + | |
| 470 | + | |
| 471 | + | |
| 472 | + | |
| 473 | + | |
| 474 | + | |
| 475 | + | |
| 476 | + | |
| 477 | + | |
| 478 | + | |
| 479 | + | |
| 480 | + | |
| 481 | + | |
| 482 | + | |
| 483 | + | |
| 484 | + | |
| 485 | + | |
| 486 | + | |
| 487 | + | |
| 488 | + | |
| 489 | + | |
| 490 | + | |
| 491 | + | |
| 492 | + | |
| 493 | + | |
| 494 | + | |
| 495 | + | |
| 496 | + | |
| 497 | + | |
| 498 | + | |
| 499 | + | |
| 500 | + | |
| 501 | + | |
| 502 | + | |
| 503 | + | |
| 504 | + | |
| 505 | + | |
| 506 | + | |
| 507 | + | |
| 508 | + | |
| 509 | + | |
| 510 | + | |
| 511 | + | |
| 512 | + | |
| 513 | + | |
| 514 | + | |
| 515 | + | |
| 516 | + | |
363 | 517 | | |
364 | 518 | | |
365 | 519 | | |
| |||
2365 | 2519 | | |
2366 | 2520 | | |
2367 | 2521 | | |
| 2522 | + | |
2368 | 2523 | | |
2369 | 2524 | | |
2370 | 2525 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
0 commit comments