Example #1
0
        private static FiMHelper.ArrayIndex GetArrayIndex(string content)
        {
            // Explicit index
            if (Regex.IsMatch(content, @"^(.+) of (.+)$"))
            {
                var match = Regex.Match(content, @"^(.+) (of) (.+)$");

                if (!FiMHelper.IsIndexInsideString(content, match.Groups[2].Index))
                {
                    string strIndex = match.Groups[1].Value;
                    string strVar   = match.Groups[3].Value;

                    // (somewhat) stricter check
                    if (KirinValue.ValidateName(strVar))
                    {
                        return(new FiMHelper.ArrayIndex()
                        {
                            RawIndex = strIndex,
                            RawVariable = strVar
                        });
                    }
                }
            }

            // Implicit index
            if (Regex.IsMatch(content, @"^(.+) (\d+)$"))
            {
                var    match    = Regex.Match(content, @"^(.+) (\d+)$");
                string varName  = match.Groups[1].Value;
                string varIndex = match.Groups[2].Value;

                // (somewhat) stricter check
                if (KirinValue.ValidateName(varName))
                {
                    return(new FiMHelper.ArrayIndex()
                    {
                        RawIndex = varIndex,
                        RawVariable = varName,
                    });
                }
            }

            return(null);
        }
Example #2
0
		public FiMVariable(string name, KirinValue value)
		{
			if (!KirinValue.ValidateName(name)) throw new Exception("Invalid variable name " + name);
			this.Name = name;
			this.KValue = value;
		}