Beispiel #1
0
        public static void compileProgram(String programText, out List <ProgramNodeInterface> nodes)
        {
            nodes = new List <ProgramNodeInterface>();

            errors = "";
            output = "";

            //TODO: Update to "Remaining Program" model
            String textLeft = removeComments(programText);

            //Split into lines
            String[] linesLeft = textLeft.Split(OP_SPLIT, StringSplitOptions.RemoveEmptyEntries);

            while (textLeft.Length >= 1 && linesLeft.Length >= 1)
            {
                try
                {
                    textLeft = textLeft.TrimStart(Environment.NewLine.ToCharArray());

                    linesLeft = textLeft.Split(OP_SPLIT, StringSplitOptions.RemoveEmptyEntries);

                    if (linesLeft[0].Contains(BlockNode.START) && !linesLeft[0].Contains(")"))
                    {
                        BlockNode node;
                        textLeft = parseFirstBlockNode(textLeft, out node);
                        if (node != null)
                        {
                            nodes.Add(node);
                        }
                        linesLeft = textLeft.Split(OP_SPLIT, StringSplitOptions.RemoveEmptyEntries);
                    }
                    else
                    {
                        //TODO move this code into a method
                        String line = linesLeft[0].Trim();
                        String op   = getOpName(line);

                        ProgramNode node = getOpByName(op, allNodes);

                        if (node == null)
                        {
                            errors  += "Failed to find OP: " + op;
                            textLeft = nextLine(textLeft, out linesLeft);
                            continue;
                        }

                        //Load the arguments of the method, comma seperated (arg1,arg2)
                        node.parseArgs(
                            splitArgString(getArgString(line))
                            );
                        nodes.Add(node);

                        textLeft = nextLine(textLeft, out linesLeft);
                    }
                } catch (Exception e)
                {
                    addError(e.Message);
                    addError(e.StackTrace);
                    addError(textLeft);
                    break;
                }
            }
        }
Beispiel #2
0
 public override string calculate(string input)
 {
     LogProcessor.filesToProcess = ProgramNode.splitTextToLines(input);
     //LogProcessor.subQueue = LogProcessor.nodes.Skip(0).ToList();
     return(LogProcessor.processNextFile(false, true));
 }
Beispiel #3
0
 public static void addAllNode(ProgramNode node)
 {
     allNodes.Add(node.getOpName(), node);
     allProgramNodeInterfaces.Add(node);
 }