示例#1
0
        /// <summary>
        /// Interpret MarkupEmbed
        /// </summary>
        /// <param name="embed">MarkupEmbed to interpret</param>
        public override void Visit(MarkupEmbed embed)
        {
            int depth = this.Depth;

            //Structure is same as MarkupMarkupStatement, so convert and interpret
            MarkupMarkupStatement markupMarkupStatement = new MarkupMarkupStatement();

            markupMarkupStatement.SetMarkups(embed.GetMarkups());
            markupMarkupStatement.SetMarkup(embed.GetMarkup());
            markupMarkupStatement.AcceptVisitor(this);

            BackToParentXHTMLElement(depth);
        }
示例#2
0
        /// <summary>
        /// Interpret MarkupMarkupStatement
        /// </summary>
        /// <param name="statement">MarkupMarkupStatement to interpret</param>
        public override void Visit(MarkupMarkupStatement 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
                        MarkupMarkupStatement markupMarkupStatement = new MarkupMarkupStatement();
                        markupMarkupStatement.SetMarkups(nonInterpretedMarkups);
                        markupMarkupStatement.SetMarkup(statement.GetMarkup());
                        PushYieldNode(markupMarkupStatement);
                    }
                    //Interpret markup
                    ((Markup)MarkupArray[i]).AcceptVisitor(this);
                    return;
                }
                else
                {   //Interpret Tag
                    ((Markup)MarkupArray[i]).AcceptVisitor(this);
                }
            }

            //Interpret markup
            statement.GetMarkup().AcceptVisitor(this);
        }
示例#3
0
        /// <summary>
        /// Parser for MarkupStatement types
        /// </summary>
        /// <returns>Parsed Statement</returns>
        public Statement ParseMarkupStatement()
        {
            //Start parsing first markup part
            Markup firstMarkup = markupParser.ParseMarkup();

            if (TokenStream.HasNext() && TokenStream.Peek(1).GetType() == TokenType.SYMBOL && TokenStream.Peek(1).GetValue().ToString() == ";")
            {   //Just a single markup statement
                MarkupStatement markupStatement = new MarkupStatement();
                markupStatement.SetMarkup(firstMarkup);

                //Skip ; token
                NextToken(";", "markup;", ';');

                return(markupStatement);
            }
            else
            {
                //Get other markups
                NodeList markups = new NodeList();

                markups.Add(firstMarkup);

                while (DetectNextIsMarkup())
                {
                    markups.Add(markupParser.ParseMarkup());
                }

                //Determine statement type
                if (TokenStream.HasNext())
                {
                    if (TokenStream.Peek(1).GetType() == TokenType.EMBEDDING)
                    {   //Markup Embedding Statement
                        MarkupEmbeddingStatement markupEmbedding = new MarkupEmbeddingStatement();
                        markupEmbedding.SetMarkups(markups);
                        markupEmbedding.SetEmbedding(embeddingParser.ParseEmbedding());

                        //Skip ; token
                        NextToken(";", "Markup+ Embedding;", ';');

                        return(markupEmbedding);
                    }
                    else if (TokenStream.Peek(1).GetValue().ToString() == ";")
                    {   //MarkupStatement
                        MarkupMarkupStatement markupStatement = new MarkupMarkupStatement();

                        //Get last parsed markup from list and remove it from list
                        Markup last = (Markup)markups.Get(markups.Count - 1);
                        markups.Remove(markups.Count - 1);

                        markupStatement.SetMarkup(last);
                        markupStatement.SetMarkups(markups);

                        //Skip ; token
                        NextToken(";", "Markup+ Markup;", ';');

                        return(markupStatement);
                    }
                    else if (IsMarkupStatStatement())
                    {   //MarkupStatStatement
                        MarkupStatStatement markupStatStatement = new MarkupStatStatement();

                        markupStatStatement.SetMarkups(markups);
                        markupStatStatement.SetStatement(ParseStatement());

                        return(markupStatStatement);
                    }
                    else if (IsMarkupExpressionStatement())
                    {   //MarkupExpressionStatement
                        MarkupExpressionStatement markupExpressionStatement = new MarkupExpressionStatement();

                        //Parse MarkupExpressionStatement
                        markupExpressionStatement.SetMarkups(markups);
                        markupExpressionStatement.SetExpression(expressionParser.ParseExpression());

                        //Skip ; token
                        NextToken(";", "Markup+ Expression;", ';');

                        return(markupExpressionStatement);
                    }
                    else
                    {   //Unexpected token
                        throw new UnexpectedToken("Markup Statement expected, but found:", CurrentToken.GetValue().ToString(), CurrentToken.GetLine());
                    }
                }
                else
                {
                    throw new UnexpectedToken("Expected MarkupStatement type, but found:", CurrentToken.GetValue().ToString(), CurrentToken.GetLine());
                }
            }
        }