Exemple #1
0
        public virtual TGraph InstructionsToGraph(GraphBuildInstructionSequence instructions)
        {
            TGraph output = new TGraph();
            GraphBuildInstructionSpanSet spans = instructions.GetSpans();

            foreach (var span in spans)
            {
                ExecuteSpan(span, output);
            }

            return(output);
        }
Exemple #2
0
        /// <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());
        }
Exemple #3
0
        /// <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);
        }
Exemple #4
0
 TGraph1 IGraphBuilder.InstructionsToGraph <TGraph1>(GraphBuildInstructionSequence instructions)
 {
     return(InstructionsToGraph(instructions) as TGraph1);
 }