forked from hsutter/cppfront
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathreflect.h
More file actions
5390 lines (4397 loc) · 210 KB
/
Copy pathreflect.h
File metadata and controls
5390 lines (4397 loc) · 210 KB
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
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
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
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
#ifndef REFLECT_H_CPP2
#define REFLECT_H_CPP2
//=== Cpp2 type declarations ====================================================
#include "cpp2util.h"
#line 1 "reflect.h2"
#line 22 "reflect.h2"
namespace cpp2 {
namespace meta {
#line 34 "reflect.h2"
class compiler_services;
#line 233 "reflect.h2"
class declaration_base;
#line 259 "reflect.h2"
class declaration;
#line 341 "reflect.h2"
class function_declaration;
#line 432 "reflect.h2"
class object_declaration;
#line 468 "reflect.h2"
class type_declaration;
#line 606 "reflect.h2"
class alias_declaration;
#line 1056 "reflect.h2"
class value_member_info;
#line 1574 "reflect.h2"
class expression_flags;
#line 1590 "reflect.h2"
class regex_token;
#line 1616 "reflect.h2"
class regex_token_check;
#line 1635 "reflect.h2"
class regex_token_code;
#line 1654 "reflect.h2"
class regex_token_empty;
#line 1670 "reflect.h2"
class regex_token_list;
#line 1709 "reflect.h2"
class parse_context_group_state;
#line 1770 "reflect.h2"
class parse_context_branch_reset_state;
#line 1813 "reflect.h2"
class parse_context;
#line 2211 "reflect.h2"
class generation_function_context;
#line 2229 "reflect.h2"
class generation_context;
#line 2427 "reflect.h2"
class alternative_token;
#line 2442 "reflect.h2"
class alternative_token_gen;
#line 2494 "reflect.h2"
class any_token;
#line 2512 "reflect.h2"
class char_token;
#line 2615 "reflect.h2"
class class_token;
#line 2830 "reflect.h2"
class group_ref_token;
#line 2961 "reflect.h2"
class group_token;
#line 3248 "reflect.h2"
class lookahead_token;
#line 3329 "reflect.h2"
class range_token;
#line 3477 "reflect.h2"
class special_range_token;
#line 3544 "reflect.h2"
template<typename Error_out> class regex_generator;
#line 3791 "reflect.h2"
}
}
//=== Cpp2 type definitions and function declarations ===========================
#line 1 "reflect.h2"
// Copyright (c) Herb Sutter
// SPDX-License-Identifier: CC-BY-NC-ND-4.0
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
//===========================================================================
// Reflection and meta
//===========================================================================
#include "parse.h"
#include "cpp2regex.h"
using namespace cpp2::regex;
#line 22 "reflect.h2"
namespace cpp2 {
namespace meta {
#line 34 "reflect.h2"
class compiler_services
{
#line 38 "reflect.h2"
private: std::vector<error_entry>* errors;
private: std::set<std::string>* includes;
private: int errors_original_size;
private: stable_vector<token>* generated_tokens;
private: cpp2::parser parser;
private: std::string metafunction_name {};
private: std::vector<std::string> metafunction_args {};
private: bool metafunctions_used {false};
#line 49 "reflect.h2"
public: explicit compiler_services(
std::vector<error_entry>* errors_,
std::set<std::string>* includes_,
stable_vector<token>* generated_tokens_
);
#line 65 "reflect.h2"
public: auto set_metafunction_name(cpp2::impl::in<std::string_view> name, cpp2::impl::in<std::vector<std::string>> args) & -> void;
#line 71 "reflect.h2"
public: [[nodiscard]] auto get_metafunction_name() const& -> std::string_view;
public: [[nodiscard]] auto get_argument(cpp2::impl::in<int> index) & -> std::string;
#line 81 "reflect.h2"
public: [[nodiscard]] auto get_arguments() & -> std::vector<std::string>;
#line 86 "reflect.h2"
public: [[nodiscard]] auto arguments_were_used() const& -> bool;
using parse_statement_ret = std::unique_ptr<statement_node>;
#line 88 "reflect.h2"
protected: [[nodiscard]] auto parse_statement(
std::string_view source
) & -> parse_statement_ret;
#line 141 "reflect.h2"
public: [[nodiscard]] auto add_runtime_support_include(cpp2::impl::in<std::string_view> s) & -> decltype(auto);
public: [[nodiscard]] virtual auto position() const -> source_position;
#line 152 "reflect.h2"
public: auto require(
cpp2::impl::in<bool> b,
cpp2::impl::in<std::string_view> msg
) const& -> void;
#line 163 "reflect.h2"
public: auto error(cpp2::impl::in<std::string_view> msg) const& -> void;
#line 175 "reflect.h2"
public: auto report_violation(auto const& msg) const& -> void;
#line 183 "reflect.h2"
public: [[nodiscard]] auto is_active() const& -> decltype(auto);
public: virtual ~compiler_services() noexcept;
public: compiler_services(compiler_services const& that);
#line 184 "reflect.h2"
};
#line 233 "reflect.h2"
class declaration_base
: public compiler_services {
#line 237 "reflect.h2"
protected: declaration_node* n;
protected: explicit declaration_base(
declaration_node* n_,
cpp2::impl::in<compiler_services> s
);
#line 250 "reflect.h2"
public: [[nodiscard]] auto position() const -> source_position override;
public: [[nodiscard]] auto print() const& -> std::string;
public: virtual ~declaration_base() noexcept;
public: declaration_base(declaration_base const& that);
#line 253 "reflect.h2"
};
#line 259 "reflect.h2"
class declaration
: public declaration_base {
#line 263 "reflect.h2"
public: explicit declaration(
declaration_node* n_,
cpp2::impl::in<compiler_services> s
);
#line 272 "reflect.h2"
public: [[nodiscard]] auto is_public() const& -> bool;
public: [[nodiscard]] auto is_protected() const& -> bool;
public: [[nodiscard]] auto is_private() const& -> bool;
public: [[nodiscard]] auto is_default_access() const& -> bool;
public: [[nodiscard]] auto default_to_public() & -> decltype(auto);
public: [[nodiscard]] auto default_to_protected() & -> decltype(auto);
public: [[nodiscard]] auto default_to_private() & -> decltype(auto);
public: [[nodiscard]] auto make_public() & -> bool;
public: [[nodiscard]] auto make_protected() & -> bool;
public: [[nodiscard]] auto make_private() & -> bool;
public: [[nodiscard]] auto has_name() const& -> bool;
public: [[nodiscard]] auto has_name(cpp2::impl::in<std::string_view> s) const& -> bool;
public: [[nodiscard]] auto name() const& -> std::string_view;
#line 293 "reflect.h2"
public: [[nodiscard]] auto has_initializer() const& -> bool;
public: [[nodiscard]] auto is_global() const& -> bool;
public: [[nodiscard]] auto is_function() const& -> bool;
public: [[nodiscard]] auto is_object() const& -> bool;
public: [[nodiscard]] auto is_base_object() const& -> bool;
public: [[nodiscard]] auto is_member_object() const& -> bool;
public: [[nodiscard]] auto is_type() const& -> bool;
public: [[nodiscard]] auto is_namespace() const& -> bool;
public: [[nodiscard]] auto is_alias() const& -> bool;
public: [[nodiscard]] auto is_type_alias() const& -> bool;
public: [[nodiscard]] auto is_namespace_alias() const& -> bool;
public: [[nodiscard]] auto is_object_alias() const& -> bool;
public: [[nodiscard]] auto is_function_expression() const& -> bool;
public: [[nodiscard]] auto as_function() const& -> function_declaration;
public: [[nodiscard]] auto as_object() const& -> object_declaration;
public: [[nodiscard]] auto as_type() const& -> type_declaration;
public: [[nodiscard]] auto as_alias() const& -> alias_declaration;
public: [[nodiscard]] auto get_parent() const& -> declaration;
public: [[nodiscard]] auto parent_is_function() const& -> bool;
public: [[nodiscard]] auto parent_is_object() const& -> bool;
public: [[nodiscard]] auto parent_is_type() const& -> bool;
public: [[nodiscard]] auto parent_is_namespace() const& -> bool;
public: [[nodiscard]] auto parent_is_alias() const& -> bool;
public: [[nodiscard]] auto parent_is_type_alias() const& -> bool;
public: [[nodiscard]] auto parent_is_namespace_alias() const& -> bool;
public: [[nodiscard]] auto parent_is_object_alias() const& -> bool;
public: [[nodiscard]] auto parent_is_polymorphic() const& -> bool;
public: auto mark_for_removal_from_enclosing_type() & -> void;
public: virtual ~declaration() noexcept;
public: declaration(declaration const& that);
#line 335 "reflect.h2"
};
#line 341 "reflect.h2"
class function_declaration
: public declaration {
#line 345 "reflect.h2"
public: explicit function_declaration(
declaration_node* n_,
cpp2::impl::in<compiler_services> s
);
#line 355 "reflect.h2"
public: [[nodiscard]] auto index_of_parameter_named(cpp2::impl::in<std::string_view> s) const& -> int;
public: [[nodiscard]] auto has_parameter_named(cpp2::impl::in<std::string_view> s) const& -> bool;
public: [[nodiscard]] auto has_in_parameter_named(cpp2::impl::in<std::string_view> s) const& -> bool;
public: [[nodiscard]] auto has_in_ref_parameter_named(cpp2::impl::in<std::string_view> s) const& -> bool;
public: [[nodiscard]] auto has_copy_parameter_named(cpp2::impl::in<std::string_view> s) const& -> bool;
public: [[nodiscard]] auto has_inout_parameter_named(cpp2::impl::in<std::string_view> s) const& -> bool;
public: [[nodiscard]] auto has_out_parameter_named(cpp2::impl::in<std::string_view> s) const& -> bool;
public: [[nodiscard]] auto has_move_parameter_named(cpp2::impl::in<std::string_view> s) const& -> bool;
public: [[nodiscard]] auto has_forward_parameter_named(cpp2::impl::in<std::string_view> s) const& -> bool;
public: [[nodiscard]] auto first_parameter_name() const& -> std::string;
public: [[nodiscard]] auto has_parameter_with_name_and_pass(cpp2::impl::in<std::string_view> s, cpp2::impl::in<passing_style> pass) const& -> bool;
public: [[nodiscard]] auto is_function_with_this() const& -> bool;
public: [[nodiscard]] auto is_virtual() const& -> bool;
public: [[nodiscard]] auto is_defaultable() const& -> bool;
public: [[nodiscard]] auto is_constructor() const& -> bool;
public: [[nodiscard]] auto is_default_constructor() const& -> bool;
public: [[nodiscard]] auto is_move() const& -> bool;
public: [[nodiscard]] auto is_swap() const& -> bool;
public: [[nodiscard]] auto is_constructor_with_that() const& -> bool;
public: [[nodiscard]] auto is_constructor_with_in_that() const& -> bool;
public: [[nodiscard]] auto is_constructor_with_move_that() const& -> bool;
public: [[nodiscard]] auto is_assignment() const& -> bool;
public: [[nodiscard]] auto is_assignment_with_that() const& -> bool;
public: [[nodiscard]] auto is_assignment_with_in_that() const& -> bool;
public: [[nodiscard]] auto is_assignment_with_move_that() const& -> bool;
public: [[nodiscard]] auto is_destructor() const& -> bool;
public: [[nodiscard]] auto is_copy_or_move() const& -> bool;
public: [[nodiscard]] auto has_declared_return_type() const& -> bool;
public: [[nodiscard]] auto has_deduced_return_type() const& -> bool;
public: [[nodiscard]] auto has_bool_return_type() const& -> bool;
public: [[nodiscard]] auto has_non_void_return_type() const& -> bool;
public: [[nodiscard]] auto unnamed_return_type() const& -> std::string;
public: [[nodiscard]] auto get_parameters() const& -> std::vector<object_declaration>;
#line 403 "reflect.h2"
public: [[nodiscard]] auto is_binary_comparison_function() const& -> bool;
public: [[nodiscard]] auto default_to_virtual() & -> decltype(auto);
public: [[nodiscard]] auto make_virtual() & -> bool;
public: auto add_initializer(cpp2::impl::in<std::string_view> source) & -> void;
public: function_declaration(function_declaration const& that);
#line 426 "reflect.h2"
};
#line 432 "reflect.h2"
class object_declaration
: public declaration {
#line 436 "reflect.h2"
public: explicit object_declaration(
declaration_node* n_,
cpp2::impl::in<compiler_services> s
);
#line 446 "reflect.h2"
public: [[nodiscard]] auto is_const() const& -> bool;
public: [[nodiscard]] auto has_wildcard_type() const& -> bool;
public: [[nodiscard]] auto type() const& -> std::string;
#line 456 "reflect.h2"
public: [[nodiscard]] auto initializer() const& -> std::string;
public: object_declaration(object_declaration const& that);
#line 462 "reflect.h2"
};
#line 468 "reflect.h2"
class type_declaration
: public declaration {
#line 472 "reflect.h2"
public: explicit type_declaration(
declaration_node* n_,
cpp2::impl::in<compiler_services> s
);
#line 482 "reflect.h2"
public: auto reserve_names(cpp2::impl::in<std::string_view> name, auto&& ...etc) const& -> void;
#line 496 "reflect.h2"
public: [[nodiscard]] auto is_polymorphic() const& -> bool;
public: [[nodiscard]] auto is_final() const& -> bool;
public: [[nodiscard]] auto make_final() & -> bool;
public: [[nodiscard]] auto get_member_functions() const& -> std::vector<function_declaration>;
#line 511 "reflect.h2"
public: [[nodiscard]] auto get_member_functions_needing_initializer() const& -> std::vector<function_declaration>;
#line 526 "reflect.h2"
public: [[nodiscard]] auto get_member_objects() const& -> std::vector<object_declaration>;
#line 536 "reflect.h2"
public: [[nodiscard]] auto get_member_types() const& -> std::vector<type_declaration>;
#line 546 "reflect.h2"
public: [[nodiscard]] auto get_member_aliases() const& -> std::vector<alias_declaration>;
#line 556 "reflect.h2"
public: [[nodiscard]] auto get_members() const& -> std::vector<declaration>;
struct query_declared_value_set_functions_ret { bool out_this_in_that; bool out_this_move_that; bool inout_this_in_that; bool inout_this_move_that; };
#line 566 "reflect.h2"
public: [[nodiscard]] auto query_declared_value_set_functions() const& -> query_declared_value_set_functions_ret;
#line 582 "reflect.h2"
public: auto add_member(cpp2::impl::in<std::string_view> source) & -> void;
#line 596 "reflect.h2"
public: [[nodiscard]] auto remove_marked_members() & -> decltype(auto);
public: [[nodiscard]] auto remove_all_members() & -> decltype(auto);
public: [[nodiscard]] auto disable_member_function_generation() & -> decltype(auto);
public: type_declaration(type_declaration const& that);
#line 600 "reflect.h2"
};
#line 606 "reflect.h2"
class alias_declaration
: public declaration {
#line 610 "reflect.h2"
public: explicit alias_declaration(
declaration_node* n_,
cpp2::impl::in<compiler_services> s
);
public: alias_declaration(alias_declaration const& that);
#line 619 "reflect.h2"
};
#line 634 "reflect.h2"
auto add_virtual_destructor(meta::type_declaration& t) -> void;
#line 652 "reflect.h2"
auto interface(meta::type_declaration& t) -> void;
#line 698 "reflect.h2"
auto polymorphic_base(meta::type_declaration& t) -> void;
#line 743 "reflect.h2"
auto ordered_impl(
meta::type_declaration& t,
cpp2::impl::in<std::string_view> ordering
) -> void;
#line 772 "reflect.h2"
auto ordered(meta::type_declaration& t) -> void;
#line 780 "reflect.h2"
auto weakly_ordered(meta::type_declaration& t) -> void;
#line 788 "reflect.h2"
auto partially_ordered(meta::type_declaration& t) -> void;
#line 810 "reflect.h2"
auto copyable(meta::type_declaration& t) -> void;
#line 843 "reflect.h2"
auto hashable(meta::type_declaration& t) -> void;
#line 876 "reflect.h2"
auto basic_value(meta::type_declaration& t) -> void;
#line 904 "reflect.h2"
auto value(meta::type_declaration& t) -> void;
#line 910 "reflect.h2"
auto weakly_ordered_value(meta::type_declaration& t) -> void;
#line 916 "reflect.h2"
auto partially_ordered_value(meta::type_declaration& t) -> void;
#line 945 "reflect.h2"
auto cpp1_rule_of_zero(meta::type_declaration& t) -> void;
#line 987 "reflect.h2"
auto cpp2_struct(meta::type_declaration& t) -> void;
#line 1056 "reflect.h2"
class value_member_info {
public: std::string name;
public: std::string type;
public: std::string value;
public: value_member_info(auto const& name_, auto const& type_, auto const& value_);
#line 1060 "reflect.h2"
};
auto basic_enum(
meta::type_declaration& t,
auto const& nextval,
cpp2::impl::in<bool> bitwise
) -> void;
#line 1326 "reflect.h2"
auto cpp2_enum(meta::type_declaration& t) -> void;
#line 1353 "reflect.h2"
auto flag_enum(meta::type_declaration& t) -> void;
#line 1399 "reflect.h2"
auto cpp2_union(meta::type_declaration& t) -> void;
#line 1550 "reflect.h2"
auto print(cpp2::impl::in<meta::type_declaration> t) -> void;
#line 1570 "reflect.h2"
using error_func = std::function<void(cpp2::impl::in<std::string> x)>;
#line 1574 "reflect.h2"
class expression_flags
{
private: cpp2::u8 _value; private: constexpr expression_flags(cpp2::impl::in<cpp2::i64> _val);
private: constexpr auto operator=(cpp2::impl::in<cpp2::i64> _val) -> expression_flags& ;
public: constexpr auto operator|=(expression_flags const& that) & -> decltype(auto);
public: constexpr auto operator&=(expression_flags const& that) & -> decltype(auto);
public: constexpr auto operator^=(expression_flags const& that) & -> decltype(auto);
public: [[nodiscard]] constexpr auto operator|(expression_flags const& that) const& -> expression_flags;
public: [[nodiscard]] constexpr auto operator&(expression_flags const& that) const& -> expression_flags;
public: [[nodiscard]] constexpr auto operator^(expression_flags const& that) const& -> expression_flags;
public: [[nodiscard]] constexpr auto has(expression_flags const& that) const& -> bool;
public: constexpr auto set(expression_flags const& that) & -> void;
public: constexpr auto clear(expression_flags const& that) & -> void;
public: static const expression_flags case_insensitive;
public: static const expression_flags multiple_lines;
public: static const expression_flags single_line;
public: static const expression_flags no_group_captures;
public: static const expression_flags perl_code_syntax;
public: static const expression_flags perl_code_syntax_in_classes;
public: static const expression_flags none;
public: [[nodiscard]] constexpr auto get_raw_value() const& -> cpp2::u8;
public: constexpr explicit expression_flags();
public: constexpr expression_flags(expression_flags const& that);
public: constexpr auto operator=(expression_flags const& that) -> expression_flags& ;
public: constexpr expression_flags(expression_flags&& that) noexcept;
public: constexpr auto operator=(expression_flags&& that) noexcept -> expression_flags& ;
public: [[nodiscard]] auto operator<=>(expression_flags const& that) const& -> std::strong_ordering = default;
public: [[nodiscard]] auto to_string_impl(cpp2::impl::in<std::string_view> prefix, cpp2::impl::in<std::string_view> separator) const& -> std::string;
public: [[nodiscard]] auto to_string() const& -> std::string;
public: [[nodiscard]] auto to_code() const& -> std::string;
public: [[nodiscard]] static auto from_string(cpp2::impl::in<std::string_view> s) -> expression_flags;
public: [[nodiscard]] static auto from_code(cpp2::impl::in<std::string_view> s) -> expression_flags;
#line 1582 "reflect.h2"
};
#line 1590 "reflect.h2"
class regex_token
{
public: std::string string_rep;
public: explicit regex_token(cpp2::impl::in<std::string> str);
#line 1598 "reflect.h2"
public: explicit regex_token();
#line 1603 "reflect.h2"
public: virtual auto generate_code([[maybe_unused]] generation_context& unnamed_param_2) const -> void = 0;
public: virtual auto add_groups([[maybe_unused]] std::set<int>& unnamed_param_2) const -> void;
public: [[nodiscard]] auto to_string() const& -> std::string;
public: auto set_string(cpp2::impl::in<std::string> s) & -> void;
public: virtual ~regex_token() noexcept;
public: regex_token(regex_token const&) = delete; /* No 'that' constructor, suppress copy */
public: auto operator=(regex_token const&) -> void = delete;
#line 1608 "reflect.h2"
};
using token_ptr = std::shared_ptr<regex_token>;
using token_vec = std::vector<token_ptr>;
#line 1614 "reflect.h2"
// Adds a check in code generation.
//
class regex_token_check
: public regex_token {
#line 1620 "reflect.h2"
private: std::string check;
public: explicit regex_token_check(cpp2::impl::in<std::string> str, cpp2::impl::in<std::string> check_);
#line 1627 "reflect.h2"
public: auto generate_code(generation_context& ctx) const -> void override;
public: virtual ~regex_token_check() noexcept;
public: regex_token_check(regex_token_check const&) = delete; /* No 'that' constructor, suppress copy */
public: auto operator=(regex_token_check const&) -> void = delete;
#line 1630 "reflect.h2"
};
#line 1633 "reflect.h2"
// Adds code in code generation.
//
class regex_token_code
: public regex_token {
#line 1639 "reflect.h2"
private: std::string code;
public: explicit regex_token_code(cpp2::impl::in<std::string> str, cpp2::impl::in<std::string> code_);
#line 1646 "reflect.h2"
public: auto generate_code(generation_context& ctx) const -> void override;
public: virtual ~regex_token_code() noexcept;
public: regex_token_code(regex_token_code const&) = delete; /* No 'that' constructor, suppress copy */
public: auto operator=(regex_token_code const&) -> void = delete;
#line 1649 "reflect.h2"
};
#line 1652 "reflect.h2"
// Token that does not influence the matching. E.g. comment.
//
class regex_token_empty
: public regex_token {
#line 1658 "reflect.h2"
public: explicit regex_token_empty(cpp2::impl::in<std::string> str);
#line 1662 "reflect.h2"
public: auto generate_code([[maybe_unused]] generation_context& unnamed_param_2) const -> void override;
public: virtual ~regex_token_empty() noexcept;
public: regex_token_empty(regex_token_empty const&) = delete; /* No 'that' constructor, suppress copy */
public: auto operator=(regex_token_empty const&) -> void = delete;
#line 1665 "reflect.h2"
};
#line 1668 "reflect.h2"
// Represents a list of regex tokens as one token.
//
class regex_token_list
: public regex_token {
#line 1674 "reflect.h2"
public: token_vec tokens;
public: explicit regex_token_list(cpp2::impl::in<token_vec> t);
#line 1681 "reflect.h2"
public: auto generate_code(generation_context& ctx) const -> void override;
#line 1687 "reflect.h2"
public: auto add_groups(std::set<int>& groups) const -> void override;
#line 1693 "reflect.h2"
public: [[nodiscard]] static auto gen_string(cpp2::impl::in<token_vec> vec) -> std::string;
public: virtual ~regex_token_list() noexcept;
public: regex_token_list(regex_token_list const&) = delete; /* No 'that' constructor, suppress copy */
public: auto operator=(regex_token_list const&) -> void = delete;
#line 1700 "reflect.h2"
};
#line 1703 "reflect.h2"
//
// Parse and generation context.
//
// State of the current capturing group. See '(<pattern>)'
//
class parse_context_group_state
{
public: token_vec cur_match_list {}; // Current list of matchers.
public: token_vec alternate_match_lists {}; // List of alternate matcher lists. E.g. ab|cd|xy.
public: expression_flags modifiers {}; // Current modifiers for the group/regular expression.
// Start a new alternative.
public: auto next_alternative() & -> void;
#line 1723 "reflect.h2"
// Swap this state with the other one. NOLINTNEXTLINE(performance-noexcept-swap)
public: auto swap(parse_context_group_state& t) & -> void;
#line 1730 "reflect.h2"
// Convert this state into a regex token.
public: [[nodiscard]] auto get_as_token() & -> token_ptr;
#line 1742 "reflect.h2"
// Add a token to the current matcher list.
public: auto add(cpp2::impl::in<token_ptr> token) & -> void;
#line 1747 "reflect.h2"
// True if current matcher list is empty.
public: [[nodiscard]] auto empty() const& -> bool;
#line 1751 "reflect.h2"
// Apply optimizations to the matcher list.
public: static auto post_process_list(token_vec& list) -> void;
public: parse_context_group_state(auto const& cur_match_list_, auto const& alternate_match_lists_, auto const& modifiers_);
public: parse_context_group_state();
#line 1765 "reflect.h2"
};
#line 1768 "reflect.h2"
// State for the branch reset. Takes care of the group numbering. See '(|<pattern>)'.
//
class parse_context_branch_reset_state
{
public: bool is_active {false}; // If we have a branch reset group.
public: int cur_group {1}; // Next group identifier. 0 == global capture group.
public: int max_group {1}; // Maximum group identifier generated.
public: int from {1}; // Starting identifier on new alternative branch.
// Next group identifier.
public: [[nodiscard]] auto next() & -> int;
#line 1786 "reflect.h2"
// Set next group identifier.
public: auto set_next(cpp2::impl::in<int> g) & -> void;
#line 1792 "reflect.h2"
// Start a new alternative branch.
public: auto next_alternative() & -> void;
#line 1799 "reflect.h2"
// Initialize for a branch reset group.
public: auto set_active_reset(cpp2::impl::in<int> restart) & -> void;
public: parse_context_branch_reset_state(auto const& is_active_, auto const& cur_group_, auto const& max_group_, auto const& from_);
public: parse_context_branch_reset_state();
#line 1806 "reflect.h2"
};
#line 1809 "reflect.h2"
// Context during parsing of the regular expressions.
//
// Keeps track of the distributed group identifiers, current parsed group and branch resets.
//
class parse_context
{
private: std::string_view regex; // Regular expression string.
private: size_t pos {0}; // Current parsing position.
private: token_ptr root; // Token representing the regular expression.
private: parse_context_group_state cur_group_state {};
private: parse_context_branch_reset_state cur_branch_reset_state {};
#line 1823 "reflect.h2"
public: std::map<std::string,int> named_groups {};
private: error_func error_out; // TODO: Declaring std::function<void(std::string)> fails for cpp2.
private: bool has_error {false};
public: explicit parse_context(cpp2::impl::in<std::string_view> r, auto const& e);
#line 1834 "reflect.h2"
// State management functions
//
// Returned group state needs to be stored and provided in `end_group`.
public: [[nodiscard]] auto start_group() & -> parse_context_group_state;
#line 1847 "reflect.h2"
// `old_state` argument needs to be from start group.
public: [[nodiscard]] auto end_group(cpp2::impl::in<parse_context_group_state> old_state) & -> token_ptr;
#line 1855 "reflect.h2"
public: [[nodiscard]] auto get_modifiers() const& -> expression_flags;
#line 1859 "reflect.h2"
public: auto set_modifiers(cpp2::impl::in<expression_flags> mod) & -> void;
#line 1863 "reflect.h2"
// Branch reset management functions
//
public: [[nodiscard]] auto branch_reset_new_state() & -> parse_context_branch_reset_state;
#line 1875 "reflect.h2"
public: auto branch_reset_restore_state(cpp2::impl::in<parse_context_branch_reset_state> old_state) & -> void;
#line 1882 "reflect.h2"
public: auto next_alternative() & -> void;
#line 1888 "reflect.h2"
// Regex token management
//
public: auto add_token(cpp2::impl::in<token_ptr> token) & -> void;
#line 1894 "reflect.h2"
public: [[nodiscard]] auto has_token() const& -> bool;
#line 1898 "reflect.h2"
public: [[nodiscard]] auto pop_token() & -> token_ptr;
#line 1909 "reflect.h2"
public: [[nodiscard]] auto get_as_token() & -> token_ptr;
#line 1913 "reflect.h2"
// Group management
//
public: [[nodiscard]] auto get_cur_group() const& -> int;
#line 1919 "reflect.h2"
public: [[nodiscard]] auto next_group() & -> int;
#line 1923 "reflect.h2"
public: auto set_named_group(cpp2::impl::in<std::string> name, cpp2::impl::in<int> id) & -> void;
#line 1930 "reflect.h2"
public: [[nodiscard]] auto get_named_group(cpp2::impl::in<std::string> name) const& -> int;
#line 1941 "reflect.h2"
// Position management functions
//
public: [[nodiscard]] auto current() const& -> char;
// Get the next token in the regex, skipping spaces according to the parameters. See `x` and `xx` modifiers.
private: [[nodiscard]] auto get_next_position(cpp2::impl::in<bool> in_class, cpp2::impl::in<bool> no_skip) const& -> size_t;
#line 1985 "reflect.h2"
// Return true if next token is available.
private: [[nodiscard]] auto next_impl(cpp2::impl::in<bool> in_class, cpp2::impl::in<bool> no_skip) & -> bool;
#line 1997 "reflect.h2"
public: [[nodiscard]] auto next() & -> decltype(auto);
public: [[nodiscard]] auto next_in_class() & -> decltype(auto);
public: [[nodiscard]] auto next_no_skip() & -> decltype(auto);
public: [[nodiscard]] auto next_n(cpp2::impl::in<int> n) & -> bool;
#line 2010 "reflect.h2"
public: [[nodiscard]] auto has_next() const& -> bool;
private: [[nodiscard]] auto grab_until_impl(cpp2::impl::in<std::string> e, cpp2::impl::out<std::string> r, cpp2::impl::in<bool> any) & -> bool;
#line 2033 "reflect.h2"
public: [[nodiscard]] auto grab_until(cpp2::impl::in<std::string> e, cpp2::impl::out<std::string> r) & -> decltype(auto);
public: [[nodiscard]] auto grab_until(cpp2::impl::in<char> e, cpp2::impl::out<std::string> r) & -> decltype(auto);
public: [[nodiscard]] auto grab_until_one_of(cpp2::impl::in<std::string> e, cpp2::impl::out<std::string> r) & -> decltype(auto);
public: [[nodiscard]] auto grab_n(cpp2::impl::in<int> n, cpp2::impl::out<std::string> r) & -> bool;
#line 2050 "reflect.h2"
public: [[nodiscard]] auto grab_number() & -> std::string;
#line 2071 "reflect.h2"
private: [[nodiscard]] auto peek_impl(cpp2::impl::in<bool> in_class) const& -> char;
#line 2081 "reflect.h2"
public: [[nodiscard]] auto peek() const& -> decltype(auto);
public: [[nodiscard]] auto peek_in_class() const& -> decltype(auto);
#line 2085 "reflect.h2"
// Parsing functions
//
public: [[nodiscard]] auto parser_group_modifiers(cpp2::impl::in<std::string> change_str, expression_flags& parser_modifiers) & -> bool;
#line 2141 "reflect.h2"
public: [[nodiscard]] auto parse_until(cpp2::impl::in<char> term) & -> bool;
#line 2179 "reflect.h2"
public: [[nodiscard]] auto parse(cpp2::impl::in<std::string> modifiers) & -> bool;
#line 2194 "reflect.h2"
// Misc functions
public: [[nodiscard]] auto get_pos() const& -> decltype(auto);
public: [[nodiscard]] auto get_range(cpp2::impl::in<size_t> start, cpp2::impl::in<size_t> end) const& -> decltype(auto);
public: [[nodiscard]] auto valid() const& -> bool;
public: [[nodiscard]] auto error(cpp2::impl::in<std::string> err) & -> token_ptr;
public: parse_context(parse_context const&) = delete; /* No 'that' constructor, suppress copy */
public: auto operator=(parse_context const&) -> void = delete;
#line 2205 "reflect.h2"
};
#line 2208 "reflect.h2"
// Context for one function generation. Generation of functions can be interleaved,
// therefore we buffer the code for one function here.
//
class generation_function_context {
public: std::string code {""};
public: std::string tabs {""};
public: auto add_tabs(cpp2::impl::in<int> c) & -> void;
#line 2222 "reflect.h2"
public: auto remove_tabs(cpp2::impl::in<int> c) & -> void;
public: generation_function_context(auto const& code_, auto const& tabs_);
public: generation_function_context();
#line 2225 "reflect.h2"
};
#line 2228 "reflect.h2"
// Context for generating the state machine.
class generation_context
{
private: std::vector<generation_function_context> gen_stack {1}; // Element 0 contains all the code.
private: int matcher_func {0};
private: int reset_func {0};
private: int temp_name {0};
private: std::string entry_func {""};
// Generation helpers
//
public: [[nodiscard]] auto match_parameters() const& -> std::string;
// Code generation.
// Add code line.
public: auto add(cpp2::impl::in<std::string> s) & -> void;
#line 2250 "reflect.h2"
// Add check for token. The check needs to be a function call that returns a boolean.
public: auto add_check(cpp2::impl::in<std::string> check) & -> void;
#line 2256 "reflect.h2"
// Add a stateful check. The check needs to return a `match_return`.
public: auto add_statefull(cpp2::impl::in<std::string> next_func, cpp2::impl::in<std::string> check) & -> void;
#line 2265 "reflect.h2"
protected: auto start_func_named(cpp2::impl::in<std::string> name) & -> void;
#line 2276 "reflect.h2"
protected: [[nodiscard]] auto start_func() & -> std::string;
#line 2283 "reflect.h2"
protected: auto end_func_statefull(cpp2::impl::in<std::string> s) & -> void;
#line 2302 "reflect.h2"
// Generate the function for a token.
public: [[nodiscard]] auto generate_func(cpp2::impl::in<token_ptr> token) & -> std::string;
#line 2312 "reflect.h2"
// Generate the reset for a list of group identifiers.
public: [[nodiscard]] auto generate_reset(cpp2::impl::in<std::set<int>> groups) & -> std::string;
#line 2335 "reflect.h2"
// Name generation
//
protected: [[nodiscard]] auto gen_func_name() & -> std::string;
#line 2343 "reflect.h2"
public: [[nodiscard]] auto next_func_name() & -> std::string;