[ https://issues.apache.org/jira/browse/VELOCITY-537?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12609417#action_12609417 ]
Nathan Bubna commented on VELOCITY-537: --------------------------------------- To aid others in investigation of this (e.g. Will), i've checked in the unit tests for VELOCITY-580 and VELOCITY-537. Also, here is the relevant stack from the TokenMgrError that is at the heart of VELOCITY-537 (and is wrapped by the ParseException shown in the original description): org.apache.velocity.runtime.parser.TokenMgrError: Lexical error at line 1, column 3. Encountered: <EOF> after : "" at org.apache.velocity.runtime.parser.ParserTokenManager.getNextToken(ParserTokenManager.java:4093) at org.apache.velocity.runtime.parser.Parser.jj_ntk(Parser.java:3343) at org.apache.velocity.runtime.parser.Parser.process(Parser.java:275) at org.apache.velocity.runtime.parser.Parser.parse(Parser.java:105) at org.apache.velocity.runtime.RuntimeInstance.parse(RuntimeInstance.java:1078) at org.apache.velocity.runtime.directive.VelocimacroProxy.parseTree(VelocimacroProxy.java:355) at org.apache.velocity.runtime.directive.VelocimacroProxy.setupMacro(VelocimacroProxy.java:335) at org.apache.velocity.runtime.directive.VelocimacroProxy.init(VelocimacroProxy.java:322) at org.apache.velocity.runtime.directive.RuntimeMacro.render(RuntimeMacro.java:218) at org.apache.velocity.runtime.parser.node.ASTDirective.render(ASTDirective.java:178) at org.apache.velocity.runtime.parser.node.SimpleNode.render(SimpleNode.java:317) at org.apache.velocity.Template.merge(Template.java:324) at org.apache.velocity.Template.merge(Template.java:232) at org.apache.velocity.test.issues.Velocity537TestCase.executeTest(Velocity537TestCase.java:96) I also traced the callstack of the relevant call to NodeUtils.tokenLiteral() (where Marnix's patch is applied) to try and figure out why his patch worked. The stack is: at org.apache.velocity.runtime.parser.node.NodeUtils.tokenLiteral(NodeUtils.java:159) at org.apache.velocity.runtime.directive.Macro.getASTAsStringArray(Macro.java:313) at org.apache.velocity.runtime.directive.Macro.processAndRegister(Macro.java:188) at org.apache.velocity.runtime.parser.Parser.Directive(Parser.java:902) at org.apache.velocity.runtime.parser.Parser.Statement(Parser.java:365) at org.apache.velocity.runtime.parser.Parser.process(Parser.java:303) at org.apache.velocity.runtime.parser.Parser.parse(Parser.java:105) at org.apache.velocity.runtime.RuntimeInstance.parse(RuntimeInstance.java:1078) at org.apache.velocity.runtime.RuntimeInstance.parse(RuntimeInstance.java:1008) at org.apache.velocity.Template.process(Template.java:121) at org.apache.velocity.runtime.resource.ResourceManagerImpl.loadResource(ResourceManagerImpl.java:434) at org.apache.velocity.runtime.resource.ResourceManagerImpl.getResource(ResourceManagerImpl.java:350) at org.apache.velocity.runtime.RuntimeInstance.getTemplate(RuntimeInstance.java:1342) at org.apache.velocity.runtime.RuntimeInstance.getTemplate(RuntimeInstance.java:1317) at org.apache.velocity.runtime.RuntimeSingleton.getTemplate(RuntimeSingleton.java:303) at org.apache.velocity.test.issues.Velocity537TestCase.executeTest(Velocity537TestCase.java:88) I'm not sure anymore how much this is a JavaCC grammar/parser problem. The lexical error is only thrown when you try to use the macro in question. It appears that the content is parsed a second time. I wonder if it is being mangled in between... > Multi-line comments causing ParseException in macros in Velocity engine 1.5 > --------------------------------------------------------------------------- > > Key: VELOCITY-537 > URL: https://issues.apache.org/jira/browse/VELOCITY-537 > Project: Velocity > Issue Type: Bug > Components: Engine > Affects Versions: 1.5 > Reporter: Christopher Townson > Fix For: 1.5.1 > > Attachments: velocity-537.zip > > > Moving from velocity engine 1.4 to 1.5, one of my macros is now causing a > ParseException: > #macro( makeLink $filepath )#* > *##if ($request.serverName.equalsIgnoreCase("www.liveserver.com") || > $request.serverName.equalsIgnoreCase("liveserver.com"))#* > *##set($mirrorDomain = "livemirror.com")#* > *##elseif($request.serverName.equalsIgnoreCase("stagingserver.com"))#* > *##set($mirrorDomain = "stagingmirror.com")#* > *##elseif($request.serverName.equalsIgnoreCase("devserver.com") || > $request.serverName.equalsIgnoreCase("localhost"))#* > *##set($mirrorDomain = "devmirror.com")#* > *##else#* > *##set($mirrorDomain = "liveserver.com")#* > *##end#* > *#http://${mirrorDomain}${filepath}#* > *##end > This macro uses the mutli-line comment hack to gobble whitespace (so that > none appears in the link text, whilst preserving some kind of readability. > This works fine in 1.4, but throws a ParseException in 1.5 (stacktrace below) > -- stacktrace -- > 2007-04-03 16:05:38,712 - VelocimacroManager.parseTree() : exception makeLink > org.apache.velocity.runtime.parser.ParseException: Lexical error: > org.apache.velocity.runtime.parser.TokenMgrError: Lexical error at line 1, > column 535. Encountered: <EOF> after : "" > at org.apache.velocity.runtime.parser.Parser.parse(Parser.java:124) > at > org.apache.velocity.runtime.RuntimeInstance.parse(RuntimeInstance.java:1042) > at > org.apache.velocity.runtime.directive.VelocimacroProxy.parseTree(VelocimacroProxy.java:342) > at > org.apache.velocity.runtime.directive.VelocimacroProxy.setupMacro(VelocimacroProxy.java:322) > at > org.apache.velocity.runtime.directive.VelocimacroProxy.init(VelocimacroProxy.java:309) > at > org.apache.velocity.runtime.parser.node.ASTDirective.init(ASTDirective.java:134) > at > org.apache.velocity.runtime.parser.node.SimpleNode.init(SimpleNode.java:285) > at org.apache.velocity.Template.initDocument(Template.java:199) > at org.apache.velocity.Template.process(Template.java:121) > at > org.apache.velocity.runtime.resource.ResourceManagerImpl.loadResource(ResourceManagerImpl.java:415) > at > org.apache.velocity.runtime.resource.ResourceManagerImpl.getResource(ResourceManagerImpl.java:335) > at > org.apache.velocity.runtime.RuntimeInstance.getTemplate(RuntimeInstance.java:1102) > at > org.apache.velocity.runtime.RuntimeInstance.getTemplate(RuntimeInstance.java:1077) > at > org.apache.velocity.app.VelocityEngine.getTemplate(VelocityEngine.java:528) > at > org.apache.velocity.tools.view.servlet.VelocityViewServlet.getTemplate(VelocityViewServlet.java:667) > at > org.apache.velocity.tools.view.servlet.VelocityViewServlet.handleRequest(VelocityViewServlet.java:601) > at > org.apache.velocity.tools.view.servlet.VelocityViewServlet.doRequest(VelocityViewServlet.java:541) > at > org.apache.velocity.tools.view.servlet.VelocityViewServlet.doGet(VelocityViewServlet.java:507) > at javax.servlet.http.HttpServlet.service(HttpServlet.java:689) > at javax.servlet.http.HttpServlet.service(HttpServlet.java:802) > at > org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252) > at > org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173) > at > org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213) > at > org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178) > at > org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126) > at > org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105) > at > org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107) > at > org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148) > at > org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:869) > at > org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:664) > at > org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527) > at > org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:80) > at > org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:684) > at java.lang.Thread.run(Thread.java:595) -- This message is automatically generated by JIRA. - You can reply to this email to add a comment to the issue online. --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]