예제 #1
0
        public static Node Make(Token token, Node parent)
        {
            int id;

            if (int.TryParse(token.Head, out id))
            {
                return Terminal.MakeNewTerminal(id, parent);
            }
            else
            {
                string f = token.Head.ToUpper();

                var t = token.Tokens;

                if (f == "AND")
                {
                    return FunctionAnd.Make(t[0], t[1], parent);
                }
                else if (f == "OR")
                {
                    return FunctionOr.Make(t[0], t[1], parent);
                }
                else if (f == "NOT")
                {
                    return FunctionNot.Make(t[0], parent);
                }
                else
                {
                    throw new Exception(string.Format("Invalid token head: {0}", f));
                }
            }
        }
예제 #2
0
        private FunctionOr(Token left, Token right,   Node parent)
        {
            _parent = parent;

            _left = NodeFactory.Make(left, this);
            _right = NodeFactory.Make(right, this);
        }
예제 #3
0
        public static Node Make(string s, Node parent)
        {
            var token = new Token(s);

            return Make(token, parent);
        }
예제 #4
0
 internal static Node Make(Token left, Token right, Node parent)
 {
     return new FunctionOr(left,right, parent);
 }
예제 #5
0
 private FunctionNot(Token token, Node parent)
 {
     _parent = parent;
     _node = NodeFactory.Make(token, this);
 }
예제 #6
0
 internal static Node Make(Token token, Node parent)
 {
     return new FunctionNot(token, parent);
 }