コード例 #1
0
        private int FillDoWhile(int index, WrapperObject doObject)
        {
            WrapperObject doContentObject = new WrapperObject("DO_CONTENT");

            index = RulesUtility.ValidateToken(this.TokenList[index], "{", "This needs is a valid \'{\'.", index);
            index = this.FillFunctionContent(index, doContentObject);
            index = RulesUtility.ValidateToken(this.TokenList[index], "}", "This needs is a valid \'}\'.", index);

            WrapperString whileCond = new WrapperString("WHILE_COND", string.Empty);

            index = RulesUtility.ValidateToken(this.TokenList[index], "while", "This needs is a valid \'while\'.", index);
            while (this.TokenList[index] != ")")
            {
                string lookAhead = this.TokenList[index + 1];
                whileCond.Value += this.TokenList[index];
                if (lookAhead != "." && lookAhead != "(" && lookAhead != ")" && lookAhead != "\'" && lookAhead != ";" &&
                    this.TokenList[index] != "." && this.TokenList[index] != "(" && this.TokenList[index] != ")" &&
                    this.TokenList[index] != "\"" && this.TokenList[index] != "\'")
                {
                    whileCond.Value += " ";
                }
                index++;
            }

            index            = RulesUtility.ValidateToken(this.TokenList[index], ")", "This needs is a valid \')\'.", index);
            whileCond.Value += ")";

            index            = RulesUtility.ValidateToken(this.TokenList[index], ";", "This needs is a valid \';\'.", index);
            whileCond.Value += ";";

            doObject.Value.Add(doContentObject);
            doObject.Value.Add(whileCond);
            return(index);
        }
コード例 #2
0
        private int BuildEnumContent(int index, WrapperObject enumObject)
        {
            int           times       = 0;
            WrapperObject enumContent = new WrapperObject("ENUM_CONTENT");

            while (this.TokenList[index] != "}")
            {
                WrapperString enumEntry = new WrapperString($"ENUM_VALUE_{times++}", string.Empty);

                while (this.TokenList[index] != "}" && this.TokenList[index] != ",")
                {
                    enumEntry.Value += this.TokenList[index++];
                }

                enumContent.Value.Add(enumEntry);

                if (this.TokenList[index] != "}")
                {
                    index = RulesUtility.ValidateToken(this.TokenList[index], ",", $"{enumObject.WrapperName} enum object needs a valid divider.", index);
                }
            }

            enumObject.Value.Add(enumContent);

            return(index);
        }
コード例 #3
0
 static void Main()
 {
     WrapperInt gi = new WrapperInt(1234);
     gi.OutValue();
     WrapperString gs = new WrapperString("문자열");
     gs.OutValue();
 }
コード例 #4
0
        private int ParseValue(int index, string valueName, WrapperObject parentNode)
        {
            WrapperType actualValue;

            if (this.TokenList[index].Contains("."))
            {
                var proposedDouble = this.TokenList[index].Split(".");
                if (int.TryParse(proposedDouble[0], out _) && int.TryParse(proposedDouble[1], out _))
                {
                    actualValue = new WrapperDouble(valueName, double.Parse(this.TokenList[index++]));
                }
                else
                {
                    actualValue = new WrapperString(valueName, this.TokenList[index++]);
                }
            }
            else if (int.TryParse(this.TokenList[index], out _))
            {
                actualValue = new WrapperInt(valueName, int.Parse(this.TokenList[index++]));
            }
            else if (this.TokenList[index].ToLower() == "true" || this.TokenList[index].ToLower() == "false")
            {
                bool boolVal = bool.Parse(this.TokenList[index++]);
                actualValue = new WrapperBool(valueName, boolVal);
            }
            else if (this.TokenList[index] == "<")
            {
                if (valueName.ToLower().Contains("array"))
                {
                    actualValue = new WrapperArray(valueName, null);
                    index       = ParseArray(index, actualValue as WrapperArray);
                }
                else
                {
                    actualValue = new WrapperObject(valueName, null);
                    index       = ParseObject(index, actualValue as WrapperObject);
                }
            }
            else
            {
                actualValue = new WrapperString(valueName, this.TokenList[index++]);
            }

            index = RulesUtility.ValidateToken(this.TokenList[index], "<", "Invalid Token. Need \'<\' for name of value", index);
            if (valueName.ToLower().Contains("array"))
            {
                index = RulesUtility.ValidateToken(this.TokenList[index], $"/{valueName.ToLower()}", $"Invalid Token. Need closing name {valueName} for name of value", index);
            }
            else
            {
                index = RulesUtility.ValidateToken(this.TokenList[index], $"/{valueName}", $"Invalid Token. Need closing name {valueName} for name of value", index);
            }
            index = RulesUtility.ValidateToken(this.TokenList[index], ">", "Invalid Token. Need \'>\' for name of value", index);

            parentNode.Value.Add(actualValue);
            return(index);
        }
コード例 #5
0
        private int BuildAutoProperty(int index, WrapperObject contentObject, WrapperObject parentObject)
        {
            index = RulesUtility.ValidateToken(this.TokenList[index], "{", "This needs is a valid \'{\'.", index);
            WrapperObject setObject = new WrapperObject("SET");
            WrapperObject getObject = new WrapperObject("GET");

            contentObject.CopyData(getObject);
            contentObject.CopyData(setObject);

            string compVariableName = "_" + char.ToLower(contentObject.WrapperName[0]).ToString() + contentObject.WrapperName.Substring(1);
            string holdOlderName    = contentObject.WrapperName;

            if (!parentObject.GetKeys().Contains(compVariableName))
            {
                contentObject.WrapperName = compVariableName;
                contentObject.UpdateStringValue("ACCESS_MOD", "private");
                parentObject.Value.Add(contentObject);
            }

            WrapperString valueType  = setObject.GetValue("VALUE_TYPE") as WrapperString;
            WrapperObject parameters = new WrapperObject("PARAMETERS");
            WrapperObject parameter  = new WrapperObject($"PARAMETER_1");

            parameter.Value.Add(new WrapperString("VALUE_TYPE", valueType.Value));
            parameter.Value.Add(new WrapperString("PARAM_NAME", "value"));
            setObject.UpdateStringValue("VALUE_TYPE", "void");
            parameters.Value.Add(parameter);
            setObject.Value.Add(parameters);

            if (this.TokenList[index] == "get")
            {
                index = this.BuildAuxMethod(index, getObject, compVariableName);
                index = this.BuildAuxMethod(index, setObject, compVariableName);
            }
            else if (this.TokenList[index] == "set")
            {
                index = this.BuildAuxMethod(index, setObject, compVariableName);
                index = this.BuildAuxMethod(index, getObject, compVariableName);
            }
            else
            {
                throw new Exception("This auto property needs an explicet get and set keywords.");
            }

            index = RulesUtility.ValidateToken(this.TokenList[index], "}", "This needs is a valid \'}\'.", index);
            getObject.WrapperName = $"Get{holdOlderName}";
            setObject.WrapperName = $"Set{holdOlderName}";
            parentObject.Value.Add(getObject);
            parentObject.Value.Add(setObject);
            this._autoPropertyList.Add(holdOlderName);
            this._autoPropertyList.Add($"this.{holdOlderName}");

            return(index);
        }
コード例 #6
0
        private int ParseValue(int index, string valueName, WrapperObject parentNode)
        {
            WrapperType actualValue = null;

            if (this.TokenList[index].Contains("\""))
            {
                index = RulesUtility.ValidateToken(this.TokenList[index], "\"", "Invalid Token. Need first double quote for string value", index);

                actualValue = new WrapperString(valueName, this.TokenList[index++]);

                index = RulesUtility.ValidateToken(this.TokenList[index], "\"", "Invalid Token. Need first double quote for string value", index);
            }
            else if (this.TokenList[index].Contains("."))
            {
                var proposedDouble = this.TokenList[index].Split(".");
                if (int.TryParse(proposedDouble[0], out _) && int.TryParse(proposedDouble[1], out _))
                {
                    actualValue = new WrapperDouble(valueName, double.Parse(this.TokenList[index++]));
                }
                else
                {
                    throw new Exception("This is an invlid Double Value");
                }
            }
            else if (int.TryParse(this.TokenList[index], out _))
            {
                actualValue = new WrapperInt(valueName, int.Parse(this.TokenList[index++]));
            }
            else if (this.TokenList[index] == "true" || this.TokenList[index] == "false")
            {
                bool boolVal = bool.Parse(this.TokenList[index++]);
                actualValue = new WrapperBool(valueName, boolVal);
            }
            else if (this.TokenList[index] == "{")
            {
                index++;
                actualValue = new WrapperObject(valueName, null);
                index       = ParseObject(index, actualValue as WrapperObject);
                index++;
            }
            else if (this.TokenList[index] == "[")
            {
                index++;
                actualValue = new WrapperArray(valueName, null);
                index       = ParseArray(index, actualValue as WrapperArray);
                index++;
            }

            parentNode.Value.Add(actualValue);
            return(index);
        }