YSTest: SContext.h 源文件

YSTest PreAlpha_b900_20201012 The YSLib Test Project

SContext.h
浏览该文件的文档.
1 /*
2 © 2012-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_SContext_h_
29 #define NPL_INC_SContext_h_ 1
30
31 #include "YModules.h"
32 #include YFM_NPL_Lexical // for function, pmr, ByteParser, ystdex::expand_proxy,
33 // ystdex::unref, ystdex::as_const, LexemeList;
34 #include YFM_YSLib_Core_ValueNode // for YSLib::Deref, YSLib::LoggedEvent,
35 // YSLib::MakeIndex, YSLib::NoContainer, YSLib::NoContainerTag,
36 // YSLib::ValueNode, YSLib::ValueObject, YSLib::forward_as_tuple, YSLib::get,
37 // YSLib::make_observer, YSLib::make_pair, YSLib::share_move,
38 // YSLib::make_shared, YSLib::make_weak, YSLib::observer_ptr, YSLib::tuple,
39 // YSLib::weak_ptr, list, YSLib::ListContainerTag, std::initializer_list,
40 // ystdex::create_and_swap, ystdex::forward_like, ystdex::invoke,
41 // YSLib::AccessPtr, ystdex::false_, std::is_convertible, ystdex::decay_t,
42 // ystdex::bool_, ystdex::cond_or_t, ystdex::not_, ystdex::enable_if_t,
43 // ystdex::call_value_or, ystdex::addrof, ystdex::compose, pair,
44 // std::is_lvalue_reference, YSLib::Alert, YSLib::stack;
45 #include <ystdex/range.hpp> // for std::iterator_traits,
46 // ystdex::range_iterator_t, ystdex::begin, ystdex::end,
47 // std::input_iterator_tag, std::random_access_iterator_tag;
48 #include <algorithm> // for std::for_each;
49 #include <ystdex/scope_guard.hpp> // for ystdex::make_guard;
50
51 namespace NPL
52 {
53
55 using YSLib::Deref;
57 using YSLib::LoggedEvent;
59 using YSLib::MakeIndex;
61 using YSLib::NoContainer;
63 using YSLib::NoContainerTag;
65 using YSLib::Nonnull;
67 using YSLib::ValueNode;
69 using YSLib::ValueObject;
71 using YSLib::forward_as_tuple;
73 using YSLib::get;
75 using YSLib::make_observer;
77 using YSLib::make_pair;
79 using YSLib::make_shared;
81 using YSLib::make_weak;
83 using YSLib::observer_ptr;
85 using YSLib::tuple;
87 using YSLib::weak_ptr;
88
89
91
92 enum TermTagIndices : size_t
94 {
95 UnqualifiedIndex = 0,
96 UniqueIndex,
97 NonmodifyingIndex,
98 TemporaryIndex
99 };
100
107 enum class TermTags
108 {
115 Unqualified = 1 << UnqualifiedIndex,
124 Unique = 1 << UniqueIndex,
133 Nonmodifying = 1 << NonmodifyingIndex,
148 Temporary = 1 << TemporaryIndex
149 };
150
152
153 DefBitmaskEnum(TermTags)
154
155
161 YB_ATTR_nodiscard YB_STATELESS yconstfn
162 PDefH(TermTags, GetLValueTagsOf, const TermTags& tags) ynothrow
163 ImplRet(tags & ~TermTags::Temporary)
165
166
167
168
175 class YF_API TermNode
176 {
177 private:
178 // TODO: Deduplicate within %ValueNode?
179 template<typename... _tParams>
180 using enable_value_constructible_t = ystdex::enable_if_t<
181 std::is_constructible<ValueObject, _tParams...>::value>;
182
183 public:
184 using Container = list<TermNode>;
185 using allocator_type = Container::allocator_type;
186 using iterator = Container::iterator;
187 using const_iterator = Container::const_iterator;
188 using reverse_iterator = Container::reverse_iterator;
189 using const_reverse_iterator = Container::const_reverse_iterator;
190
191 private:
193
194 Container container{};
196
197 public:
199 ValueObject Value{};
201
205 TermTags Tags = TermTags::Unqualified;
206
207 DefDeCtor(TermNode)
208 // XXX: Not all constructors like %ValueNode need to be supported here.
210
211 explicit
212 TermNode(allocator_type a)
213 : container(a)
214 {}
215 TermNode(const Container& con)
216 : container(con)
217 {}
218 TermNode(Container&& con)
219 : container(std::move(con))
220 {}
222
223 template<typename... _tParams,
224 yimpl(typename = enable_value_constructible_t<_tParams...>)>
225 inline
226 TermNode(NoContainerTag, _tParams&&... args)
227 : Value(yforward(args)...)
228 {}
229 template<typename... _tParams,
230 yimpl(typename = enable_value_constructible_t<_tParams...>)>
231 TermNode(const Container& con, _tParams&&... args)
232 : container(con), Value(yforward(args)...)
233 {}
234 template<typename... _tParams,
235 yimpl(typename = enable_value_constructible_t<_tParams...>)>
236 TermNode(Container&& con, _tParams&&... args)
237 : container(std::move(con)), Value(yforward(args)...)
238 {}
239 template<typename... _tParams,
240 yimpl(typename = enable_value_constructible_t<_tParams...>)>
241 inline
242 TermNode(std::allocator_arg_t, allocator_type a, NoContainerTag,
243 _tParams&&... args)
244 : container(a), Value(yforward(args)...)
245 {}
246 template<typename... _tParams,
247 yimpl(typename = enable_value_constructible_t<_tParams...>)>
248 inline
249 TermNode(std::allocator_arg_t, allocator_type a, const Container& con,
250 _tParams&&... args)
251 : container(con, a), Value(yforward(args)...)
252 {}
253 template<typename... _tParams,
254 yimpl(typename = enable_value_constructible_t<_tParams...>)>
255 inline
256 TermNode(std::allocator_arg_t, allocator_type a, Container&& con,
257 _tParams&&... args)
258 : container(std::move(con), a), Value(yforward(args)...)
259 {}
261 TermNode(const ValueNode& nd, allocator_type a)
262 : container(ConCons(nd.GetContainer(), a)), Value(nd.Value)
263 {}
264 TermNode(ValueNode&& nd, allocator_type a)
265 : container(ConCons(std::move(nd.GetContainerRef()), a)),
266 Value(std::move(nd.Value))
267 {}
269 // XXX: This needs tag to avoid clash with other constructors.
270 TermNode(YSLib::ListContainerTag, std::initializer_list<TermNode> il)
271 : container(il)
272 {}
273 TermNode(std::initializer_list<TermNode> il, allocator_type a)
274 : container(il, a)
275 {}
277 template<typename... _tParams,
278 yimpl(typename = enable_value_constructible_t<_tParams...>)>
279 inline
280 TermNode(std::allocator_arg_t, allocator_type a,
281 std::initializer_list<TermNode> il, _tParams&&... args)
282 : TermNode(std::allocator_arg, a, Container(il, a), yforward(args)...)
283 {}
284 explicit
285 TermNode(const ValueNode& nd)
286 : container(ConCons(nd.GetContainer())), Value(nd.Value)
287 {}
288 explicit
289 TermNode(ValueNode&& nd)
290 : container(ConCons(std::move(nd.GetContainer()))),
291 Value(std::move(nd.Value))
292 {}
297 TermNode(const TermNode& tm)
298 : TermNode(tm, tm.get_allocator())
299 {}
300 TermNode(const TermNode& tm, allocator_type a)
301 : container(tm.container, a), Value(tm.Value), Tags(tm.Tags)
302 {}
303 DefDeMoveCtor(TermNode)
304 TermNode(TermNode&& tm, allocator_type a)
305 : container(std::move(tm.container), a), Value(std::move(tm.Value)),
306 Tags(tm.Tags)
307 {}
308
313 PDefHOp(TermNode&, =, const TermNode& tm)
314 ImplRet(ystdex::copy_and_swap(*this, tm))
319 DefDeMoveAssignment(TermNode)
320
321
322 YB_PURE DefBoolNeg(YB_PURE explicit, bool(Value) || !empty())
323
324
325
326 DefGetter(const ynothrow, const Container&, Container, container)
327 DefGetter(ynothrow, Container&, ContainerRef, container)
328
329 template<class _tCon, class _type>
330 yimpl(ystdex::enable_if_t)<
331 ystdex::and_<std::is_assignable<Container, _tCon&&>,
332 std::is_assignable<ValueObject, _type&&>>::value>
333 SetContent(_tCon&& con, _type&& val) ynoexcept(ystdex::and_<
334 std::is_nothrow_assignable<Container, _tCon&&>,
335 std::is_nothrow_assignable<ValueObject, _type&&>>())
336 {
337 container = yforward(con);
338 Value = yforward(val);
339 }
340 PDefH(void, SetContent, const TermNode& term)
341 ImplExpr(SetContent(term.container, term.Value))
342 PDefH(void, SetContent, TermNode&& term)
343 ImplExpr(SetContent(std::move(term.container), std::move(term.Value)))
345
347 PDefH(void, Add, const TermNode& term)
348 ImplExpr(container.push_back(term))
350 PDefH(void, Add, TermNode&& term)
351 ImplExpr(container.push_back(std::move(term)))
352
353
354
355 template<typename... _tParams>
356 static inline void
357 AddValueTo(Container& con, _tParams&&... args)
358 {
359 con.emplace_back(NoContainer, yforward(args)...);
360 }
361 template<typename... _tParams>
362 static inline void
363 AddValueTo(const_iterator position, Container& con, _tParams&&... args)
364 {
365 con.emplace(position, NoContainer, yforward(args)...);
366 }
367
368 PDefH(void, Clear, ) ynothrow
369 ImplExpr(Value.Clear(), ClearContainer())
370
371 PDefH(void, ClearContainer, ) ynothrow
372 ImplExpr(container.clear())
373
374 private:
375 static TermNode::Container
376 ConCons(const ValueNode::Container&);
377 static TermNode::Container
378 ConCons(ValueNode::Container&&);
379 static TermNode::Container
380 ConCons(const ValueNode::Container&, allocator_type);
381 static TermNode::Container
382 ConCons(ValueNode::Container&&, allocator_type);
383
384 public:
385 template<class _tCon, typename _fCallable,
386 yimpl(typename = ystdex::enable_if_t<
387 std::is_same<Container&, ystdex::remove_cvref_t<_tCon>&>::value>)>
388 static Container
389 CreateRecursively(_tCon&& con, _fCallable f)
390 {
391 Container res(con.get_allocator());
392
393 for(auto&& tm : con)
394 res.emplace_back(CreateRecursively(
395 ystdex::forward_like<_tCon>(tm.container), f),
396 ystdex::invoke(f, ystdex::forward_like<_tCon>(tm.Value)));
397 return res;
398 }
400
401 template<typename _fCallable>
402 Container
403 CreateWith(_fCallable f) &
404 {
405 return CreateRecursively(container, f);
406 }
407 template<typename _fCallable>
408 Container
409 CreateWith(_fCallable f) const&
410 {
411 return CreateRecursively(container, f);
412 }
413 template<typename _fCallable>
414 Container
415 CreateWith(_fCallable f) &&
416 {
417 return CreateRecursively(std::move(container), f);
418 }
419 template<typename _fCallable>
420 Container
421 CreateWith(_fCallable f) const&&
422 {
423 return CreateRecursively(std::move(container), f);
424 }
425
434 void
435 MoveContent(TermNode&&);
436
437 PDefH(void, Remove, const_iterator i)
438 ImplExpr(erase(i))
439
440 PDefH(void, SwapContainer, TermNode& term) ynothrowv
441 ImplExpr(YAssert(get_allocator() == term.get_allocator(),
442 "Invalid allocator found."), container.swap(term.container))
443
444 void
445 SwapContent(TermNode&) ynothrowv;
446
447 YB_ATTR_nodiscard YB_PURE PDefH(iterator, begin, ) ynothrow
448 ImplRet(container.begin())
449 YB_ATTR_nodiscard YB_PURE PDefH(const_iterator, begin, ) const ynothrow
450 ImplRet(container.begin())
451
452
453 DefFwdTmpl(, iterator, emplace, (container.emplace_back(yforward(args)...),
454 std::prev(container.end())))
455
456
457 YB_ATTR_nodiscard YB_PURE PDefH(bool, empty, ) const ynothrow
458 ImplRet(container.empty())
459
460 PDefH(iterator, erase, const_iterator i)
461 ImplRet(container.erase(i))
462 PDefH(iterator, erase, const_iterator first, const_iterator last)
463 ImplRet(container.erase(first, last))
464
465 YB_ATTR_nodiscard YB_PURE PDefH(iterator, end, ) ynothrow
466 ImplRet(container.end())
467 YB_ATTR_nodiscard YB_PURE PDefH(const_iterator, end, ) const ynothrow
468 ImplRet(container.end())
469
470
471 YB_ATTR_nodiscard YB_PURE
472 PDefH(allocator_type, get_allocator, ) const ynothrow
473 ImplRet(container.get_allocator())
474
475 DefFwdTmpl(-> decltype(container.insert(yforward(args)...)), auto,
476 insert, container.insert(yforward(args)...))
477
478 YB_ATTR_nodiscard YB_PURE PDefH(reverse_iterator, rbegin, ) ynothrow
479 ImplRet(container.rbegin())
480 YB_ATTR_nodiscard YB_PURE
481 PDefH(const_reverse_iterator, rbegin, ) const ynothrow
482 ImplRet(container.rbegin())
483
484 YB_ATTR_nodiscard YB_PURE PDefH(reverse_iterator, rend, ) ynothrow
485 ImplRet(container.rend())
486 YB_ATTR_nodiscard YB_PURE
487 PDefH(const_reverse_iterator, rend, ) const ynothrow
488 ImplRet(container.rend())
489
490
491 YB_ATTR_nodiscard YB_PURE PDefH(size_t, size, ) const ynothrow
492 ImplRet(container.size())
493
494 YF_API friend void
495 swap(TermNode&, TermNode&) ynothrowv;
496 };
497
499
500 using TNIter = TermNode::iterator;
503 using TNCIter = TermNode::const_iterator;
504
510 YB_ATTR_nodiscard YB_PURE inline PDefH(bool, IsBranch, const TermNode& term)
512 ynothrow
513 ImplRet(!term.empty())
514
515
519 YB_ATTR_nodiscard YB_PURE inline PDefH(bool, IsBranchedList,
520 const TermNode& term) ynothrow
521 ImplRet(!(term.empty() || term.Value))
522
524 YB_ATTR_nodiscard YB_PURE inline PDefH(bool, IsEmpty, const TermNode& term)
525 ynothrow
526 ImplRet(!term)
527
532 YB_ATTR_nodiscard YB_PURE inline PDefH(bool, IsExtendedList,
533 const TermNode& term) ynothrow
534 ImplRet(!(term.empty() && term.Value))
535
537 YB_ATTR_nodiscard YB_PURE inline PDefH(bool, IsLeaf, const TermNode& term)
538 ynothrow
539 ImplRet(term.empty())
540
545 YB_ATTR_nodiscard YB_PURE inline PDefH(bool, IsList, const TermNode& term)
546 ynothrow
547 ImplRet(!term.Value)
549
551 using YSLib::Access;
553 template<typename _type>
554 YB_ATTR_nodiscard YB_PURE inline _type&
555 Access(TermNode& term)
556 {
557 return term.Value.Access<_type>();
558 }
560 template<typename _type>
561 YB_ATTR_nodiscard YB_PURE inline const _type&
562 Access(const TermNode& term)
563 {
564 return term.Value.Access<_type>();
565 }
566
568 using YSLib::AccessPtr;
570 template<typename _type>
571 YB_ATTR_nodiscard YB_PURE inline observer_ptr<_type>
572 AccessPtr(TermNode& term) ynothrow
573 {
574 return term.Value.AccessPtr<_type>();
575 }
577 template<typename _type>
578 YB_ATTR_nodiscard YB_PURE inline observer_ptr<const _type>
579 AccessPtr(const TermNode& term) ynothrow
580 {
581 return term.Value.AccessPtr<_type>();
582 }
583
589 inline PDefH(void, AssertBranch, const TermNode& term,
590 const char* msg = "Invalid term found.") ynothrowv
591 ImplExpr(yunused(term), yunused(msg), YAssert(IsBranch(term), msg))
592
594
595 template<typename... _tParam, typename... _tParams>
597 YB_ATTR_nodiscard YB_PURE inline
598 ystdex::enable_if_t<ystdex::not_<ystdex::cond_or_t<ystdex::bool_<
599 (sizeof...(_tParams) >= 1)>, ystdex::false_, std::is_convertible,
600 ystdex::decay_t<_tParams>..., TermNode::allocator_type>>::value, TermNode>
601 AsTermNode(_tParams&&... args)
602 {
603 return TermNode(NoContainer, yforward(args)...);
604 }
606 template<typename... _tParams>
607 YB_ATTR_nodiscard YB_PURE inline TermNode
608 AsTermNode(TermNode::allocator_type a, _tParams&&... args)
609 {
610 return TermNode(std::allocator_arg, a, NoContainer, yforward(args)...);
611 }
613
615
616 // NOTE: Like %YSLib::GetValueOf.
617 YB_ATTR_nodiscard YB_PURE inline
618 PDefH(ValueObject, GetValueOf, observer_ptr<const TermNode> p_term)
619 ImplRet(ystdex::call_value_or(
620 [](const TermNode& term) -> const ValueObject&{
621 return term.Value;
622 }, p_term))
623
624 // NOTE: Like %YSLib::GetValuePtrOf.
625 YB_ATTR_nodiscard YB_PURE inline PDefH(observer_ptr<const ValueObject>,
626 GetValuePtrOf, observer_ptr<const TermNode> p_term)
627 ImplRet(ystdex::call_value_or(ystdex::compose(make_observer<const
628 ValueObject>, ystdex::addrof<>(),
629 [](const TermNode& term) -> const ValueObject&{
630 return term.Value;
631 }), p_term))
632
634
635
637 YB_ATTR_nodiscard YB_PURE inline
638 PDefH(TermNode&, AccessFirstSubterm, TermNode& term)
639 ImplRet(AssertBranch(term), NPL::Deref(term.begin()))
640 YB_ATTR_nodiscard YB_PURE inline
641 PDefH(const TermNode&, AccessFirstSubterm, const TermNode& term)
642 ImplRet(AssertBranch(term), NPL::Deref(term.begin()))
643
644 YB_ATTR_nodiscard YB_PURE inline
645 PDefH(TermNode&&, MoveFirstSubterm, TermNode& term)
646 ImplRet(std::move(AccessFirstSubterm(term)))
648
649 YB_ATTR_nodiscard inline
650 PDefH(shared_ptr<TermNode>, ShareMoveTerm, TermNode& term)
651 ImplRet(YSLib::share_move(term.get_allocator(), term))
652 YB_ATTR_nodiscard inline
653 PDefH(shared_ptr<TermNode>, ShareMoveTerm, TermNode&& term)
654 ImplRet(YSLib::share_move(term.get_allocator(), term))
656
658 inline PDefH(void, RemoveHead, TermNode& term) ynothrowv
659 ImplExpr(YAssert(!term.empty(), "Empty term container found."),
660 term.erase(term.begin()))
661
667 template<typename _fCallable, class _tNode>
668 void
669 SetContentWith(TermNode& dst, _tNode&& node, _fCallable f)
670 {
671 // NOTE: Similar to %YSLib::SetContentWith.
672 auto con(yforward(node).CreateWith(f));
673 auto vo(ystdex::invoke(f, yforward(node).Value));
674
675 dst.SetContent(std::move(con), std::move(vo));
676 }
678
679
688 template<typename _fCallable, class _tNode>
689 void
690 TraverseSubnodes(_fCallable f, const _tNode& node)
691 {
692 // TODO: Null coalescing or variant value?
693 if(const auto p = AccessPtr<YSLib::NodeSequence>(node))
694 for(const auto& nd : *p)
695 ystdex::invoke(f, _tNode(nd));
696 else
697 for(const auto& nd : node)
698 ystdex::invoke(f, nd);
699 }
700
701
706 template<typename _type>
707 YB_ATTR_nodiscard YB_PURE inline bool
708 HasValue(const TermNode& term, const _type& x)
709 {
710 return term.Value == x;
711 }
712
713
715
716
721 template<class _type, yimpl(typename = ystdex::enable_if_convertible_t<
722 const _type&, const LexemeList::value_type&>)>
723 YB_ATTR_nodiscard YB_STATELESS const _type&
724 ToLexeme(const _type& val) ynothrow
725 {
726 return val;
727 }
728 YB_ATTR_nodiscard YB_PURE inline PDefH(const string&, ToLexeme,
729 const SourcedByteParser::ParseResult::value_type& val) ynothrow
730 ImplRet(val.second)
732
737 struct LexemeTokenizer
738 {
739 TermNode::allocator_type Allocator;
740
741 LexemeTokenizer(TermNode::allocator_type a = {})
742 : Allocator(a)
743 {}
744
746 template<class _type>
747 YB_ATTR_nodiscard YB_PURE TermNode
748 operator()(const _type& val) const
749 {
750 return NPL::AsTermNode(Allocator, std::allocator_arg, Allocator,
751 ToLexeme(val));
752 }
753 };
754
755
761 class YF_API ReaderState
762 {
763 public:
764 char LeftDelimiter = '(';
765 char RightDelimiter = ')';
766 size_t LeftDelimiterCount = 0;
767 size_t RightDelimiterCount = 0;
768
769 DefDeCtor(ReaderState)
770
771 DefPred(const ynothrow, Balanced, LeftDelimiterCount == RightDelimiterCount)
772 DefPred(const ynothrow, Valid, LeftDelimiterCount >= RightDelimiterCount)
773
774 PDefH(void, Reset, ) ynothrow
775 ImplExpr(*this = ReaderState())
776
778 template<class _type>
779 void
780 Update(const _type& val)
781 {
782 UpdateLexeme(ToLexeme(val));
783 }
784
785 void
786 UpdateLexeme(const string&);
787 };
788
789
791
792
796 class YF_API Session
797 {
798 public:
800 using DefaultParser = ByteParser;
802 LexicalAnalyzer Lexer{};
803
804 private:
806 pmr::polymorphic_allocator<yimpl(byte)> allocator;
807
808 public:
810 DefDeCtor(Session)
812 Session(pmr::polymorphic_allocator<yimpl(byte)> a)
813 : allocator(a)
814 {}
815
822 template<typename _fParse>
823 auto
824 GetResult(const _fParse& parse) const -> decltype(ystdex::expand_proxy<
825 GParserResult<_fParse>(const decltype(ystdex::as_const(
826 ystdex::unref(std::declval<const _fParse&>())))&,
827 const Session&)>::invoke(&ParserClassOf<_fParse>::GetResult,
828 ystdex::as_const(ystdex::unref(std::declval<const _fParse&>())),
829 std::declval<const Session&>()))
830 {
831 return ystdex::expand_proxy<GParserResult<_fParse>(const
832 decltype(ystdex::as_const(ystdex::unref(
833 std::declval<const _fParse&>())))&, const Session&)>::invoke(
834 &ParserClassOf<_fParse>::GetResult,
835 ystdex::as_const(ystdex::unref(parse)), *this);
836 }
837
854 template<typename _tIn>
856 YB_ATTR_nodiscard inline DefaultParser
857 Process(_tIn first, _tIn last)
858 {
859 return ProcessSequence(first, last,
860 typename std::iterator_traits<_tIn>::iterator_category());
861 }
862 template<typename _tIn, typename _fParse>
863 YB_ATTR_nodiscard inline _fParse
864 Process(_tIn first, _tIn last, _fParse parse)
865 {
866 return ProcessSequence(first, last, parse,
867 typename std::iterator_traits<_tIn>::iterator_category());
868 }
870 template<typename _tRange>
871 YB_ATTR_nodiscard inline DefaultParser
872 Process(const _tRange& c)
873 {
874 return Process(ystdex::begin(c), ystdex::end(c));
875 }
876 template<typename _tRange, typename _fParse>
877 YB_ATTR_nodiscard inline _fParse
878 Process(const _tRange& c, _fParse parse)
879 {
880 return Process(ystdex::begin(c), ystdex::end(c), parse);
881 }
883
891 template<typename _tIn>
892 YB_ATTR_nodiscard inline pair<DefaultParser, _tIn>
893 ProcessOne(ReaderState& rs, _tIn first, _tIn last)
894 {
895 return ProcessSequenceOne(rs, first, last,
896 typename std::iterator_traits<_tIn>::iterator_category());
897 }
898 template<typename _tIn, typename _fParse>
899 YB_ATTR_nodiscard inline pair<_fParse, _tIn>
900 ProcessOne(ReaderState& rs, _tIn first, _tIn last, _fParse parse)
901 {
902 return ProcessSequenceOne(rs, first, last, parse,
903 typename std::iterator_traits<_tIn>::iterator_category());
904 }
905 template<typename _tRange>
906 YB_ATTR_nodiscard inline
907 pair<DefaultParser, ystdex::range_iterator_t<const _tRange>>
908 ProcessOne(ReaderState& rs, const _tRange& c)
909 {
910 return ProcessOne(rs, ystdex::begin(c), ystdex::end(c));
911 }
912 template<typename _tRange, typename _fParse>
913 YB_ATTR_nodiscard inline
914 pair<_fParse, ystdex::range_iterator_t<const _tRange>>
915 ProcessOne(ReaderState& rs, const _tRange& c, _fParse parse)
916 {
917 return ProcessOne(rs, ystdex::begin(c), ystdex::end(c), parse);
918 }
920
921
922 private:
924 template<class _tParser>
925 static auto
926 ProcessReserve(_tParser&& parse, size_t n)
927 -> decltype(ystdex::unref(parse).reserve(n))
928 {
929 ystdex::unref(parse).reserve(n);
930 }
932 template<typename... _tParams>
933 static void
934 ProcessReserve(_tParams&&...)
935 {}
936
938
939 template<typename _tIn, class _tTag>
940 YB_ATTR_nodiscard inline DefaultParser
941 ProcessSequence(_tIn first, _tIn last, _tTag)
942 {
943 DefaultParser parse(Lexer, allocator);
944
945 yunused(ProcessSequence(first, last, ystdex::ref(parse), _tTag()));
946 // NOTE: Return the parser object with copy elimination.
947 return parse;
948 }
949 template<typename _tIn, typename _fParse>
950 YB_ATTR_nodiscard inline _fParse
951 ProcessSequence(_tIn first, _tIn last, _fParse parse,
952 std::input_iterator_tag)
953 {
954 std::for_each(first, last, parse);
955 return parse;
956 }
957 template<typename _tRandom, typename _fParse>
958 YB_ATTR_nodiscard inline _fParse
959 ProcessSequence(_tRandom first, _tRandom last, _fParse parse,
960 std::random_access_iterator_tag)
961 {
962 // XXX: This should be safe since there should be no more space out of
963 // the range of %size_t.
964 ProcessReserve(parse, size_t(last - first));
965 return ProcessSequence(first, last, parse, std::input_iterator_tag());
966 }
967
968 template<typename _tIn, class _tTag>
969 YB_ATTR_nodiscard inline pair<DefaultParser, _tIn>
970 ProcessSequenceOne(ReaderState& rs, _tIn first, _tIn last, _tTag)
971 {
972 DefaultParser parse(Lexer, allocator);
973
974 return {std::move(parse), ProcessSequenceOne(rs, first, last,
975 ystdex::ref(parse), _tTag()).second};
976 }
977 template<typename _tIn, typename _fParse>
978 YB_ATTR_nodiscard inline pair<_fParse, _tIn>
979 ProcessSequenceOne(ReaderState& rs, _tIn first, _tIn last, _fParse parse,
980 std::input_iterator_tag)
981 {
982 static_assert(std::is_lvalue_reference<decltype(GetResult(parse))>(),
983 "Reader requires a parser has the result in a fixed location.");
984
985 const auto& res(GetResult(parse));
986 auto size(res.size());
987
988 while(first != last)
989 {
990 parse(*first);
991
992 const auto new_size(res.size());
993
994 if(new_size != size)
995 {
996 rs.Update(res.back());
997 if(rs.IsBalanced() && !ystdex::unref(parse).IsUpdating())
998 break;
999 size = new_size;
1000 }
1001 ++first;
1002 }
1003 return {parse, first};
1004 }
1005 template<typename _tRandom, typename _fParse>
1006 YB_ATTR_nodiscard inline pair<_fParse, _tRandom>
1007 ProcessSequenceOne(ReaderState& rs, _tRandom first, _tRandom last,
1008 _fParse parse, std::random_access_iterator_tag)
1009 {
1010 // XXX: This should be safe since there should be no more space out of
1011 // the range of %size_t.
1012 ProcessReserve(parse, size_t(last - first));
1013 return ProcessSequenceOne(rs, first, last, parse,
1014 std::input_iterator_tag());
1015 }
1017
1018 public:
1023 YB_ATTR_nodiscard YB_PURE PDefH(pmr::polymorphic_allocator<yimpl(byte)>,
1024 get_allocator, ) const ynothrow
1025 ImplRet(allocator)
1026 };
1028
1029
1034 namespace SContext
1035 {
1036
1047 template<typename _tIn>
1049 YB_ATTR_nodiscard _tIn
1050 Validate(_tIn first, _tIn last)
1051 {
1052 size_t left(0);
1053
1054 for(; first != last; ++first)
1055 if(ToLexeme(*first) == "(")
1056 ++left;
1057 else if(ToLexeme(*first) == ")")
1058 {
1059 if(left != 0)
1060 --left;
1061 else
1062 return first;
1063 }
1064 if(left == 0)
1065 return first;
1066 throw LoggedEvent("Redundant '(' found.", YSLib::Alert);
1067 }
1068
1074 template<typename _tIn, typename _fTokenize>
1076 YB_ATTR_nodiscard _tIn
1077 Reduce(TermNode& term, _tIn first, _tIn last, _fTokenize tokenize)
1078 {
1079 const auto a(term.get_allocator());
1080 YSLib::stack<TermNode> tms(a);
1081 const auto gd(ystdex::make_guard([&]() ynothrowv{
1082 YAssert(!tms.empty(), "Invalid state found.");
1083 term = std::move(tms.top());
1084 }));
1085
1086 tms.push(std::move(term));
1087 for(; first != last; ++first)
1088 if(ToLexeme(*first) == "(")
1089 tms.push(NPL::AsTermNode(a));
1090 else if(ToLexeme(*first) != ")")
1091 {
1092 YAssert(!tms.empty(), "Invalid state found.");
1093 tms.top().Add(tokenize(*first));
1094 }
1095 else if(tms.size() != 1)
1096 {
1097 auto tm(std::move(tms.top()));
1098
1099 tms.pop();
1100 YAssert(!tms.empty(), "Invalid state found.");
1101 tms.top().Add(std::move(tm));
1102 }
1103 else
1104 return first;
1105 if(tms.size() == 1)
1106 return first;
1107 throw LoggedEvent("Redundant '(' found.", YSLib::Alert);
1108 }
1109 template<typename _tIn>
1110 YB_ATTR_nodiscard inline _tIn
1111 Reduce(TermNode& term, _tIn first, _tIn last)
1112 {
1113 return SContext::Reduce(term, first, last,
1114 LexemeTokenizer{term.get_allocator()});
1115 }
1117
1118
1119
1125 template<class _tParseResult>
1126 void
1127 Analyze(TermNode& root, const _tParseResult& parse_result)
1128 {
1129 if(SContext::Reduce(root, parse_result.cbegin(), parse_result.cend())
1130 != parse_result.cend())
1131 throw LoggedEvent("Redundant ')' found.", YSLib::Alert);
1132 }
1134 template<typename _fParse>
1135 inline void
1136 Analyze(TermNode& root, const Session& sess, const _fParse& parse)
1137 {
1138 Analyze(root, sess.GetResult(parse));
1139 }
1140 template<class _tParseResult, typename _fTokenize>
1141 void
1142 Analyze(TermNode& root, _fTokenize tokenize, const _tParseResult& parse_result)
1143 {
1144 if(SContext::Reduce(root, parse_result.cbegin(), parse_result.cend(),
1145 std::move(tokenize)) != parse_result.cend())
1146 throw LoggedEvent("Redundant ')' found.", YSLib::Alert);
1147 }
1148 template<typename _fParse, typename _fTokenize>
1149 inline void
1150 Analyze(TermNode& root, _fTokenize tokenize, const Session& sess,
1151 const _fParse& parse)
1152 {
1153 Analyze(root, std::move(tokenize), sess.GetResult(parse));
1154 }
1156
1158 template<typename _tParam, typename... _tParams,
1160 yimpl(ystdex::exclude_self_t<TermNode, _tParam, int> = 0)>
1161 YB_ATTR_nodiscard
1162 yimpl(ystdex::exclude_self_t)<std::allocator_arg_t, _tParam, TermNode>
1163 Analyze(_tParam&& arg, _tParams&&... args)
1164 {
1165 TermNode root;
1166
1167 Analyze(root, yforward(arg), yforward(args)...);
1168 return root;
1169 }
1171 template<typename... _tParams>
1172 YB_ATTR_nodiscard TermNode
1173 Analyze(std::allocator_arg_t, TermNode::allocator_type a, _tParams&&... args)
1174 {
1175 TermNode root(a);
1176
1177 Analyze(root, yforward(args)...);
1178 return root;
1179 }
1181
1182 } // namespace SContext;
1183
1184 } // namespace NPL;
1185
1186 #endif
1187
ystdex::make_weak
std::weak_ptr< _type > make_weak(const std::shared_ptr< _type > &p)
使用指定的 std::shared_ptr 实例的对象创建对应的 std::weak_ptr 实例的对象。
Definition: memory.hpp:866
NPL::Session::DefDeCtor
DefDeCtor(Session) Session(pmr
Definition: SContext.h:810
ystdex::mapped_set< ValueNode, ystdex::less<>, MappedSetTraits, allocator_type >
NPL::TNCIter
TermNode::const_iterator TNCIter
Definition: SContext.h:503
DefDeCtor
#define DefDeCtor(_t)
简单通用成员函数定义。
Definition: YBaseMacro.h:157
YB_ATTR_nodiscard
#define YB_ATTR_nodiscard
标记返回值不被忽略的属性。
Definition: ydef.h:715
DefPred
#define DefPred(_q, _n,...)
Definition: YBaseMacro.h:232
x
const EncapsulationBase & x
Definition: NPLA1Forms.cpp:1536
platform::Nonnull
YB_PURE _type && Nonnull(_type &&p) ynothrowv
断言并返回非空参数。
Definition: Debug.h:518
size
size_t size
Definition: memory_resource.cpp:295
NPL::TemporaryIndex
@ TemporaryIndex
Definition: SContext.h:98
NPL::YAssert
YB_ATTR_nodiscard YB_PURE yconstfn YAssert(!buf.empty(), "Invalid buffer found.")
ystdex::make_guard
guard< _type > make_guard(_type f)
Definition: scope_guard.hpp:84
NPL::Session::Process
YB_ATTR_nodiscard _fParse Process(_tIn first, _tIn last, _fParse parse)
Definition: SContext.h:864
NPL::Session::ProcessSequence
YB_ATTR_nodiscard DefaultParser ProcessSequence(_tIn first, _tIn last, _tTag)
Definition: SContext.h:941
CHRLib::c
c
Definition: CharacterProcessing.h:84
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
YB_PURE
#define YB_PURE
指示函数或函数模板实例为纯函数。
Definition: ydef.h:919
NPL::UnqualifiedIndex
@ UnqualifiedIndex
Definition: SContext.h:95
NPL::IsEmpty
YB_ATTR_nodiscard YB_PURE const TermNode &term ynothrow IsEmpty
Definition: SContext.h:524
NPL::AccessPtr
YB_ATTR_nodiscard YB_PURE observer_ptr< _type > AccessPtr(TermNode &term) ynothrow
Definition: SContext.h:572
NPL::LexicalAnalyzer
词法分析器。
Definition: Lexical.h:210
NPL::A1::Internals::term
_fCurrent TermNode &decltype(cur(term, ctx)) term
Definition: NPLA1Internals.h:593
DefDeMoveCtor
#define DefDeMoveCtor(_t)
Definition: YBaseMacro.h:167
NPL::ReaderState
读取器状态：支持解析一个记号或列表的解析器的辅助状态。
Definition: SContext.h:762
YSLib::GetValuePtrOf
YB_ATTR_nodiscard YF_API YB_PURE observer_ptr< const ValueObject > GetValuePtrOf(observer_ptr< const ValueNode >)
取指定名称指称的值的指针。
Definition: ValueNode.cpp:172
ystdex::cpp2014::enable_if_t
typename enable_if< _bCond, _type >::type enable_if_t
Definition: meta.hpp:199
ystdex::make_shared
std::shared_ptr< _type > make_shared(std::initializer_list< _tValue > il)
使用指定类型的初始化列表构造指定类型的 std::shared_ptr 对象。
Definition: memory.hpp:855
TermTags
TermTags
标签：表示引用元数据的位。
Definition: SContext.h:108
NPL::Session::ProcessSequenceOne
YB_ATTR_nodiscard pair< DefaultParser, _tIn > ProcessSequenceOne(ReaderState &rs, _tIn first, _tIn last, _tTag)
Definition: SContext.h:970
ystdex::share_move
std::shared_ptr< decay_t< _type > > share_move(_tValue &&v)
转移值创建对应的 std::shared_ptr 实例的对象。
Definition: memory.hpp:942
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
ystdex::rend
reverse_iterator< _type * > rend(_type(&&array)[_vN])
Definition: range.hpp:397
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::Session::Process
YB_ATTR_nodiscard DefaultParser Process(_tIn first, _tIn last)
使用解析器处理输入范围。
Definition: SContext.h:857
ystdex::expand_proxy
Definition: functional.hpp:471
ystdex::cond_or_t
_t< cond_or< _tCond, _tDefault, _gOp, _tParams... > > cond_or_t
Definition: type_op.hpp:265
NPL::SContext::Reduce
YB_ATTR_nodiscard _tIn Reduce(TermNode &term, _tIn first, _tIn last, _fTokenize tokenize)
遍历规约记号列表，取抽象语法树储存至指定值类型节点。
Definition: SContext.h:1077
YSLib::ListContainerTag
标记列表构造容器。
Definition: ValueNode.h:52
CHRLib::f
f(d, s)
NPL::IsExtendedList
YB_ATTR_nodiscard YB_PURE const TermNode &term ynothrow const TermNode &term ynothrow IsExtendedList
Definition: SContext.h:532
YSLib::MakeIndex
YB_ATTR_nodiscard YF_API YB_PURE string MakeIndex(size_t)
转换节点大小为新的节点索引值。
Definition: ValueNode.cpp:209
NPL::yunused
yunused(msg)
CHRLib::args
YB_ATTR_nodiscard _tParams && args
Definition: CharacterProcessing.h:649
ystdex::bool_
integral_constant< bool, _vInt > bool_
Definition: integral_constant.hpp:93
NPL::tm
tm
Definition: NPLA.h:1941
ystdex::cpp2014::decay_t
typename decay< _type >::type decay_t
Definition: meta.hpp:196
NPL::Session::allocator
pmr::polymorphic_allocator< yimpl(byte)> allocator
Definition: SContext.h:806
NPL::Session::Process
YB_ATTR_nodiscard DefaultParser Process(const _tRange &c)
Definition: SContext.h:872
platform::Descriptions::Alert
@ Alert
Definition: YCommon.h:180
DefBoolNeg
#define DefBoolNeg(_spec,...)
定义表示显式转换 bool 操作符及其否定的 operator! 。
Definition: YBaseMacro.h:228
DefFwdTmpl
#define DefFwdTmpl(_q, _t, _n,...)
传递模板。
Definition: YBaseMacro.h:332
TNIter
TermNode::iterator TNIter
Definition: SContext.h:501
NPL::GetLValueTagsOf
GetLValueTagsOf
Definition: SContext.h:162
NPL::TraverseSubnodes
void TraverseSubnodes(_fCallable f, const _tNode &node)
遍历子节点。
Definition: SContext.h:690
YSLib::LoggedEvent
记录日志的异常事件类。
Definition: YException.h:51
platform::containers::stack
std::stack< _type, _tSeqCon > stack
Definition: Container.h:153
YSLib::RemoveHead
YF_API void RemoveHead(ValueNode::Container &) ynothrowv
移除第一个子节点。
Definition: ValueNode.cpp:186
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
NPL::SContext::Reduce
YB_ATTR_nodiscard _tIn Reduce(TermNode &term, _tIn first, _tIn last)
Definition: SContext.h:1111
scope_guard.hpp
作用域守卫。
NPL::ByteParser
字节解析器。
Definition: Lexical.h:520
YB_STATELESS
#define YB_STATELESS
指示函数或函数模板实例为无状态函数。
Definition: ydef.h:941
ystdex::cpp2017::end
auto end(_tRange &c) -> decltype(c.end())
Definition: range.hpp:345
NPL::GParserResult
const ParseResultOf< _fParse > & GParserResult
泛型解析器结果返回类型。
Definition: Lexical.h:457
NPL::UniqueIndex
@ UniqueIndex
Definition: SContext.h:96
NPL::SContext::Analyze
YB_ATTR_nodiscard TermNode Analyze(std::allocator_arg_t, TermNode::allocator_type a, _tParams &&... args)
Definition: SContext.h:1173
NPL::Session::Process
YB_ATTR_nodiscard _fParse Process(const _tRange &c, _fParse parse)
Definition: SContext.h:878
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
std
Definition: optional.h:982
NPL::ParserClassOf
ystdex::remove_reference_t< ystdex::unwrap_ref_decay_t< _fParse > > ParserClassOf
取参数类型对应的解析器类类型。
Definition: Lexical.h:439
platform_ex::Windows::Temporary
@ Temporary
Definition: Win32/include/YCLib/MinGW32.h:470
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::NonmodifyingIndex
@ NonmodifyingIndex
Definition: SContext.h:97
ystdex::list::value_type
_type value_type
Definition: list.hpp:1053
YSLib::i
return i
Definition: YCoreUtilities.h:177
NPL::Session::ProcessSequence
YB_ATTR_nodiscard _fParse ProcessSequence(_tRandom first, _tRandom last, _fParse parse, std::random_access_iterator_tag)
Definition: SContext.h:959
NPL::TermTagIndices
TermTagIndices
项标签索引：指定项标签元数据掩码的位。
Definition: SContext.h:94
NPL
Definition: NPL/Configuration.h:35
NPL::ToLexeme
YB_ATTR_nodiscard YB_STATELESS const _type & ToLexeme(const _type &val) ynothrow
转换参数为词素。
Definition: SContext.h:724
range.hpp
范围操作。
YSLib
YSLib 命名空间。
Definition: AndroidHost.h:46
ystdex::unref
_type & unref(_type &&x)
解除引用包装。
Definition: ref.hpp:243
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::Session::ProcessOne
YB_ATTR_nodiscard pair< DefaultParser, ystdex::range_iterator_t< const _tRange > > ProcessOne(ReaderState &rs, const _tRange &c)
Definition: SContext.h:908
NPL::SContext::Validate
YB_ATTR_nodiscard _tIn Validate(_tIn first, _tIn last)
遍历记号列表，验证基本合法性：圆括号是否对应。
Definition: SContext.h:1050
platform::Deref
YB_PURE yconstfn auto Deref(_type &&p) -> decltype(*p)
断言并解引用非空指针。
Definition: Debug.h:547
ystdex::enable_if_convertible_t
enable_if_t< is_convertible< _tFrom, _tTo >::value, _type > enable_if_convertible_t
Definition: meta.hpp:837
ynothrowv
#define ynothrowv
YSLib 无异常抛出保证验证：有条件地使用无异常抛出规范。
Definition: ydef.h:1219
ystdex
<memory> 特性测试宏。
Definition: ydef.h:1262
NPL::Session
会话：分析组成 NPL 基本翻译单元的源代码。
Definition: SContext.h:797
NPL::Session::ProcessOne
YB_ATTR_nodiscard pair< DefaultParser, _tIn > ProcessOne(ReaderState &rs, _tIn first, _tIn last)
使用解析器处理输入范围读取列表或元素。
Definition: SContext.h:893
YSLib::AccessPtr
YB_ATTR_nodiscard YB_PURE observer_ptr< _type > AccessPtr(ValueNode &node) ynothrow
访问节点的指定类型对象指针。
Definition: ValueNode.h:976
NPL::Session::ProcessReserve
static void ProcessReserve(_tParams &&...)
Definition: SContext.h:934
YSLib::_tParams
YB_ATTR_nodiscard YB_PURE typename _tParams
Definition: ValueNode.h:1294
NPL::Session::ProcessSequenceOne
YB_ATTR_nodiscard pair< _fParse, _tIn > ProcessSequenceOne(ReaderState &rs, _tIn first, _tIn last, _fParse parse, std::input_iterator_tag)
Definition: SContext.h:979
DefGetter
#define DefGetter(_q, _t, _n,...)
Definition: YBaseMacro.h:241
NPL::Session::ProcessSequenceOne
YB_ATTR_nodiscard pair< _fParse, _tRandom > ProcessSequenceOne(ReaderState &rs, _tRandom first, _tRandom last, _fParse parse, std::random_access_iterator_tag)
Definition: SContext.h:1007
DefBitmaskEnum
#define DefBitmaskEnum(_tEnum)
Definition: YBaseMacro.h:505
NPL::Access
YB_ATTR_nodiscard YB_PURE const TermNode &term ynothrow const TermNode &term ynothrow const TermNode &term ynothrow const TermNode &term ynothrow const TermNode &term ynothrow ImplRet(!term.Value) using YSLib YB_ATTR_nodiscard YB_PURE _type & Access(TermNode &term)
Definition: SContext.h:555
NPL::ReaderState::DefDeCtor
DefDeCtor(ReaderState) DefPred(const ynothrow
NPL::Session::ProcessReserve
static auto ProcessReserve(_tParser &&parse, size_t n) -> decltype(ystdex::unref(parse).reserve(n))
Definition: SContext.h:926
NPL::swap
void swap(ContextNode &x, ContextNode &y) ynothrow
Definition: NPLA.cpp:1188
NPL::Session::GetResult
auto GetResult(const _fParse &parse) const -> decltype(ystdex::expand_proxy< GParserResult< _fParse >(const decltype(ystdex::as_const(ystdex::unref(std::declval< const _fParse & >())))&, const Session &)>::invoke(&ParserClassOf< _fParse >::GetResult, ystdex::as_const(ystdex::unref(std::declval< const _fParse & >())), std::declval< const Session & >()))
取解析结果。
Definition: SContext.h:824
platform::p
return p p
Definition: YCLib/FileSystem.h:209
const
const Decapsulate const Decapsulate &y ynothrow ContextNode &ctx const
Definition: NPLA1Forms.cpp:1629
ystdex::rbegin
reverse_iterator< _type * > rbegin(_type(&&array)[_vN])
Definition: range.hpp:390
ystdex::compose
auto compose(_func f, _func2 g, _func3 h, _funcs... args) -> decltype(ystdex::compose(ystdex::compose(f, g), h, args...))
Definition: functional.hpp:124
NPL::dst
YF_API const char src const string const char * dst
Definition: Dependency.h:96
DefDeMoveAssignment
#define DefDeMoveAssignment(_t)
Definition: YBaseMacro.h:191
NPL::Session::ProcessOne
YB_ATTR_nodiscard pair< _fParse, ystdex::range_iterator_t< const _tRange > > ProcessOne(ReaderState &rs, const _tRange &c, _fParse parse)
Definition: SContext.h:915
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
ystdex::false_
bool_< false > false_
Definition: integral_constant.hpp:110
YSLib::GetValueOf
YB_ATTR_nodiscard YF_API YB_PURE ValueObject GetValueOf(observer_ptr< const ValueNode >)
取指定名称指称的值。
Definition: ValueNode.cpp:166
ynothrow
#define ynothrow
YSLib 无异常抛出保证：若支持 noexcept 关键字， 指定特定的 noexcept 异常规范。
Definition: ydef.h:1199
YSLib::vo
vo
Definition: YApplication.h:231
ynoexcept
#define ynoexcept(...)
YSLib 无异常抛出保证：指定特定的异常规范。
Definition: ydef.h:1151
YSLib::ValueNode::Value
ValueObject Value
Definition: ValueNode.h:223
NPL::Session::ProcessSequence
YB_ATTR_nodiscard _fParse ProcessSequence(_tIn first, _tIn last, _fParse parse, std::input_iterator_tag)
Definition: SContext.h:951
NPL::get
PDefH(void, LiftTermRef, TermNode &term, const TermNode &tm) ImplExpr(NPL ref get()
Definition: NPLA.h:1737
ystdex::ref
void ref(const _type &&)=delete
NPL::Session::ProcessOne
YB_ATTR_nodiscard pair< _fParse, _tIn > ProcessOne(ReaderState &rs, _tIn first, _tIn last, _fParse parse)
Definition: SContext.h:900
YSLib::NoContainer
yconstexpr const struct YSLib::NoContainerTag NoContainer
ystdex::remove_cvref_t
_t< remove_cvref< _type > > remove_cvref_t
Definition: meta.hpp:236
NPL::yimpl
yimpl(using) Reducer
规约器：和绑定上下文以外参数的求值遍的处理器具有等价签名的多态函数。
YSLib::NoContainerTag
标记不使用容器。
Definition: ValueNode.h:55
platform_ex::Reset
unsigned long Reset(COMPtr< _iCOM > &ptr) ynothrow
Definition: Win32/include/YCLib/COM.h:406
ystdex::list
列表容器。
Definition: list.hpp:1051
ystdex::cpp2017::as_const
add_const_t< _type > & as_const(_type &t)
转换 const 引用。
Definition: utility.hpp:77
NPL::HasValue
YB_ATTR_nodiscard YB_PURE bool HasValue(const TermNode &term, const _type &x)
检查项节点是否具有指定的值。
Definition: SContext.h:708
ystdex::call_value_or
auto call_value_or(_func f, _type &&p) -> decay_t< decltype(f(*std::forward< decltype(p)>(p)))>
调用非空值或取默认值。
Definition: deref_op.hpp:152
yconstfn
#define yconstfn
指定编译时常量函数。
Definition: ydef.h:1073
ystdex::cpp2017::begin
auto begin(_tRange &c) -> decltype(c.begin())
Definition: range.hpp:323
YSLib::a
YB_PURE const _type * a
Definition: YCoreUtilities.h:168
NPL::_tParam
_tParam
Definition: NPLA.h:2367
ystdex::and_
逻辑操作元函数。
Definition: integral_constant.hpp:151
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