Neuron®
The Neuron® is the basis for the creation of open and secure federated networks for smart societies.
Loading...
Searching...
No Matches
SemanticScriptElement.cs
3
5{
10 {
11 private ScriptNode node;
12
18 {
19 this.node = Node;
20 }
21
25 public ScriptNode Node => this.node;
26
30 public override bool IsLiteral => false;
31
35 public override object AssociatedObjectValue => this.node;
36
38 public override bool Equals(object obj)
39 {
40 return obj is SemanticScriptElement Typed &&
41 this.node.SubExpression.Equals(Typed.node.SubExpression);
42 }
43
45 public override int GetHashCode()
46 {
47 return this.node.SubExpression.GetHashCode();
48 }
49
55 public override int CompareTo(object obj)
56 {
57 if (obj is SemanticScriptElement Typed)
58 return this.node.SubExpression.CompareTo(Typed.node.SubExpression);
59 else
60 return -1;
61 }
62
70 public bool ForAll(ScriptNodeEventHandler Callback, object State, SearchMethod Order)
71 {
72 bool b;
73
74 if (!(this.node is null))
75 {
76 b = !Callback(this.node, out ScriptNode NewNode, State);
77 if (!(NewNode is null))
78 {
79 ScriptNode Parent = this.node.Parent;
80
81 this.node = NewNode;
82 this.node.SetParent(Parent);
83 }
84
85 if (b || (Order == SearchMethod.TreeOrder && !this.node.ForAllChildNodes(Callback, State, Order)))
86 return false;
87 }
88
89 return true;
90 }
91 }
92}
Abstract base class for semantic elements.
Base class for all nodes in a parsed script tree.
Definition: ScriptNode.cs:69
string SubExpression
Sub-expression defining the node.
Definition: ScriptNode.cs:183
ScriptNode Parent
Parent node.
Definition: ScriptNode.cs:126
void SetParent(ScriptNode Parent)
Sets the parent node. Can only be used when expression is being parsed.
Definition: ScriptNode.cs:132
SemanticScriptElement(ScriptNode Node)
Semantic element based on script.
override object AssociatedObjectValue
Associated object value.
bool ForAll(ScriptNodeEventHandler Callback, object State, SearchMethod Order)
Calls the callback method for all child nodes.
override int CompareTo(object obj)
Compares element to another.
delegate bool ScriptNodeEventHandler(ScriptNode Node, out ScriptNode NewNode, object State)
Delegate for ScriptNode callback methods.
SearchMethod
Method to traverse the expression structure
Definition: ScriptNode.cs:38