Exemple #1
0
        /// <summary>
        /// Interpret PostTextTail
        /// </summary>
        /// <param name="textTail">PostTextTail to interpret</param>
        public override void Visit(PostTextTail textTail)
        {
            XHTMLElement element = new XHTMLElement(textTail.GetPostText().GetText(), Current);

            element.SetTagState(false);
            AddElement(element);
        }
Exemple #2
0
        /// <summary>
        /// Interpret CommentStatement
        /// </summary>
        /// <param name="statement">CommentStatement to interpret</param>
        public override void Visit(CommentStatement statement)
        {
            XHTMLElement comment = new XHTMLElement("comment", Current);

            comment.SetTagState(false);
            comment.AddContent(statement.GetCommentString());
            AddElement(comment);
        }
Exemple #3
0
        /// <summary>
        /// Interpret CdataStatement
        /// </summary>
        /// <param name="statement">CdataStatement to interpret</param>
        public override void Visit(CdataStatement statement)
        {
            statement.GetExpression().AcceptVisitor(this);
            XHTMLElement cdata = new XHTMLElement("cdata", Current);

            cdata.SetTagState(false);
            cdata.AddContent(TextValue);
            AddElement(cdata);
        }
Exemple #4
0
        /// <summary>
        /// Interpret MidTextTail
        /// </summary>
        /// <param name="textTail">MidTextTail to Interpret</param>
        public override void Visit(MidTextTail textTail)
        {
            XHTMLElement element = new XHTMLElement(textTail.GetMidText().GetText(), Current);

            element.SetTagState(false);
            AddElement(element);

            textTail.GetEmbed().AcceptVisitor(this);
            textTail.GetTextTail().AcceptVisitor(this);
        }
Exemple #5
0
        /// <summary>
        /// Interpret EchoExpressionStatement
        /// </summary>
        /// <param name="statement">EchoExpressionStatement to interpret</param>
        public override void Visit(EchoExpressionStatement statement)
        {
            statement.GetExpression().AcceptVisitor(this);

            //Add just an tag to current as parent
            XHTMLElement echoElement = new XHTMLElement(TextValue, Current);

            echoElement.SetTagState(false);

            AddElement(echoElement);
        }
Exemple #6
0
        /// <summary>
        /// Interpret Embedding
        /// </summary>
        /// <param name="embedding">Embedding to interpret</param>
        public override void Visit(Embedding embedding)
        {
            //Add content of pretext
            XHTMLElement element = new XHTMLElement(embedding.GetPreText().GetText(), Current);

            element.SetTagState(false);
            AddElement(element);

            //Interpret Embed and TextTail
            embedding.GetEmbed().AcceptVisitor(this);
            embedding.GetTextTail().AcceptVisitor(this);
        }
Exemple #7
0
        /// <summary>
        /// Interpret MarkupExpressionStatement
        /// </summary>
        /// <param name="statement">MarkupExpressionStatement to interpret</param>
        public override void Visit(MarkupExpressionStatement statement)
        {
            //Iterate through Markup+
            ISyntaxNode[] MarkupArray = statement.GetMarkups().ToArray();
            for (int i = 0; i <= (MarkupArray.Length - 1); i++)
            {
                if (IsMarkupCall((Markup)MarkupArray[i]))
                {
                    //Check if called function contains an yield, if so, add remaining markups/expression to yield stack
                    String functionIdentifier = ((Markup)MarkupArray[i]).GetDesignator().GetIdentifier();
                    if (NodeContainsYield(SymbolTable.GetFunctionDefinition(functionIdentifier)))
                    {
                        //Get remaining markups
                        NodeList nonInterpretedMarkups = new NodeList();
                        for (int j = i + 1; j <= (MarkupArray.Length - 1); j++)
                        {
                            nonInterpretedMarkups.Add(MarkupArray[j]);
                        }
                        //Create new MarkupExpressionStatement and push it to stack
                        MarkupExpressionStatement markupExpressionStatement = new MarkupExpressionStatement();
                        markupExpressionStatement.SetMarkups(nonInterpretedMarkups);
                        markupExpressionStatement.SetExpression(statement.GetExpression());
                        PushYieldNode(markupExpressionStatement);
                    }
                    //Interpret markup
                    ((Markup)MarkupArray[i]).AcceptVisitor(this);
                    return;
                }
                else
                {   //Interpret Tag
                    ((Markup)MarkupArray[i]).AcceptVisitor(this);
                }
            }

            //Interpret expression
            statement.GetExpression().AcceptVisitor(this);

            XHTMLElement element = new XHTMLElement(TextValue, Current);

            element.SetTagState(false);
            AddElement(element);
        }
Exemple #8
0
        /// <summary>
        /// Interpret YieldStatement
        /// </summary>
        /// <param name="statement">YieldStatement to interpret</param>
        public override void Visit(YieldStatement statement)
        {
            if (YieldStack.Count == 0)
            {
                return;
            }

            //Pop from YieldStack and lets interpet it
            YieldElement yieldElement = YieldStack.Pop();

            if (yieldElement != null && yieldElement.GetRootElement() != null)
            {
                //Let's copy yieldstack, because there are possible yields in the yield.
                Stack <YieldElement> tempYieldStack = new Stack <YieldElement>();
                List <YieldElement>  yieldList      = YieldStack.ToList();
                foreach (YieldElement yieldNode in yieldList)
                {
                    tempYieldStack.Push(yieldNode);
                }

                //Lets interpret it with specific symboltable
                SymbolTable temp = (SymbolTable)SymbolTable.Clone();
                SymbolTable = yieldElement.GetSymbolTable();

                yieldElement.GetRootElement().AcceptVisitor(this);

                //Add some content when node is an expression or embedding
                if (yieldElement.GetRootElement() is Expression || yieldElement.GetRootElement() is Embedding)
                {
                    XHTMLElement element = new XHTMLElement(TextValue, Current);
                    element.SetTagState(false);
                    AddElement(element);
                }

                //Restore symboltable
                SymbolTable = temp;

                //Restore YieldStack in original shape before interpreting
                YieldStack = tempYieldStack;
            }
        }