Пример #1
0
        protected override Box __Translate(WordSym s)
        {
            /* TODO: need to handle accent, format */
            StringBox sb = new StringBox(s, s.Word, Syntax.TType.Ord);

            if (s.Subscript != new NullExpr())
            {
                return(new AtomBox(null, sb, Translate(s.Subscript), null, Syntax.TType.Ord));
            }
            else
            {
                return(sb);
            }
        }
Пример #2
0
 private Expr _Numericize(WordSym s)
 {
     return s;
 }
Пример #3
0
 private Expr _Canonicalize(WordSym s)
 {
     return s;
 }
Пример #4
0
        public static Expr Generate(object obj)
        {
            var boolValue = obj as bool?;

            if (boolValue != null)
            {
                return(new WordSym(boolValue.ToString()));
            }

            var ss = obj as ShapeSymbol;

            if (ss != null)
            {
                return(Generate(ss));
            }

            var eqGoal = obj as EqGoal;

            if (eqGoal != null)
            {
                return(Generate(eqGoal));
            }

            var term = obj as Term;

            if (term != null)
            {
                return(Generate(term));
            }

            var equation = obj as Equation;

            if (equation != null)
            {
                return(Generate(equation));
            }

            var variable = obj as Var;

            if (variable != null)
            {
                return(new WordSym(variable.Token.ToString()));
            }

            int integer;

            if (LogicSharp.IsInt(obj, out integer))
            {
                var integerExpr = new IntegerNumber(integer.ToString());
                if (integer < 0)
                {
                    return(new CompositeExpr(WellKnownSym.times, new Expr[] { integerExpr }));
                }
                else
                {
                    return(integerExpr);
                }
            }

            double dNumber;

            if (LogicSharp.IsDouble(obj, out dNumber))
            {
                var doubleExpr = new WordSym(dNumber.ToString());
                //var doubleExpr = new DoubleNumber(dNumber);

                if (dNumber < 0)
                {
                    return(new CompositeExpr(WellKnownSym.times, new Expr[] { doubleExpr }));
                }
                return(doubleExpr);
            }

            return(null);
        }
Пример #5
0
        public static Expr Generate(object obj)
        {
            var boolValue = obj as bool?;
            if (boolValue != null) return new WordSym(boolValue.ToString());

            var ss = obj as ShapeSymbol;
            if (ss != null) return Generate(ss);

            var eqGoal = obj as EqGoal;
            if (eqGoal != null) return Generate(eqGoal);

            var term = obj as Term;
            if (term != null) return Generate(term);

            var equation = obj as Equation;
            if (equation != null) return Generate(equation);

            var variable = obj as Var;
            if (variable != null)
            {
                return new WordSym(variable.Token.ToString());
            }

            int integer;
            if (LogicSharp.IsInt(obj, out integer))
            {
                var integerExpr = new IntegerNumber(integer.ToString());
                if (integer < 0)
                {
                    return new CompositeExpr(WellKnownSym.times, new Expr[] { integerExpr });
                }
                else
                {
                    return integerExpr;
                }
            }

            double dNumber;
            if (LogicSharp.IsDouble(obj, out dNumber))
            {
                var doubleExpr = new WordSym(dNumber.ToString());
                //var doubleExpr = new DoubleNumber(dNumber);

                if (dNumber < 0)
                {
                    return new CompositeExpr(WellKnownSym.times, new Expr[] { doubleExpr });
                }
                return doubleExpr;
            }

            return null;
        }