コード例 #1
0
        private FunctionCallContext(List <string> content,
                                    System.Drawing.Point startPoint, System.Drawing.Point endPoint)
        {
            lineOffsetIntoContent = startPoint.Y;

            StringBuilder contentBuilder = new StringBuilder();

            for (int index = startPoint.Y; index <= endPoint.Y; ++index)
            {
                string line = content[index];
                if (index == startPoint.Y)
                {
                    // We're looking at the first line to copy, replace
                    // everything before the start point with blank space.
                    if (startPoint.X > 0)
                    {
                        contentBuilder.Append(new string(' ', startPoint.X));
                    }

                    contentBuilder.Append(line.Substring(startPoint.X));
                    continue;
                }

                // We have come into region of another statement
                if (line.IndexOf('=') != -1)
                {
                    break; // Get outta here!
                }
                contentBuilder.Append(line);
            }

            string intermediate = contentBuilder.ToString();

            intermediate = PatchContent(intermediate);

            MemoryStream inputStream = new MemoryStream(
                Encoding.Default.GetBytes(intermediate));

            FunctionCallParser.Scanner scanner = new FunctionCallParser.Scanner(inputStream);
            FunctionCallParser.Parser  parser  = new FunctionCallParser.Parser(scanner);
            parser.Parse();
            topMostFunctionPart = parser.RootFunctionCallPart;
        }
コード例 #2
0
        private FunctionCallContext(List<string> content,
            System.Drawing.Point startPoint, System.Drawing.Point endPoint)
        {
            lineOffsetIntoContent = startPoint.Y;

            StringBuilder contentBuilder = new StringBuilder();
            for (int index = startPoint.Y; index <= endPoint.Y; ++index)
            {
                string line = content[index];
                if (index == startPoint.Y)
                {
                    // We're looking at the first line to copy, replace
                    // everything before the start point with blank space.
                    if (startPoint.X > 0)
                        contentBuilder.Append(new string(' ', startPoint.X));

                    contentBuilder.Append(line.Substring(startPoint.X));
                    continue;
                }

                // We have come into region of another statement
                if (line.IndexOf('=') != -1)
                    break; // Get outta here!

                contentBuilder.Append(line);
            }

            string intermediate = contentBuilder.ToString();
            intermediate = PatchContent(intermediate);

            MemoryStream inputStream = new MemoryStream(
                Encoding.Default.GetBytes(intermediate));

            FunctionCallParser.Scanner scanner = new FunctionCallParser.Scanner(inputStream);
            FunctionCallParser.Parser parser = new FunctionCallParser.Parser(scanner);
            parser.Parse();
            topMostFunctionPart = parser.RootFunctionCallPart;
        }