Esempio n. 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);
        }
Esempio n. 2
0
        /// <summary>
        /// Parser for Embed
        /// </summary>
        /// <returns>Parsed Embed</returns>
        public Embed ParseEmbed()
        {
            Embed    embed      = null;
            NodeList markupList = new NodeList();

            //Set up MarkupParser
            markupParser = new MarkupParser(EmbeddingTokenStream);

            //Parse Markup*
            //EmbeddingTokenStream.HasNext(2) && !(EmbeddingTokenStream.Peek(2).GetValue().ToString() == ">"
            while (NextTokenIsMarkup())
            {
                markupList.Add(markupParser.ParseMarkup());
            }

            //Check if an expression is remaining, otherwise embed is MarkupEmbedding
            if (IsExpressionRemaining())
            {   //ExpressionEmbedding
                ExpressionEmbed expressionEmbed = new ExpressionEmbed();

                //Add already parsed markups to expressionEmbed
                expressionEmbed.SetMarkups(markupList);

                //Set up expressionparser
                expressionParser = new ExpressionParser(EmbeddingTokenStream);

                //Parse expression
                expressionEmbed.SetExpression(expressionParser.ParseExpression());

                embed = expressionEmbed;
            }
            else
            {   //MarkupEmbedding
                //Get last item from markupList and add it as Markup
                if (markupList.Count != 0)
                {
                    Markup markup = (Markup)markupList.Get(markupList.Count - 1);
                    markupList.Remove(markupList.Count - 1);

                    MarkupEmbed markupEmbed = new MarkupEmbed();
                    markupEmbed.SetMarkups(markupList);
                    markupEmbed.SetMarkup(markup);

                    embed = markupEmbed;
                }
                else
                {   //Markup* Markup must contain at least one markup element
                    throw new UnexpectedToken("Markup expected, but found:", CurrentToken.GetValue().ToString(), CurrentToken.GetLine());
                }
            }

            /*//Determine if remaining embed is Markup or Expression
             * if (NextTokenIsMarkup())
             * {   //MarkupEmbedding
             *  MarkupEmbed markupEmbed = new MarkupEmbed();
             *
             *  //Add already parsed markups to markupEmbed
             *  markupEmbed.SetMarkups(markupList);
             *
             *  //Parse latest markup
             *  markupEmbed.SetMarkup(markupParser.ParseMarkup());
             *
             *  embed = markupEmbed;
             * }
             * else
             * {   //ExpressionEmbedding
             *  ExpressionEmbed expressionEmbed = new ExpressionEmbed();
             *
             *  //Add already parsed markups to expressionEmbed
             *  expressionEmbed.SetMarkups(markupList);
             *
             *  //Set up expressionparser
             *  expressionParser = new ExpressionParser(EmbeddingTokenStream);
             *
             *  //Parse expression
             *  expressionEmbed.SetExpression(expressionParser.ParseExpression());
             *
             *  embed = expressionEmbed;
             * }           */

            return(embed);
        }
Esempio n. 3
0
 public virtual void Visit(MarkupEmbed embed)
 {
     VisitSubNodes(embed);
 }
Esempio n. 4
0
 public virtual void Visit(MarkupEmbed embed)
 {
     VisitSubNodes(embed);
 }
Esempio n. 5
0
        /// <summary>
        /// Parser for Embed
        /// </summary>
        /// <returns>Parsed Embed</returns>
        public Embed ParseEmbed()
        {
            Embed embed = null;
            NodeList markupList = new NodeList();

            //Set up MarkupParser
            markupParser = new MarkupParser(EmbeddingTokenStream);

            //Parse Markup*
            //EmbeddingTokenStream.HasNext(2) && !(EmbeddingTokenStream.Peek(2).GetValue().ToString() == ">"
            while(NextTokenIsMarkup())
            {
                markupList.Add(markupParser.ParseMarkup());
            }

            //Check if an expression is remaining, otherwise embed is MarkupEmbedding
            if (IsExpressionRemaining())
            {   //ExpressionEmbedding
                ExpressionEmbed expressionEmbed = new ExpressionEmbed();

                //Add already parsed markups to expressionEmbed
                expressionEmbed.SetMarkups(markupList);

                //Set up expressionparser
                expressionParser = new ExpressionParser(EmbeddingTokenStream);

                //Parse expression
                expressionEmbed.SetExpression(expressionParser.ParseExpression());

                embed = expressionEmbed;
            }
            else
            {   //MarkupEmbedding
                //Get last item from markupList and add it as Markup
                if (markupList.Count != 0)
                {
                    Markup markup = (Markup)markupList.Get(markupList.Count - 1);
                    markupList.Remove(markupList.Count - 1);

                    MarkupEmbed markupEmbed = new MarkupEmbed();
                    markupEmbed.SetMarkups(markupList);
                    markupEmbed.SetMarkup(markup);

                    embed = markupEmbed;
                }
                else
                {   //Markup* Markup must contain at least one markup element
                    throw new UnexpectedToken("Markup expected, but found:", CurrentToken.GetValue().ToString(), CurrentToken.GetLine());
                }
            }

            /*//Determine if remaining embed is Markup or Expression
            if (NextTokenIsMarkup())
            {   //MarkupEmbedding
                MarkupEmbed markupEmbed = new MarkupEmbed();

                //Add already parsed markups to markupEmbed
                markupEmbed.SetMarkups(markupList);

                //Parse latest markup
                markupEmbed.SetMarkup(markupParser.ParseMarkup());

                embed = markupEmbed;
            }
            else
            {   //ExpressionEmbedding
                ExpressionEmbed expressionEmbed = new ExpressionEmbed();

                //Add already parsed markups to expressionEmbed
                expressionEmbed.SetMarkups(markupList);

                //Set up expressionparser
                expressionParser = new ExpressionParser(EmbeddingTokenStream);

                //Parse expression
                expressionEmbed.SetExpression(expressionParser.ParseExpression());

                embed = expressionEmbed;
            }           */

            return embed;
        }