Exemple #1
0
 static Parser <ESOperator> AssignOperator(string op, AssignType opType)
 {
     return
         (Parse
          .String(op)
          .Token()
          .Named("Solvable Operator")
          .Return(new ESOAssign(op, opType)));
 }
Exemple #2
0
 public AssignNode(IdNode id, ExprNode expr, LexLocation exprLoc, AssignType assop = AssignType.Assign)
 {
     if (id.Type != expr.Type)
     {
         throw new Exception($"({exprLoc.StartLine},{exprLoc.StartColumn}): Переменной типа " +
                             $"\"{TypeName(id.Type)}\" нельзя присвоить значение типа \"{TypeName(expr.Type)}\".");
     }
     Id    = id;
     Expr  = expr;
     AssOp = assop;
 }
Exemple #3
0
    private static Assign TryParseAssign(string line)
    {
        Match m = AssignRegex.Match(line);

        if (m.Success)
        {
            int        bot       = int.Parse(m.Groups[1].Value);
            AssignType lowType   = Enum.Parse <AssignType>(m.Groups[2].Value, true);
            int        lowValue  = int.Parse(m.Groups[3].Value);
            AssignType highType  = Enum.Parse <AssignType>(m.Groups[4].Value, true);
            int        highValue = int.Parse(m.Groups[5].Value);
            return(new Assign(bot, lowType, lowValue, highType, highValue));
        }

        return(null);
    }
Exemple #4
0
        public void Assign(string s, AssignType type)
        {
            _type = type;

            if (s != string.Empty)
            {
                if (type == AssignType.Read)
                {
                    reader = new System.IO.StreamReader(s);
                }
                else
                {
                    writer = new System.IO.StreamWriter(s);
                }
            }

            field_2 = 0xD7B0;
        }
Exemple #5
0
        public void Assign(string s, AssignType type)
        {
            _type = type;

            if (s != string.Empty)
            {
                if (type == AssignType.Read)
                {
                    reader = new System.IO.StreamReader(s);
                }
                else
                {
                    writer = new System.IO.StreamWriter(s);
                }
            }

            field_2 = 0xD7B0;
        }
Exemple #6
0
        private static void LoadArguments(string[] args)
        {
            for (int i = 0; i < args.Length; i++)
            {
                if (args[i].StartsWith("--") && args[i].Contains("="))
                {
                    string[] data  = args[i].Split("=");
                    string   param = data[0].ToLower().Trim().Replace("\"", "").Substring(2);
                    string   value = data[1].Trim().Replace("\"", "");

                    switch (param)
                    {
                    case "path":
                        _PATH = value;
                        break;

                    case "folder":
                        _FOLDER = value;
                        break;

                    case "assig":
                        try{
                            _ASSIG = (AssignType)Enum.Parse(typeof(AssignType), value, true);
                        }
                        catch {
                            _ASSIG = AssignType.UNDEFINED;
                        }

                        break;

                    case "server":
                        _SERVER = value;
                        break;

                    case "database":
                        _DATABASE = value;
                        break;
                    }
                }
            }
        }
Exemple #7
0
        public static string ToFriendlyString(this AssignType me)
        {
            switch (me)
            {
            case AssignType.Assign:
                return("=");

            case AssignType.AssignPlus:
                return("+=");

            case AssignType.AssignMult:
                return("*=");

            case AssignType.AssignMinus:
                return("-=");

            case AssignType.AssignDivide:
                return("/=");

            default:
                return("ErrorAssignType");
            }
        }
 /// <summary>
 /// Main constructor
 /// </summary>
 /// <param name="superBlock">Block</param>
 /// <param name="name">Variable name</param>
 /// <param name="type">Assign type</param>
 /// <param name="expressions">Expressions</param>
 public AssignStatement(Block superBlock, string name, AssignType type, List<IExpression> expressions) : base(superBlock)
 {
     Name = name;
     Type = type;
     Expressions = expressions;
 }
Exemple #9
0
 public AssignmentExpressionCPPModel(AssignType Type = 0, ExpressionCPPModel Left = null, ExpressionCPPModel Right = null)
 {
     this.Type  = Type;
     this.Left  = Left ?? default(ExpressionCPPModel);
     this.Right = Right ?? default(ExpressionCPPModel);
 }
Exemple #10
0
 public static Instruction Create(AssignType type, uint reg0, uint reg1)
 {
     return(Create <AsmLessOrEqual>(0b11, type, reg0, reg1));
 }
Exemple #11
0
 public BuildConfig(AssignType ast, string catName, string pa)
 {
     assignType   = ast;
     categoryName = catName;
     path         = pa;
 }
        /// <summary>
        /// Set value
        /// </summary>
        /// <param name="newValue">New value</param>
        public void SetValue(Value newValue, AssignType op)
        {
            switch (newValue.VariableType)
            {

                #region STRING

                case VariableType.STRING:
                    if (VariableType == VariableType.STRING)
                        switch (op)
                        {
                            case AssignType.EQUAL:
                                ObjectValue = newValue.ValueToString();
                                break;
                            case AssignType.PLUSEQUAL:
                                ObjectValue = ValueToString() + newValue.ValueToString();
                                break;
                            default:
                                Logger.Error(LocaString.Get("UnhandledError") + " : Value.cs #1");
                                break;
                        }
                    else if (VariableType == VariableType.BOOL && CanBe.Converted(typeof(bool), newValue.ValueToString()))
                        switch (op)
                        {
                            case AssignType.EQUAL:
                                ObjectValue = newValue.ValueToBool();
                                break;
                            default:
                                Logger.Error(LocaString.Get("UnhandledError") + " : Value.cs #2");
                                break;
                        }
                    else if (VariableType == VariableType.FLOAT && CanBe.Converted(typeof(float), newValue.ValueToString()))
                        switch (op)
                        {
                            case AssignType.EQUAL:
                                ObjectValue = newValue.ValueToFloat();
                                break;
                            case AssignType.PLUSEQUAL:
                                ObjectValue = ValueToFloat() + newValue.ValueToFloat();
                                break;
                            case AssignType.MINUSEQUAL:
                                ObjectValue = ValueToFloat() - newValue.ValueToFloat();
                                break;
                            case AssignType.MULTIPLYEQUAL:
                                ObjectValue = ValueToFloat() * newValue.ValueToFloat();
                                break;
                            case AssignType.DIVIDEEQUAL:
                                ObjectValue = ValueToFloat() / newValue.ValueToFloat();
                                break;
                            case AssignType.PLUSPLUS:
                                ObjectValue = ValueToFloat() + 1;
                                break;
                            case AssignType.MINUSMINUS:
                                ObjectValue = ValueToFloat() - 1;
                                break;
                        }
                    else if (VariableType == VariableType.INT && CanBe.Converted(typeof(int), newValue.ValueToString()))
                        switch (op)
                        {
                            case AssignType.EQUAL:
                                ObjectValue = newValue.ValueToInt();
                                break;
                            case AssignType.PLUSEQUAL:
                                ObjectValue = ValueToInt() + newValue.ValueToInt();
                                break;
                            case AssignType.MINUSEQUAL:
                                ObjectValue = ValueToInt() - newValue.ValueToInt();
                                break;
                            case AssignType.MULTIPLYEQUAL:
                                ObjectValue = ValueToInt() * newValue.ValueToInt();
                                break;
                            case AssignType.DIVIDEEQUAL:
                                ObjectValue = ValueToInt() / newValue.ValueToInt();
                                break;
                            case AssignType.PLUSPLUS:
                                ObjectValue = ValueToInt() + 1;
                                break;
                            case AssignType.MINUSMINUS:
                                ObjectValue = ValueToInt() - 1;
                                break;
                        }
                    else
                        Logger.Error($"You cant assign a string value to a {VariableType} variable.");
                    break;

                #endregion

                #region INT

                case VariableType.INT:
                    if (VariableType == VariableType.INT)
                        switch (op)
                        {
                            case AssignType.EQUAL:
                                ObjectValue = newValue.ValueToInt();
                                break;
                            case AssignType.PLUSEQUAL:
                                ObjectValue = ValueToInt() + newValue.ValueToInt();
                                break;
                            case AssignType.MINUSEQUAL:
                                ObjectValue = ValueToInt() - newValue.ValueToInt();
                                break;
                            case AssignType.MULTIPLYEQUAL:
                                ObjectValue = ValueToInt() * newValue.ValueToInt();
                                break;
                            case AssignType.DIVIDEEQUAL:
                                ObjectValue = ValueToInt() / newValue.ValueToInt();
                                break;
                            case AssignType.PLUSPLUS:
                                ObjectValue = ValueToInt() + 1;
                                break;
                            case AssignType.MINUSMINUS:
                                ObjectValue = ValueToInt() - 1;
                                break;
                        }
                    else if (VariableType == VariableType.FLOAT)
                        switch (op)
                        {
                            case AssignType.EQUAL:
                                ObjectValue = newValue.ValueToFloat();
                                break;
                            case AssignType.PLUSEQUAL:
                                ObjectValue = ValueToFloat() + newValue.ValueToFloat();
                                break;
                            case AssignType.MINUSEQUAL:
                                ObjectValue = ValueToFloat() - newValue.ValueToFloat();
                                break;
                            case AssignType.MULTIPLYEQUAL:
                                ObjectValue = ValueToFloat() * newValue.ValueToFloat();
                                break;
                            case AssignType.DIVIDEEQUAL:
                                ObjectValue = ValueToFloat() / newValue.ValueToFloat();
                                break;
                            case AssignType.PLUSPLUS:
                                ObjectValue = ValueToFloat() + 1;
                                break;
                            case AssignType.MINUSMINUS:
                                ObjectValue = ValueToFloat() - 1;
                                break;
                        }
                    else if (VariableType == VariableType.BOOL && CanBe.Converted(typeof(bool), newValue.ValueToInt()))
                        switch (op)
                        {
                            case AssignType.EQUAL:
                                ObjectValue = newValue.ValueToBool();
                                break;
                            default:
                                Logger.Error(LocaString.Get("UnhandledError") + " : Value.cs #3");
                                break;
                        }
                    else if (VariableType == VariableType.STRING && CanBe.Converted(typeof(string), newValue.ValueToInt()))
                        switch (op)
                        {
                            case AssignType.EQUAL:
                                ObjectValue = newValue.ValueToString();
                                break;
                            case AssignType.PLUSEQUAL:
                                ObjectValue = ValueToString() + newValue.ValueToString();
                                break;
                            default:
                                Logger.Error(LocaString.Get("UnhandledError") + " : Value.cs #4");
                                break;
                        }
                    else
                        Logger.Error($"You cant assign a int value to a {VariableType} variable.");
                    break;

                #endregion

                #region FLOAT

                case VariableType.FLOAT:
                    if (VariableType == VariableType.FLOAT)
                        switch (op)
                        {
                            case AssignType.EQUAL:
                                ObjectValue = newValue.ValueToFloat();
                                break;
                            case AssignType.PLUSEQUAL:
                                ObjectValue = ValueToFloat() + newValue.ValueToFloat();
                                break;
                            case AssignType.MINUSEQUAL:
                                ObjectValue = ValueToFloat() - newValue.ValueToFloat();
                                break;
                            case AssignType.MULTIPLYEQUAL:
                                ObjectValue = ValueToFloat() * newValue.ValueToFloat();
                                break;
                            case AssignType.DIVIDEEQUAL:
                                ObjectValue = ValueToFloat() / newValue.ValueToFloat();
                                break;
                            case AssignType.PLUSPLUS:
                                ObjectValue = ValueToFloat() + 1;
                                break;
                            case AssignType.MINUSMINUS:
                                ObjectValue = ValueToFloat() + 1;
                                break;
                        }
                    else if (VariableType == VariableType.INT)
                        switch (op)
                        {
                            case AssignType.EQUAL:
                                ObjectValue = newValue.ValueToInt();
                                break;
                            case AssignType.PLUSEQUAL:
                                ObjectValue = ValueToInt() + newValue.ValueToInt();
                                break;
                            case AssignType.MINUSEQUAL:
                                ObjectValue = ValueToInt() - newValue.ValueToInt();
                                break;
                            case AssignType.MULTIPLYEQUAL:
                                ObjectValue = ValueToInt() * newValue.ValueToInt();
                                break;
                            case AssignType.DIVIDEEQUAL:
                                ObjectValue = ValueToInt() / newValue.ValueToInt();
                                break;
                            case AssignType.PLUSPLUS:
                                ObjectValue = ValueToInt() + 1;
                                break;
                            case AssignType.MINUSMINUS:
                                ObjectValue = ValueToInt() + 1;
                                break;
                        }
                    else if (VariableType == VariableType.BOOL && CanBe.Converted(typeof(bool), newValue.ValueToFloat()))
                        switch (op)
                        {
                            case AssignType.EQUAL:
                                ObjectValue = newValue.ValueToBool();
                                break;
                            default:
                                Logger.Error(LocaString.Get("UnhandledError") + " : Value.cs #5");
                                break;
                        }
                    else if (VariableType == VariableType.STRING && CanBe.Converted(typeof(string), newValue.ValueToFloat()))
                        switch (op)
                        {
                            case AssignType.EQUAL:
                                ObjectValue = newValue.ValueToString();
                                break;
                            case AssignType.PLUSEQUAL:
                                ObjectValue = ValueToString() + newValue.ValueToString();
                                break;
                            default:
                                Logger.Error(LocaString.Get("UnhandledError") + " : Value.cs #6");
                                break;
                        }
                    else
                        Logger.Error($"You cant assign a float value to a {VariableType} variable.");
                    break;

                #endregion

                #region BOOL

                case VariableType.BOOL:
                    if (VariableType == VariableType.BOOL)
                        switch (op)
                        {
                            case AssignType.EQUAL:
                                ObjectValue = newValue.ValueToBool();
                                break;
                            default:
                                Logger.Error(LocaString.Get("UnhandledError") + " : Value.cs #7");
                                break;
                        }
                    else if (VariableType == VariableType.FLOAT && CanBe.Converted(typeof(float), newValue.ValueToBool()))
                        switch (op)
                        {
                            case AssignType.EQUAL:
                                ObjectValue = newValue.ValueToFloat();
                                break;
                            default:
                                Logger.Error(LocaString.Get("UnhandledError") + " : Value.cs #8");
                                break;
                        }
                    else if (VariableType == VariableType.INT && CanBe.Converted(typeof(float), newValue.ValueToInt()))
                        switch (op)
                        {
                            case AssignType.EQUAL:
                                ObjectValue = newValue.ValueToInt();
                                break;
                            default:
                                Logger.Error(LocaString.Get("UnhandledError") + " : Value.cs #9");
                                break;
                        }
                    else if (VariableType == VariableType.STRING && CanBe.Converted(typeof(float), newValue.ValueToString()))
                        switch (op)
                        {
                            case AssignType.EQUAL:
                                ObjectValue = newValue.ValueToString();
                                break;
                            default:
                                Logger.Error(LocaString.Get("UnhandledError") + " : Value.cs #10");
                                break;
                        }
                    else
                        Logger.Error($"You cant assign a bool value to a {VariableType} variable.");
                    break;

                #endregion

                #region CUSTOM

                case VariableType.CUSTOM:
                    if (VariableType == VariableType.CUSTOM)
                        switch (op)
                        {
                            case AssignType.EQUAL:
                                if (newValue.CustomType == CustomType)
                                    ObjectValue = newValue.ObjectValue;
                                else
                                    Logger.Error(LocaString.Get("WrongCustomObjectType"));
                                break;
                            default:
                                Logger.Error(LocaString.Get("UnhandledError") + " : Value.cs #11");
                                break;
                        }
                    else
                        Logger.Error($"You cant assign a custom value to a {VariableType} variable.");
                    break;

                    #endregion

            }

            CheckType();
        }
Exemple #13
0
 private record Assign(int Bot, AssignType LowType, int Low, AssignType HighType, int High);
Exemple #14
0
 public ESOAssign(string op, AssignType type) :
     base(op)
 {
     this.type = type;
 }
Exemple #15
0
 public ProFileOption(string optname)
 {
     name = optname;
     astype = AssignType.AT_PlusEquals;
     comment = null;
     shortComment = "Default";
     incComment = false;
     newOpt = " \\\r\n    ";
     list = new List<string>();
 }
Exemple #16
0
 public AssignNode(IdNode id, ExprNode expr, AssignType assop = AssignType.Assign)
 {
     Id    = id;
     Expr  = expr;
     AssOp = assop;
 }
Exemple #17
0
 public static Instruction Create(AssignType type, uint reg0, uint reg1)
 {
     return(Create <AsmLessThan>(0b10, type, reg0, reg1));
 }