Antares Simulator
Power System Simulator
Loading...
Searching...
No Matches
pre-order.h
1
#pragma once
2
3
#include <stack>
4
#include <vector>
5
6
namespace
Antares::Expressions::Nodes
7
{
8
// Forward-declaration is enough
9
10
class
Node;
11
12
// PreOrder Iterator for AST
13
class
ASTPreOrderIterator
14
{
15
std::stack<Node*> nodeStack;
16
17
public
:
18
// Iterator type aliases
19
using
iterator_category = std::forward_iterator_tag;
20
using
value_type
=
Node
;
21
using
difference_type = std::ptrdiff_t;
22
using
pointer
=
Node
*;
23
using
reference
=
Node
&;
24
25
// Constructor
26
explicit
ASTPreOrderIterator
(
Node
* root =
nullptr
);
27
28
// Dereference operator
29
reference
operator*()
const
;
30
31
// Pointer access operator
32
pointer
operator->()
const
;
33
34
// Increment operator (pre-order traversal)
35
ASTPreOrderIterator
& operator++();
36
37
// Equality comparison
38
bool
operator==(
const
ASTPreOrderIterator
& other)
const
;
39
40
// Inequality comparison
41
bool
operator!=(
const
ASTPreOrderIterator
& other)
const
;
42
};
43
44
// AST container class to expose begin/end iterators
45
class
AST
46
{
47
Node
* root;
48
49
public
:
50
explicit
AST
(
Node
* rootNode);
51
52
// Begin iterator
53
ASTPreOrderIterator
begin();
54
55
// End iterator (indicating traversal is complete)
56
ASTPreOrderIterator
end();
57
};
58
}
// namespace Antares::Expressions::Nodes
Antares::Expressions::Nodes::ASTPreOrderIterator
Definition
pre-order.h:14
Antares::Expressions::Nodes::AST
Definition
pre-order.h:46
Antares::Expressions::Nodes::Node
Base class for nodes in a syntax tree.
Definition
Node.h:30
src
expressions
include
antares
expressions
iterators
pre-order.h
Generated by
1.12.0