/// <summary> /// Parse the input and return the root of the AST node structure. /// </summary> /// <param name="reader">inputstream retrieved by a resource loader</param> /// <param name="templateName">name of the template being parsed</param> /// <param name="dumpNamespace">flag to dump the Velocimacro namespace for this template</param> public SimpleNode Parse(TextReader reader, String templateName, bool dumpNamespace) { SimpleNode ast = null; Parser.Parser parser = (Parser.Parser)parserPool.get(); bool madeNew = false; if (parser == null) { // if we couldn't get a parser from the pool // make one and log it. Error( "Runtime : ran out of parsers. Creating new. Please increment the parser.pool.size property. The current value is too small."); parser = CreateNewParser(); if (parser != null) { madeNew = true; } } // now, if we have a parser if (parser == null) { Error("Runtime : ran out of parsers and unable to create more."); } else { try { // dump namespace if we are told to. Generally, you want to // do this - you don't in special circumstances, such as // when a VM is getting init()-ed & parsed if (dumpNamespace) { DumpVMNamespace(templateName); } ast = parser.Parse(reader, templateName); } finally { // if this came from the pool, then put back if (!madeNew) { parserPool.put(parser); } } } return(ast); }