YSTest: NPLA.h 源文件

YSTest PreAlpha_b900_20201012 The YSLib Test Project

NPLA.h
浏览该文件的文档.
1 /*
2 © 2014-2020 FrankHB.
3
4 This file is part of the YSLib project, and may only be used,
5 modified, and distributed under the terms of the YSLib project
6 license, LICENSE.TXT. By continuing to use, modify, or distribute
7 this file you indicate that you have read the license and
8 understand and accept it fully.
9 */
10
28 #ifndef NPL_INC_NPLA_h_
29 #define NPL_INC_NPLA_h_ 1
30
31 #include "YModules.h"
32 #include YFM_NPL_SContext // for YSLib::any_ops, YSLib::NodeLiteral, YSLib::any,
33 // YSLib::bad_any_cast, YSLib::in_place_type, YSLib::to_string, NPLTag, string,
34 // ValueNode, function, std::ostream, TermNode, YSLib::MakeIndex,
35 // std::initializer_list, LoggedEvent, YSLib::RecordLevel, shared_ptr,
36 // NPL::Deref, ystdex::isdigit, ystdex::is_nothrow_copy_constructible,
37 // ystdex::is_nothrow_copy_assignable, ystdex::is_nothrow_move_constructible,
38 // ystdex::is_nothrow_move_assignable, observer_ptr, ystdex::type_id,
39 // std::addressof, NPL::make_observer, ystdex::equality_comparable, weak_ptr,
40 // lref, ystdex::get_equal_to, pair, ystdex::expand_proxy, NPL::Access,
41 // ystdex::ref_eq, ValueObject, NPL::SetContentWith, std::for_each,
42 // AccessFirstSubterm, ystdex::less, YSLib::map, pmr, ystdex::copy_and_swap,
43 // NoContainer, ystdex::try_emplace, ystdex::try_emplace_hint,
44 // ystdex::insert_or_assign, ystdex::type_info, ystdex::expanded_function,
45 // YSLib::forward_list, ystdex::swap_dependent, YSLib::allocate_shared,
46 // ystdex::enable_if_same_param_t, ystdex::exclude_self_t,
47 // ystdex::make_obj_using_allocator, ystdex::exchange, NPL::AsTermNode;
48 #include <ystdex/base.h> // for ystdex::derived_entity;
49 #include <libdefect/exception.h> // for std::exception_ptr;
50
51 namespace NPL
52 {
53
61 namespace any_ops = YSLib::any_ops;
63
65 using YSLib::NodeLiteral;
67 using YSLib::any;
69 using YSLib::bad_any_cast;
71 using YSLib::in_place_type;
73 using YSLib::to_string;
74
75
81 struct YF_API NPLATag : NPLTag
82 {};
83
84
94 YB_ATTR_nodiscard YF_API YB_PURE string
95 DecodeNodeIndex(const string&);
96
97
99 using NodeToString = function<string(const ValueNode&)>;
100
107 YB_ATTR_nodiscard YF_API YB_PURE string
108 EscapeNodeLiteral(const ValueNode&);
109
117 YB_ATTR_nodiscard YF_API YB_PURE string
118 LiteralizeEscapeNodeLiteral(const ValueNode&);
119
126 YB_ATTR_nodiscard YF_API YB_PURE string
127 ParseNPLANodeString(const ValueNode&);
128
129
131
132 using IndentGenerator = function<string(size_t)>;
134
136 YB_ATTR_nodiscard YF_API YB_PURE string
137 DefaultGenerateIndent(size_t);
138
140
141
145 YF_API void
146 PrintIndent(std::ostream&, IndentGenerator = DefaultGenerateIndent, size_t = 1);
147
152 template<typename _func, typename _fCallable>
153 void
154 PrintContainedNodes(_func print_bound, _fCallable f)
155 {
156 print_bound('(');
157 TryExpr(ystdex::invoke(f))
158 CatchIgnore(std::out_of_range&)
159 print_bound(')');
160 }
161
177 YF_API void
178 PrintNode(std::ostream&, const ValueNode&, NodeToString = EscapeNodeLiteral,
179 IndentGenerator = DefaultGenerateIndent, size_t = 0);
180
191 YF_API bool
192 PrintNodeString(std::ostream&, const ValueNode&,
193 NodeToString = EscapeNodeLiteral);
195
196
197
204 YB_ATTR_nodiscard YF_API YB_PURE string
205 ParseNPLATermString(const TermNode&);
206
207
216 YB_ATTR_nodiscard YF_API YB_PURE ValueNode
217 MapNPLALeafNode(const TermNode&);
218
234 YB_ATTR_nodiscard YF_API YB_PURE TermNode
235 TransformToSyntaxNode(ValueNode&&);
236 YB_ATTR_nodiscard YB_PURE inline
237 PDefH(TermNode, TransformToSyntaxNode, NodeLiteral&& nl)
238 ImplRet(TransformToSyntaxNode(std::move(nl.GetNodeRef())))
240
241
242
244
250
252 template<class _tNodeOrCon, typename... _tParams>
253 TNIter
254 InsertSyntaxNode(_tNodeOrCon&& node_or_con,
255 std::initializer_list<TermNode> il, _tParams&&... args)
256 {
257 return node_or_con.emplace(TermNode::Container(il), yforward(args)...);
258 }
259 template<class _tNodeOrCon, typename _type, typename... _tParams>
260 TNIter
261 InsertSyntaxNode(_tNodeOrCon&& node_or_con, _type&& arg, _tParams&&... args)
262 {
263 return node_or_con.emplace(yforward(arg), yforward(args)...);
264 }
266
268
269 template<class _tNodeOrCon>
270 TNIter
271 InsertChildSyntaxNode(_tNodeOrCon&& node_or_con, TermNode& child)
272 {
273 return NPL::InsertSyntaxNode(yforward(node_or_con),
274 child.GetContainerRef());
275 }
276 template<class _tNodeOrCon>
277 TNIter
278 InsertChildSyntaxNode(_tNodeOrCon&& node_or_con, TermNode&& child)
279 {
280 return NPL::InsertSyntaxNode(yforward(node_or_con),
281 std::move(child.GetContainerRef()));
282 }
283 template<class _tNodeOrCon>
284 TNIter
285 InsertChildSyntaxNode(_tNodeOrCon&& node_or_con, NodeLiteral&& nl)
286 {
287 return NPL::InsertChildSyntaxNode(yforward(node_or_con),
288 TransformToSyntaxNode(std::move(nl.GetNodeRef())));
289 }
291
292
293
295 namespace SXML
296 {
297
299
300
305 YB_ATTR_nodiscard YF_API YB_PURE string
306 ConvertAttributeNodeString(const TermNode&);
307
320 YB_ATTR_nodiscard YF_API string
321 ConvertDocumentNode(const TermNode&, IndentGenerator = DefaultGenerateIndent,
322 size_t = 0, ParseOption = ParseOption::Normal);
323
328 YB_ATTR_nodiscard YF_API YB_PURE string
329 ConvertStringNode(const TermNode&);
330
339 YF_API void
340 PrintSyntaxNode(std::ostream& os, const TermNode&,
341 IndentGenerator = DefaultGenerateIndent, size_t = 0);
343
344
346
347 template<typename _tString, typename _tLiteral = NodeLiteral>
348 YB_ATTR_nodiscard inline YB_PURE TermNode
349 NodeLiteralToTerm(_tString&& name, std::initializer_list<_tLiteral> il)
350 {
351 return TermNode(YSLib::AsNodeLiteral(yforward(name), il));
352 }
353
355
356 template<typename... _tParams>
357 YB_ATTR_nodiscard YB_PURE TermNode
358 MakeTop(const string& name, _tParams&&... args)
359 {
360 return SXML::NodeLiteralToTerm(name,
361 {{MakeIndex(0), "*TOP*"}, NodeLiteral(yforward(args))...});
362 }
363 YB_ATTR_nodiscard YB_PURE inline PDefH(TermNode, MakeTop, )
364 ImplRet(MakeTop({}))
366
373 YB_ATTR_nodiscard YF_API YB_PURE TermNode
374 MakeXMLDecl(const string& = {}, const string& = "1.0",
375 const string& = "UTF-8", const string& = {});
376
382 YB_ATTR_nodiscard YF_API YB_PURE TermNode
383 MakeXMLDoc(const string& = {}, const string& = "1.0",
384 const string& = "UTF-8", const string& = {});
386
388
389
391 YB_ATTR_nodiscard YB_PURE inline PDefH(NodeLiteral, MakeAttributeTagLiteral,
392 std::initializer_list<NodeLiteral> il)
393 ImplRet({"@", il})
394 template<typename... _tParams>
395 YB_ATTR_nodiscard YB_PURE NodeLiteral
396 MakeAttributeTagLiteral(_tParams&&... args)
397 {
398 return SXML::MakeAttributeTagLiteral({NodeLiteral(yforward(args)...)});
399 }
401
403
404 YB_ATTR_nodiscard YB_PURE inline PDefH(NodeLiteral, MakeAttributeLiteral,
405 const string& name, std::initializer_list<NodeLiteral> il)
406 ImplRet({name, {MakeAttributeTagLiteral(il)}})
407 template<typename... _tParams>
408 YB_ATTR_nodiscard YB_PURE NodeLiteral
409 MakeAttributeLiteral(const string& name, _tParams&&... args)
410 {
411 return {name, {SXML::MakeAttributeTagLiteral(yforward(args)...)}};
412 }
414
416
417 template<class _tNodeOrCon>
418 inline void
419 InsertAttributeNode(_tNodeOrCon&& node_or_con, const string& name,
420 std::initializer_list<NodeLiteral> il)
421 {
422 InsertChildSyntaxNode(node_or_con, MakeAttributeLiteral(name, il));
423 }
424 template<class _tNodeOrCon, typename... _tParams>
425 inline void
426 InsertAttributeNode(_tNodeOrCon&& node_or_con, const string& name,
427 _tParams&&... args)
428 {
429 InsertChildSyntaxNode(node_or_con,
430 SXML::MakeAttributeLiteral(name, yforward(args)...));
431 }
433
434
435 } // namespace SXML;
436
437
443 class YF_API NPLException : public LoggedEvent
445 {
446 public:
447 YB_NONNULL(2)
448 NPLException(const char* str = "", YSLib::RecordLevel lv = YSLib::Err)
449 : LoggedEvent(str, lv)
450 {}
451 NPLException(string_view sv, YSLib::RecordLevel lv = YSLib::Err)
452 : LoggedEvent(sv, lv)
453 {}
455 DefDeCopyCtor(NPLException)
457 ~NPLException() override;
458
460 DefDeCopyAssignment(NPLException)
461 };
462
463
474 class YF_API TypeError : public NPLException
475 {
476 public:
478 using NPLException::NPLException;
480 DefDeCopyCtor(TypeError)
482 ~TypeError() override;
483
485 DefDeCopyAssignment(TypeError)
486 };
487
488
493 class YF_API ValueCategoryMismatch : public TypeError
494 {
495 public:
497 using TypeError::TypeError;
499 DefDeCopyCtor(ValueCategoryMismatch)
501 ~ValueCategoryMismatch() override;
502
504 DefDeCopyAssignment(ValueCategoryMismatch)
505 };
506
507
514 class YF_API ListTypeError : public TypeError
515 {
516 public:
518 using TypeError::TypeError;
520 DefDeCopyCtor(ListTypeError)
522 ~ListTypeError() override;
523
525 DefDeCopyAssignment(ListTypeError)
526 };
528
529
536 class YF_API ListReductionFailure : public TypeError
537 {
538 public:
540 using TypeError::TypeError;
542 DefDeCopyCtor(ListReductionFailure)
544 ~ListReductionFailure() override;
545
547 DefDeCopyAssignment(ListReductionFailure)
548 };
549
550
556 class YF_API InvalidSyntax : public NPLException
557 {
558 public:
559 using NPLException::NPLException;
561 DefDeCopyCtor(InvalidSyntax)
563 ~InvalidSyntax() override;
564
566 DefDeCopyAssignment(InvalidSyntax)
567 };
568
569
574 class YF_API ParameterMismatch : public InvalidSyntax
575 {
576 public:
577 using InvalidSyntax::InvalidSyntax;
579 DefDeCopyCtor(ParameterMismatch)
581 ~ParameterMismatch() override;
582
584 DefDeCopyAssignment(ParameterMismatch)
585 };
586
587
594 class YF_API ArityMismatch : public ParameterMismatch
595 {
596 private:
597 size_t expected;
598 size_t received;
599
600 public:
605 ArityMismatch(size_t, size_t, YSLib::RecordLevel = YSLib::Err);
607 DefDeCopyCtor(ArityMismatch)
609 ~ArityMismatch() override;
610
612 DefDeCopyAssignment(ArityMismatch)
613
614 DefGetter(const ynothrow, size_t, Expected, expected)
615 DefGetter(const ynothrow, size_t, Received, received)
616 };
617
618
625 class YF_API BadIdentifier : public InvalidSyntax
626 {
627 private:
628 shared_ptr<string> p_identifier;
629
630 public:
635 SourceInformation Source{};
636
647 YB_NONNULL(2)
648 BadIdentifier(const char*, size_t = 0, YSLib::RecordLevel = YSLib::Err);
649 BadIdentifier(string_view, size_t = 0, YSLib::RecordLevel = YSLib::Err);
651 DefDeCopyCtor(BadIdentifier)
653 ~BadIdentifier() override;
654
656 DefDeCopyAssignment(BadIdentifier)
657
658 DefGetter(const ynothrow, const string&, Identifier,
659 NPL::Deref(p_identifier))
660 };
661
662
669 class YF_API InvalidReference : public NPLException
670 {
671 public:
672 using NPLException::NPLException;
674 DefDeCopyCtor(InvalidReference)
676 ~InvalidReference() override;
677
679 DefDeCopyAssignment(InvalidReference)
680 };
682
683
688 enum class LexemeCategory
689 {
691 Symbol,
693 Code,
695 Data,
697 Extended
698 };
699
700
702
703
705
714 YB_ATTR_nodiscard YF_API YB_PURE LexemeCategory
715 CategorizeBasicLexeme(string_view) ynothrowv;
716
721 YB_ATTR_nodiscard YF_API YB_PURE LexemeCategory
722 CategorizeLexeme(string_view) ynothrowv;
724
731 YB_ATTR_nodiscard YF_API YB_PURE bool
732 IsNPLAExtendedLiteral(string_view) ynothrowv;
733
738 YB_ATTR_nodiscard YB_STATELESS yconstfn
739 PDefH(bool, IsNPLAExtendedLiteralNonDigitPrefix, char c) ynothrow
740 ImplRet(c == '#'|| c == '+' || c == '-')
741
742 YB_ATTR_nodiscard YB_STATELESS inline
744 PDefH(bool, IsNPLAExtendedLiteralPrefix, char c) ynothrow
745 ImplRet(ystdex::isdigit(c) || IsNPLAExtendedLiteralNonDigitPrefix(c))
746
754 YB_ATTR_nodiscard YB_PURE inline
755 PDefH(bool, IsNPLASymbol, string_view id) ynothrowv
756 ImplRet(CategorizeLexeme(id) == LexemeCategory::Symbol)
758
759
760
769 using TokenValue = ystdex::derived_entity<string, NPLATag>;
770
771
777 using AnchorPtr = yimpl(shared_ptr<const void>);
778
784 static_assert(ystdex::is_nothrow_copy_constructible<AnchorPtr>(),
785 "Invalid type found.");
786 static_assert(ystdex::is_nothrow_copy_assignable<AnchorPtr>(),
787 "Invalid type found.");
788 static_assert(ystdex::is_nothrow_move_assignable<AnchorPtr>(),
789 "Invalid type found.");
790 static_assert(ystdex::is_nothrow_move_constructible<AnchorPtr>(),
791 "Invalid type found.");
793
794
800 YB_ATTR_nodiscard YB_PURE inline observer_ptr<const TokenValue>
801 TermToNamePtr(const TermNode&);
802
815 YB_ATTR_nodiscard YF_API YB_PURE string
816 TermToString(const TermNode&);
817
824 YB_ATTR_nodiscard YF_API YB_PURE string
825 TermToStringWithReferenceMark(const TermNode&, bool);
827
837 YB_ATTR_nodiscard YF_API YB_PURE TermTags
838 TermToTags(TermNode&);
839
847 YB_NORETURN YF_API void
848 ThrowListTypeErrorForInvalidType(const ystdex::type_info&, const TermNode&,
849 bool);
850
856 YF_API void
857 TokenizeTerm(TermNode& term);
858
860
861
869 template<typename _type>
870 YB_ATTR_nodiscard YB_PURE inline observer_ptr<_type>
871 TryAccessLeaf(TermNode& term)
872 {
873 return term.Value.type() == ystdex::type_id<_type>() ? NPL::make_observer(
874 std::addressof(term.Value.GetObject<_type>())) : nullptr;
875 }
876 template<typename _type>
877 YB_ATTR_nodiscard YB_PURE inline observer_ptr<const _type>
878 TryAccessLeaf(const TermNode& term)
879 {
880 return term.Value.type() == ystdex::type_id<_type>() ? NPL::make_observer(
881 std::addressof(term.Value.GetObject<_type>())) : nullptr;
882 }
884
893 template<typename _type>
894 YB_ATTR_nodiscard YB_PURE inline observer_ptr<_type>
895 TryAccessTerm(TermNode& term)
896 {
897 return IsLeaf(term) ? NPL::TryAccessLeaf<_type>(term) : nullptr;
898 }
899 template<typename _type>
900 YB_ATTR_nodiscard YB_PURE inline observer_ptr<const _type>
901 TryAccessTerm(const TermNode& term)
902 {
903 return IsLeaf(term) ? NPL::TryAccessLeaf<_type>(term) : nullptr;
904 }
906
907
908 YB_ATTR_nodiscard YB_PURE inline
909 PDefH(observer_ptr<const TokenValue>, TermToNamePtr, const TermNode& term)
910 ImplRet(NPL::TryAccessTerm<TokenValue>(term))
911
912
913
931 #ifndef NPL_NPLA_CheckEnvironmentReferenceCount
932 # ifndef NDEBUG
933 # define NPL_NPLA_CheckEnvironmentReferenceCount true
934 # else
935 # define NPL_NPLA_CheckEnvironmentReferenceCount false
936 # endif
937 #endif
938
950 #ifndef NPL_NPLA_CheckParentEnvironment
951 # ifndef NDEBUG
952 # define NPL_NPLA_CheckParentEnvironment true
953 # else
954 # define NPL_NPLA_CheckParentEnvironment false
955 # endif
956 #endif
957
964 #ifndef NPL_NPLA_CheckTermReferenceIndirection
965 # ifndef NDEBUG
966 # define NPL_NPLA_CheckTermReferenceIndirection true
967 #else
968 # define NPL_NPLA_CheckTermReferenceIndirection false
969 # endif
970 #endif
971
972
973
975 class Environment;
976
984 class YF_API EnvironmentReference
985 : private ystdex::equality_comparable<EnvironmentReference>
986 {
987 private:
988 weak_ptr<Environment> p_weak{};
993 AnchorPtr p_anchor{};
994
995 public:
997 DefDeCtor(EnvironmentReference)
999
1000 EnvironmentReference(const shared_ptr<Environment>&) ynothrow;
1006 template<typename _tParam1, typename _tParam2>
1007 EnvironmentReference(_tParam1&& arg1, _tParam2&& arg2) ynothrow
1008 : p_weak(yforward(arg1)), p_anchor(yforward(arg2))
1009 {
1010 #if NPL_NPLA_CheckEnvironmentReferenceCount
1011 ReferenceEnvironmentAnchor();
1012 #endif
1013 }
1014 #if NPL_NPLA_CheckEnvironmentReferenceCount
1015
1017 EnvironmentReference(const EnvironmentReference& env_ref) ynothrow
1018 : p_weak(env_ref.p_weak), p_anchor(env_ref.p_anchor)
1019 {
1020 ReferenceEnvironmentAnchor();
1021 }
1023 DefDeMoveCtor(EnvironmentReference)
1024
1025 ~EnvironmentReference();
1026
1027 DefDeCopyAssignment(EnvironmentReference)
1028 DefDeMoveAssignment(EnvironmentReference)
1030 #else
1031 DefDeCopyMoveCtorAssignment(EnvironmentReference)
1032 #endif
1033
1035 YB_ATTR_nodiscard YB_PURE friend PDefHOp(bool, ==,
1036 const EnvironmentReference& x, const EnvironmentReference& y) ynothrow
1037 ImplRet(x.p_weak.lock() == y.p_weak.lock())
1038
1039
1040 DefGetter(const ynothrow, const AnchorPtr&, AnchorPtr, p_anchor)
1041 DefGetter(const ynothrow, const weak_ptr<Environment>&, Ptr, p_weak)
1042
1043 PDefH(shared_ptr<Environment>, Lock, ) const ynothrow
1044 ImplRet(p_weak.lock())
1045 #if NPL_NPLA_CheckEnvironmentReferenceCount
1046
1047 private:
1049 void
1050 ReferenceEnvironmentAnchor();
1051 #endif
1052 };
1053
1054
1066 class YF_API TermReference
1067 : private ystdex::equality_comparable<TermReference>
1068 {
1069 private:
1071 lref<TermNode> term_ref;
1076 TermTags tags = TermTags::Unqualified;
1081 EnvironmentReference r_env;
1082
1083 public:
1088 template<typename _tParam, typename... _tParams>
1089 inline
1090 TermReference(TermNode& term, _tParam&& arg, _tParams&&... args) ynothrow
1091 : TermReference(TermToTags(term), term, yforward(arg),
1092 yforward(args)...)
1093 {}
1098 template<typename _tParam, typename... _tParams>
1099 inline
1100 TermReference(TermTags t, TermNode& term, _tParam&& arg, _tParams&&... args)
1101 ynothrow
1102 : term_ref(term), tags(t),
1103 r_env(yforward(arg), yforward(args)...)
1104 {}
1110 TermReference(TermTags t, const TermReference& ref) ynothrow
1111 : term_ref(ref.term_ref), tags(t), r_env(ref.r_env)
1112 {}
1113 TermReference(TermTags t, TermReference&& ref) ynothrow
1114 : term_ref(ref.term_ref), tags(t), r_env(std::move(ref.r_env))
1115 {}
1117 DefDeCopyMoveCtorAssignment(TermReference)
1119
1120
1121 YB_ATTR_nodiscard YB_PURE friend
1122 PDefHOp(bool, ==, const TermReference& x, const TermReference& y)
1123 ImplRet(ystdex::get_equal_to<>()(x.term_ref, y.term_ref))
1124
1129 DefPred(const ynothrow, Modifiable, !bool(tags & TermTags::Nonmodifying))
1131
1132 DefPred(const ynothrow, Movable, (tags
1134 & (TermTags::Unique | TermTags::Nonmodifying)) == TermTags::Unique)
1162 DefPred(const ynothrow, ReferencedLValue,
1163 !(bool(tags & TermTags::Unique) || bool(tags & TermTags::Temporary)))
1165
1169 DefPred(const ynothrow, Unique, bool(tags & TermTags::Unique))
1170
1171 DefGetter(const ynothrow, TermTags, Tags, tags)
1172
1174 DefSetter(ynothrow, TermNode&, Referent, term_ref)
1176 DefSetter(ynothrow, TermTags, Tags, tags)
1177
1178 explicit DefCvtMem(const ynothrow, TermNode&, term_ref)
1179
1184 DefGetterMem(const ynothrow, const AnchorPtr&, AnchorPtr, r_env)
1189 DefGetter(const ynothrow, const EnvironmentReference&, EnvironmentReference,
1190 r_env)
1191
1197 #if NPL_NPLA_CheckTermReferenceIndirection
1198 YB_ATTR_nodiscard YB_PURE TermNode&
1199 get() const;
1200 #else
1201 YB_ATTR_nodiscard YB_PURE PDefH(TermNode&, get, ) const ynothrow
1202 ImplRet(term_ref.get())
1203 #endif
1204 };
1205
1220 YB_ATTR_nodiscard YF_API pair<TermReference, bool>
1221 Collapse(TermReference);
1222
1237 YB_ATTR_nodiscard YF_API TermNode
1238 PrepareCollapse(TermNode&, const shared_ptr<Environment>&);
1240
1247 YB_ATTR_nodiscard YB_PURE inline
1248 PDefH(TermNode&, ReferenceTerm, TermNode& term)
1249 ynoexcept_spec(std::declval<TermReference>().get())
1250 ImplRet(ystdex::invoke_value_or(&TermReference::get,
1251 NPL::TryAccessLeaf<const TermReference>(term), term))
1252 YB_ATTR_nodiscard YB_PURE inline
1253 PDefH(const TermNode&, ReferenceTerm, const TermNode& term)
1254 ynoexcept_spec(std::declval<TermReference>().get())
1255 ImplRet(ystdex::invoke_value_or(&TermReference::get,
1256 NPL::TryAccessLeaf<const TermReference>(term), term))
1257
1258
1260
1261
1273 using ResolvedTermReferencePtr = yimpl(const TermReference*);
1274
1279 YB_ATTR_nodiscard YB_PURE yconstfn PDefH(ResolvedTermReferencePtr,
1280 ResolveToTermReferencePtr, observer_ptr<const TermReference> p) ynothrow
1281 ImplRet(p.get())
1283
1284
1294 YB_ATTR_nodiscard YB_PURE inline
1295 PDefH(bool, IsMovable, const TermReference& ref) ynothrow
1296 ImplRet(ref.IsMovable())
1298 template<typename _tPointer>
1299 YB_ATTR_nodiscard YB_PURE inline auto
1300 IsMovable(_tPointer p) ynothrow
1301 -> decltype(!bool(p) || NPL::IsMovable(*p))
1302 {
1303 return !bool(p) || NPL::IsMovable(*p);
1304 }
1306
1307
1309
1310
1312
1317 template<typename _type>
1318 YB_ATTR_nodiscard YB_PURE inline observer_ptr<_type>
1319 TryAccessReferencedLeaf(TermNode& term)
1320 {
1321 return NPL::TryAccessLeaf<_type>(ReferenceTerm(term));
1322 }
1323 template<typename _type>
1324 YB_ATTR_nodiscard YB_PURE inline observer_ptr<const _type>
1325 TryAccessReferencedLeaf(const TermNode& term)
1326 {
1327 return NPL::TryAccessLeaf<_type>(ReferenceTerm(term));
1328 }
1330
1336 template<typename _type>
1337 YB_ATTR_nodiscard YB_PURE inline observer_ptr<_type>
1338 TryAccessReferencedTerm(TermNode& term)
1339 {
1340 return NPL::TryAccessTerm<_type>(ReferenceTerm(term));
1341 }
1342 template<typename _type>
1343 YB_ATTR_nodiscard YB_PURE inline observer_ptr<const _type>
1344 TryAccessReferencedTerm(const TermNode& term)
1345 {
1346 return NPL::TryAccessTerm<_type>(ReferenceTerm(term));
1347 }
1349
1350
1352
1353
1355 YB_ATTR_nodiscard YF_API YB_PURE bool
1357 IsReferenceTerm(const TermNode&);
1358
1366 YB_ATTR_nodiscard YF_API YB_PURE bool
1367 IsBoundLValueTerm(const TermNode&);
1369
1374 YB_ATTR_nodiscard YF_API YB_PURE bool
1375 IsUncollapsedTerm(const TermNode&);
1376
1382 YB_ATTR_nodiscard YF_API YB_PURE bool
1383 IsUniqueTerm(const TermNode&);
1385
1387
1388
1408 template<typename _func, class _tTerm>
1409 auto
1410 ResolveTerm(_func do_resolve, _tTerm&& term)
1411 -> yimpl(decltype(ystdex::expand_proxy<yimpl(void)(_tTerm&&,
1412 ResolvedTermReferencePtr)>::call(do_resolve, yforward(term),
1413 ResolvedTermReferencePtr())))
1414 {
1415 using handler_t = yimpl(void)(_tTerm&&, ResolvedTermReferencePtr);
1416
1417 // XXX: Assume value representation of %term is not trivially regular.
1418 if(const auto p = NPL::TryAccessLeaf<const TermReference>(term))
1419 return ystdex::expand_proxy<handler_t>::call(do_resolve, p->get(),
1420 NPL::ResolveToTermReferencePtr(p));
1421 return ystdex::expand_proxy<handler_t>::call(do_resolve,
1422 yforward(term), ResolvedTermReferencePtr());
1423 }
1424
1430 template<typename _type, class _tTerm>
1431 void
1432 CheckRegular(_tTerm& term, bool has_ref)
1433 {
1434 if(YB_UNLIKELY(IsList(term)))
1435 ThrowListTypeErrorForInvalidType(ystdex::type_id<_type>(), term,
1436 has_ref);
1437 }
1438
1445 template<typename _type, class _tTerm>
1446 YB_ATTR_nodiscard YB_PURE inline auto
1447 AccessRegular(_tTerm& term, bool has_ref)
1448 -> yimpl(decltype(NPL::Access<_type>(term)))
1449 {
1450 NPL::CheckRegular<_type>(term, has_ref);
1451 return NPL::Access<_type>(term);
1452 }
1453
1465 template<typename _type, class _tTerm>
1466 YB_ATTR_nodiscard YB_PURE inline auto
1467 ResolveRegular(_tTerm& term) -> yimpl(decltype(NPL::Access<_type>(term)))
1468 {
1469 return NPL::ResolveTerm([&](_tTerm& nd, bool has_ref)
1470 -> yimpl(decltype(NPL::Access<_type>(term))){
1471 return NPL::AccessRegular<_type>(nd, has_ref);
1472 }, term);
1473 }
1475
1476
1477
1478
1480
1481
1486 struct ReferenceTermOp
1487 {
1489 template<typename _type>
1490 auto
1491 operator()(_type&& term) const
1492 ynoexcept_spec(NPL::ReferenceTerm(yforward(term)))
1493 -> decltype(NPL::ReferenceTerm(yforward(term)))
1494 {
1495 return NPL::ReferenceTerm(yforward(term));
1496 }
1497 };
1498
1504 template<typename _func>
1505 YB_STATELESS auto
1506 ComposeReferencedTermOp(_func f)
1507 -> yimpl(decltype(ystdex::compose_n(f, ReferenceTermOp())))
1508 {
1509 return ystdex::compose_n(f, ReferenceTermOp());
1510 }
1512
1513
1519 enum class ReductionStatus : yimpl(size_t)
1520 {
1526 Partial = yimpl(0x00),
1532 Neutral = yimpl(0x01),
1537 Clean = yimpl(0x02),
1542 Retained = yimpl(0x03),
1547 Regular = yimpl(Retained),
1552 Retrying = yimpl(0x10)
1553 };
1554
1565 YB_ATTR_nodiscard YF_API YB_STATELESS bool
1566 CheckReducible(ReductionStatus);
1567
1568
1573 template<typename _func, typename... _tParams>
1574 auto
1575 CheckedReduceWith(_func f, _tParams&&... args)
1576 -> decltype(ystdex::retry_on_cond(CheckReducible, f, yforward(args)...))
1577 {
1578 return ystdex::retry_on_cond(CheckReducible, f, yforward(args)...);
1579 }
1580
1586 YF_API ReductionStatus
1587 RegularizeTerm(TermNode&, ReductionStatus) ynothrow;
1588
1589
1602 inline PDefH(void, LiftOther, TermNode& term, TermNode& tm)
1603 ImplExpr(term.MoveContent(std::move(tm)))
1604
1605
1609 inline PDefH(void, LiftTerm, TermNode& term, TermNode& tm)
1610 ImplExpr(!ystdex::ref_eq<>()(term, tm) ? LiftOther(term, tm) : void())
1611 inline PDefH(void, LiftTerm, ValueObject& tv, ValueObject& vo) ynothrow
1612 ImplExpr(!ystdex::ref_eq<>()(tv, vo) ? void(tv = std::move(vo)) : void())
1613 inline PDefH(void, LiftTerm, TermNode& term, ValueObject& vo) ynothrow
1614 ImplExpr(LiftTerm(term.Value, vo))
1616
1629 YF_API void
1630 LiftOtherOrCopy(TermNode&, TermNode&, bool);
1631
1636 YF_API void
1637 LiftTermOrCopy(TermNode&, TermNode&, bool);
1639
1652 YF_API void
1653 LiftTermValueOrCopy(TermNode&, TermNode&, bool);
1654
1655
1657
1658
1669 YF_API void
1670 LiftCollapsed(TermNode&, TermNode&, TermReference);
1671
1684 YF_API void
1685 MoveCollapsed(TermNode&, TermNode&);
1687
1699 inline PDefH(void, LiftTermRef, TermNode& term, const TermNode& tm)
1701 ImplExpr(NPL::SetContentWith(term, tm, &ValueObject::MakeIndirect))
1702 inline PDefH(void, LiftTermRef, ValueObject& term_v, const ValueObject& vo)
1703 ImplExpr(term_v = vo.MakeIndirect())
1704 inline PDefH(void, LiftTermRef, TermNode& term, const ValueObject& vo)
1705 ImplExpr(LiftTermRef(term.Value, vo))
1707
1719 YF_API void
1720 LiftToReference(TermNode&, TermNode&);
1721
1722
1735 inline PDefH(void, LiftMoved, TermNode& term, const TermReference& ref,
1736 bool move)
1737 ImplExpr(LiftTermOrCopy(term, ref.get(), move))
1738
1745 inline PDefH(void, LiftMovedOther, TermNode& term, const TermReference& ref,
1746 bool move)
1747 ImplExpr(LiftOtherOrCopy(term, ref.get(), move))
1749
1760 YF_API void
1761 LiftToReturn(TermNode&);
1763
1786 YF_API void
1787 MoveRValueToForward(TermNode&, TermNode&);
1788
1803 YF_API void
1804 MoveRValueToReturn(TermNode&, TermNode&);
1806
1812 inline PDefH(void, LiftSubtermsToReturn, TermNode& term)
1813 ImplExpr(std::for_each(term.begin(), term.end(), LiftToReturn))
1814
1816
1817
1821 inline PDefH(void, LiftFirst, TermNode& term)
1822 ImplExpr(LiftOther(term, AccessFirstSubterm(term)))
1823
1828 inline PDefH(void, LiftLast, TermNode& term)
1829 ImplExpr(AssertBranch(term), LiftTerm(term, NPL::Deref(term.rbegin())))
1831
1832
1839 YF_API ReductionStatus
1841 ReduceBranchToList(TermNode&) ynothrowv;
1842
1847 YF_API ReductionStatus
1848 ReduceBranchToListValue(TermNode&) ynothrowv;
1850
1859 inline PDefH(ReductionStatus, ReduceForLiftedResult, TermNode& term)
1860 // NOTE: This is mainly used to update %LastStatus in the enclosing context.
1861 ImplRet(LiftToReturn(term), ReductionStatus::Retained)
1862
1872 YF_API ReductionStatus
1873 ReduceHeadEmptyList(TermNode&) ynothrow;
1874
1888 inline PDefH(ReductionStatus, ReduceToList, TermNode& term) ynothrow
1889 ImplRet(IsBranchedList(term) ? ReduceBranchToList(term)
1890 : ReductionStatus::Regular)
1891
1899 inline PDefH(ReductionStatus, ReduceToListValue, TermNode& term) ynothrow
1900 ImplRet(IsBranchedList(term) ? ReduceBranchToListValue(term)
1901 : ReductionStatus::Regular)
1903
1909
1911
1921 YF_API ReductionStatus
1922 ReduceToReference(TermNode&, TermNode&, ResolvedTermReferencePtr);
1923
1931 YF_API ReductionStatus
1932 ReduceToReferenceAt(TermNode&, TermNode&, ResolvedTermReferencePtr);
1934
1940 inline PDefH(ReductionStatus, ReduceToValue, TermNode& term, TermNode& tm)
1941 ImplRet(MoveRValueToReturn(term, tm), ReductionStatus::Retained)
1943
1944
1950 YB_ATTR_nodiscard yconstfn YB_STATELESS PDefH(bool,
1951 IsOverridableReductionResult, ReductionStatus r) ynothrow
1952 ImplRet(yimpl(r == ReductionStatus::Clean
1953 || r == ReductionStatus::Retained))
1954
1967 YB_ATTR_nodiscard yconstfn YB_STATELESS PDefH(ReductionStatus,
1968 CombineReductionResult, ReductionStatus res, ReductionStatus r) ynothrow
1969 ImplRet(IsOverridableReductionResult(r) ? r : res)
1970
1980 YB_ATTR_nodiscard YB_PURE inline
1981 PDefH(ReductionStatus, CombineSequenceReductionResult, ReductionStatus res,
1982 ReductionStatus r) ynothrow
1983 ImplRet(CheckReducible(r) ? r : CombineReductionResult(res, r))
1985
1986
1988
1989
1995 using EnvironmentList = vector<ValueObject>;
1996
1997
2003 class YF_API Environment : private ystdex::equality_comparable<Environment>
2004 {
2005 public:
2006 // TODO: Wait for %unordered_set to support transparent keys.
2008 using BindingMap = YSLib::map<string, TermNode, ystdex::less<>>;
2015 using NameResolution
2016 = pair<observer_ptr<BindingMap::mapped_type>, shared_ptr<Environment>>;
2022 using allocator_type = BindingMap::allocator_type;
2023
2025 mutable BindingMap Bindings;
2031 ValueObject Parent{};
2037 bool Frozen = {};
2038
2039 private:
2044 AnchorPtr p_anchor{InitAnchor()};
2045
2046 public:
2048
2049 Environment(allocator_type a)
2051 : Bindings(a)
2052 {}
2054 Environment(pmr::memory_resource& rsrc)
2055 : Environment(allocator_type(&rsrc))
2056 {}
2058
2063 explicit
2065 Environment(const BindingMap& m)
2066 : Bindings(m)
2067 {}
2068 explicit
2069 Environment(BindingMap&& m)
2070 : Bindings(std::move(m))
2071 {}
2073
2080
2082 Environment(const ValueObject& vo, allocator_type a)
2083 : Bindings(a), Parent((CheckParent(vo), vo))
2084 {}
2085 Environment(ValueObject&& vo, allocator_type a)
2086 : Bindings(a), Parent((CheckParent(vo), std::move(vo)))
2087 {}
2089 Environment(pmr::memory_resource& rsrc, const ValueObject& vo)
2090 : Environment(vo, allocator_type(&rsrc))
2091 {}
2092 Environment(pmr::memory_resource& rsrc, ValueObject&& vo)
2093 : Environment(std::move(vo), allocator_type(&rsrc))
2094 {}
2096
2098 Environment(const Environment& e)
2099 : Bindings(e.Bindings), Parent(e.Parent)
2100 {}
2101 DefDeMoveCtor(Environment)
2102
2103
2104 PDefHOp(Environment&, =, const Environment& e)
2105 ImplRet(ystdex::copy_and_swap(*this, e))
2111 ~Environment();
2112
2113 DefDeMoveAssignment(Environment)
2115
2117 template<typename _tKey>
2118 TermNode&
2119 operator[](_tKey&& k)
2120 {
2121 return NPL::Deref(ystdex::try_emplace(Bindings, yforward(k),
2122 NoContainer).first).second;
2123 }
2124
2125 YB_ATTR_nodiscard YB_PURE friend
2126 PDefHOp(bool, ==, const Environment& x, const Environment& y) ynothrow
2127 // XXX: This is usd rarely (more often, equality on
2128 // %shared_ptr<Environment> is instead), but just keep it simple here
2129 // to avoid wrong ("always true") complement like it in %ValueObject.
2130 ImplRet(ystdex::ref_eq<>()(x, y))
2131
2132
2136 DefPred(const ynothrow, Orphan, p_anchor.use_count() == 1)
2137
2138
2142 DefGetter(const ynothrow, const AnchorPtr&, AnchorPtr, p_anchor)
2147 DefGetter(const ynothrow, size_t, AnchorCount, size_t(p_anchor.use_count()))
2152 DefGetter(const ynothrow, BindingMap&, MapRef, Bindings)
2153
2159 template<typename _tKey, typename... _tParams>
2160 inline yimpl(ystdex::enable_if_inconvertible_t)<_tKey&&,
2161 BindingMap::const_iterator, bool>
2162 AddValue(_tKey&& k, _tParams&&... args)
2163 {
2164 return ystdex::try_emplace(Bindings, yforward(k), NoContainer,
2165 yforward(args)...).second;
2166 }
2167 template<typename _tKey, typename... _tParams>
2168 inline bool
2169 AddValue(BindingMap::const_iterator hint, _tKey&& k, _tParams&&... args)
2170 {
2171 return ystdex::try_emplace_hint(Bindings, hint, yforward(k),
2172 NoContainer, yforward(args)...).second;
2173 }
2175
2180 template<typename _tKey, class _tNode>
2181 TermNode&
2182 Bind(_tKey&& k, _tNode&& tm)
2183 {
2184 // XXX: %YSLib::map::insert_or_assign does not allows keys not of
2185 // %BindingMap::key_type to be directly forwarded.
2186 return NPL::Deref(ystdex::insert_or_assign(Bindings, yforward(k),
2187 yforward(tm)).first).second;
2188 }
2189
2197 static void
2198 CheckParent(const ValueObject&);
2199
2205 static bool
2206 Deduplicate(BindingMap&, const BindingMap&);
2207
2218 void
2219 Define(string_view, ValueObject&&);
2220
2225 void
2226 DefineChecked(string_view, ValueObject&&);
2228
2235 static Environment&
2236 EnsureValid(const shared_ptr<Environment>&);
2237
2238 private:
2243 YB_ATTR_nodiscard YB_PURE AnchorPtr
2244 InitAnchor() const;
2245
2246 public:
2254 YB_ATTR_nodiscard YB_PURE NameResolution::first_type
2255 LookupName(string_view) const;
2256
2262 PDefH(TermTags, MakeTermTags, const TermNode& term) const
2263 ImplRet(Frozen ? term.Tags | TermTags::Nonmodifying : term.Tags)
2264
2265
2275 bool
2276 Remove(string_view);
2281 void
2282 RemoveChecked(string_view);
2283
2290 bool
2291 Replace(string_view, ValueObject&&);
2292
2297 void
2298 ReplaceChecked(string_view, ValueObject&&);
2300
2306 YB_NORETURN static void
2307 ThrowForInvalidType(const ystdex::type_info&);
2308
2316 YB_NORETURN static void
2317 ThrowForInvalidValue(bool = {});
2318
2320 friend PDefH(void, swap, Environment& x, Environment& y) ynothrow
2321 ImplExpr(swap(x.Bindings, y.Bindings), swap(x.Parent, y.Parent),
2322 swap(x.p_anchor, y.p_anchor))
2323 };
2324
2325 inline
2326 EnvironmentReference::EnvironmentReference(const shared_ptr<Environment>& p_env)
2327 ynothrow
2328 : EnvironmentReference(p_env, p_env ? p_env->GetAnchorPtr() : nullptr)
2329 {}
2330
2331
2333 class ContextNode;
2334
2335
2340 using ReducerFunctionType = ReductionStatus(ContextNode&);
2341
2350 yimpl(using) Reducer = ystdex::expanded_function<ReducerFunctionType>;
2352
2358 template<class _tAlloc, class _func,
2359 yimpl(typename = ystdex::enable_if_same_param_t<Reducer, _func>)>
2360 YB_FLATTEN inline _func&&
2361 ToReducer(const _tAlloc&, _func&& f)
2362 {
2363 return yforward(f);
2364 }
2365 template<class _tAlloc, typename _tParam, typename... _tParams>
2366 inline
2367 yimpl(ystdex::exclude_self_t)<Reducer, _tParam, Reducer>
2368 ToReducer(const _tAlloc& a, _tParam&& arg, _tParams&&... args)
2369 {
2370 #if true
2371 return Reducer(std::allocator_arg, a, yforward(arg), yforward(args)...);
2372 #else
2373 return ystdex::make_obj_using_allocator<Reducer>(a, yforward(arg),
2374 yforward(args)...);
2375 #endif
2376 }
2378
2379
2384 class YF_API ContextNode
2385 {
2386 public:
2391 using ExceptionHandler = function<void(std::exception_ptr)>;
2392
2393 private:
2399 using ReducerSequenceBase = YSLib::forward_list<Reducer>;
2400
2401 public:
2403 class YF_API ReducerSequence : public ReducerSequenceBase,
2404 private ystdex::equality_comparable<ReducerSequence>
2405 {
2406 public:
2408
2409
2417 ValueObject Parent{};
2418
2420 #if YB_IMPL_CLANGPP || YB_IMPL_GNUCPP >= 100000
2421 // XXX: See https://bugs.llvm.org/show_bug.cgi?id=36684.
2422 // XXX: See https://gcc.gnu.org/bugzilla/show_bug.cgi?id=88165.
2423 // XXX: If the default constructor is not existed, G++ 10.1 crash on
2424 // the default argument of a default constructed %ReducerSequence:
2425 // internal compiler error. G++ 7.1 works.
2426 ReducerSequence() ynoexcept_spec(ReducerSequenceBase())
2427 : ReducerSequenceBase()
2428 {}
2429 #elif __cpp_inheriting_constructors < 201511L
2430 DefDeCtor(ReducerSequence)
2431 #endif
2432
2433 using ReducerSequenceBase::ReducerSequenceBase;
2434 // XXX: This ignores %select_on_container_copy_construction.
2435 ReducerSequence(const ReducerSequence& act)
2436 : ReducerSequenceBase(act, act.get_allocator())
2437 {}
2438 DefDeMoveCtor(ReducerSequence)
2439 ~ReducerSequence()
2440 {
2441 clear();
2442 }
2443
2445 DefDeCopyAssignment(ReducerSequence)
2447 PDefHOp(ReducerSequence&, =, ReducerSequence&& rs) ynothrowv
2448 ImplRet(YAssert(get_allocator() == rs.get_allocator(),
2449 "Invalid allocator found."), swap(rs), *this)
2450
2451 void
2452 clear() ynothrow
2453 {
2454 while(!empty())
2455 pop_front();
2456 }
2457
2459 friend
2460 PDefH(void, swap, ReducerSequence& x, ReducerSequence& y) ynothrowv
2461 ImplExpr(YAssert(x.get_allocator() == y.get_allocator(),
2462 "Invalid allocator found."), x.swap(y),
2463 ystdex::swap_dependent(x.Parent, y.Parent))
2464
2465
2466 YB_ATTR_nodiscard YB_PURE friend PDefHOp(bool, ==,
2467 const ReducerSequence& x, const ReducerSequence& y) ynothrow
2468 ImplRet(ystdex::ref_eq<>()(x, y))
2469 };
2470
2472 class YF_API ReductionGuard
2473 {
2474 private:
2475 observer_ptr<ContextNode> p_ctx;
2476 ReducerSequence::const_iterator i_stacked;
2477
2478 public:
2479 ReductionGuard(ContextNode& ctx) ynothrow
2480 : p_ctx(NPL::make_observer(&ctx)), i_stacked(ctx.stacked.cbegin())
2481 {
2482 ctx.stacked.splice_after(ctx.stacked.cbefore_begin(),
2483 ctx.current);
2484 }
2485 ReductionGuard(ReductionGuard&& gd) ynothrow
2486 : p_ctx(gd.p_ctx), i_stacked(gd.i_stacked)
2487 {
2488 gd.p_ctx = {};
2489 }
2491 ~ReductionGuard()
2492 {
2493 if(p_ctx)
2494 {
2495 auto& ctx(*p_ctx);
2496
2497 // XXX: The actions are inserted in the front for efficiency. If
2498 // necessary, the current action sequence can be saved
2499 // elsewhere before the guard destruction.
2500 ctx.current.splice_after(ctx.current.cbefore_begin(),
2501 ctx.stacked, ctx.stacked.cbefore_begin(), i_stacked);
2502 }
2503 }
2504 };
2506
2507 private:
2512 lref<pmr::memory_resource> memory_rsrc;
2518 shared_ptr<Environment> p_record{YSLib::allocate_shared<Environment>(
2519 Environment::allocator_type(&memory_rsrc.get()))};
2520
2521 public:
2554 function<Environment::NameResolution(shared_ptr<Environment>, string_view)>
2555 Resolve{DefaultResolve};
2556
2557 private:
2559
2560
2564 ReducerSequence
2565 current{ReducerSequence::allocator_type(&memory_rsrc.get())};
2571 ReducerSequenceBase stashed{current.get_allocator()};
2576 ReducerSequence stacked{current.get_allocator()};
2578
2579 public:
2584 Reducer TailAction{};
2590 ExceptionHandler HandleException{DefaultHandleException};
2596 ReductionStatus LastStatus = ReductionStatus::Neutral;
2601 YSLib::Logger Trace{};
2602
2607 ContextNode(pmr::memory_resource&);
2618 ContextNode(const ContextNode&, shared_ptr<Environment>&&);
2626 ContextNode(const ContextNode&);
2632 ContextNode(ContextNode&&) ynothrow;
2638 virtual
2639 ~ContextNode();
2640
2641 DefDeCopyMoveAssignment(ContextNode)
2642
2644
2645 DefPred(const ynothrow, Alive, !current.empty())
2647
2649 DefGetter(const ynothrow, Environment::BindingMap&, BindingsRef,
2650 GetRecordRef().GetMapRef())
2651 DefGetter(const ynothrow, const ReducerSequence&, Current, current)
2652 DefGetter(const ynothrow
2653 -> decltype(std::declval<Reducer>().target_type()), auto,
2654 CurrentActionType, IsAlive() ? current.front().target_type()
2655 : ystdex::type_id<void>())
2657 DefGetter(const ynothrow, pmr::memory_resource&, MemoryResourceRef,
2659 memory_rsrc)
2664 DefGetter(const ynothrow, Environment&, RecordRef, *p_record)
2669 DefGetter(const ynothrow, const shared_ptr<Environment>&, RecordPtr,
2670 p_record)
2671
2677 template<typename _type>
2678 YB_ATTR_nodiscard YB_PURE _type*
2679 AccessCurrentAs()
2680 {
2681 return IsAlive() ? current.front().template target<_type>() : nullptr;
2682 }
2683
2698 ReductionStatus
2699 ApplyTail();
2700
2707 YB_NORETURN static void
2708 DefaultHandleException(std::exception_ptr);
2709
2734 YB_ATTR_nodiscard static Environment::NameResolution
2735 DefaultResolve(shared_ptr<Environment>, string_view);
2736
2753 YB_FLATTEN PDefH(ReductionStatus, Rewrite, Reducer reduce)
2754 ImplRet(SetupCurrent(std::move(reduce)), RewriteLoop())
2755
2756
2766 YB_FLATTEN ReductionStatus
2767 RewriteLoop();
2769
2776 PDefH(void, SaveExceptionHandler, )
2777 // TODO: Blocked. Use C++14 lambda initializers to simplify the
2778 // implementation.
2779 ImplExpr(SetupFront(std::bind([this](ExceptionHandler& h) ynothrow{
2780 HandleException = std::move(h);
2781 return LastStatus;
2782 }, std::move(HandleException))))
2783
2790 template<typename... _tParams>
2791 inline void
2792 SetupCurrent(_tParams&&... args)
2793 {
2794 YAssert(!IsAlive(), "Old continuation is overriden.");
2795 return SetupFront(yforward(args)...);
2796 }
2797
2803 template<typename... _tParams>
2804 inline void
2805 SetupFront(_tParams&&... args)
2806 {
2807 if(!stashed.empty())
2808 {
2809 stashed.front()
2810 = NPL::ToReducer(get_allocator(), yforward(args)...);
2811 current.splice_after(current.cbefore_begin(), stashed,
2812 stashed.cbefore_begin());
2813 }
2814 else
2815 current.push_front(
2816 NPL::ToReducer(get_allocator(), yforward(args)...));
2817 }
2818
2823 PDefH(void, Shift, ReducerSequence& rs, ReducerSequence::const_iterator i)
2824 ynothrow
2825 ImplExpr(rs.splice_after(rs.cbefore_begin(), current,
2826 current.cbefore_begin(), i))
2834 PDefH(ReducerSequence, Switch, ) ynothrowv
2835 ImplRet(Switch(ReducerSequence(get_allocator())))
2837 PDefH(ReducerSequence, Switch, ReducerSequence acts) ynothrowv
2838 ImplRet(ystdex::exchange(current, std::move(acts)))
2840
2850 shared_ptr<Environment>
2851 SwitchEnvironment(const shared_ptr<Environment>&);
2852
2854 PDefH(shared_ptr<Environment>, SwitchEnvironmentUnchecked,
2855 const shared_ptr<Environment>& p_env) ynothrowv
2856 ImplRet(YAssertNonnull(p_env), ystdex::exchange(p_record, p_env))
2858
2860 YB_ATTR_nodiscard YB_PURE
2861 PDefH(shared_ptr<Environment>, ShareRecord, ) const ynothrow
2862 ImplRet(p_record)
2863
2868 PDefH(void, UnwindCurrent, ) ynothrow
2869 ImplExpr(current.clear())
2870
2872 YB_ATTR_nodiscard YB_PURE
2873 PDefH(EnvironmentReference, WeakenRecord, ) const ynothrow
2874 ImplRet(ShareRecord())
2875
2880 YB_ATTR_nodiscard YB_PURE PDefH(pmr::polymorphic_allocator<yimpl(byte)>,
2881 get_allocator, ) const ynothrow
2882 ImplRet(pmr::polymorphic_allocator<yimpl(byte)>(
2883 &GetMemoryResourceRef()))
2884
2890 PDefH(void, shrink_to_fit, )
2891 ImplExpr(stashed.clear())
2892
2897 YF_API friend void
2898 swap(ContextNode&, ContextNode&) ynothrow;
2899 };
2900
2901
2908 template<typename... _tParams>
2910 inline shared_ptr<Environment>
2911 AllocateEnvironment(const Environment::allocator_type& a, _tParams&&... args)
2912 {
2913 return YSLib::allocate_shared<Environment>(a, yforward(args)...);
2914 }
2915 template<typename... _tParams>
2916 inline shared_ptr<Environment>
2917 AllocateEnvironment(ContextNode& ctx, _tParams&&... args)
2918 {
2919 return NPL::AllocateEnvironment(ctx.GetBindingsRef().get_allocator(),
2920 yforward(args)...);
2921 }
2922 template<typename... _tParams>
2923 inline shared_ptr<Environment>
2924 AllocateEnvironment(TermNode& term, ContextNode& ctx, _tParams&&... args)
2925 {
2926 const auto a(ctx.GetBindingsRef().get_allocator());
2927
2928 yunused(term);
2929 YAssert(a == term.get_allocator(),
2930 "Allocator mismatch between term and context.");
2931 return NPL::AllocateEnvironment(a, yforward(args)...);
2932 }
2934
2940 template<typename... _tParams>
2941 inline shared_ptr<Environment>
2942 SwitchToFreshEnvironment(ContextNode& ctx, _tParams&&... args)
2943 {
2944 return ctx.SwitchEnvironmentUnchecked(
2945 NPL::AllocateEnvironment(ctx, yforward(args)...));
2946 }
2947
2948
2960 template<typename _type, typename... _tParams>
2961 inline bool
2962 EmplaceLeaf(Environment::BindingMap& m, string_view name, _tParams&&... args)
2963 {
2964 YAssertNonnull(name.data());
2965 // XXX: The implementation is depended on the fact that %TermNode is simply
2966 // an alias of %ValueNode and it is same to %BindingMap currently.
2967 // XXX: Allocators are not used on %ValueObject for performance in most
2968 // cases.
2969 return ystdex::insert_or_assign(m, name, NPL::AsTermNode(m.get_allocator(),
2970 in_place_type<_type>, yforward(args)...)).second;
2971 // NOTE: The following code is incorrect because the subterms are not
2972 // cleared, as well as lacking of %bool return value of insertion result.
2973 // m[name].Value.emplace<_type>(yforward(args)...);
2974 }
2975 template<typename _type, typename... _tParams>
2976 inline bool
2977 EmplaceLeaf(Environment& env, string_view name, _tParams&&... args)
2978 {
2979 return NPL::EmplaceLeaf<_type>(env.Bindings, name, yforward(args)...);
2980 }
2981 template<typename _type, typename... _tParams>
2982 inline bool
2983 EmplaceLeaf(ContextNode& ctx, string_view name, _tParams&&... args)
2984 {
2985 return NPL::EmplaceLeaf<_type>(ctx.GetRecordRef(), name, yforward(args)...);
2986 }
2988
2990
2991
3000 YB_ATTR_nodiscard inline PDefH(Environment::NameResolution, ResolveName,
3001 const ContextNode& ctx, string_view id)
3002 ImplRet(YAssertNonnull(id.data()), ctx.Resolve(ctx.GetRecordPtr(), id))
3003
3019 YB_ATTR_nodiscard YF_API TermNode
3020 MoveResolved(const ContextNode&, string_view);
3021
3033 YB_ATTR_nodiscard YF_API TermNode
3034 ResolveIdentifier(const ContextNode&, string_view);
3036
3037
3044 YB_ATTR_nodiscard YF_API pair<shared_ptr<Environment>, bool>
3046 ResolveEnvironment(const ValueObject&);
3053 YB_ATTR_nodiscard YF_API pair<shared_ptr<Environment>, bool>
3054 ResolveEnvironment(const TermNode& term);
3056
3057
3067 struct EnvironmentSwitcher
3068 {
3070 lref<ContextNode> Context;
3071 mutable shared_ptr<Environment> SavedPtr;
3072
3073 EnvironmentSwitcher(ContextNode& ctx,
3074 shared_ptr<Environment>&& p_saved = {})
3075 : Context(ctx), SavedPtr(std::move(p_saved))
3076 {}
3077 DefDeMoveCtor(EnvironmentSwitcher)
3078
3079 DefDeMoveAssignment(EnvironmentSwitcher)
3080
3081 void
3082 operator()() const ynothrowv
3083 {
3084 if(SavedPtr)
3085 Context.get().SwitchEnvironmentUnchecked(std::move(SavedPtr));
3086 }
3087 };
3088
3089
3099 template<typename _fCurrent>
3100 inline ReductionStatus
3101 RelaySwitched(ContextNode& ctx, _fCurrent&& cur)
3102 {
3103 ctx.SetupFront(yforward(cur));
3104 return ReductionStatus::Partial;
3105 }
3106
3107 } // namespace NPL;
3108
3109 #endif
3110
NPL::ParseNPLANodeString
YB_ATTR_nodiscard YF_API YB_PURE string ParseNPLANodeString(const ValueNode &)
解析 NPLA 节点字符串。
Definition: NPLA.cpp:76
DefDeCtor
#define DefDeCtor(_t)
简单通用成员函数定义。
Definition: YBaseMacro.h:157
NPL::TypeError
类型错误。
Definition: NPLA.h:475
YB_ATTR_nodiscard
#define YB_ATTR_nodiscard
标记返回值不被忽略的属性。
Definition: ydef.h:715
DefPred
#define DefPred(_q, _n,...)
Definition: YBaseMacro.h:232
NPL::Environment::Environment
Environment(const ValueObject &vo, allocator_type a)
构造：使用父环境。
Definition: NPLA.h:2082
NPL::ContextNode::ReductionGuard
规约守卫：暂存当前动作序列。
Definition: NPLA.h:2473
ystdex::fseq::front
identity< _type > front(empty_base< _type, _types... >)
Definition: variadic.hpp:74
CHRLib::e
const char const char * e
Definition: CharacterProcessing.h:112
NPL::EnvironmentSwitcher::DefDeMoveCtor
DefDeMoveCtor(EnvironmentSwitcher) DefDeMoveAssignment(EnvironmentSwitcher) void operator()() const ynothrowv
Definition: NPLA.h:3077
NPL::ParameterMismatch
参数不匹配。
Definition: NPLA.h:575
NPL::TermReference
项引用。
Definition: NPLA.h:1068
DefGetterMem
#define DefGetterMem(_q, _t, _n, _m)
Definition: YBaseMacro.h:247
x
const EncapsulationBase & x
Definition: NPLA1Forms.cpp:1536
NPL::Environment::CheckParent
static void CheckParent(const ValueObject &)
检查可作为父环境的宿主对象。
NPL::SXML::MakeAttributeLiteral
YB_ATTR_nodiscard YB_PURE NodeLiteral MakeAttributeLiteral(const string &name, _tParams &&... args)
Definition: NPLA.h:409
NPL::IndentGenerator
function< string(size_t)> IndentGenerator
生成前缀缩进的函数类型。
Definition: NPLA.h:133
NPL::YAssert
YB_ATTR_nodiscard YB_PURE yconstfn YAssert(!buf.empty(), "Invalid buffer found.")
NPL::ContextNode::ReductionGuard::~ReductionGuard
~ReductionGuard()
Definition: NPLA.h:2491
CatchIgnore
#define CatchIgnore(_ex)
指定异常处理器忽略指定异常。
Definition: YBaseMacro.h:133
NPL::ParseNPLATermString
YB_ATTR_nodiscard YF_API YB_PURE string ParseNPLATermString(const TermNode &)
解析 NPLA 项节点字符串。
Definition: NPLA.cpp:133
CHRLib::c
c
Definition: CharacterProcessing.h:84
NPL::InsertSyntaxNode
TNIter InsertSyntaxNode(_tNodeOrCon &&node_or_con, _type &&arg, _tParams &&... args)
Definition: NPLA.h:261
NPL::TryAccessTerm
YB_ATTR_nodiscard YB_PURE observer_ptr< _type > TryAccessTerm(TermNode &term)
尝试访问项的指定类型叶节点对象指针。
Definition: NPLA.h:895
ystdex::derived_entity
bases::derived_entity< _tBase, _tParams... > derived_entity
Definition: base.h:225
ystdex::invoke
invoke_result_t< _fCallable, _tParams... > invoke(_fCallable &&f, _tParams &&... args)
调用可调用对象。
Definition: invoke.hpp:538
YSLib::SetContentWith
_fCallable void SetContentWith(ValueNode &dst, _tNode &&node, _fCallable f)
Definition: ValueNode.h:1440
NPL::ReductionStatus::Neutral
@ Neutral
中立规约：规约成功终止，且未指定是否需要保留子项。
base.h
基类实用设施。
NPL::TermToString
YB_ATTR_nodiscard YF_API YB_PURE string TermToString(const TermNode &)
访问项的值并转换为字符串形式的外部表示。
Definition: NPLA.cpp:558
YB_PURE
#define YB_PURE
指示函数或函数模板实例为纯函数。
Definition: ydef.h:919
NPL::ReferenceTermOp::operator()
auto operator()(_type &&term) const ynoexcept_spec(NPL
Definition: NPLA.h:1491
NPL::Environment::swap
friend y swap(x.Parent, y.Parent)
NPL::SXML::MakeXMLDoc
YB_ATTR_nodiscard YF_API YB_PURE TermNode MakeXMLDoc(const string &={}, const string &="1.0", const string &="UTF-8", const string &={})
构造包含 XML 声明的 SXML 文档节点。
Definition: NPLA.cpp:330
NPL::ListTypeError
列表类型错误。
Definition: NPLA.h:515
NPL::ContextNode::PDefH
PDefH(void, Shift, ReducerSequence &rs, ReducerSequence::const_iterator i) ynothrow ImplExpr(rs.splice_after(rs.cbefore_begin()
转移当第二参数指定的位置之前的当前动作序列的动作到第一参数。
NPL::NPLTag
NPL 元标签。
Definition: NPL.h:44
NPL::TermReference::r_env
EnvironmentReference r_env
包含引用的锚对象指针的环境引用。
Definition: NPLA.h:1081
NPL::RelaySwitched
ReductionStatus RelaySwitched(ContextNode &ctx, _fCurrent &&cur)
异步规约指定动作和上下文中的当前动作。
Definition: NPLA.h:3101
NPL::BadIdentifier
标识符错误。
Definition: NPLA.h:626
NPL::Environment
环境。
Definition: NPLA.h:2004
NPL::TermReference::term_ref
lref< TermNode > term_ref
Definition: NPLA.h:1071
ystdex::retry_on_cond
invoke_result_t< _fCallable, _tParams... > retry_on_cond(_fCond cond, _fCallable &&f, _tParams &&... args)
循环重复调用：代替直接使用 do-while 语句以避免过多引入作用域外的变量。
Definition: functional.hpp:554
YSLib::Drawing::r
The boundary is out of the const Graphics const Rect const Point const Point Color c const Rect const Rect & r
Definition: YDraw.h:174
NPL::MapNPLALeafNode
YB_ATTR_nodiscard YF_API YB_PURE ValueNode MapNPLALeafNode(const TermNode &)
映射 NPLA 叶节点。
Definition: NPLA.cpp:139
NPL::A1::Internals::term
_fCurrent TermNode &decltype(cur(term, ctx)) term
Definition: NPLA1Internals.h:593
NPL::Environment::NameResolution
pair< observer_ptr< BindingMap::mapped_type >, shared_ptr< Environment > > NameResolution
名称解析结果。
Definition: NPLA.h:2016
platform::Descriptions::RecordLevel
RecordLevel
记录等级。
Definition: YCommon.h:178
NPL::Environment::AddValue
bool AddValue(BindingMap::const_iterator hint, _tKey &&k, _tParams &&... args)
Definition: NPLA.h:2169
NPL::Environment::Bind
TermNode & Bind(_tKey &&k, _tNode &&tm)
添加或覆盖绑定。
Definition: NPLA.h:2182
NPL::ReducerFunctionType
ReductionStatus(ContextNode &) ReducerFunctionType
规约器函数原型。
Definition: NPLA.h:2340
DefDeMoveCtor
#define DefDeMoveCtor(_t)
Definition: YBaseMacro.h:167
NPL::CategorizeLexeme
YB_ATTR_nodiscard YF_API YB_PURE LexemeCategory CategorizeLexeme(string_view) ynothrowv
对词素分类。
Definition: NPLA.cpp:532
ystdex::dep_ops::equality_comparable
_t< details::ops_seq< _type, _type2, _tOpt, cond_t< is_same< _type, _type2 >, index_sequence< 7 >, index_sequence< 6, 7, 8 > >> > equality_comparable
Definition: operators.hpp:265
NPL::string_view
YB_ATTR_nodiscard ctx string_view
Definition: NPLA.h:3020
NPL::Environment::Environment
Environment(const Environment &e)
Definition: NPLA.h:2098
YB_FLATTEN
#define YB_FLATTEN
标记函数尽可能内联定义内的调用。
Definition: ydef.h:843
NPL::LexemeCategory
LexemeCategory
字面量类别。
Definition: NPLA.h:689
TermTags
TermTags
标签：表示引用元数据的位。
Definition: SContext.h:108
NPL::ThrowListTypeErrorForInvalidType
YB_NORETURN YF_API void ThrowListTypeErrorForInvalidType(const ystdex::type_info &, const TermNode &, bool)
对列表项抛出指定预期访问值的类型的异常。
Definition: NPLA.cpp:583
NPL::InvalidSyntax::DefDeCopyCtor
DefDeCopyCtor(InvalidSyntax) ~InvalidSyntax() override
虚析构：类定义外默认实现。
NPL::NodeToString
function< string(const ValueNode &)> NodeToString
Definition: NPLA.h:99
Parent
IO::Path Parent
Definition: Initialization.cpp:117
NPL::ContextNode::ReducerSequence::DefDeMoveCtor
DefDeMoveCtor(ReducerSequence) ~ReducerSequence()
Definition: NPLA.h:2438
NPL::DefaultGenerateIndent
YB_ATTR_nodiscard YF_API YB_PURE string DefaultGenerateIndent(size_t)
默认生成缩进：生成水平制表符为单位的缩进。
Definition: NPLA.cpp:83
NPL::Environment::PDefH
friend PDefH(void, swap, Environment &x, Environment &y) ynothrow ImplExpr(swap(x.Bindings
NPL::AllocateEnvironment
shared_ptr< Environment > AllocateEnvironment(ContextNode &ctx, _tParams &&... args)
Definition: NPLA.h:2917
NPL::TermReference::TermReference
TermReference(TermTags t, TermNode &term, _tParam &&arg, _tParams &&... args) ynothrow
构造：使用参数指定的标签及引用。
Definition: NPLA.h:1100
ynoexcept_spec
#define ynoexcept_spec(...)
表达式 noexcept 异常规范。
Definition: ydef.h:1181
NPL::TermToNamePtr
YB_ATTR_nodiscard YB_PURE observer_ptr< const TokenValue > TermToNamePtr(const TermNode &)
访问项的值作为记号。
NPL::ReduceHeadEmptyList
ReductionStatus::Retained YF_API ReductionStatus ReduceHeadEmptyList(TermNode &) ynothrow
规约第一个非结尾空列表子项。
Definition: NPLA.cpp:831
NPL::SXML::ConvertStringNode
YB_ATTR_nodiscard YF_API YB_PURE string ConvertStringNode(const TermNode &)
转换 SXML 节点为被转义的 XML 字符串。
Definition: NPLA.cpp:299
NPL::ReductionStatus::Clean
@ Clean
纯值规约：规约成功终止，且要求最终清理子项。
YF_API
#define YF_API
Definition: Platform.h:56
ystdex::copy_and_swap
_type & copy_and_swap(_type &obj, const _type2 &new_val)
复制对象并交换。
Definition: swap.hpp:514
NPL::SXML::PrintSyntaxNode
YF_API void PrintSyntaxNode(std::ostream &os, const TermNode &, IndentGenerator=DefaultGenerateIndent, size_t=0)
打印 SContext::Analyze 分析取得的 SXML 语法树节点并刷新流。
Definition: NPLA.cpp:305
NPL::ParameterMismatch::DefDeCopyCtor
DefDeCopyCtor(ParameterMismatch) ~ParameterMismatch() override
虚析构：类定义外默认实现。
ystdex::any_ops
Definition: any.h:68
NPL::IsList
YB_ATTR_nodiscard YB_PURE const TermNode &term ynothrow const TermNode &term ynothrow const TermNode &term ynothrow const TermNode &term ynothrow IsList
Definition: SContext.h:545
NPL::ReduceToReferenceAt
PDefH(ReductionStatus, ReduceToList, TermNode &term) ynothrow ImplRet(IsBranchedList(term) ? ReduceBranchToList(term) YF_API ReductionStatus ReduceToReferenceAt(TermNode &, TermNode &, ResolvedTermReferencePtr)
规约为列表：对分支列表节点移除第一个子项，保留余下的子项作为列表。
Definition: NPLA.h:1932
NPL::TypeError::DefDeCopyCtor
DefDeCopyCtor(TypeError) ~TypeError() override
虚析构：类定义外默认实现。
NPL::SXML::ParseOption
ParseOption
限定解析选项。
Definition: NPL.h:61
ystdex::expand_proxy
Definition: functional.hpp:471
NPL::IsNPLAExtendedLiteral
YB_ATTR_nodiscard YF_API YB_PURE bool IsNPLAExtendedLiteral(string_view) ynothrowv
判断不是非扩展字面量的词素是否为 NPLA 扩展字面量。
Definition: NPLA.cpp:541
NPL::TermToTags
YB_ATTR_nodiscard YF_API YB_PURE TermTags TermToTags(TermNode &)
访问项初始化标签。
Definition: NPLA.cpp:575
ystdex::map::get_allocator
allocator_type get_allocator() const
Definition: map.hpp:221
platform_ex::Windows::Invalid
@ Invalid
Definition: Win32/include/YCLib/MinGW32.h:485
NPL::LiftTermOrCopy
PDefH(void, LiftOther, TermNode &term, TermNode &tm) ImplExpr(term.MoveContent(std YF_API void LiftTermOrCopy(TermNode &, TermNode &, bool)
提升项：设置项的内容为参数指定的项或值。
Definition: NPLA.h:1637
NPL::ReductionStatus::Retained
@ Retained
非纯值规约：规约成功终止，且需要保留子项。
NPL::ReduceBranchToListValue
PDefH(void, LiftSubtermsToReturn, TermNode &term) ImplExpr(std YF_API ReductionStatus ReduceBranchToListValue(TermNode &) ynothrowv
对每个子项提升项的值数据成员可能包含的引用值。
Definition: NPLA.h:1848
exception.h
标准库实现 <exception> 修正。
ystdex::bad_any_cast
动态泛型转换失败异常。
Definition: any.h:1091
ystdex::invoke_value_or
auto invoke_value_or(_func f, _type &&p) -> decay_t< decltype(ystdex::invoke(f, *std::forward< decltype(p)>(p)))>
使用 invoke 调用非空值或取默认值。
Definition: invoke.hpp:588
CHRLib::f
f(d, s)
NPL::A1::Internals::cur
_fCurrent && cur
Definition: NPLA1Internals.h:591
NPL::SXML::MakeAttributeTagLiteral
YB_ATTR_nodiscard YB_PURE NodeLiteral MakeAttributeTagLiteral(_tParams &&... args)
Definition: NPLA.h:396
NPL::Environment::Environment
Environment(BindingMap &&m)
Definition: NPLA.h:2069
ystdex::swap_dependent
void swap_dependent(_type &x, _type &y)(is_nothrow_swappable< _type >())
支持基于 ystdex_swap::swap 的 ADL 的左值交换。
Definition: swap.hpp:371
NPL::InsertChildSyntaxNode
TNIter InsertChildSyntaxNode(_tNodeOrCon &&node_or_con, TermNode &child)
插入语法子节点。
Definition: NPLA.h:271
YSLib::MakeIndex
YB_ATTR_nodiscard YF_API YB_PURE string MakeIndex(size_t)
转换节点大小为新的节点索引值。
Definition: ValueNode.cpp:209
NPL::ValueCategoryMismatch::DefDeCopyCtor
DefDeCopyCtor(ValueCategoryMismatch) ~ValueCategoryMismatch() override
虚析构：类定义外默认实现。
ystdex::map
映射容器。
Definition: map.hpp:79
platform::KeyCategory::Lock
@ Lock
表示锁定键。
Definition: Keys.h:115
NPL::ArityMismatch::expected
size_t expected
Definition: NPLA.h:597
NPL::ArityMismatch::ArityMismatch
ArityMismatch(size_t, size_t, YSLib::RecordLevel=YSLib::Err)
NPL::yunused
yunused(msg)
CHRLib::args
YB_ATTR_nodiscard _tParams && args
Definition: CharacterProcessing.h:649
act
Action act
Definition: NPLA1.cpp:580
NPL::LexemeCategory::Symbol
@ Symbol
符号：非字面量。
NPL::tm
tm
Definition: NPLA.h:1941
NPL::Collapse
pair< TermReference, bool > Collapse(TermReference ref)
Definition: NPLA.cpp:614
ystdex::enable_if_inconvertible_t
enable_if_t<!is_convertible< _tFrom, _tTo >::value, _type > enable_if_inconvertible_t
Definition: meta.hpp:842
NPL::LexemeCategory::Data
@ Data
数据字面量。
ystdex::isdigit
bool isdigit(char c)
区域无关的 std::isdigit 。
Definition: cctype.h:129
NPL::EnvironmentReference::DefDeCopyMoveCtorAssignment
DefDeCopyMoveCtorAssignment(EnvironmentReference) YB_ATTR_nodiscard YB_PURE friend PDefHOp(bool
NPL::ResolveTerm
auto ResolveTerm(_func do_resolve, _tTerm &&term) -> yimpl(decltype(ystdex::expand_proxy< yimpl(void)(_tTerm &&, ResolvedTermReferencePtr)>::call(do_resolve, yforward(term), ResolvedTermReferencePtr())))
解析并间接引用处理可能是引用值的项。
Definition: NPLA.h:1410
YSLib::lv
const char RecordLevel lv
Definition: YException.cpp:61
NPL::MoveCollapsed
YF_API void MoveCollapsed(TermNode &, TermNode &)
提升折叠后的第二参数指定的项。
Definition: NPLA.cpp:741
NPL::ReduceBranchToList
ReductionStatus ReduceBranchToList(TermNode &term) ynothrowv
Definition: NPLA.cpp:816
NPL::MoveRValueToReturn
YF_API void MoveRValueToReturn(TermNode &, TermNode &)
提升第二参数指定的右值项作为第一参数指定项中的返回值。
Definition: NPLA.cpp:801
NPL::ContextNode::ReducerSequence::DefDeCopyAssignment
DefDeCopyAssignment(ReducerSequence) PDefHOp(ReducerSequence &
NPL::TryAccessReferencedTerm
YB_ATTR_nodiscard YB_PURE observer_ptr< _type > TryAccessReferencedTerm(TermNode &term)
Definition: NPLA.h:1338
NPL::BadIdentifier::YB_NONNULL
YB_NONNULL(2) BadIdentifier(const char *
构造：使用作为标识符的字符串、已知实例数和和记录等级。
NPL::TermReference::TermReference
TermReference(TermNode &term, _tParam &&arg, _tParams &&... args) ynothrow
构造：使用参数指定的项并自动判断是否使用引用值初始化。
Definition: NPLA.h:1090
NPL::Environment::RemoveChecked
PDefH(TermTags, MakeTermTags, const TermNode &term) const ImplRet(Frozen ? term.Tags|TermTags void RemoveChecked(string_view)
根据当前状态创建指定项的引用。
Definition: NPLA.h:2282
TNIter
TermNode::iterator TNIter
Definition: SContext.h:501
DefDeCopyMoveCtorAssignment
#define DefDeCopyMoveCtorAssignment(_t)
Definition: YBaseMacro.h:202
NPL::ArityMismatch::DefDeCopyAssignment
DefDeCopyAssignment(ArityMismatch) DefGetter(const ynothrow
YSLib::LoggedEvent
记录日志的异常事件类。
Definition: YException.h:51
YSLib::IO::_tString
const string &path const String &path class class class _tString
Definition: YSLib/Service/FileSystem.h:612
NPL::Environment::Environment
Environment(pmr::memory_resource &rsrc)
构造：使用指定的存储资源构造的绑定映射分配器初始化空环境。
Definition: NPLA.h:2054
NPL::Environment::PDefHOp
YB_ATTR_nodiscard YB_PURE friend PDefHOp(bool,==, const Environment &x, const Environment &y) ynothrow ImplRet(ystdex
判断锚对象未被外部引用。
Definition: NPLA.h:2126
YB_NORETURN
#define YB_NORETURN
指定无返回值函数。
Definition: ydef.h:877
ystdex::make_observer
observer_ptr< _type > make_observer(_type *p)
Definition: pointer.hpp:405
NPL::IsBranchedList
YB_ATTR_nodiscard YB_PURE IsBranchedList
Definition: SContext.h:519
yforward
#define yforward(_expr)
根据参数类型使用 std::forward 转发对应参数。
Definition: ydef.h:1508
NPL::ImplExpr
YF_API const char src const string const char const char *src ImplExpr(InstallDirectory(string(dst), string(src))) YF_API YB_NONNULL(1
安装硬链接：创建硬链接，失败则安装文件。
YSLib::ValueObject
值类型对象类。
Definition: YObject.h:1068
ystdex::try_emplace
std::pair< typename _tAssocCon::iterator, bool > try_emplace(_tAssocCon &con, _tKey &&k, _tParams &&... args)
Definition: container.hpp:1039
ystdex::cpp2017::data
auto data(_tRange &c) -> decltype(c.data())
Definition: range.hpp:581
NPL::AccessRegular
YB_ATTR_nodiscard YB_PURE auto AccessRegular(_tTerm &term, bool has_ref) -> yimpl(decltype(NPL::Access< _type >(term)))
访问项的指定类型正规值。
Definition: NPLA.h:1447
NPL::IsUniqueTerm
YB_ATTR_nodiscard YF_API YB_PURE bool IsUniqueTerm(const TermNode &)
判断项（的值数据成员）是否表示非引用项或唯一引用。
Definition: NPLA.cpp:657
NPL::InvalidSyntax
无效语法。
Definition: NPLA.h:557
NPL::ContextNode::ReducerSequence::PDefH
friend PDefH(void, swap, ReducerSequence &x, ReducerSequence &y) ynothrowv ImplExpr(YAssert(x.get_allocator()
ystdex::expand_proxy::call
static auto call(_tParams &&... args) -> decltype(expand_proxy< _fCallable, _vLen - 1 >::call(std::forward< decltype(args)>(args)...))
Definition: functional.hpp:505
NPL::EnvironmentReference::EnvironmentReference
EnvironmentReference(_tParam1 &&arg1, _tParam2 &&arg2) ynothrow
构造：使用指定的环境指针和锚对象指针。
Definition: NPLA.h:1007
NPL::Environment::allocator_type
BindingMap::allocator_type allocator_type
分配器类型。
Definition: NPLA.h:2022
NPL::NPLException
NPL 异常基类。
Definition: NPLA.h:445
platform::KeyCodes::DS::Shift
@ Shift
Definition: Keys.h:254
NPL::EnvironmentReference
环境引用计数检查支持。
Definition: NPLA.h:986
NPL::ContextNode::ReducerSequence
动作序列类型：蕴含当前上下文的续延。
Definition: NPLA.h:2405
NPL::ResolveRegular
YB_ATTR_nodiscard YB_PURE auto ResolveRegular(_tTerm &term) -> yimpl(decltype(NPL::Access< _type >(term)))
访问一次解析引用值后的项的指定类型正规值。
Definition: NPLA.h:1467
YB_STATELESS
#define YB_STATELESS
指示函数或函数模板实例为无状态函数。
Definition: ydef.h:941
ystdex::cpp2017::end
auto end(_tRange &c) -> decltype(c.end())
Definition: range.hpp:345
YSLib::ValueNode
值类型节点。
Definition: ValueNode.h:73
NPL::IsLeaf
YB_ATTR_nodiscard YB_PURE const TermNode &term ynothrow const TermNode &term ynothrow const TermNode &term ynothrow IsLeaf
Definition: SContext.h:537
NPL::ReductionStatus::Partial
@ Partial
部分规约：需要继续进行规约。
NPL::NPLException::YB_NONNULL
YB_NONNULL(2) NPLException(const char *str
std
Definition: optional.h:982
YAssertNonnull
#define YAssertNonnull(_expr)
Definition: cassert.h:165
NPL::PrintIndent
YF_API void PrintIndent(std::ostream &, IndentGenerator=DefaultGenerateIndent, size_t=1)
打印缩进。
Definition: NPLA.cpp:89
NPL::ReductionStatus::Regular
@ Regular
已取得正规表示的规约：规约成功且已保证正规化，不指定是否需要保留子项。
platform_ex::Windows::Temporary
@ Temporary
Definition: Win32/include/YCLib/MinGW32.h:470
NPL::ResolveIdentifier
YB_ATTR_nodiscard YF_API TermNode ResolveIdentifier(const ContextNode &, string_view)
解析标识符：解析名称并折叠引用。
Definition: NPLA.cpp:1214
NPL::PDefH
PDefH(void, LiftTermRef, TermNode &term, const TermNode &tm) ImplExpr(NPL PDefH(void, LiftMoved, TermNode &term, const TermReference &ref, bool move) ImplExpr(LiftTermOrCopy(term
提升项引用：使用第二参数指定的项的内容引用替换第一个项的内容。
Definition: NPLA.h:1735
NPL::ReductionStatus::Retrying
@ Retrying
重规约。
DefDeCopyMoveAssignment
#define DefDeCopyMoveAssignment(_t)
Definition: YBaseMacro.h:197
YSLib::i
return i
Definition: YCoreUtilities.h:177
NPL::CheckedReduceWith
auto CheckedReduceWith(_func f, _tParams &&... args) -> decltype(ystdex::retry_on_cond(CheckReducible, f, yforward(args)...))
Definition: NPLA.h:1575
NPL::LiftCollapsed
YF_API void LiftCollapsed(TermNode &, TermNode &, TermReference)
提升折叠后的项引用到指定的项。
Definition: NPLA.cpp:729
NPL::ContextNode::memory_rsrc
lref< pmr::memory_resource > memory_rsrc
内部存储资源。
Definition: NPLA.h:2512
NPL::ArityMismatch::DefDeCopyCtor
DefDeCopyCtor(ArityMismatch) ~ArityMismatch() override
虚析构：类定义外默认实现。
ystdex::type_id
const type_info & type_id()
Definition: typeinfo.h:149
NPL::SXML::MakeTop
YB_ATTR_nodiscard YB_PURE TermNode MakeTop(const string &name, _tParams &&... args)
构造 SXML 文档顶级节点。
Definition: NPLA.h:358
NPL::Resolve
YB_ATTR_nodiscard ctx Resolve(ctx.GetRecordPtr(), id)) YB_ATTR_nodiscard YF_API TermNode MoveResolved(const ContextNode &
转移解析标识符的对象：解析名称并从环境中转移被绑定的对象。
NPL::TermReference::TermReference
TermReference(TermTags t, TermReference &&ref) ynothrow
Definition: NPLA.h:1113
NPL::EnvironmentSwitcher::EnvironmentSwitcher
EnvironmentSwitcher(ContextNode &ctx, shared_ptr< Environment > &&p_saved={})
Definition: NPLA.h:3073
NPL::ValueCategoryMismatch
值类别不匹配。
Definition: NPLA.h:494
NPL::ReferenceTermOp
项引用函数对象操作。
Definition: NPLA.h:1487
NPL::EnvironmentSwitcher
环境切换器。
Definition: NPLA.h:3068
platform::Descriptions::Err
@ Err
Definition: YCommon.h:182
NPL::ArityMismatch
元数不匹配。
Definition: NPLA.h:595
NPL::PrintContainedNodes
void PrintContainedNodes(_func print_bound, _fCallable f)
打印容器边界和其中的 NPLA 节点，且在打印边界前调用前置操作。
Definition: NPLA.h:154
NPL::EnvironmentReference::ImplRet
const EnvironmentReference const EnvironmentReference &y ynothrow ImplRet(x.p_weak.lock()==y.p_weak.lock()) DefGetter(const ynothrow
NPL::SXML::ParseOption::Normal
@ Normal
NPL::LiftToReturn
PDefH(void, LiftTermRef, TermNode &term, const TermNode &tm) ImplExpr(NPL ref move ref move YF_API void LiftToReturn(TermNode &)
提升项作为返回值。
Definition: NPLA.h:1761
platform::containers::vector
std::vector< _type, _tAlloc > vector
Definition: Container.h:102
NPL::IsBoundLValueTerm
YB_ATTR_nodiscard YF_API YB_PURE bool IsBoundLValueTerm(const TermNode &)
判断项（的值数据成员）是否表示被绑定的左值引用。
Definition: NPLA.cpp:642
YSLib::NodeLiteral
包装节点的组合字面量。
Definition: ValueNode.h:1498
NPL::TokenizeTerm
YF_API void TokenizeTerm(TermNode &term)
标记记号节点：递归变换节点，转换其中的词素为记号值。
Definition: NPLA.cpp:592
NPL
Definition: NPL/Configuration.h:35
NPL::BadIdentifier::p_identifier
shared_ptr< string > p_identifier
Definition: NPLA.h:628
NPL::SXML::NodeLiteralToTerm
YB_ATTR_nodiscard YB_PURE TermNode NodeLiteralToTerm(_tString &&name, std::initializer_list< _tLiteral > il)
Definition: NPLA.h:349
YSLib::UI::y
SPos SPos y
Definition: YWidget.cpp:44
NPL::TryAccessReferencedLeaf
YB_ATTR_nodiscard YB_PURE observer_ptr< _type > TryAccessReferencedLeaf(TermNode &term)
尝试访问解析 TermReference 后的项的指定类型对象指针。
Definition: NPLA.h:1319
ystdex::ref_eq
引用等价关系仿函数。
Definition: functor.hpp:450
ystdex::to_string
std::string to_string(const std::thread::id &)
转换 thread::id 为字符串表示。
NPL::ContextNode::ExceptionHandler
function< void(std::exception_ptr)> ExceptionHandler
异常处理器类型。
Definition: NPLA.h:2391
NPL::ListTypeError::DefDeCopyCtor
DefDeCopyCtor(ListTypeError) ~ListTypeError() override
虚析构：类定义外默认实现。
NPL::RegularizeTerm
YF_API ReductionStatus RegularizeTerm(TermNode &, ReductionStatus) ynothrow
按规约结果正规化项。
Definition: NPLA.cpp:686
NPL::CheckRegular
void CheckRegular(_tTerm &term, bool has_ref)
Definition: NPLA.h:1432
ystdex::compose_n
auto compose_n(_func f, _func2 g, _func3 h, _funcs... args) -> decltype(ystdex::compose_n(ystdex::compose_n(f, g), h, args...))
Definition: functional.hpp:168
NPL::ToReducer
Reducer ToReducer(const _tAlloc &a, _tParam &&arg, _tParams &&... args)
Definition: NPLA.h:2368
DefDeCopyAssignment
#define DefDeCopyAssignment(_t)
Definition: YBaseMacro.h:186
NPL::AnchorPtr
yimpl(shared_ptr< const void >) AnchorPtr
锚对象指针。
Definition: NPLA.h:777
YSLib
YSLib 命名空间。
Definition: AndroidHost.h:46
NPL::Environment::Environment
Environment(pmr::memory_resource &rsrc, const ValueObject &vo)
Definition: NPLA.h:2089
NPL::SXML::InsertAttributeNode
void InsertAttributeNode(_tNodeOrCon &&node_or_con, const string &name, std::initializer_list< NodeLiteral > il)
插入只有 XML 属性节点到语法节点。
Definition: NPLA.h:419
NPL::EmplaceLeaf
bool EmplaceLeaf(Environment::BindingMap &m, string_view name, _tParams &&... args)
构造并向绑定目标添加叶节点值。
Definition: NPLA.h:2962
YModules.h
YSLib 用户界面模块配置文件。
ystdex::exclude_self_t
enable_if_t<!is_same_param< _tSelected, _tParam >::value, _type > exclude_self_t
排除选择类型的特定参数的重载。
Definition: meta.hpp:865
NPL::EscapeNodeLiteral
YB_ATTR_nodiscard YF_API YB_PURE string EscapeNodeLiteral(const ValueNode &)
转义 NPLA 节点字面量。
Definition: NPLA.cpp:64
NPL::TermToStringWithReferenceMark
YB_ATTR_nodiscard YF_API YB_PURE string TermToStringWithReferenceMark(const TermNode &, bool)
访问项的值并转换为可选带有引用标记的字符串形式。
Definition: NPLA.cpp:567
NPL::ListReductionFailure
列表规约失败。
Definition: NPLA.h:537
NPL::EnvironmentReference::DefDeCtor
DefDeCtor(EnvironmentReference) EnvironmentReference(const shared_ptr< Environment > &) ynothrow
构造：使用指定的环境指针和此环境的锚对象指针。
Context
ContextNode & Context
Definition: NPLA1Forms.cpp:488
NPL::LiftToReference
void LiftToReference(TermNode &term, TermNode &tm)
Definition: NPLA.cpp:751
NPL::CheckReducible
bool CheckReducible(ReductionStatus status)
Definition: NPLA.cpp:665
NPL::NPLATag
NPLA 元标签。
Definition: NPLA.h:82
NPL::InvalidReference
无效引用。
Definition: NPLA.h:670
NPL::ContextNode
上下文节点。
Definition: NPLA.h:2385
NPL::A1::name
const char * name
Definition: NPLA1.h:1876
NPL::ReduceToReference
ReductionStatus ReduceToReference(TermNode &term, TermNode &tm, ResolvedTermReferencePtr p_ref)
Definition: NPLA.cpp:839
platform::Deref
YB_PURE yconstfn auto Deref(_type &&p) -> decltype(*p)
断言并解引用非空指针。
Definition: Debug.h:547
NPL::TransformToSyntaxNode
YB_ATTR_nodiscard YF_API YB_PURE TermNode TransformToSyntaxNode(ValueNode &&)
变换 NPLA 语法节点为语法分析树的叶节点。
Definition: NPLA.cpp:146
DefSetter
#define DefSetter(_q, _t, _n, _m)
Definition: YBaseMacro.h:252
ynothrowv
#define ynothrowv
YSLib 无异常抛出保证验证：有条件地使用无异常抛出规范。
Definition: ydef.h:1219
ystdex::insert_or_assign
std::pair< typename _tAssocCon::iterator, bool > insert_or_assign(_tAssocCon &con, _tKey &&k, _tParam &&arg)
Definition: container.hpp:1068
NPL::ReferenceTermOp::ComposeReferencedTermOp
YB_STATELESS auto ComposeReferencedTermOp(_func f) -> yimpl(decltype(ystdex::compose_n(f, ReferenceTermOp())))
包装一个非项引用的操作为 NPL::ReferenceTermOp 以支持项引用。
Definition: NPLA.h:1506
ystdex
<memory> 特性测试宏。
Definition: ydef.h:1262
NPL::SXML::MakeXMLDecl
YB_ATTR_nodiscard YF_API YB_PURE TermNode MakeXMLDecl(const string &={}, const string &="1.0", const string &="UTF-8", const string &={})
构造 SXML 文档 XML 声明节点。
Definition: NPLA.cpp:316
NPL::IsMovable
YB_ATTR_nodiscard YB_PURE PDefH(TermNode &, ReferenceTerm, TermNode &term) ynoexcept_spec(std YB_ATTR_nodiscard YB_PURE yconstfn IsMovable
Definition: NPLA.h:1295
NPL::IsUncollapsedTerm
YB_ATTR_nodiscard YF_API YB_PURE bool IsUncollapsedTerm(const TermNode &)
判断项（的值数据成员）是否表示未折叠的引用。
Definition: NPLA.cpp:649
RecordPtr
shared_ptr< Environment > RecordPtr
Definition: NPLA1Forms.cpp:260
YSLib::_tParams
YB_ATTR_nodiscard YB_PURE typename _tParams
Definition: ValueNode.h:1294
NPL::ContextNode::ReductionGuard::ReductionGuard
ReductionGuard(ReductionGuard &&gd) ynothrow
Definition: NPLA.h:2485
NPL::PrintNodeString
YF_API bool PrintNodeString(std::ostream &, const ValueNode &, NodeToString=EscapeNodeLiteral)
打印节点字符串。
Definition: NPLA.cpp:123
NPL::SXML::ConvertDocumentNode
YB_ATTR_nodiscard YF_API string ConvertDocumentNode(const TermNode &, IndentGenerator=DefaultGenerateIndent, size_t=0, ParseOption=ParseOption::Normal)
转换 SXML 文档节点为 XML 字符串。
Definition: NPLA.cpp:197
ystdex::map::const_iterator
typename rep_type::const_iterator const_iterator
Definition: map.hpp:128
DefDeCopyCtor
#define DefDeCopyCtor(_t)
Definition: YBaseMacro.h:162
NPL::ContextNode::ReducerSequenceBase
YSLib::forward_list< Reducer > ReducerSequenceBase
Definition: NPLA.h:2399
DefCvtMem
#define DefCvtMem(_q, _t, _m)
Definition: YBaseMacro.h:211
NPL::EnvironmentSwitcher::SavedPtr
shared_ptr< Environment > SavedPtr
Definition: NPLA.h:3071
ystdex::cpp2017::in_place_type
uniformed_tags::in_place_tag in_place_type(empty_base< _type >)
Definition: placement.hpp:255
NPL::LiftTermValueOrCopy
YF_API void LiftTermValueOrCopy(TermNode &, TermNode &, bool)
提升项的值数据成员或项的值数据成员的副本。
Definition: NPLA.cpp:716
ystdex::any
基于类型擦除的动态泛型对象。
Definition: any.h:1634
NPL::MoveResolved
TermNode MoveResolved(const ContextNode &ctx, string_view id)
Definition: NPLA.cpp:1200
NPL::LiftOtherOrCopy
void LiftOtherOrCopy(TermNode &term, TermNode &tm, bool move)
Definition: NPLA.cpp:696
ystdex::addressof
enable_if_t< has_no_overloaded_addressof< _type >::value, _type * > addressof(_type &r)
尝试对非重载 operator& 提供 constexpr 的 std::addressof 替代。
Definition: addressof.hpp:131
NPL::ContextNode::ReducerSequence::ImplRet
ReducerSequence &&rs ynothrowv ImplRet(YAssert(get_allocator()==rs.get_allocator(), "Invalid allocator found."), swap(rs), *this) void clear() ynothrow
Definition: NPLA.h:2448
NPL::LiteralizeEscapeNodeLiteral
YB_ATTR_nodiscard YF_API YB_PURE string LiteralizeEscapeNodeLiteral(const ValueNode &)
转义 NPLA 节点字面量。
Definition: NPLA.cpp:70
NPL::PrepareCollapse
YB_ATTR_nodiscard YF_API TermNode PrepareCollapse(TermNode &, const shared_ptr< Environment > &)
准备折叠项引用。
Definition: NPLA.cpp:626
NPL::LexemeCategory::Code
@ Code
代码字面量。
NPL::Environment::Environment
Environment(pmr::memory_resource &rsrc, ValueObject &&vo)
Definition: NPLA.h:2092
NPL::ContextNode::SetupFront
void SetupFront(_tParams &&... args)
在当前动作序列中添加动作以重规约。
Definition: NPLA.h:2805
DefGetter
#define DefGetter(_q, _t, _n,...)
Definition: YBaseMacro.h:241
platform::Logger
日志记录器。
Definition: Debug.h:97
NPL::ContextNode::ReductionGuard::ReductionGuard
ReductionGuard(ContextNode &ctx) ynothrow
Definition: NPLA.h:2479
NPL::EnvironmentSwitcher::Context
lref< ContextNode > Context
Definition: NPLA.h:3070
NPL::DecodeNodeIndex
YB_ATTR_nodiscard YF_API YB_PURE string DecodeNodeIndex(const string &)
解码索引节点名称。
Definition: NPLA.cpp:54
ystdex::cpp2014::exchange
_type exchange(_type &obj, _type2 &&new_val)
交换值并返回旧值。
Definition: swap.hpp:535
YB_UNLIKELY
#define YB_UNLIKELY(_expr)
分支预测提示。
Definition: ydef.h:828
NPL::swap
void swap(ContextNode &x, ContextNode &y) ynothrow
Definition: NPLA.cpp:1188
NPL::SXML::ConvertAttributeNodeString
YB_ATTR_nodiscard YF_API YB_PURE string ConvertAttributeNodeString(const TermNode &)
转换 SXML 节点为 XML 属性字符串。
Definition: NPLA.cpp:173
NPL::InvalidReference::DefDeCopyCtor
DefDeCopyCtor(InvalidReference) ~InvalidReference() override
虚析构：类定义外默认实现。
NPL::ContextNode::ReductionGuard::p_ctx
observer_ptr< ContextNode > p_ctx
Definition: NPLA.h:2475
platform::p
return p p
Definition: YCLib/FileSystem.h:209
NPL::PrintNode
YF_API void PrintNode(std::ostream &, const ValueNode &, NodeToString=EscapeNodeLiteral, IndentGenerator=DefaultGenerateIndent, size_t=0)
打印 NPLA 节点。
Definition: NPLA.cpp:96
YSLib::Text::str
YB_ATTR_nodiscard YB_PURE const char const char * str
Definition: TextFile.h:83
NPL::MoveRValueToForward
YF_API void MoveRValueToForward(TermNode &, TermNode &)
提升第二参数指定的右值项作为转发的第一参数指定项中的返回值。
Definition: NPLA.cpp:784
ystdex::enable_if_same_param_t
enable_if_t< is_same_param< _type1, _type2 >::value, _type > enable_if_same_param_t
Definition: meta.hpp:856
const
const Decapsulate const Decapsulate &y ynothrow ContextNode &ctx const
Definition: NPLA1Forms.cpp:1629
ystdex::single_thread::lock
void lock(_tLock1 &&, _tLock2 &&, _tLocks &&...)
Definition: pseudo_mutex.h:990
ystdex::rbegin
reverse_iterator< _type * > rbegin(_type(&&array)[_vN])
Definition: range.hpp:390
platform::bool
YB_ATTR_nodiscard std::FILE *fp bool
Definition: FileIO.h:1271
DefDeMoveAssignment
#define DefDeMoveAssignment(_t)
Definition: YBaseMacro.h:191
NPL::AsTermNode
typename _tParams YB_ATTR_nodiscard YB_PURE ystdex::enable_if_t< ystdex::not_< ystdex::cond_or_t< ystdex::bool_<(sizeof...(_tParams) >=1)>, ystdex::false_, std::is_convertible, ystdex::decay_t< _tParams >..., TermNode::allocator_type > >::value, TermNode > AsTermNode(_tParams &&... args)
Definition: SContext.h:601
NPL::SourceInformation
pair< SourceName, SourceLocation > SourceInformation
源代码信息。
Definition: Lexical.h:109
NPL::TryAccessLeaf
YB_ATTR_nodiscard YB_PURE observer_ptr< _type > TryAccessLeaf(TermNode &term)
尝试访问项的指定类型对象指针。
Definition: NPLA.h:871
ystdex::cpp2017::string
basic_string< char > string
Definition: string.hpp:772
NPL::ListReductionFailure::DefDeCopyCtor
DefDeCopyCtor(ListReductionFailure) ~ListReductionFailure() override
虚析构：类定义外默认实现。
NPL::LexemeCategory::Extended
@ Extended
扩展字面量：由 NPLA 定义的其它字面量类别。
NPL::SXML::PDefH
YB_ATTR_nodiscard YB_PURE PDefH(TermNode, MakeTop,) ImplRet(MakeTop(
Definition: NPLA.h:363
ynothrow
#define ynothrow
YSLib 无异常抛出保证：若支持 noexcept 关键字， 指定特定的 noexcept 异常规范。
Definition: ydef.h:1199
ystdex::try_emplace_hint
std::pair< typename _tAssocCon::iterator, bool > try_emplace_hint(_tAssocCon &con, typename _tAssocCon::const_iterator hint, _tKey &&k, _tParams &&... args)
Definition: container.hpp:1050
YSLib::vo
vo
Definition: YApplication.h:231
TryExpr
#define TryExpr(...)
指定表达式在 try 块中求值。
Definition: YBaseMacro.h:120
ystdex::fseq::pop_front
integer_sequence< _tInt, _vSeq... > pop_front(integer_sequence< _tInt, _vInt, _vSeq... >)
Definition: integer_sequence.hpp:91
NPL::ContextNode::ReductionGuard::i_stacked
ReducerSequence::const_iterator i_stacked
Definition: NPLA.h:2476
platform::containers::forward_list
std::forward_list< _type, _tAlloc > forward_list
Definition: Container.h:96
NPL::Environment::Environment
Environment(ValueObject &&vo, allocator_type a)
Definition: NPLA.h:2085
NPL::get
PDefH(void, LiftTermRef, TermNode &term, const TermNode &tm) ImplExpr(NPL ref get()
Definition: NPLA.h:1737
ystdex::map::allocator_type
_tAlloc allocator_type
Definition: map.hpp:91
ystdex::ref
void ref(const _type &&)=delete
YSLib::NoContainer
yconstexpr const struct YSLib::NoContainerTag NoContainer
NPL::CategorizeBasicLexeme
YB_ATTR_nodiscard YF_API YB_PURE LexemeCategory CategorizeBasicLexeme(string_view) ynothrowv
对排除扩展字面量的词素分类。
NPL::yimpl
yimpl(using) Reducer
规约器：和绑定上下文以外参数的求值遍的处理器具有等价签名的多态函数。
NPL::ContextNode::GetRecordRef
!current Environment::BindingMap GetRecordRef().GetMapRef()) DefGetter(const ynothrow
NPL::ContextNode::SwitchToFreshEnvironment
shared_ptr< Environment > SwitchToFreshEnvironment(ContextNode &ctx, _tParams &&... args)
切换到参数指定的新创建的环境。
Definition: NPLA.h:2942
NPL::IsReferenceTerm
YB_ATTR_nodiscard YF_API YB_PURE bool IsReferenceTerm(const TermNode &)
判断项（的值数据成员）是否为引用项。
Definition: NPLA.cpp:636
NPL::ReductionStatus
ReductionStatus
规约状态：某个项上的一遍规约可能的中间结果。
Definition: NPLA.h:1520
NPL::Environment::DefDeMoveCtor
DefDeMoveCtor(Environment) PDefHOp(Environment &
NPL::Environment::Bindings
BindingMap Bindings
Definition: NPLA.h:2025
yconstfn
#define yconstfn
指定编译时常量函数。
Definition: ydef.h:1073
ystdex::cpp2017::begin
auto begin(_tRange &c) -> decltype(c.begin())
Definition: range.hpp:323
NPL::Environment::Environment
Environment(const BindingMap &m)
构造：使用包含绑定节点的指针。
Definition: NPLA.h:2065
YSLib::a
YB_PURE const _type * a
Definition: YCoreUtilities.h:168
NPL::TermReference::TermReference
TermReference(TermTags t, const TermReference &ref) ynothrow
构造：使用参数指定的标签及现有的项引用。
Definition: NPLA.h:1110
NPL::_tParam
_tParam
Definition: NPLA.h:2367
NPL::ResolveEnvironment
YB_ATTR_nodiscard YF_API pair< shared_ptr< Environment >, bool > ResolveEnvironment(const ValueObject &)
解析环境。
Definition: NPLA.cpp:1224
NPL::ContextNode::ReducerSequence::ReducerSequence
DefDeCtor(ReducerSequence) using ReducerSequenceBase ReducerSequence(const ReducerSequence &act)
Definition: NPLA.h:2435
NPL::ArityMismatch::received
size_t received
Definition: NPLA.h:598
NPL::ImplRet
YB_ATTR_nodiscard YB_PURE PDefH(TermNode &, ReferenceTerm, TermNode &term) ynoexcept_spec(std YB_ATTR_nodiscard YB_PURE yconstfn const TermReference &ref ynothrow ImplRet(ref.IsMovable()) template< typename _tPointer > YB_ATTR_nodiscard YB_PURE inline auto IsMovable(_tPointer p) ynothrow -> decltype(!bool(p)||NPL::IsMovable(*p))
Definition: NPLA.h:1296