Example #1
0
 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());
 }
Example #2
0
 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));
 }
Example #3
0
        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);
        }
Example #4
0
 /// <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>();
 }
Example #5
0
 public SyntaxNode Instantiate(SyntaxNodeContext context, int depth) => func(context, depth);
Example #6
0
 public Error(SyntaxNodeContext context, int depth, Label label, string code, Pos pos)
     : base(SyntaxKind.ERROR, context, depth, label, code, pos)
 {
 }
Example #7
0
 public Token(SyntaxNodeContext context, int depth, Label label, string code, Pos pos)
     : base(SyntaxKind.TOKEN, context, depth, label, code, pos)
 {
 }