Beispiel #1
0
        public void TestParseList()
        {
            var       main = new Interpreter.Sequence();
            ArrayList list;

            for (int i = 0; i < testLists.Length; ++i)
            {
                list = main.ParseList(testLists[i]);

                for (int j = 0; j < list.Count; ++j)
                {
                    Assert.AreEqual(resultLists[i][j], list[j]);
                }
            }
        }
Beispiel #2
0
        public static void CallProcess(Interpreter.Sequence receiver, string line)
        {
            line = line.Trim();

            if (String.IsNullOrEmpty(line))
            {
                throw new FormatException("Not a valid expression.");
            }

            // "FunctionName(arg1, arg2, arg3)"

            string first = MicroRegex.Match.NextOuterGroup(line).Value;

            // first : "FunctionName"
            // secnd : ""

            if (Regex.IsMatch(first, Patterns.getname))
            {
                string secnd = MicroRegex.Match.NextOuterGroup(line.Substring(first.Length)).Value;

                // secnd : "(arg1, arg2, arg3)"

                Match argsCapture = Regex.Match(secnd, Patterns.getargs);

                if (argsCapture.Success)
                {
                    // argsCapture.Value : "arg1, arg2, arg3"

                    receiver.LookUpFunction(first.TrimEnd(), receiver.ParseList(argsCapture.Value.Trim()));
                }
                else
                {
                    throw new Exception("Syntax Error: Not a valid process call.");
                }
            }
        }