Example #1
0
 public DefaultVisitor(ForestInternal root)
 {
     if (root == null)
     {
         throw new ArgumentNullException();
     }
     _root = root;
 }
Example #2
0
		public virtual bool Visit(ForestInternal node) {
			foreach (var option in node.Options) {
				foreach (var children in option.Children()) {
					foreach (var child in children) {
						child.Accept(this);
					}
				}
			}
			return true;
		}
Example #3
0
 public virtual bool Visit(ForestInternal node)
 {
     foreach (var option in node.Options)
     {
         foreach (var children in option.Children())
         {
             foreach (var child in children)
             {
                 child.Accept(this);
             }
         }
     }
     return(true);
 }
Example #4
0
        public override bool Visit(ForestInternal node)
        {
            if (_visited.Contains(node.InternalNode))
            {
                return(true);
            }
            _visited.Add(node.InternalNode);

            var currentNode = _currentNode;

            for (int i = 0; i < node.Options.Count; i++)
            {
                var    option     = node.Options[i];
                string optionId   = _ids[node.InternalNode] + "-" + i;
                var    optionNode = new ChildNode(option.Production.Rhs, node.StartPosition, node.EndPosition, optionId, currentNode.Rank + 1);

                _graph.AddEdge(currentNode, optionNode, option.Production);
                foreach (var children in option.Children())
                {
                    foreach (var child in children)
                    {
                        int childSeenId;
                        if (child is ForestLeaf)
                        {
                            childSeenId = _id++;
                        }
                        else
                        {
                            var internalChild = (ForestInternal)child;
                            if (!_ids.TryGetValue(internalChild.InternalNode, out childSeenId))
                            {
                                childSeenId = _id++;
                                _ids[internalChild.InternalNode] = childSeenId;
                            }
                        }

                        string childId   = "" + childSeenId;
                        var    childNode = new ForestNodeNode(child, childId, optionNode.Rank + 1);
                        _graph.AddEdge(optionNode, childNode);
                        _currentNode = childNode;
                        child.Accept(this);
                        // child.GetGraphHelper(g, childNode, visited, ids, ref id);
                    }
                }
            }
            return(true);
        }
Example #5
0
		public override bool Visit(ForestInternal node) {
			if (_visited.Contains(node.InternalNode)) {
				return true;
			}
			_visited.Add(node.InternalNode);

			var currentNode = _currentNode;

			for (int i = 0; i < node.Options.Count; i++) {
				var option = node.Options[i];
				string optionId = _ids[node.InternalNode] + "-" + i;
				var optionNode = new ChildNode(option.Production.Rhs, node.StartPosition, node.EndPosition, optionId, currentNode.Rank + 1);

				_graph.AddEdge(currentNode, optionNode, option.Production);
				foreach (var children in option.Children()) {
					foreach (var child in children) {
						int childSeenId;
						if (child is ForestLeaf) {
							childSeenId = _id++;
						} else {
							var internalChild = (ForestInternal)child;
							if (!_ids.TryGetValue(internalChild.InternalNode, out childSeenId)) {
								childSeenId = _id++;
								_ids[internalChild.InternalNode] = childSeenId;
							}
						}

						string childId = "" + childSeenId;
						var childNode = new ForestNodeNode(child, childId, optionNode.Rank + 1);
						_graph.AddEdge(optionNode, childNode);
						_currentNode = childNode;
						child.Accept(this);
						// child.GetGraphHelper(g, childNode, visited, ids, ref id);
					}
				}
			}
			return true;
		}
Example #6
0
		public DefaultVisitor(ForestInternal root) {
			if (root == null) {
				throw new ArgumentNullException();
			}
			_root = root;
		}
Example #7
0
		public GraphVisitor(ForestInternal root) : base(root) {
		}
Example #8
0
 public GraphVisitor(ForestInternal root) : base(root)
 {
 }