tpriorities.hpp
Go to the documentation of this file.
1
2#pragma once
3
5
6namespace by {
8 enum priorType {
9 EXACT_MATCH = 0,
17 };
18
19 const _nout nchar* getPriorTypeName(priorType type);
20
24 template <typename T> struct tprior: instance {
25 BY(CLASS(tprior, instance))
26
27 public:
28 tprior(const node& newElem, priorType type, ncnt lv);
29
30 public:
31 T* operator->();
32 T& operator*();
33 const T* operator->() const BY_CONST_FUNC(operator->())
34 const T& operator*() const BY_CONST_FUNC(operator*())
35
36 public:
37 T* get();
38 const T* get() const BY_CONST_FUNC(get())
39
42 nbool isSamePrecedence(const me& rhs) const;
43
44 public:
45 tstr<T> elem;
47 ncnt lv;
48 };
49
53 template <typename T> class tpriorities: public tnarr<T> {
54 BY(CLASS(tpriorities, tnarr<T>))
55 template <typename E> friend class tprioritiesBucket;
56
57 public:
59
60 template <typename... Es> tpriorities(const Es&... elems) {
61 static_assert(areBaseOfT<T, Es...>::value, "some of type of args are not based on type 'T'");
62 this->add({(T&) elems...});
63 }
64
65 public:
66 nbool isMatched() const;
67
68 using super::get;
69 T* get();
70 const T* get() const BY_CONST_FUNC(get())
71
74 priorType getPriorType() const;
75
76 protected:
77 void _setPriorType(priorType new1);
78
79 private:
80 priorType _type;
81 };
82
84} // namespace by
Base class for all managed instances in memlite system.
Definition: instance.hpp:20
Base class for all AST nodes in byeol language.
Definition: node.hpp:30
Definition: tnarr.hpp:9
Definition: node.inl:17
Collection of prioritized elements.
Definition: tpriorities.hpp:53
const T * get() const BY_CONST_FUNC(get()) priorType getPriorType() const
Strong reference smart pointer with strict type checking.
Definition: tstr.hpp:13
Base class for runtime type information in byeol language.
Definition: type.hpp:12
Priority wrapper for type matching.
Definition: tpriorities.hpp:24
const T * get() const BY_CONST_FUNC(get()) nbool isSamePrecedence(const me &rhs) const
precedence is more detail concept of priority. it considers the owner of them are equal above priorit...
priorType
the lower value, the higher priority.
Definition: tpriorities.hpp:8
@ NO_MATCH
Definition: tpriorities.hpp:16
@ NUMERIC_MATCH
lv0: exact match.
Definition: tpriorities.hpp:10
@ IMPLICIT_MATCH
Definition: tpriorities.hpp:13