Exemple #1
0
        public static string parseFirstBlockNode(string program, out BlockNode node)
        {
            int    firstBlockStart = int.MaxValue;
            int    firstBlockEnd   = int.MaxValue;
            String firstBlock      = "";
            //Get the next block op name
            String opName = program.Trim().Split(BLOCK_NAME_SPLIT, StringSplitOptions.RemoveEmptyEntries)[0].Trim();

            if (allBlockNodes.ContainsKey(opName))
            {
                BlockNode foundNode = allBlockNodes[opName];

                int    startLocation, endLocation;
                String block =
                    BlockNode.getFullStartAndEndLocations
                        (program, foundNode.getOpName(), out startLocation, out endLocation);
                if (firstBlockStart > startLocation)
                {
                    firstBlockStart = startLocation;
                    firstBlockEnd   = endLocation;
                    firstBlock      = block;
                }
                //store the program in the list
                node = loadBlockProgram(firstBlock);
            }
            else
            {
                node = null;
                addError("Could not find block node with Op Name: " + opName);
            }

            String strippedProgram = program.Substring(firstBlockEnd);

            return(strippedProgram);
        }