Exemplo n.º 1
0
        public void ParseMarkupMarkupStatementTest()
        {
            //Create parser
            StatementParser statementParser = new StatementParser(Init("tr td img(src=\"test.png\", width=300);"));
            Statement       parsedStatement = statementParser.ParseMarkupStatement();

            //Test statement
            Assert.AreEqual(typeof(MarkupMarkupStatement), parsedStatement.GetType());

            //Test MarkupMarkupStatement
            MarkupMarkupStatement statement = (MarkupMarkupStatement)parsedStatement;

            List <ISyntaxNode> .Enumerator markupEnumerator = statement.GetMarkups().GetEnumerator();

            //Test TR
            markupEnumerator.MoveNext();
            Assert.AreEqual("tr", ((Markup)markupEnumerator.Current).ToString());

            //Test TD
            markupEnumerator.MoveNext();
            Assert.AreEqual("td", ((Markup)markupEnumerator.Current).ToString());

            //Test IMG
            Assert.AreEqual("img(src=\"test.png\",width=300)", statement.GetMarkup().ToString());
        }
Exemplo n.º 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);
        }