Ejemplo n.º 1
0
        public override object Visit(TemplateAstNode node)
        {
            var stringbuilder = new StringBuilder();

            // Concatenate the results of the child nodes
            foreach (var childNode in node.Children)
            {
                object fragment = null;

                if (CurrentErrorMode == ErrorMode.ThrowExceptions)
                {
                    fragment = childNode.Accept(this);
                }
                else
                {
                    try
                    {
                        fragment = childNode.Accept(this);
                    }
                    catch (Exception e)
                    {
                        if (CurrentErrorMode == ErrorMode.SubstituteExceptions)
                        {
                            fragment = e.Message;
                        }
                    }
                }

                stringbuilder.Append(fragment);
            }

            return(stringbuilder.ToString());
        }
Ejemplo n.º 2
0
        /// <summary>
        /// template		: (program | STRING_CONST)*
        /// </summary>
        private TemplateAstNode ParseTemplate()
        {
            var templateNode = new TemplateAstNode(CurrentToken);

            while (CurrentToken.Type != TokenType.EOF)
            {
                // When we encounter a '{' token that signifies the start of a program,
                // hand off control for the current node to the program parser
                if (CurrentToken.Type == TokenType.LBRACE)
                {
                    templateNode.AddNode(ParseProgram());
                    continue;
                }

                templateNode.AddNode(new TerminalAstNode <string>(CurrentToken, CurrentToken.Value));
                Next();
            }

            return(templateNode);
        }
Ejemplo n.º 3
0
 public virtual object Visit(TemplateAstNode node)
 {
     return(null);
 }