Esempio n. 1
0
        private void ParsePreProcessorMacro(string PreP)
        {
            string PrePNameAndArgs = PreP.Substring(1, PreP.Length - 2);

            string[] words = PrePNameAndArgs.Split(' ');

            string ArgString = "";

            for (int i = 1; i < words.Length; ++i)
            {
                ArgString += words[i];
            }

            string[] Args = ArgString.Split(',');

            List <decimal> Operands = new List <decimal>();

            if (PreProcessors.TryGetValue(words[0], out PreP PP))
            {
                if (Args.Length != PP.Types.Length)
                {
                    throw new ArgumentException($"The Pre-Processor \"{words[0]}\" requires {PP.Types.Length} arguments.");
                }

                for (int i = 0; i < Args.Length; ++i)
                {
                    Operands.Add(Parser.ParseOperand(Args[i], PP.Types[i]));
                }

                PP.Method(Operands.ToArray());
            }
            else
            {
                throw new ArgumentException($"\"{words[0]}\" is not a valid Pre-Processor.");
            }
        }