Ejemplo n.º 1
0
 public override void EvaluateInternal(PonyTextContext textContext)
 {
     foreach (var item in structs)
     {
         item.Evaluate(textContext);
     }
 }
Ejemplo n.º 2
0
 public override void EvaluateInternal(PonyTextContext textContext)
 {
     foreach (var directive in textDirectives)
     {
         textContext.WriteTextElement(TextElementFactory.CreateTextElement(TextElementType.Paragraph));
         directive.Evaluate(textContext);
     }
 }
Ejemplo n.º 3
0
 public void Evaluate(PonyTextContext textContext)
 {
     try {
         EvaluateInternal(textContext);
     }
     catch (PreProcessorException e) {
         e.AddToStackTrace(PreProcessTrace.CreateTraceTokenLevel(AssociatedToken));
         throw e;
     }
 }
Ejemplo n.º 4
0
        public static PonyTextStructureBase CreateEvaluable(string ponyTextPath, PonyTextContext ctx)
        {
            string fileLocation = ctx.Metadata.GetAbsolutePath(ponyTextPath);

            if (!File.Exists(fileLocation))
            {
                throw new ArgumentException($"Unable to process PonyText source file locate at \"{fileLocation}\". Not such file.");
            }

            return(CreateEvaluable(File.ReadAllText(fileLocation, Encoding.UTF8), fileLocation, ctx));
        }
Ejemplo n.º 5
0
        public override void EvaluateInternal(PonyTextContext textContext)
        {
            var             textElement = TextElementFactory.CreateTextElement(TextElementType.Paragraph);
            PonyTextContext ctx         = new DerivedTextContext(textContext, textElement);

            foreach (var item in structureBases)
            {
                item.Evaluate(ctx);
            }
            textContext.WriteTextElement(textElement);
        }
Ejemplo n.º 6
0
        public override void Render(AbstractRendererBase rendererBase, PonyTextContext textContext)
        {
            AbstractProcessor abstractProcessor = null;

            if (CustomProperty.HasProperty(AbstractProcessor.RENDER_PROCESSOR_PROPERTY))
            {
                var processor = CustomProperty.GetProperty(AbstractProcessor.RENDER_PROCESSOR_PROPERTY) as string;
                abstractProcessor = textContext.ProcessorFactory.GetRenderProcessor(processor);
                abstractProcessor.PreRendering(textContext, rendererBase, this);
            }
            rendererBase.RenderText(Content, CustomProperty);
            abstractProcessor?.PostRendering(textContext, rendererBase, this);
        }
Ejemplo n.º 7
0
 public PonyTextStructureBase[] ToParameter(PonyTextContext ctx)
 {
     PonyTextStructureBase[] arr = new PonyTextStructureBase[arguments.Count];
     for (int i = 0; i < arguments.Count; i++)
     {
         PonyTextStructureBase structBase = arguments[i];
         if (structBase.StructureType == StructureType.MarcoStruct)
         {
             arr[i] = ctx.MacroTable.GetMarco(((PonyTextMarcoStruct)structBase).MarcoName);
         }
         else
         {
             arr[i] = structBase;
         }
     }
     return(arr);
 }
Ejemplo n.º 8
0
        public override void Render(AbstractRendererBase rendererBase, PonyTextContext textContext)
        {
            rendererBase.StartParagraphRendering(CustomProperty);
            AbstractProcessor abstractProcessor = null;

            if (CustomProperty.HasProperty(AbstractProcessor.RENDER_PROCESSOR_PROPERTY))
            {
                var processor = CustomProperty.GetProperty(AbstractProcessor.RENDER_PROCESSOR_PROPERTY) as string;
                abstractProcessor = textContext.ProcessorFactory.GetRenderProcessor(processor);
                abstractProcessor.PreRendering(textContext, rendererBase, this);
            }
            foreach (var text in texts)
            {
                text.Render(rendererBase, textContext);
            }
            abstractProcessor?.PostRendering(textContext, rendererBase, this);
            rendererBase.EndParagraphRendering();
        }
Ejemplo n.º 9
0
 public override void EvaluateInternal(PonyTextContext textContext)
 {
     if (!textContext.MacroTable.ContainsMarco(name))
     {
         var processor = textContext.ProcessorFactory.GetPreProcessor(name);
         processor.Preporcess(textContext, ToParameter(textContext));
     }
     else
     {
         var structureBase             = textContext.MacroTable.GetMarco(name);
         PonyTextStructureBase[] param = ToParameter(textContext);
         for (var i = 0; i < arguments.Count; i++)
         {
             textContext.MacroTable.PutMarco($"_{i + 1}", param[i]);
         }
         structureBase.Evaluate(textContext);
     }
 }
Ejemplo n.º 10
0
 public void Preporcess(PonyTextContext context, PonyTextStructureBase[] args)
 {
     ctx = context;
     try {
         ProcessorParam?.ValidateParameter(args);
         OnPreProcessInternal(args);
     }
     catch (Exception e) {
         if (e is PreProcessorException)
         {
             PreProcessorException ppe = (PreProcessorException)e;
             ppe.AddToStackTrace(PreProcessTrace.CreateTrace(ProcessorAttribute.ProcessorName));
             throw ppe;
         }
         else
         {
             throw new PreProcessorException(ProcessorAttribute.ProcessorName, e.Message);
         }
     }
 }
Ejemplo n.º 11
0
 public override void Render(AbstractRendererBase rendererBase, PonyTextContext textContext)
 {
     rendererBase.RenderDirectives(directives, CustomProperty);
 }
Ejemplo n.º 12
0
 public abstract void Render(AbstractRendererBase rendererBase, PonyTextContext textContext);
Ejemplo n.º 13
0
 public abstract void EvaluateInternal(PonyTextContext textContext);
Ejemplo n.º 14
0
        public static PonyTextStructureBase CreateEvaluable(string ponyTextContent, string ponyTextIdentifier, PonyTextContext ctx)
        {
            ctx.Metadata.DependencyList.AddDependency(ponyTextIdentifier);

            PonyLexer  ponyLexer = new PonyLexer();
            PonyParser parser    = new PonyParser(ponyLexer);

            parser.errorListener    = GlobalConfiguration.Instance.ParserErrorListener;
            ponyLexer.errorListener = parser.errorListener;

            return(parser.Parse(ponyTextContent));
        }
Ejemplo n.º 15
0
 public void PostRendering(PonyTextContext context, AbstractRendererBase rendererBase, AbstractTextElement textElement)
 {
     ctx = context;
     OnPostRenderInternal(textElement, rendererBase);
 }
Ejemplo n.º 16
0
 public override void EvaluateInternal(PonyTextContext textContext)
 {
 }
Ejemplo n.º 17
0
 public override void EvaluateInternal(PonyTextContext textContext)
 {
     textContext.WriteTextElement(TextElementFactory.CreateTextElement(TextElementType.TextUnit, num.ToString()));
 }
Ejemplo n.º 18
0
 public override void EvaluateInternal(PonyTextContext textContext)
 {
     textContext.MacroTable.GetMarco(MarcoName).Evaluate(textContext);
 }