tcalc 0.2.0
 
Loading...
Searching...
No Matches
number.hpp
Go to the documentation of this file.
1
12#pragma once
13
14#include "tcalc/ast/node.hpp"
15#include "tcalc/common.hpp"
16
17namespace tcalc::ast {
18
23class NumberNode : public Node
24{
25private:
26 double _value;
27
28public:
34 explicit NumberNode(double value)
35 : Node{ NodeType::NUMBER }
36 , _value{ value }
37 {
38 }
39
40 ~NumberNode() override = default;
41
47 [[nodiscard]] TCALC_INLINE auto value() const noexcept { return _value; }
48
54 TCALC_INLINE void value(double value) noexcept { _value = value; }
55};
56
57}
Base class for AST nodes.
Definition node.hpp:87
Number AST node.
Definition number.hpp:24
TCALC_INLINE void value(double value) noexcept
Set the number value.
Definition number.hpp:54
TCALC_INLINE auto value() const noexcept
Get the number value.
Definition number.hpp:47
NumberNode(double value)
Construct a new Number Node object.
Definition number.hpp:34
tcalc common header.
Base class for AST nodes.
NodeType
AST node type.
Definition node.hpp:30