コード例 #1
0
ファイル: XHTMLVisitor.cs プロジェクト: tvdstorm/waebric
        /// <summary>
        /// Interpret MarkupStatement
        /// </summary>
        /// <param name="statement">MarkupStatement to interpret</param>
        public override void Visit(MarkupStatement statement)
        {
            //Determine if markup is a call
            if (IsCall(statement.GetMarkup()))
            {
                String functionIdentifier = statement.GetMarkup().GetDesignator().GetIdentifier();
                if (NodeContainsYield(SymbolTable.GetFunctionDefinition(functionIdentifier)))
                {   //Store null element, because there is nothing to yield in this statement
                    YieldStack.Push(null);
                }
            }

            //Interpret markup
            statement.GetMarkup().AcceptVisitor(this);
        }
コード例 #2
0
        public void ParseMarkupStatementTest()
        {
            //Create parser
            StatementParser statementParser = new StatementParser(Init("p();"));
            Statement       parsedStatement = statementParser.ParseMarkupStatement();

            //Test statatement
            Assert.AreEqual(typeof(MarkupStatement), parsedStatement.GetType());

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

            Assert.AreEqual("p", statement.GetMarkup().GetDesignator().GetIdentifier());
            Assert.AreEqual(0, statement.GetMarkup().GetArguments().Count);
        }
コード例 #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());
                }
            }
        }
コード例 #4
0
ファイル: SyntaxNodeVisitor.cs プロジェクト: tvdstorm/waebric
 public virtual void Visit(MarkupStatement statement)
 {
     VisitSubNodes(statement);
 }