~alexreg/mathtexdotnet/0.1

« back to all changes in this revision

Viewing changes to TexDotNet/Semantics/ParseNode.cs

  • Committer: Alex Regueiro
  • Date: 2009-09-21 00:06:28 UTC
  • Revision ID: alexreg@gmail.com-20090921000628-88xvb2n2v57vsr0d
Updated grammar specification.
Modified parser so that it now creates a binary tree for implicitly multiplied values (rather than a node with n children).

Show diffs side-by-side

added added

removed removed

Lines of Context:
8
8
    // TODO: Use SymbolKind and Value properties instead of Token?
9
9
    public class ParseNode
10
10
    {
11
 
        public ParseNode(Token token, IList<ParseNode> children)
12
 
            : this()
 
11
        public ParseNode(Token token, IEnumerable<ParseNode> children)
 
12
            : this(token)
13
13
        {
14
 
            this.Kind = ParseNodeKind.Token;
15
 
            this.Token = token;
16
 
            this.Children = new ParseNodeCollection(children);
 
14
            foreach (var childNode in children)
 
15
                this.Children.Add(childNode);
17
16
        }
18
17
 
19
18
        public ParseNode(Token token)
21
20
        {
22
21
            this.Kind = ParseNodeKind.Token;
23
22
            this.Token = token;
24
 
            this.Children = null;
 
23
            this.Children = new ParseNodeCollection();
25
24
        }
26
25
 
27
 
        public ParseNode(ParseNodeKind kind, IList<ParseNode> children)
28
 
            : this()
 
26
        public ParseNode(ParseNodeKind kind, IEnumerable<ParseNode> children)
 
27
            : this(kind)
29
28
        {
30
 
            this.Kind = kind;
31
 
            this.Token = Token.Null;
32
 
            this.Children = new ParseNodeCollection(children);
 
29
            foreach (var childNode in children)
 
30
                this.Children.Add(childNode);
33
31
        }
34
32
 
35
33
        public ParseNode(ParseNodeKind kind)