Leonardus
Loading...
Searching...
No Matches
so.h
Go to the documentation of this file.
1
17#pragma once
18
19// Inc Library
20#include <string>
21
22// Inc HAA
23#include "dbc.h"
24#include "helper.h"
25#include "error.h"
26
27// Inc Medium
28#include "counter.h"
29
30
33enum class OTCode : char {
34 L,
35 B,
36 I,
37 M,
38 N,
39 Nx,
40 O,
41 o,
42 Q,
43 R,
44
45 A,
46 Ax,
47 D,
48 S,
49 K,
50
51 X
52};
53
54
58class SO : public Counter<SO>, protected DbC {
59 bool exec_;
62public:
64 explicit SO( bool p_exec = false ) : exec_(p_exec) {}
65
66
69 virtual ~SO() = default;
70
71
72public: /* accessor */
74 bool getExec() const {
75 return exec_;
76 }
77
78
80 void setExec( bool p_exec ) {
81 exec_ = p_exec;
82 }
83
84
86 virtual size_t getSize() const {
87 return 1;
88 }
89
90
91public: /* virtual */
93 [[nodiscard]] virtual SO * dup() const = 0;
94
95
97 [[nodiscard]] virtual SO * clone() const {
98 return dup();
99 }
100
101
103 virtual std::string opequal() const = 0;
104
105
108 virtual std::string opequalequal() const {
109 return opequal();
110 }
111
112
117 virtual OTCode ot() const = 0;
118
119
123 virtual std::string type() const = 0;
124
125
136 virtual bool equal( const SO * /* unused */ ) const = 0;
137
138
143 virtual bool gt( const SO * /* unused */ ) const {
145 }
146
147
152 virtual bool ge( const SO * /* unused */ ) const {
154 }
155};
156
157
159using SOp = SO *;
160
161
165class SOcomposite : public SO {
166
167public:
169 using SO::SO;
170
171
172public: /* virtual */
173 std::string opequal() const override {
174 return "--nostringval--";
175 }
176
177
189 virtual size_t treeheight( size_t p_myheigth ) const {
190 return p_myheigth;
191 }
192};
Counter base class.
Definition counter.h:27
Design by contract interface class.
Definition dbc.h:26
Semantic Object.
Definition so.h:58
virtual bool equal(const SO *) const =0
Equality.
void setExec(bool p_exec)
Setter for exec_.
Definition so.h:80
virtual std::string type() const =0
Returns a type name.
virtual SO * dup() const =0
Creates a new instance as copy following the red book definition.
SO(bool p_exec=false)
Ctor.
Definition so.h:64
virtual ~SO()=default
Virtual dtor.
virtual std::string opequalequal() const
For operators '==' and 'pstack'.
Definition so.h:108
virtual std::string opequal() const =0
For operators '=', 'cvs' and 'stack'.
virtual bool ge(const SO *) const
Greater or equal.
Definition so.h:152
virtual OTCode ot() const =0
Returns an OTCode.
virtual bool gt(const SO *) const
Greater than.
Definition so.h:143
bool getExec() const
Getter for exec_.
Definition so.h:74
virtual SO * clone() const
Creates a new instance as copy with deep cloning.
Definition so.h:97
bool exec_
All SOs have executive vs literal attribut.
Definition so.h:59
virtual size_t getSize() const
Getter for the number of characters or number of objects.
Definition so.h:86
Composite Semantic Object.
Definition so.h:165
std::string opequal() const override
For operators '=', 'cvs' and 'stack'.
Definition so.h:173
virtual size_t treeheight(size_t p_myheigth) const
Tree Height.
Definition so.h:189
The class Counter.
Helpers for design by contract idioms.
void opErrExit(OpError p_err, const std::string &p_details, const std::source_location p_location)
Operator error message to interpreter cout_ and exit( EC_OPERATOR ).
Definition error.cpp:31
Error handling.
@ typecheck
PS operator error typecheck.
Definition error.h:34
Miscellaneous definitions and functions.
OTCode
OTCode - the Object Type Code.
Definition so.h:33
@ X
any SO
@ S
SOS.
@ M
SOM.
@ A
SOA literal.
@ N
SON literal.
@ B
SOB.
@ Nx
SON executable.
@ K
SOK.
@ Ax
SOA executable.
@ L
SOL.
@ o
SOo.
@ I
SOI.
@ R
SOR.
@ Q
SOQ.
@ O
SOO.
@ D
SOD.