Example #1
0
 /*
  * Creates the root expression which recursively creates the whole expression
  */
 private void CreateRootExpression(String expression)
 {
     if (BooleanNode.IsSingleVar(expression))
     {
         this.RootExpression = new VariableNode(expression);
     }
     else
     {
         this.RootExpression = new GateNode(expression);
     }
 }
Example #2
0
        /*
         * The actually important function, creates children expressions, and then determines the types of nodes that need to be created as
         * children
         */
        public override Dictionary <String, List <VariableNode> > CreateChildren(Dictionary <String, List <VariableNode> > variables)
        {
            Tuple <String, String> expressions = this.CreateChildrenExpressions();

            if (expressions.Item1.Equals("") && expressions.Item2.Equals(""))
            {
                Console.WriteLine("ERROR");
            }
            if (expressions.Item2.Equals("SingleInv")) // single inverter case
            {
                this.firstVar = new VariableNode(expressions.Item1);
                this.firstVar.CreateChildren(variables);
                this.secondVar = null;
            }
            else if (expressions.Item2.Equals("MultiInv")) // single inverter case
            {
                this.firstVar = new GateNode(expressions.Item1);
                this.firstVar.CreateChildren(variables);
                this.secondVar = null;
            }
            else
            {
                if (BooleanNode.IsSingleVar(expressions.Item1))
                {
                    this.firstVar = new VariableNode(expressions.Item1);
                }
                else
                {
                    this.firstVar = new GateNode(expressions.Item1);
                }

                this.firstVar.CreateChildren(variables);

                if (BooleanNode.IsSingleVar(expressions.Item2))
                {
                    this.secondVar = new VariableNode(expressions.Item2);
                }
                else
                {
                    this.secondVar = new GateNode(expressions.Item2);
                }

                this.secondVar.CreateChildren(variables);
            }

            return(variables);
        }