YSTest: NPLA1Forms.h 源文件

YSTest PreAlpha_b900_20201012 The YSLib Test Project

NPLA1Forms.h
浏览该文件的文档.
1 /*
2 © 2016-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_NPLA1Forms_h_
29 #define NPL_INC_NPLA1Forms_h_ 1
30
31 #include "YModules.h"
32 #include YFM_NPL_NPLA1 // for string, TokenValue, ReductionStatus, TermNode,
33 // AssertBranch, ystdex::expand_proxy, NPL::Access, std::next, NPL::Deref,
34 // Forms::CallResolvedUnary, ResolvedTermReferencePtr, NPL::AccessRegular,
35 // ystdex::make_expanded, std::ref, ystdex::invoke_nonvoid, TNIter,
36 // NPL::ResolveRegular, ystdex::make_transform, std::accumulate,
37 // std::placeholders::_2, ystdex::bind1, ContextNode,
38 // ystdex::equality_comparable, ystdex::examiners::equal_examiner, Environment,
39 // shared_ptr;
40
41 namespace NPL
42 {
43
45 namespace A1
46 {
47
59 namespace Forms
60 {
61
69 YB_ATTR_nodiscard YF_API YB_PURE bool
70 IsSymbol(const string&) ynothrow;
71
73
74
79 YB_ATTR_nodiscard YF_API YB_PURE TokenValue
80 StringToSymbol(const string&);
82 YB_ATTR_nodiscard YF_API YB_PURE TokenValue
83 StringToSymbol(string&&);
85
87 YB_ATTR_nodiscard YF_API YB_STATELESS const string&
88 SymbolToString(const TokenValue&) ynothrow;
90
91
107 // XXX: G++ will warn with [-Wunused-value] if it is pure. See also $2019-01
108 // @ %Documentation::Workflow.
109 #if defined(NDEBUG) && YB_IMPL_GNUCPP >= 100000
110 YB_Diag_Push
111 YB_Diag_Ignore(suggest-attribute=pure)
112 #endif
113 inline PDefH(ReductionStatus, Retain, const TermNode& term) ynothrowv
115 ImplRet(AssertBranch(term), ReductionStatus::Retained)
116 #if defined(NDEBUG) && YB_IMPL_GNUCPP >= 100000
117 YB_Diag_Pop
118 #endif
119
126 YF_API size_t
127 RetainN(const TermNode&, size_t = 1);
129
130
132
133 template<typename _func, typename... _tParams>
135 inline auto
136 CallRawUnary(_func&& f, TermNode& term, _tParams&&... args)
137 -> yimpl(decltype(ystdex::expand_proxy<void(TermNode&, _tParams&&...)>
138 ::call(f, NPL::Deref(std::next(term.begin())), yforward(args)...)))
139 {
140 RetainN(term);
141 return ystdex::expand_proxy<yimpl(void)(TermNode&, _tParams&&...)>::call(f,
142 NPL::Deref(std::next(term.begin())), yforward(args)...);
143 }
144
146 template<typename _func>
147 inline auto
148 CallResolvedUnary(_func&& f, TermNode& term)
149 -> yimpl(decltype(NPL::ResolveTerm(yforward(f), term)))
150 {
151 return Forms::CallRawUnary([&](TermNode& tm)
152 -> yimpl(decltype(NPL::ResolveTerm(yforward(f), term))){
153 return NPL::ResolveTerm(yforward(f), tm);
154 }, term);
155 }
156
158
159 template<typename _type, typename _func, typename... _tParams>
161 inline auto
162 CallResolvedUnaryAs(_func&& f, TermNode& term, _tParams&&... args)
163 -> yimpl(decltype(ystdex::expand_proxy<void(_type&, const
164 ResolvedTermReferencePtr&, _tParams&&...)>::call(f, NPL::Access<_type>(
165 term), ResolvedTermReferencePtr(), std::forward<_tParams>(args)...)))
166 {
167 using handler_t
168 = yimpl(void)(_type&, const ResolvedTermReferencePtr&, _tParams&&...);
169
170 return Forms::CallResolvedUnary(
171 [&](TermNode& nd, ResolvedTermReferencePtr p_ref)
172 // TODO: Blocked. Use C++14 'decltype(auto)'.
173 -> decltype(ystdex::expand_proxy<handler_t>::call(f,
174 std::declval<_type&>(), p_ref)){
175 // XXX: Blocked. 'yforward' cause G++ 7.1.0 failed silently.
176 return ystdex::expand_proxy<handler_t>::call(f, NPL::Access<_type>(nd),
177 p_ref, std::forward<_tParams>(args)...);
178 }, term);
179 }
180
186 template<typename _type, typename _func, typename... _tParams>
187 inline auto
188 CallRegularUnaryAs(_func&& f, TermNode& term, _tParams&&... args)
189 -> yimpl(decltype(ystdex::expand_proxy<void(_type&, const
190 ResolvedTermReferencePtr&, _tParams&&...)>::call(f, NPL::Access<_type>(
191 term), ResolvedTermReferencePtr(), std::forward<_tParams>(args)...)))
192 {
193 using handler_t
194 = yimpl(void)(_type&, const ResolvedTermReferencePtr&, _tParams&&...);
195
196 return Forms::CallResolvedUnary(
197 // TODO: Blocked. Use C++14 'decltype(auto)'.
198 [&](TermNode& nd, ResolvedTermReferencePtr p_ref)
199 -> decltype(ystdex::expand_proxy<handler_t>::call(f,
200 std::declval<_type&>(), p_ref)){
201 // XXX: Blocked. 'yforward' cause G++ 7.1.0 failed silently.
202 return ystdex::expand_proxy<handler_t>::call(f, NPL::AccessRegular<
203 _type>(nd, p_ref), p_ref, std::forward<_tParams>(args)...);
204 }, term);
205 }
207
208
226 template<typename _func, typename... _tParams>
227 void
228 CallUnary(_func&& f, TermNode& term, _tParams&&... args)
229 {
230 Forms::CallRawUnary([&](TermNode& tm){
231 YSLib::EmplaceCallResult(term.Value, ystdex::invoke_nonvoid(
232 ystdex::make_expanded<void(TermNode&, _tParams&&...)>(std::ref(f)),
233 tm, yforward(args)...), term.get_allocator());
234 }, term);
235 }
236
237 template<typename _type, typename _func, typename... _tParams>
238 void
239 CallUnaryAs(_func&& f, TermNode& term, _tParams&&... args)
240 {
241 Forms::CallUnary([&](TermNode& tm){
242 // XXX: Blocked. 'yforward' cause G++ 5.3 crash: internal compiler
243 // error: Segmentation fault.
244 return ystdex::make_expanded<void(_type&, _tParams&&...)>(std::ref(f))(
245 NPL::ResolveRegular<_type>(tm), std::forward<_tParams>(args)...);
246 }, term);
247 }
249
255 template<typename _func, typename... _tParams>
256 void
257 CallBinary(_func&& f, TermNode& term, _tParams&&... args)
258 {
259 RetainN(term, 2);
260
261 auto i(term.begin());
262 auto& x(NPL::Deref(++i));
263
264 YSLib::EmplaceCallResult(term.Value, ystdex::invoke_nonvoid(
265 ystdex::make_expanded<void(TermNode&, TermNode&, _tParams&&...)>(
266 std::ref(f)), x, NPL::Deref(++i), yforward(args)...),
267 term.get_allocator());
268 }
269
271 template<typename _type, typename _type2, typename _func, typename... _tParams>
272 void
273 CallBinaryAs(_func&& f, TermNode& term, _tParams&&... args)
274 {
275 RetainN(term, 2);
276
277 auto i(term.begin());
278 auto& x(NPL::ResolveRegular<_type>(NPL::Deref(++i)));
279
280 YSLib::EmplaceCallResult(term.Value, ystdex::invoke_nonvoid(
281 ystdex::make_expanded<void(_type&, _type2&, _tParams&&...)>(
282 std::ref(f)), x, NPL::ResolveRegular<_type2>(NPL::Deref(++i)),
283 yforward(args)...), term.get_allocator());
284 }
286
287
288
294 template<typename _type, typename _func, typename... _tParams>
295 void
296 CallBinaryFold(_func f, _type val, TermNode& term, _tParams&&... args)
297 {
298 const auto n(FetchArgumentN(term));
299 auto i(term.begin());
300 const auto j(ystdex::make_transform(++i, [](TNIter it){
301 return NPL::ResolveRegular<_type>(NPL::Deref(it));
302 }));
303
304 YSLib::EmplaceCallResult(term.Value, std::accumulate(j, std::next(j,
305 typename std::iterator_traits<decltype(j)>::difference_type(n)), val,
306 ystdex::bind1(f, std::placeholders::_2, yforward(args)...)),
307 term.get_allocator());
308 }
309
310
321
323 template<typename _func>
325 struct UnaryExpansion
326 : private ystdex::equality_comparable<UnaryExpansion<_func>>
327 {
328 _func Function;
329
331 UnaryExpansion(_func f)
332 : Function(std::move(f))
333 {}
334
339 YB_ATTR_nodiscard YB_PURE friend PDefHOp(bool, ==, const UnaryExpansion& x,
340 const UnaryExpansion& y)
341 ImplRet(ystdex::examiners::equal_examiner::are_equal(x.Function,
342 y.Function))
343
344
345 template<typename... _tParams>
346 inline void
347 operator()(_tParams&&... args) const
348 {
349 Forms::CallUnary(Function, yforward(args)...);
350 }
351 };
352
353
355 template<typename _type, typename _func>
356 struct UnaryAsExpansion
357 : private ystdex::equality_comparable<UnaryAsExpansion<_type, _func>>
358 {
359 _func Function;
360
362 UnaryAsExpansion(_func f)
363 : Function(std::move(f))
364 {}
365
370 YB_ATTR_nodiscard YB_PURE friend
371 PDefHOp(bool, ==, const UnaryAsExpansion& x, const UnaryAsExpansion& y)
372 ImplRet(ystdex::examiners::equal_examiner::are_equal(x.Function,
373 y.Function))
374
375
376 template<typename... _tParams>
377 inline void
378 operator()(_tParams&&... args) const
379 {
380 Forms::CallUnaryAs<_type>(Function, yforward(args)...);
381 }
382 };
384
385
387
388 template<typename _func>
390 struct BinaryExpansion
391 : private ystdex::equality_comparable<BinaryExpansion<_func>>
392 {
393 _func Function;
394
396 BinaryExpansion(_func f)
397 : Function(std::move(f))
398 {}
399
404 YB_ATTR_nodiscard YB_PURE friend
405 PDefHOp(bool, ==, const BinaryExpansion& x, const BinaryExpansion& y)
406 ImplRet(ystdex::examiners::equal_examiner::are_equal(x.Function,
407 y.Function))
408
409 template<typename... _tParams>
410 inline void
411 operator()(_tParams&&... args) const
412 {
413 Forms::CallBinary(Function, yforward(args)...);
414 }
415 };
416
417
422 template<typename _type, typename _type2, typename _func>
423 struct BinaryAsExpansion : private
424 ystdex::equality_comparable<BinaryAsExpansion<_type, _type2, _func>>
425 {
426 _func Function;
427
429 BinaryAsExpansion(_func f)
430 : Function(std::move(f))
431 {}
432
437 YB_ATTR_nodiscard YB_PURE friend PDefHOp(bool, ==,
438 const BinaryAsExpansion& x, const BinaryAsExpansion& y)
439 ImplRet(ystdex::examiners::equal_examiner::are_equal(x.Function,
440 y.Function))
441
442 template<typename... _tParams>
443 inline void
444 operator()(_tParams&&... args) const
445 {
446 Forms::CallBinaryAs<_type, _type2>(Function, yforward(args)...);
447 }
448 };
450
451
452
458
460 template<size_t _vWrapping = Strict, typename _func, class _tTarget>
461 inline void
462 RegisterUnary(_tTarget& target, string_view name, _func f)
463 {
464 A1::RegisterHandler<_vWrapping>(target, name,
465 UnaryExpansion<_func>(std::move(f)));
466 }
467 template<size_t _vWrapping = Strict, typename _type, typename _func,
468 class _tTarget>
469 inline void
470 RegisterUnary(_tTarget& target, string_view name, _func f)
471 {
472 A1::RegisterHandler<_vWrapping>(target, name,
473 UnaryAsExpansion<_type, _func>(std::move(f)));
474 }
476
478
479 template<size_t _vWrapping = Strict, typename _func, class _tTarget>
480 inline void
481 RegisterBinary(_tTarget& target, string_view name, _func f)
482 {
483 A1::RegisterHandler<_vWrapping>(target, name,
484 BinaryExpansion<_func>(std::move(f)));
485 }
486 template<size_t _vWrapping = Strict, typename _type, typename _type2,
487 typename _func, class _tTarget>
488 inline void
489 RegisterBinary(_tTarget& target, string_view name, _func f)
490 {
491 A1::RegisterHandler<_vWrapping>(target, name,
492 BinaryAsExpansion<_type, _type2, _func>(std::move(f)));
493 }
495
496
497
506 YF_API void
507 Equal(TermNode&);
508
517 YF_API void
518 EqualLeaf(TermNode&);
519
521
522
529 YF_API void
530 EqualReference(TermNode&);
531
539 YF_API void
540 EqualValue(TermNode&);
542
543
560 YF_API ReductionStatus
561 If(TermNode&, ContextNode&);
562
570 YF_API ReductionStatus
571 Cond(TermNode&, ContextNode&);
572
582 YF_API ReductionStatus
583 When(TermNode&, ContextNode&);
584
594 YF_API ReductionStatus
595 Unless(TermNode&, ContextNode&);
597
607 YF_API YB_PURE bool
608 Not(TermNode&);
609
626 YF_API ReductionStatus
627 And(TermNode&, ContextNode&);
628
639 YF_API ReductionStatus
640 Or(TermNode&, ContextNode&);
642
643
661 YF_API ReductionStatus
662 Cons(TermNode&);
663
672 YF_API ReductionStatus
673 ConsRef(TermNode&);
675
677
678
689 YF_API ReductionStatus
690 ForwardListFirst(TermNode&, ContextNode&);
691
703 YF_API ReductionStatus
704 First(TermNode&);
705
707
708
716 YF_API ReductionStatus
717 FirstAt(TermNode&);
718
725 YF_API ReductionStatus
726 FirstRef(TermNode&);
727
734 YF_API ReductionStatus
735 FirstVal(TermNode&);
737
738
739
746
748
755 YF_API void
756 SetFirst(TermNode&);
757
759
760
768 YF_API void
769 SetFirstAt(TermNode&);
770
777 YF_API void
778 SetFirstRef(TermNode&);
780
781
796 YF_API void
797 SetRest(TermNode&);
798
807 YF_API void
808 SetRestRef(TermNode&);
810
811
812
830 YF_API ReductionStatus
831 Eval(TermNode&, ContextNode&);
832
841 YF_API ReductionStatus
842 EvalRef(TermNode&, ContextNode&);
844
858 YF_API ReductionStatus
859 EvalString(TermNode&, ContextNode&);
860
871 YF_API ReductionStatus
872 EvalStringRef(TermNode&, ContextNode&);
873
885 YF_API ReductionStatus
886 EvalUnit(TermNode&);
888
889
891
892
905 YF_API void
906 MakeEnvironment(TermNode&);
907
917 YF_API void
918 GetCurrentEnvironment(TermNode&, ContextNode&);
919
929 YF_API void
930 LockCurrentEnvironment(TermNode&, ContextNode&);
931
943 YF_API ReductionStatus
944 ValueOf(TermNode&, const ContextNode&);
945
946
970 YF_API ReductionStatus
971 DefineLazy(TermNode&, ContextNode&);
972
981 YF_API ReductionStatus
982 DefineWithNoRecursion(TermNode&, ContextNode&);
983
997 YF_API ReductionStatus
998 DefineWithRecursion(TermNode&, ContextNode&);
1000
1002
1003
1011 YF_API ReductionStatus
1012 SetWithNoRecursion(TermNode&, ContextNode&);
1013
1022 YF_API ReductionStatus
1023 SetWithRecursion(TermNode&, ContextNode&);
1025
1043 YF_API void
1044 Undefine(TermNode&, ContextNode&);
1045
1056 YF_API void
1057 UndefineChecked(TermNode&, ContextNode&);
1059
1060
1092 YF_API ReductionStatus
1093 Lambda(TermNode&, ContextNode&);
1094
1101 YF_API ReductionStatus
1102 LambdaRef(TermNode&, ContextNode&);
1104
1128 YF_API ReductionStatus
1129 Vau(TermNode&, ContextNode&);
1130
1139 YF_API ReductionStatus
1140 VauRef(TermNode&, ContextNode&);
1142
1158 YF_API ReductionStatus
1159 VauWithEnvironment(TermNode&, ContextNode&);
1160
1167 YF_API ReductionStatus
1168 VauWithEnvironmentRef(TermNode&, ContextNode&);
1170
1171
1172
1173
1175
1176
1183 YF_API ReductionStatus
1184 Wrap(TermNode&, ContextNode&);
1185
1195 YF_API ReductionStatus
1196 WrapRef(TermNode&, ContextNode&);
1197
1199
1200
1206 YF_API ReductionStatus
1207 WrapOnce(TermNode&, ContextNode&);
1208
1217 YF_API ReductionStatus
1218 WrapOnceRef(TermNode&, ContextNode&);
1219
1227 YF_API ReductionStatus
1228 Unwrap(TermNode&, ContextNode&);
1230
1231
1232
1250 YF_API ReductionStatus
1251 CheckEnvironment(TermNode&);
1252
1265 YF_API ReductionStatus
1266 CheckListReference(TermNode&);
1268
1269
1283 YF_API ReductionStatus
1284 MakeEncapsulationType(TermNode&);
1285
1286
1298 YF_API ReductionStatus
1299 Sequence(TermNode&, ContextNode&);
1300
1311 YF_API ReductionStatus
1312 Apply(TermNode&, ContextNode&);
1313
1327 YF_API ReductionStatus
1328 ListAsterisk(TermNode&);
1329
1336 YF_API ReductionStatus
1337 ListAsteriskRef(TermNode&);
1339
1357 YF_API ReductionStatus
1358 AccL(TermNode&, ContextNode&);
1359
1367 YF_API ReductionStatus
1368 AccR(TermNode&, ContextNode&);
1370
1372
1373
1385 YF_API ReductionStatus
1386 FoldR1(TermNode&, ContextNode&);
1387
1396 YF_API ReductionStatus
1397 Map1(TermNode&, ContextNode&);
1399
1400
1409 YF_API void
1410 CallSystem(TermNode&);
1412
1413 } // namespace Forms;
1414
1415 } // namesapce A1;
1416
1417 } // namespace NPL;
1418
1419 #endif
1420
NPL::A1::Forms::Apply
YF_API ReductionStatus Apply(TermNode &, ContextNode &)
函数应用：应用参数指定的函数和作为函数参数的列表。
Definition: NPLA1Forms.cpp:2613
NPL::A1::Forms::MakeEnvironment
YF_API void MakeEnvironment(TermNode &)
创建以参数指定的环境列表作为父环境的新环境。
Definition: NPLA1Forms.cpp:2348
NPL::A1::Forms::LambdaRef
YF_API ReductionStatus LambdaRef(TermNode &, ContextNode &)
Definition: NPLA1Forms.cpp:2474
YB_ATTR_nodiscard
#define YB_ATTR_nodiscard
标记返回值不被忽略的属性。
Definition: ydef.h:715
NPL::A1::Forms::BinaryExpansion::BinaryExpansion
BinaryExpansion(_func f)
Definition: NPLA1Forms.h:396
x
const EncapsulationBase & x
Definition: NPLA1Forms.cpp:1536
NPL::A1::Forms::CallResolvedUnary
auto CallResolvedUnary(_func &&f, TermNode &term) -> yimpl(decltype(NPL::ResolveTerm(yforward(f), term)))
解析节点的子节点并调用一元函数。
Definition: NPLA1Forms.h:148
NPL::A1::Forms::ConsRef
YF_API ReductionStatus ConsRef(TermNode &)
Definition: NPLA1Forms.cpp:2134
NPL::A1::Forms::EvalString
YF_API ReductionStatus EvalString(TermNode &, ContextNode &)
在参数指定的环境中求值作为外部表示的字符串。
Definition: NPLA1Forms.cpp:2325
NPL::A1::Forms::ValueOf
YF_API ReductionStatus ValueOf(TermNode &, const ContextNode &)
求值标识符得到指称的实体。
Definition: NPLA1Forms.cpp:2400
NPL::A1::Forms::If
YF_API ReductionStatus If(TermNode &, ContextNode &)
分支判断：根据求值的条件选取表达式求值。
Definition: NPLA1Forms.cpp:2047
NPL::A1::Forms::VauRef
YF_API ReductionStatus VauRef(TermNode &, ContextNode &)
Definition: NPLA1Forms.cpp:2486
NPL::A1::Forms::ListAsteriskRef
YF_API ReductionStatus ListAsteriskRef(TermNode &)
Definition: NPLA1Forms.cpp:2637
NPL::A1::Forms::ListAsterisk
YF_API ReductionStatus ListAsterisk(TermNode &)
使用可选的参数指定的不定数量的元素和结尾列表构造新列表。
Definition: NPLA1Forms.cpp:2629
NPL::A1::Forms::RetainN
ReductionStatus::Retained YF_API size_t RetainN(const TermNode &, size_t=1)
保留经检查确保具有指定个数参数的项：保留求值。
Definition: NPLA1Forms.cpp:2011
NPL::A1::Forms::EqualValue
YF_API void EqualValue(TermNode &)
比较两个子项表示的值相等。
Definition: NPLA1Forms.cpp:2040
ystdex::bind1
auto bind1(_func &&f, _tParams &&... args) -> decltype(std::bind(std::forward< decltype(f)>(f), std::placeholders::_1, std::forward< decltype(args)>(args)...))
复合调用 std::bind 和 std::placeholders::_1 。
Definition: functional.hpp:53
NPL::A1::Forms::CallRegularUnaryAs
auto CallRegularUnaryAs(_func &&f, TermNode &term, _tParams &&... args) -> yimpl(decltype(ystdex::expand_proxy< void(_type &, const ResolvedTermReferencePtr &, _tParams &&...)>::call(f, NPL::Access< _type >(term), ResolvedTermReferencePtr(), std::forward< _tParams >(args)...)))
Definition: NPLA1Forms.h:188
YB_PURE
#define YB_PURE
指示函数或函数模板实例为纯函数。
Definition: ydef.h:919
ystdex::invoke_nonvoid
nonvoid_result_t< invoke_result_t< _fCallable, _tParams... > > invoke_nonvoid(_fCallable &&f, _tParams &&... args)
调用可调用对象，保证返回值非空。
Definition: invoke.hpp:572
NPL::A1::Forms::BinaryAsExpansion::BinaryAsExpansion
BinaryAsExpansion(_func f)
Definition: NPLA1Forms.h:429
YSLib::EmplaceCallResult
void EmplaceCallResult(ValueObject &, _type &&, ystdex::false_, _tParams &&...) ynothrow
以指定参数按需构造替换值。
Definition: YObject.h:1585
YB_Diag_Pop
#define YB_Diag_Pop
Definition: ydef.h:442
NPL::A1::Forms::UnaryAsExpansion
Definition: NPLA1Forms.h:358
NPL::A1::Internals::term
_fCurrent TermNode &decltype(cur(term, ctx)) term
Definition: NPLA1Internals.h:593
NPL::A1::Forms::CallSystem
YF_API void CallSystem(TermNode &)
调用 UTF-8 字符串的系统命令，并保存 int 类型的结果到项的值中。
Definition: NPLA1Forms.cpp:2696
NPL::A1::Forms::LockCurrentEnvironment
YF_API void LockCurrentEnvironment(TermNode &, ContextNode &)
锁定当前环境的引用。
Definition: NPLA1Forms.cpp:2393
NPL::A1::Forms::FirstVal
YF_API ReductionStatus FirstVal(TermNode &)
Definition: NPLA1Forms.cpp:2260
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::A1::Forms::AccL
YF_API ReductionStatus AccL(TermNode &, ContextNode &)
在抽象列表元素上应用左结合的二元操作。
Definition: NPLA1Forms.cpp:2644
NPL::A1::Forms::CallResolvedUnaryAs
auto CallResolvedUnaryAs(_func &&f, TermNode &term, _tParams &&... args) -> yimpl(decltype(ystdex::expand_proxy< void(_type &, const ResolvedTermReferencePtr &, _tParams &&...)>::call(f, NPL::Access< _type >(term), ResolvedTermReferencePtr(), std::forward< _tParams >(args)...)))
Definition: NPLA1Forms.h:162
NPL::A1::Forms::CallBinaryFold
void CallBinaryFold(_func f, _type val, TermNode &term, _tParams &&... args)
访问节点并以指定的初始值为基础逐项调用二元函数。
Definition: NPLA1Forms.h:296
NPL::A1::Forms::Or
YF_API ReductionStatus Or(TermNode &, ContextNode &)
支持短路求值的逻辑或。
Definition: NPLA1Forms.cpp:2119
NPL::A1::Forms::CallBinary
void CallBinary(_func &&f, TermNode &term, _tParams &&... args)
访问节点并调用二元函数。
Definition: NPLA1Forms.h:257
next
tidy_ptr< slink > next
Definition: memory_resource.cpp:223
NPL::A1::Forms::Equal
YF_API void Equal(TermNode &)
比较两个子项表示的值引用相同的对象。
Definition: NPLA1Forms.cpp:2022
NPL::A1::Forms::When
YF_API ReductionStatus When(TermNode &, ContextNode &)
条件顺序求值：预期条件成立。
Definition: NPLA1Forms.cpp:2093
NPL::A1::Forms::AccR
YF_API ReductionStatus AccR(TermNode &, ContextNode &)
在抽象列表元素上应用右结合的二元操作。
Definition: NPLA1Forms.cpp:2661
YF_API
#define YF_API
Definition: Platform.h:56
NPL::A1::Forms::Undefine
YF_API void Undefine(TermNode &, ContextNode &)
移除定义引入的绑定。
Definition: NPLA1Forms.cpp:2451
NPL::A1::Forms::Unwrap
YF_API ReductionStatus Unwrap(TermNode &, ContextNode &)
解包装应用子为合并子。
Definition: NPLA1Forms.cpp:2540
ystdex::expand_proxy
Definition: functional.hpp:471
NPL::A1::Forms::SetFirst
YF_API void SetFirst(TermNode &)
修改第一参数指定的列表以第二参数作为第一个元素。
Definition: NPLA1Forms.cpp:2275
NPL::ReductionStatus::Retained
@ Retained
非纯值规约：规约成功终止，且需要保留子项。
NPL::A1::Forms::Cond
YF_API ReductionStatus Cond(TermNode &, ContextNode &)
条件分支选择：根据条件列表顺序选取第一个符合其中条件对应的表达式求值。
Definition: NPLA1Forms.cpp:2072
NPL::A1::Forms::StringToSymbol
YB_ATTR_nodiscard YF_API YB_PURE TokenValue StringToSymbol(const string &)
创建等于指定字符串值的记号值。
Definition: NPLA1Forms.cpp:1992
CHRLib::f
f(d, s)
NPL::A1::Forms::UnaryAsExpansion::UnaryAsExpansion
UnaryAsExpansion(_func f)
Definition: NPLA1Forms.h:362
ystdex::details::_type2
_type2
Definition: operators.hpp:241
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
NPL::A1::Forms::Wrap
YF_API ReductionStatus Wrap(TermNode &, ContextNode &)
包装合并子为应用子。
Definition: NPLA1Forms.cpp:2505
NPL::A1::Forms::Unless
YF_API ReductionStatus Unless(TermNode &, ContextNode &)
条件顺序求值：预期条件不成立。
Definition: NPLA1Forms.cpp:2099
NPL::A1::Forms::CallUnary
void CallUnary(_func &&f, TermNode &term, _tParams &&... args)
访问节点并调用一元函数。
Definition: NPLA1Forms.h:228
NPL::A1::Forms::RegisterBinary
void RegisterBinary(_tTarget &target, string_view name, _func f)
注册二元严格求值上下文处理器。
Definition: NPLA1Forms.h:481
TNIter
TermNode::iterator TNIter
Definition: SContext.h:501
NPL::A1::Forms::SetRestRef
YF_API void SetRestRef(TermNode &)
Definition: NPLA1Forms.cpp:2306
NPL::A1::Forms::FirstRef
YF_API ReductionStatus FirstRef(TermNode &)
Definition: NPLA1Forms.cpp:2254
NPL::A1::Forms::FoldR1
YF_API ReductionStatus FoldR1(TermNode &, ContextNode &)
在列表元素上应用右结合的二元操作。
Definition: NPLA1Forms.cpp:2677
NPL::A1::Forms::UndefineChecked
YF_API void UndefineChecked(TermNode &, ContextNode &)
检查并移除名称绑定。
Definition: NPLA1Forms.cpp:2459
yforward
#define yforward(_expr)
根据参数类型使用 std::forward 转发对应参数。
Definition: ydef.h:1508
NPL::AccessRegular
YB_ATTR_nodiscard YB_PURE auto AccessRegular(_tTerm &term, bool has_ref) -> yimpl(decltype(NPL::Access< _type >(term)))
访问项的指定类型正规值。
Definition: NPLA.h:1447
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
YB_STATELESS
#define YB_STATELESS
指示函数或函数模板实例为无状态函数。
Definition: ydef.h:941
NPL::A1::Forms::FirstAt
YF_API ReductionStatus FirstAt(TermNode &)
Definition: NPLA1Forms.cpp:2248
NPL::A1::Forms::GetCurrentEnvironment
YF_API void GetCurrentEnvironment(TermNode &, ContextNode &)
取当前环境的引用。
Definition: NPLA1Forms.cpp:2386
NPL::A1::Forms::Eval
YF_API ReductionStatus Eval(TermNode &, ContextNode &)
对指定项以指定的环境求值。
Definition: NPLA1Forms.cpp:2313
NPL::A1::Forms::BinaryAsExpansion
Definition: NPLA1Forms.h:425
std
Definition: optional.h:982
NPL::A1::Forms::DefineWithNoRecursion
YF_API ReductionStatus DefineWithNoRecursion(TermNode &, ContextNode &)
不带递归匹配的定义。
Definition: NPLA1Forms.cpp:2427
NPL::A1::Forms::EvalRef
YF_API ReductionStatus EvalRef(TermNode &, ContextNode &)
Definition: NPLA1Forms.cpp:2319
NPL::A1::Forms::CallBinaryAs
void CallBinaryAs(_func &&f, TermNode &term, _tParams &&... args)
Definition: NPLA1Forms.h:273
NPL::A1::Forms::WrapOnce
YF_API ReductionStatus WrapOnce(TermNode &, ContextNode &)
包装操作子为应用子。
Definition: NPLA1Forms.cpp:2528
NPL::A1::Forms::BinaryExpansion::Function
_func Function
Definition: NPLA1Forms.h:393
YSLib::i
return i
Definition: YCoreUtilities.h:177
NPL::A1::Forms::SetWithNoRecursion
YF_API ReductionStatus SetWithNoRecursion(TermNode &, ContextNode &)
修改指定环境的绑定，不带递归匹配。
Definition: NPLA1Forms.cpp:2439
NPL::A1::Forms::PDefH
PDefH(ReductionStatus, Retain, const TermNode &term) ynothrowv ImplRet(AssertBranch(term)
保留项：保留求值。
NPL::A1::Forms::VauWithEnvironment
YF_API ReductionStatus VauWithEnvironment(TermNode &, ContextNode &)
带环境的 vau 抽象：求值为一个捕获当前上下文的非严格求值的函数。
Definition: NPLA1Forms.cpp:2492
NPL::A1::Forms::And
YF_API ReductionStatus And(TermNode &, ContextNode &)
支持短路求值的逻辑与。
Definition: NPLA1Forms.cpp:2113
NPL::A1::Forms::SymbolToString
YB_ATTR_nodiscard YF_API YB_STATELESS const string & SymbolToString(const TokenValue &) ynothrow
取符号对应的名称字符串。
Definition: NPLA1Forms.cpp:2005
NPL::A1::Forms::UnaryExpansion
保存函数展开调用的函数对象。
Definition: NPLA1Forms.h:327
NPL::A1::Forms::IsSymbol
YB_ATTR_nodiscard YF_API YB_PURE bool IsSymbol(const string &) ynothrow
判断字符串值是否可构成符号。
Definition: NPLA1Forms.cpp:1986
NPL
Definition: NPL/Configuration.h:35
YSLib::UI::y
SPos SPos y
Definition: YWidget.cpp:44
NPL::A1::Forms::RegisterUnary
void RegisterUnary(_tTarget &target, string_view name, _func f)
注册一元严格求值上下文处理器。
Definition: NPLA1Forms.h:462
NPL::A1::Forms::Not
YF_API YB_PURE bool Not(TermNode &)
逻辑非。
Definition: NPLA1Forms.cpp:2105
NPL::A1::Forms::Sequence
YF_API ReductionStatus Sequence(TermNode &, ContextNode &)
序列有序参数规约：移除第一项后顺序规约子项，结果为最后一个子项的规约结果。
Definition: NPLA1Forms.cpp:2605
NPL::A1::Forms::UnaryExpansion::UnaryExpansion
UnaryExpansion(_func f)
Definition: NPLA1Forms.h:331
YModules.h
YSLib 用户界面模块配置文件。
NPL::A1::Forms::CallRawUnary
auto CallRawUnary(_func &&f, TermNode &term, _tParams &&... args) -> yimpl(decltype(ystdex::expand_proxy< void(TermNode &, _tParams &&...)> ::call(f, NPL::Deref(std::next(term.begin())), yforward(args)...)))
访问节点的子节点并调用一元函数。
Definition: NPLA1Forms.h:136
NPL::A1::Forms::Vau
YF_API ReductionStatus Vau(TermNode &, ContextNode &)
vau 抽象：求值为一个捕获当前上下文的非严格求值的函数。
Definition: NPLA1Forms.cpp:2480
NPL::A1::Forms::UnaryExpansion::Function
_func Function
Definition: NPLA1Forms.h:328
NPL::ContextNode
上下文节点。
Definition: NPLA.h:2385
NPL::A1::name
const char * name
Definition: NPLA1.h:1876
NPL::A1::Forms::BinaryExpansion
Definition: NPLA1Forms.h:392
platform::Deref
YB_PURE yconstfn auto Deref(_type &&p) -> decltype(*p)
断言并解引用非空指针。
Definition: Debug.h:547
NPL::A1::Forms::SetRest
YF_API void SetRest(TermNode &)
修改第一参数指定的列表以第二参数作为第一个元素外的列表。
Definition: NPLA1Forms.cpp:2300
NPL::A1::Forms::BinaryAsExpansion::Function
_func Function
Definition: NPLA1Forms.h:426
NPL::A1::Forms::Cons
YF_API ReductionStatus Cons(TermNode &)
接受两个参数，返回以第一参数作为第一个元素插入第二参数创建的新的列表。
Definition: NPLA1Forms.cpp:2126
NPL::A1::Forms::UnaryAsExpansion::Function
_func Function
Definition: NPLA1Forms.h:359
ynothrowv
#define ynothrowv
YSLib 无异常抛出保证验证：有条件地使用无异常抛出规范。
Definition: ydef.h:1219
NPL::A1::Forms::First
YF_API ReductionStatus First(TermNode &)
取参数指定的列表中的第一元素的引用值。
Definition: NPLA1Forms.cpp:2197
NPL::A1::Forms::EqualLeaf
YF_API void EqualLeaf(TermNode &)
比较两个子项的值相等。
Definition: NPLA1Forms.cpp:2028
YSLib::_tParams
YB_ATTR_nodiscard YB_PURE typename _tParams
Definition: ValueNode.h:1294
ystdex::examiners::equal::are_equal
static auto are_equal(_type &&x, _type2 &&y) -> decltype(bool(x==y))
Definition: examiner.hpp:53
NPL::A1::Forms::EvalStringRef
YF_API ReductionStatus EvalStringRef(TermNode &, ContextNode &)
在参数指定的环境中求值作为外部表示的字符串。
Definition: NPLA1Forms.cpp:2331
NPL::A1::Forms::Map1
YF_API ReductionStatus Map1(TermNode &, ContextNode &)
单列表映射操作。
Definition: NPLA1Forms.cpp:2686
NPL::A1::Forms::Lambda
YF_API ReductionStatus Lambda(TermNode &, ContextNode &)
λ 抽象：求值为一个捕获当前上下文的严格求值的函数。
Definition: NPLA1Forms.cpp:2468
YB_Diag_Push
#define YB_Diag_Push
Definition: ydef.h:441
NPL::A1::Forms::EqualReference
YF_API void EqualReference(TermNode &)
比较两个子项的值引用相同的对象。
Definition: NPLA1Forms.cpp:2034
NPL::A1::tm
tm
Definition: NPLA1.h:593
NPL::A1::Forms::DefineLazy
YF_API ReductionStatus DefineLazy(TermNode &, ContextNode &)
以惰性求值的表达式定义值。
Definition: NPLA1Forms.cpp:2419
NPL::A1::Forms::CheckEnvironment
YF_API ReductionStatus CheckEnvironment(TermNode &)
检查参数指定的项表示环境。
Definition: NPLA1Forms.cpp:2550
NPL::A1::Forms::ForwardListFirst
YF_API ReductionStatus ForwardListFirst(TermNode &, ContextNode &)
取列表的第一元素并转发给指定的应用子。
Definition: NPLA1Forms.cpp:2141
NPL::A1::Forms::WrapOnceRef
YF_API ReductionStatus WrapOnceRef(TermNode &, ContextNode &)
包装操作子为应用子。
Definition: NPLA1Forms.cpp:2534
NPL::A1::Forms::WrapRef
YF_API ReductionStatus WrapRef(TermNode &, ContextNode &)
包装合并子为应用子。
Definition: NPLA1Forms.cpp:2518
ynothrow
#define ynothrow
YSLib 无异常抛出保证：若支持 noexcept 关键字， 指定特定的 noexcept 异常规范。
Definition: ydef.h:1199
NPL::A1::Forms::SetFirstAt
YF_API void SetFirstAt(TermNode &)
Definition: NPLA1Forms.cpp:2283
NPL::A1::Forms::CheckListReference
YF_API ReductionStatus CheckListReference(TermNode &)
检查参数指定的项表示非空列表的引用。
Definition: NPLA1Forms.cpp:2562
NPL::A1::Forms::SetFirstRef
YF_API void SetFirstRef(TermNode &)
Definition: NPLA1Forms.cpp:2291
NPL::A1::string_view
YB_ATTR_nodiscard YB_PURE term string_view
Definition: NPLA1.h:1072
NPL::A1::Forms::VauWithEnvironmentRef
YF_API ReductionStatus VauWithEnvironmentRef(TermNode &, ContextNode &)
Definition: NPLA1Forms.cpp:2498
ystdex::ref
void ref(const _type &&)=delete
YB_Diag_Ignore
#define YB_Diag_Ignore
Definition: ydef.h:443
NPL::yimpl
yimpl(using) Reducer
规约器：和绑定上下文以外参数的求值遍的处理器具有等价签名的多态函数。
NPL::A1::Forms::MakeEncapsulationType
YF_API ReductionStatus MakeEncapsulationType(TermNode &)
创建封装类型。
Definition: NPLA1Forms.cpp:2574
NPL::A1::Forms::CallUnaryAs
void CallUnaryAs(_func &&f, TermNode &term, _tParams &&... args)
Definition: NPLA1Forms.h:239
NPL::ReductionStatus
ReductionStatus
规约状态：某个项上的一遍规约可能的中间结果。
Definition: NPLA.h:1520
NPL::A1::args
const char _tParams && args
Definition: NPLA1.h:1877
NPL::A1::Forms::EvalUnit
YF_API ReductionStatus EvalUnit(TermNode &)
在参数指定的 REPL 环境中规约字符串表示的翻译单元以求值。
Definition: NPLA1Forms.cpp:2337
NPL::A1::Forms::SetWithRecursion
YF_API ReductionStatus SetWithRecursion(TermNode &, ContextNode &)
修改指定环境的绑定，带递归匹配。
Definition: NPLA1Forms.cpp:2445
NPL::A1::Strict
@ Strict
严格求值形式：对参数求值 1 次。
Definition: NPLA1.h:1002
NPL::A1::Forms::DefineWithRecursion
YF_API ReductionStatus DefineWithRecursion(TermNode &, ContextNode &)
带递归匹配的定义。
Definition: NPLA1Forms.cpp:2433
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