Example #1
0
 public ParsedExpression(String paramString, LogicExpression paramLogicExpression, LogicSyntax paramInt1, NegationSyntax paramInt2)
 {
     InitialText = paramString;
     Expression = paramLogicExpression;
     LogicSyntax = paramInt1;
     NegationSyntax = paramInt2;
 }
Example #2
0
        public void Check(LogicSyntax paramInt1, NegationSyntax paramInt2)
        {
            int i = 0;

            int j = paramInt1 != LogicSyntax.f0 ? 1 : 0;

            int k = LogicSyntax != LogicSyntax.f0 ? 1 : 0;

            int m = paramInt2 != 0 ? 1 : 0;

            int n = NegationSyntax != 0 ? 1 : 0;

            if ((j != 0) && (LogicSyntax != paramInt1))
                i = 1;
            else if ((m != 0) && (NegationSyntax != paramInt2))
                i = 1;
            else if ((j != 0) && (n != 0) && (LogicParser.GetNegationSyntax(paramInt1) != NegationSyntax))
            {
                i = 1;
            }
            else if ((k != 0) && (m != 0) && (LogicParser.GetNegationSyntax(LogicSyntax) != paramInt2))
            {
                i = 1;
            }
            if (i != 0)
                throw new DifferentSyntaxesUsedException("Change of logic syntax");
        }
Example #3
0
 public ParsedExpression(String initialText, LogicExpression expression, LogicSyntax logicSyntax,
     NegationSyntax negationSyntax)
 {
     InitialText = initialText;
     Expression = expression;
     LogicSyntax = logicSyntax;
     NegationSyntax = negationSyntax;
 }
Example #4
0
 public static String GetImpliesString(LogicSyntax paramInt)
 {
     switch (paramInt)
     {
         case LogicSyntax.Written:
             return "IMPLIES";
     }
     return "=>";
 }
Example #5
0
 public override void ToString(StringBuilder paramStringBuilder, LogicSyntax paramInt1, NegationSyntax paramInt2)
 {
     if (Negated)
     {
         string value = NegationSyntaxer.GetNegatedString(paramInt2, Name);
         paramStringBuilder.Append(value);
     }
     else
         paramStringBuilder.Append(Name);
 }
Example #6
0
        public void UpdateLogicSyntax(LogicSyntax paramInt)
        {
            if (((LogicSyntax != 0) && (LogicSyntax != paramInt)) ||
                ((NegationSyntax != NegationSyntax.Unknown) &&
                (LogicParser.GetNegationSyntax(paramInt) != NegationSyntax)))
            {
                throw new DifferentSyntaxesUsedException("Change in logic syntax");
            }

            LogicSyntax = paramInt;
            NegationSyntax = LogicParser.GetNegationSyntax(paramInt);
        }
Example #7
0
 public static String GetAndString(LogicSyntax paramInt)
 {
     switch (paramInt)
     {
         case LogicSyntax.Written:
             return "AND";
         case LogicSyntax.LogicSyntaxNu:
             return "n";
         case LogicSyntax.LogicSyntaxUpDown:
             return "^";
         case LogicSyntax.LogicSyntaxSlashes:
             return "/\\";
         case LogicSyntax.LogicSyntaxDotPlus:
             return ".";
     }
     return ".";
 }
Example #8
0
 public static String GetAndString(LogicSyntax paramInt)
 {
     switch (paramInt)
     {
         case LogicSyntax.f1:
             return "AND";
         case LogicSyntax.f2:
             return "n";
         case LogicSyntax.f3:
             return "^";
         case LogicSyntax.f4:
             return "/\\";
         case LogicSyntax.f5:
             return ".";
     }
     return ".";
 }
Example #9
0
 public override void ToString(StringBuilder paramStringBuilder, LogicSyntax paramInt1, NegationSyntax paramInt2)
 {
     if (Negated)
     {
         if (paramInt2 == NegationSyntax.Written)
             paramStringBuilder.Append("NOT " + Value);
         else if (paramInt2 == NegationSyntax.Before)
             paramStringBuilder.Append("~" + Value);
         else if (paramInt2 == NegationSyntax.After)
             paramStringBuilder.Append(Value + "'");
         else
         {
             Console.Error.WriteLine("Software Error: Unknown negationSyntax passed: " + paramInt2);
         }
     }
     else
         paramStringBuilder.Append(Value);
 }
Example #10
0
        public static NegationSyntax GetNegationSyntax(LogicSyntax paramInt)
        {
            switch (paramInt)
            {
                case LogicSyntax.Written:
                    return NegationSyntax.Written;
                case LogicSyntax.LogicSyntaxNu:
                    return NegationSyntax.Before;
                case LogicSyntax.LogicSyntaxUpDown:
                    return NegationSyntax.Before;
                case LogicSyntax.LogicSyntaxSlashes:
                    return NegationSyntax.Before;
                case LogicSyntax.LogicSyntaxDotPlus:
                    return NegationSyntax.After;
                case LogicSyntax.Unknown:
                    return NegationSyntax.Unknown;
            }
            Console.Error.WriteLine("Software error: unknown negationSyntax; logicSyntax: " + paramInt);

            return NegationSyntax.Unknown;
        }
Example #11
0
 public override void ToString(StringBuilder paramStringBuilder, LogicSyntax paramInt1, NegationSyntax paramInt2)
 {
     if (Negated)
     {
         switch (paramInt2)
         {
             case NegationSyntax.Written:
                 paramStringBuilder.Append("NOT " + _value);
                 break;
             case NegationSyntax.Before:
                 paramStringBuilder.Append("~" + _value);
                 break;
             case NegationSyntax.After:
                 paramStringBuilder.Append(_value + "'");
                 break;
             default:
                 Console.Error.WriteLine("Software Error: Unknown negationSyntax passed: " + paramInt2);
                 break;
         }
     }
     else
         paramStringBuilder.Append(_value);
 }
Example #12
0
 public ParserBlock(LogicExpression paramLogicExpression, LogicSyntax paramInt1, NegationSyntax paramInt2)
 {
     Expression = paramLogicExpression;
     LogicSyntax = paramInt1;
     NegationSyntax = paramInt2;
 }
Example #13
0
 public static String GetOrString(LogicSyntax paramInt)
 {
     switch (paramInt)
     {
         case LogicSyntax.f1:
             return "OR";
         case LogicSyntax.f2:
             return "u";
         case LogicSyntax.f3:
             return "v";
         case LogicSyntax.f4:
             return "\\/";
         case LogicSyntax.f5:
             return "+";
     }
     return "+";
 }
Example #14
0
 public static String GetXorString(LogicSyntax paramInt)
 {
     switch (paramInt)
     {
         case LogicSyntax.Written:
             return "XOR";
     }
     return "!=";
 }
Example #15
0
        public override void ToString(StringBuilder paramStringBuilder, LogicSyntax paramInt1, NegationSyntax paramInt2)
        {
            if (Negated)
            {
                string value = NegationSyntaxer.GetNegation(paramInt2);
                paramStringBuilder.Append(value);
            }
            if (Parent != null)
            {
                paramStringBuilder.Append("(");
            }
            for (int i = 0; i < _logicBranches.Length; i++)
            {
                if (i > 0)
                {
                    paramStringBuilder.Append(" ");
                    paramStringBuilder.Append(LogicSyntaxer.GetOperatorString(paramInt1, Operator));
                    paramStringBuilder.Append(" ");
                }

                _logicBranches[i].ToString(paramStringBuilder, paramInt1, paramInt2);
            }

            if (Parent != null)
            {
                paramStringBuilder.Append(")");
            }
            if ((Negated) && (paramInt2 == NegationSyntax.After))
                paramStringBuilder.Append("'");
        }
Example #16
0
        public void PrintTrace(LogicSyntax paramInt1, NegationSyntax paramInt2)
        {
            int i = _initialText.Length;
            var localStringBuilder = new StringBuilder();

            for (int j = 0; j < i; j++)
            {
                localStringBuilder.Append(" ");
            }
            String str = localStringBuilder.ToString();
            int k = 1;

            foreach (LogicStep localLogicStep in _steps)
            {
                Console.WriteLine(
                    new StringBuilder().Append(k != 0 ? _initialText : str).Append(" |=| ").Append(
                        localLogicStep.Expression.ToString(paramInt1, paramInt2)).Append(" - ").Append(
                            localLogicStep.Comment).Append(" - ").Append(LogicHandler.GetFormName(localLogicStep.Form)).
                        ToString());

                k = 0;
            }

            Console.WriteLine(new StringBuilder().Append("CNF: ").Append(CNF.ToString(paramInt1, paramInt2)).ToString());
            Console.WriteLine(new StringBuilder().Append("DNF: ").Append(DNF.ToString(paramInt1, paramInt2)).ToString());
        }
Example #17
0
        public static NegationSyntax GetNegationSyntax(LogicSyntax paramInt)
        {
            switch (paramInt)
            {
                case LogicSyntax.f1:
                    return NegationSyntax.Written;
                case LogicSyntax.f2:
                    return NegationSyntax.Before;
                case LogicSyntax.f3:
                    return NegationSyntax.Before;
                case LogicSyntax.f4:
                    return NegationSyntax.Before;
                case LogicSyntax.f5:
                    return NegationSyntax.After;
                case LogicSyntax.f0:
                    return NegationSyntax.Unknown;
            }
            Console.Error.WriteLine("Software error: unknown negationSyntax; logicSyntax: " + paramInt);

            return NegationSyntax.Unknown;
        }
Example #18
0
        public String ToString(LogicSyntax logicSyntax, NegationSyntax negationSyntax)
        {
            var localStringBuilder = new StringBuilder();

            ToString(localStringBuilder, logicSyntax, negationSyntax);

            return localStringBuilder.ToString();
        }
Example #19
0
        public String ToString(LogicSyntax paramInt1, NegationSyntax paramInt2)
        {
            var localStringBuilder = new StringBuilder();

            ToString(localStringBuilder, paramInt1, paramInt2);

            return localStringBuilder.ToString();
        }
Example #20
0
        public void UpdateLogicSyntax(LogicSyntax paramInt)
        {
            NegationSyntax negationSyntax = LogicParser.GetNegationSyntax(paramInt);

            if ((LogicSyntax    == LogicSyntax.Unknown || (LogicSyntax == paramInt)) &&
                (NegationSyntax == NegationSyntax.Unknown || (negationSyntax == NegationSyntax)))
            {
                LogicSyntax = paramInt;
                NegationSyntax = negationSyntax;
            }
            else
            {
                throw new DifferentSyntaxesUsedException("Change in logic syntax");
            }
        }
Example #21
0
 public static String GetOperatorString(LogicSyntax logic, Operator @operator)
 {
     switch (@operator)
     {
         case Operator.And:
             return LogicParser.GetAndString(logic);
         case Operator.Or:
             return LogicParser.GetOrString(logic);
         case Operator.Implies:
             return LogicParser.GetImpliesString(logic);
         case Operator.Biimplies:
             return LogicParser.GetBiimpliesString(logic);
         case Operator.Xor:
             return LogicParser.GetXorString(logic);
     }
     Console.Error.WriteLine("Software Error: Unknown operator passed");
     return LogicParser.GetAndString(logic);
 }
Example #22
0
 public static String GetBiimpliesString(LogicSyntax paramInt)
 {
     switch (paramInt)
     {
         case LogicSyntax.f1:
             return "BIIMPLIES";
     }
     return "<=>";
 }
Example #23
0
 public static String GetOrString(LogicSyntax paramInt)
 {
     switch (paramInt)
     {
         case LogicSyntax.Written:
             return "OR";
         case (LogicSyntax) 2:
             return "u";
         case (LogicSyntax) 3:
             return "v";
         case (LogicSyntax) 4:
             return "\\/";
         case (LogicSyntax) 5:
             return "+";
     }
     return "+";
 }
Example #24
0
 private String GetOperatorString(LogicSyntax paramInt1, Operator paramInt2)
 {
     switch (paramInt2)
     {
         case Operator.And:
             return LogicParser.GetAndString(paramInt1);
         case Operator.Or:
             return LogicParser.GetOrString(paramInt1);
         case Operator.OperatorImplies:
             return LogicParser.GetImpliesString(paramInt1);
         case Operator.OperatorBiimplies:
             return LogicParser.GetBiimpliesString(paramInt1);
         case Operator.OperatorXor:
             return LogicParser.GetXorString(paramInt1);
     }
     Console.Error.WriteLine("Software Error: Unknown operator passed");
     return LogicParser.GetAndString(paramInt1);
 }
Example #25
0
 public abstract void ToString(StringBuilder paramStringBuilder, LogicSyntax paramInt1, NegationSyntax paramInt2);
Example #26
0
 public ParserSyntax(LogicSyntax paramInt1 = LogicSyntax.Unknown, NegationSyntax paramInt2=NegationSyntax.Unknown)
 {
     LogicSyntax = paramInt1;
     NegationSyntax = paramInt2;
 }
Example #27
0
        public override void ToString(StringBuilder paramStringBuilder, LogicSyntax paramInt1, NegationSyntax paramInt2)
        {
            String str = GetOperatorString(paramInt1, Operator);

            if (Negated)
            {
                if (paramInt2 == NegationSyntax.Written)
                    paramStringBuilder.Append("NOT ");
                else if (paramInt2 == NegationSyntax.Before)
                {
                    paramStringBuilder.Append("~");
                }
            }
            paramStringBuilder.Append("(");
            for (int i = 0; i < _logicBranches.Length; i++)
            {
                if (i > 0)
                {
                    paramStringBuilder.Append(" ");
                    paramStringBuilder.Append(str);
                    paramStringBuilder.Append(" ");
                }

                _logicBranches[i].ToString(paramStringBuilder, paramInt1, paramInt2);
            }

            paramStringBuilder.Append(")");
            if ((Negated) && (paramInt2 == NegationSyntax.After))
                paramStringBuilder.Append("'");
        }
Example #28
0
 public ParserSyntax(LogicSyntax paramInt1, NegationSyntax paramInt2)
 {
     LogicSyntax = paramInt1;
     NegationSyntax = paramInt2;
 }