public Leaf(SyntaxKind kind, SyntaxNodeContext context, int depth, Label label, string code, Pos pos) : base(kind, context, depth, label, code) { this.pos = pos; this.treeHash = Hash.Combine(label.GetHashCode(), code.GetHashCode()); }
public Node(SyntaxNodeContext context, int depth, Label label, IEnumerable <PartialNode> children, string code = "") : base(SyntaxKind.NODE, context, depth, label, code) { this.children = children.Select(t => t.Instantiate(context, depth + 1)).ToList(); this.children.ForEach(t => t.parent = this); this.treeHash = Hash.Combine(label.GetHashCode(), this.children.Select(t => t.treeHash)); }
public static SyntaxNodeContext FromJSON(string json) { var context = new SyntaxNodeContext(); var obj = JObject.Parse(json); context.root = Node.CreatePartialFromJSON(obj).Instantiate(context, 0); return(context); }
/// <summary> /// Internal base constructor. /// </summary> /// <param name="kind"></param> /// <param name="context"></param> /// <param name="depth"></param> /// <param name="label"></param> /// <param name="name"></param> /// <param name="code"></param> protected SyntaxNode(SyntaxKind kind, SyntaxNodeContext context, int depth, Label label, string code = "") { this.kind = kind; this.context = context; this.depth = depth; this.label = label; this.id = context.AllocateId(); this.code = code; this.matches = new List <SyntaxNode>(); }
public SyntaxNode Instantiate(SyntaxNodeContext context, int depth) => func(context, depth);
public Error(SyntaxNodeContext context, int depth, Label label, string code, Pos pos) : base(SyntaxKind.ERROR, context, depth, label, code, pos) { }
public Token(SyntaxNodeContext context, int depth, Label label, string code, Pos pos) : base(SyntaxKind.TOKEN, context, depth, label, code, pos) { }