public virtual TGraph InstructionsToGraph(GraphBuildInstructionSequence instructions) { TGraph output = new TGraph(); GraphBuildInstructionSpanSet spans = instructions.GetSpans(); foreach (var span in spans) { ExecuteSpan(span, output); } return(output); }
/// <summary> /// Interprets sequence of instructions into syntax code /// </summary> /// <param name="instructions">The instructions.</param> /// <returns></returns> public String Interpret(GraphBuildInstructionSequence instructions) { StringBuilder sb = new StringBuilder(); for (int i = 0; i < instructions.Count; i++) { IRegexFormatMarker definition = (IRegexFormatMarker)SyntaxMarkers.GetDefinition(instructions[i]); if (definition.marker == null) { sb.AppendLine(); } else { sb.Append(definition.Convert(instructions[i].Parameters)); } } return(sb.ToString()); }
/// <summary> /// Interprets the specified code into graph instruction sequence /// </summary> /// <param name="code">The code.</param> /// <returns></returns> public GraphBuildInstructionSequence Interpret(String code) { GraphBuildInstructionSequence output = new GraphBuildInstructionSequence(); List <String> lines = code.SplitSmart(Environment.NewLine); foreach (String line in lines) { regexMarkerResultCollection syntaxInstructions = SyntaxMarkers.process(line); foreach (regexMarkerResult result in syntaxInstructions.GetByOrder()) { GraphBuildInstruction instruction = new GraphBuildInstruction() { InstructionType = result.marker, Parameters = result.GetGroups() }; output.Add(instruction); } output.Add(new GraphBuildInstruction()); } return(output); }
TGraph1 IGraphBuilder.InstructionsToGraph <TGraph1>(GraphBuildInstructionSequence instructions) { return(InstructionsToGraph(instructions) as TGraph1); }