Author: cbrisson
Date: Thu Aug 22 14:22:58 2019
New Revision: 1865687
URL: http://svn.apache.org/viewvc?rev=1865687&view=rev
Log:
[VELOCITY-917] Merge custom parser characters example back to trunk
Added:
velocity/engine/trunk/velocity-custom-parser-example/
- copied from r1865676,
velocity/engine/branches/parser_experiments/velocity-custom-parser-example/
velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/ParserConfiguration.java
- copied unchanged from r1865676,
velocity/engine/branches/parser_experiments/velocity-engine-core/src/main/java/org/apache/velocity/runtime/ParserConfiguration.java
velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/parser/Parser.java
- copied unchanged from r1865676,
velocity/engine/branches/parser_experiments/velocity-engine-core/src/main/java/org/apache/velocity/runtime/parser/Parser.java
velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/parser/node/JJTParserState.java
- copied unchanged from r1865676,
velocity/engine/branches/parser_experiments/velocity-engine-core/src/main/java/org/apache/velocity/runtime/parser/node/JJTParserState.java
velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/parser/node/ParserTreeConstants.java
- copied unchanged from r1865676,
velocity/engine/branches/parser_experiments/velocity-engine-core/src/main/java/org/apache/velocity/runtime/parser/node/ParserTreeConstants.java
velocity/engine/trunk/velocity-engine-core/src/main/parser/Parser.jjt
- copied unchanged from r1865676,
velocity/engine/branches/parser_experiments/velocity-engine-core/src/main/parser/Parser.jjt
Modified:
velocity/engine/trunk/ (props changed)
velocity/engine/trunk/pom.xml
velocity/engine/trunk/velocity-engine-core/pom.xml
velocity/engine/trunk/velocity-engine-core/src/main/java/ (props changed)
velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/RuntimeConstants.java
velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/RuntimeInstance.java
velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/RuntimeServices.java
velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/directive/Macro.java
velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/directive/RuntimeMacro.java
velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/directive/Scope.java
velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/parser/node/ASTComment.java
velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/parser/node/ASTDirective.java
velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/parser/node/ASTIfStatement.java
velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/parser/node/ASTReference.java
velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/parser/node/ASTSetDirective.java
velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/parser/node/ASTStringLiteral.java
velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/parser/node/ASTText.java
velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/parser/node/ASTTextblock.java
velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/parser/node/Node.java
velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/parser/node/NodeUtils.java
velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/parser/node/SimpleNode.java
velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/visitor/NodeViewMode.java
velocity/engine/trunk/velocity-engine-core/src/test/java/ (props changed)
velocity/engine/trunk/velocity-engine-core/src/test/java/org/apache/velocity/test/TextblockTestCase.java
velocity/engine/trunk/velocity-engine-examples/pom.xml
velocity/engine/trunk/velocity-engine-scripting/pom.xml
Propchange: velocity/engine/trunk/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Thu Aug 22 14:22:58 2019
@@ -2,4 +2,5 @@
/velocity/engine/branches/VELOCITY-892:1844076-1854372
/velocity/engine/branches/VELOCITY-898:1843220-1843786
/velocity/engine/branches/VELOCITY-909:1854851-1855185
+/velocity/engine/branches/parser_experiments:1860001-1865676
/velocity/engine/trunk:992133,1032159
Modified: velocity/engine/trunk/pom.xml
URL:
http://svn.apache.org/viewvc/velocity/engine/trunk/pom.xml?rev=1865687&r1=1865686&r2=1865687&view=diff
==============================================================================
--- velocity/engine/trunk/pom.xml (original)
+++ velocity/engine/trunk/pom.xml Thu Aug 22 14:22:58 2019
@@ -21,303 +21,324 @@
-->
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/xsd/maven-4.0.0.xsd">
- <modelVersion>4.0.0</modelVersion>
+ <modelVersion>4.0.0</modelVersion>
- <parent>
- <groupId>org.apache.velocity</groupId>
- <artifactId>velocity-master</artifactId>
- <version>3</version>
- <relativePath />
- </parent>
+ <parent>
+ <groupId>org.apache.velocity</groupId>
+ <artifactId>velocity-master</artifactId>
+ <version>3</version>
+ <relativePath />
+ </parent>
- <artifactId>velocity-engine-parent</artifactId>
- <version>2.2-SNAPSHOT</version>
+ <artifactId>velocity-engine-parent</artifactId>
+ <version>2.2-SNAPSHOT</version>
- <name>Apache Velocity</name>
- <url>http://velocity.apache.org/engine/devel/</url>
- <description>Apache Velocity is a general purpose template
engine.</description>
- <inceptionYear>2000</inceptionYear>
- <packaging>pom</packaging>
+ <name>Apache Velocity</name>
+ <url>http://velocity.apache.org/engine/devel/</url>
+ <description>Apache Velocity is a general purpose template
engine.</description>
+ <inceptionYear>2000</inceptionYear>
+ <packaging>pom</packaging>
- <properties>
- <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
- <junit.version>4.12</junit.version>
- <slf4j.version>1.7.26</slf4j.version>
- <surefire.plugin.version>2.19.1</surefire.plugin.version>
- <jira.browse.url>https://issues.apache.org/jira/browse</jira.browse.url>
- <maven.compiler.source>1.8</maven.compiler.source>
- <maven.compiler.target>1.8</maven.compiler.target>
- </properties>
+ <properties>
+ <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+ <junit.version>4.12</junit.version>
+ <slf4j.version>1.7.26</slf4j.version>
+ <surefire.plugin.version>2.19.1</surefire.plugin.version>
+
<jira.browse.url>https://issues.apache.org/jira/browse</jira.browse.url>
+ <maven.compiler.source>1.8</maven.compiler.source>
+ <maven.compiler.target>1.8</maven.compiler.target>
+ </properties>
- <build>
- <defaultGoal>install</defaultGoal>
- <pluginManagement>
- <plugins>
- <plugin>
- <artifactId>maven-release-plugin</artifactId>
- <version>2.5.3</version>
- <configuration>
- <useReleaseProfile>false</useReleaseProfile>
- <autoVersionSubmodules>true</autoVersionSubmodules>
- <goals>deploy</goals>
- <arguments>-Papache-release</arguments>
- </configuration>
- </plugin>
- <plugin>
- <artifactId>maven-jar-plugin</artifactId>
- <version>3.1.1</version>
- <configuration>
- <archive>
-
<manifestFile>${project.build.outputDirectory}/META-INF/MANIFEST.MF</manifestFile>
- </archive>
- </configuration>
- </plugin>
- <plugin>
- <groupId>org.apache.felix</groupId>
- <artifactId>maven-bundle-plugin</artifactId>
- <version>3.5.0</version>
- <executions>
- <execution>
- <id>bundle-manifest</id>
- <phase>process-classes</phase>
- <goals>
- <goal>manifest</goal>
- </goals>
- </execution>
- </executions>
- </plugin>
- </plugins>
- </pluginManagement>
- <plugins>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-compiler-plugin</artifactId>
- <configuration>
- <showDeprecation>true</showDeprecation>
- <showWarning>true</showWarning>
- <source>${maven.compiler.source}</source>
- <target>${maven.compiler.target}</target>
- </configuration>
- </plugin>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-javadoc-plugin</artifactId>
- <version>3.1.0</version>
- <configuration>
- <!-- full checking is left disabled
- <doclint>html,missing,reference,syntax</doclint>
- -->
- <doclint>none</doclint>
- </configuration>
- <executions>
- <execution>
- <id>aggregate</id>
- <goals>
- <goal>aggregate</goal>
- </goals>
- </execution>
- </executions>
- </plugin>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-enforcer-plugin</artifactId>
- <executions>
- <execution>
- <id>enforce-bytecode-version</id>
- <goals>
- <goal>enforce</goal>
- </goals>
- <configuration>
- <rules>
- <enforceBytecodeVersion>
- <maxJdkVersion>${maven.compiler.target}</maxJdkVersion>
- </enforceBytecodeVersion>
- <requireJavaVersion>
- <version>[1.8,)</version>
- </requireJavaVersion>
- </rules>
- <fail>true</fail>
- </configuration>
- </execution>
- <execution>
- <id>ban-known-bad-maven-versions</id>
- <goals>
- <goal>enforce</goal>
- </goals>
- <configuration>
- <rules>
- <requireMavenVersion>
- <version>[3.0.5,)</version>
- <message>Maven minimal expected version is 3.0.5.</message>
- </requireMavenVersion>
- </rules>
- </configuration>
- </execution>
- </executions>
- <dependencies>
- <dependency>
- <groupId>org.codehaus.mojo</groupId>
- <artifactId>extra-enforcer-rules</artifactId>
- <version>1.0-beta-9</version>
- </dependency>
- </dependencies>
- </plugin>
- </plugins>
- </build>
+ <build>
+ <defaultGoal>install</defaultGoal>
+ <pluginManagement>
+ <plugins>
+ <plugin>
+ <artifactId>maven-release-plugin</artifactId>
+ <version>2.5.3</version>
+ <configuration>
+ <useReleaseProfile>false</useReleaseProfile>
+ <autoVersionSubmodules>true</autoVersionSubmodules>
+ <goals>deploy</goals>
+ <arguments>-Papache-release</arguments>
+ </configuration>
+ </plugin>
+ <plugin>
+ <artifactId>maven-jar-plugin</artifactId>
+ <version>3.1.1</version>
+ <configuration>
+ <archive>
+
<manifestFile>${project.build.outputDirectory}/META-INF/MANIFEST.MF</manifestFile>
+ </archive>
+ </configuration>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.felix</groupId>
+ <artifactId>maven-bundle-plugin</artifactId>
+ <version>3.5.0</version>
+ <executions>
+ <execution>
+ <id>bundle-manifest</id>
+ <phase>process-classes</phase>
+ <goals>
+ <goal>manifest</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-dependency-plugin</artifactId>
+ <version>3.1.1</version>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-resources-plugin</artifactId>
+ <version>3.1.0</version>
+ </plugin>
+ <plugin>
+ <groupId>com.google.code.maven-replacer-plugin</groupId>
+ <artifactId>replacer</artifactId>
+ <version>1.5.3</version>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-clean-plugin</artifactId>
+ <version>3.1.0</version>
+ </plugin>
+ </plugins>
+ </pluginManagement>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <configuration>
+ <showDeprecation>true</showDeprecation>
+ <showWarning>true</showWarning>
+ <source>${maven.compiler.source}</source>
+ <target>${maven.compiler.target}</target>
+ </configuration>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-javadoc-plugin</artifactId>
+ <version>3.1.0</version>
+ <configuration>
+ <!-- full checking is left disabled
+ <doclint>html,missing,reference,syntax</doclint>
+ -->
+ <doclint>none</doclint>
+ </configuration>
+ <executions>
+ <execution>
+ <id>aggregate</id>
+ <goals>
+ <goal>aggregate</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-enforcer-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>enforce-bytecode-version</id>
+ <goals>
+ <goal>enforce</goal>
+ </goals>
+ <configuration>
+ <rules>
+ <enforceBytecodeVersion>
+
<maxJdkVersion>${maven.compiler.target}</maxJdkVersion>
+ </enforceBytecodeVersion>
+ <requireJavaVersion>
+ <version>[1.8,)</version>
+ </requireJavaVersion>
+ </rules>
+ <fail>true</fail>
+ </configuration>
+ </execution>
+ <execution>
+ <id>ban-known-bad-maven-versions</id>
+ <goals>
+ <goal>enforce</goal>
+ </goals>
+ <configuration>
+ <rules>
+ <requireMavenVersion>
+ <version>[3.0.5,)</version>
+ <message>Maven minimal expected version is
3.0.5.</message>
+ </requireMavenVersion>
+ </rules>
+ </configuration>
+ </execution>
+ </executions>
+ <dependencies>
+ <dependency>
+ <groupId>org.codehaus.mojo</groupId>
+ <artifactId>extra-enforcer-rules</artifactId>
+ <version>1.0-beta-9</version>
+ </dependency>
+ </dependencies>
+ </plugin>
+ </plugins>
+ </build>
- <distributionManagement>
- <site>
- <id>velocity.apache.org</id>
- <url>scpexe://people.apache.org/www/velocity.apache.org/engine/devel/
- </url>
- </site>
- </distributionManagement>
+ <distributionManagement>
+ <site>
+ <id>velocity.apache.org</id>
+
<url>scpexe://people.apache.org/www/velocity.apache.org/engine/devel/
+ </url>
+ </site>
+ </distributionManagement>
- <scm>
-
<connection>scm:svn:http://svn.apache.org/repos/asf/velocity/engine/trunk</connection>
-
<developerConnection>scm:svn:https://svn.apache.org/repos/asf/velocity/engine/trunk</developerConnection>
- <url>http://svn.apache.org/viewvc/velocity/engine/trunk</url>
- </scm>
+ <scm>
+
<connection>scm:svn:http://svn.apache.org/repos/asf/velocity/engine/trunk</connection>
+
<developerConnection>scm:svn:https://svn.apache.org/repos/asf/velocity/engine/trunk</developerConnection>
+ <url>http://svn.apache.org/viewvc/velocity/engine/trunk</url>
+ </scm>
- <issueManagement>
- <system>JIRA</system>
- <url>${jira.browse.url}/VELOCITY</url>
- </issueManagement>
- <modules>
- <module>velocity-engine-core</module>
- <module>velocity-engine-examples</module>
- <module>velocity-engine-scripting</module>
- </modules>
+ <issueManagement>
+ <system>JIRA</system>
+ <url>${jira.browse.url}/VELOCITY</url>
+ </issueManagement>
+ <modules>
+ <module>velocity-engine-core</module>
+ <module>velocity-engine-examples</module>
+ <module>velocity-engine-scripting</module>
+ <module>velocity-custom-parser-example</module>
+ </modules>
- <!-- This project is an effort by many people. If you feel that your name
- should be in here and has been omitted in error, please open an issue
- with the Apache Velocity Issue tracker. -->
- <contributors>
- <contributor>
- <name>Adrian Tarau</name>
- </contributor>
- <contributor>
- <name>Aki Nieminen</name>
- </contributor>
- <contributor>
- <name>Alexey Pachenko</name>
- </contributor>
- <contributor>
- <name>Anil K. Vijendran</name>
- </contributor>
- <contributor>
- <name>Attila Szegedi</name>
- </contributor>
- <contributor>
- <name>Bob McWhirter</name>
- </contributor>
- <contributor>
- <name>Byron Foster</name>
- </contributor>
- <contributor>
- <name>Candid Dauth</name>
- </contributor>
- <contributor>
- <name>Christoph Reck</name>
- </contributor>
- <contributor>
- <name>Darren Cruse</name>
- </contributor>
- <contributor>
- <name>Dave Bryson</name>
- </contributor>
- <contributor>
- <name>David Kinnvall</name>
- </contributor>
- <contributor>
- <name>Dawid Weiss</name>
- </contributor>
- <contributor>
- <name>Dishara Wijewardana</name>
- </contributor>
- <contributor>
- <name>Eelco Hillenius</name>
- </contributor>
- <contributor>
- <name>Fedor Karpelevitch</name>
- </contributor>
- <contributor>
- <name>Felipe Maschio</name>
- </contributor>
- <contributor>
- <name>Gal Shachor</name>
- </contributor>
- <contributor>
- <name>Hervé Boutemy</name>
- </contributor>
- <contributor>
- <name>Jarkko Viinamäki</name>
- </contributor>
- <contributor>
- <name>Jeff Bowden</name>
- </contributor>
- <contributor>
- <name>Jorgen Rydenius</name>
- </contributor>
- <contributor>
- <name>Jose Alberto Fernandez</name>
- </contributor>
- <contributor>
- <name>Kasper Nielsen</name>
- </contributor>
- <contributor>
- <name>Kent Johnson</name>
- </contributor>
- <contributor>
- <name>Kyle F. Downey</name>
- </contributor>
- <contributor>
- <name>Leon Messerschmidt</name>
- </contributor>
- <contributor>
- <name>Llewellyn Falco</name>
- </contributor>
- <contributor>
- <name>Matt Raible</name>
- </contributor>
- <contributor>
- <name>Matt Ryall</name>
- </contributor>
- <contributor>
- <name>Matthijs Lambooy</name>
- </contributor>
- <contributor>
- <name>Oswaldo Hernandez</name>
- </contributor>
- <contributor>
- <name>Paulo Gaspar</name>
- </contributor>
- <contributor>
- <name>Peter Romianowski</name>
- </contributor>
- <contributor>
- <name>Robert Burrell Donkin</name>
- </contributor>
- <contributor>
- <name>Robert Fuller</name>
- </contributor>
- <contributor>
- <name>Sam Ruby</name>
- </contributor>
- <contributor>
- <name>Sean Legassick</name>
- </contributor>
- <contributor>
- <name>Serge Knystautas</name>
- </contributor>
- <contributor>
- <name>Stephane Bailliez</name>
- </contributor>
- <contributor>
- <name>Stephen Habermann</name>
- </contributor>
- <contributor>
- <name>Sylwester Lachiewicz</name>
- </contributor>
- </contributors>
+ <!-- This project is an effort by many people. If you feel that your name
+ should be in here and has been omitted in error, please open an issue
+ with the Apache Velocity Issue tracker. -->
+ <contributors>
+ <contributor>
+ <name>Adrian Tarau</name>
+ </contributor>
+ <contributor>
+ <name>Aki Nieminen</name>
+ </contributor>
+ <contributor>
+ <name>Alexey Pachenko</name>
+ </contributor>
+ <contributor>
+ <name>Anil K. Vijendran</name>
+ </contributor>
+ <contributor>
+ <name>Attila Szegedi</name>
+ </contributor>
+ <contributor>
+ <name>Bob McWhirter</name>
+ </contributor>
+ <contributor>
+ <name>Byron Foster</name>
+ </contributor>
+ <contributor>
+ <name>Candid Dauth</name>
+ </contributor>
+ <contributor>
+ <name>Christoph Reck</name>
+ </contributor>
+ <contributor>
+ <name>Darren Cruse</name>
+ </contributor>
+ <contributor>
+ <name>Dave Bryson</name>
+ </contributor>
+ <contributor>
+ <name>David Kinnvall</name>
+ </contributor>
+ <contributor>
+ <name>Dawid Weiss</name>
+ </contributor>
+ <contributor>
+ <name>Dishara Wijewardana</name>
+ </contributor>
+ <contributor>
+ <name>Eelco Hillenius</name>
+ </contributor>
+ <contributor>
+ <name>Fedor Karpelevitch</name>
+ </contributor>
+ <contributor>
+ <name>Felipe Maschio</name>
+ </contributor>
+ <contributor>
+ <name>Gal Shachor</name>
+ </contributor>
+ <contributor>
+ <name>Hervé Boutemy</name>
+ </contributor>
+ <contributor>
+ <name>Jarkko Viinamäki</name>
+ </contributor>
+ <contributor>
+ <name>Jeff Bowden</name>
+ </contributor>
+ <contributor>
+ <name>Jorgen Rydenius</name>
+ </contributor>
+ <contributor>
+ <name>Jose Alberto Fernandez</name>
+ </contributor>
+ <contributor>
+ <name>Kasper Nielsen</name>
+ </contributor>
+ <contributor>
+ <name>Kent Johnson</name>
+ </contributor>
+ <contributor>
+ <name>Kyle F. Downey</name>
+ </contributor>
+ <contributor>
+ <name>Leon Messerschmidt</name>
+ </contributor>
+ <contributor>
+ <name>Llewellyn Falco</name>
+ </contributor>
+ <contributor>
+ <name>Matt Raible</name>
+ </contributor>
+ <contributor>
+ <name>Matt Ryall</name>
+ </contributor>
+ <contributor>
+ <name>Matthijs Lambooy</name>
+ </contributor>
+ <contributor>
+ <name>Oswaldo Hernandez</name>
+ </contributor>
+ <contributor>
+ <name>Paulo Gaspar</name>
+ </contributor>
+ <contributor>
+ <name>Peter Romianowski</name>
+ </contributor>
+ <contributor>
+ <name>Robert Burrell Donkin</name>
+ </contributor>
+ <contributor>
+ <name>Robert Fuller</name>
+ </contributor>
+ <contributor>
+ <name>Sam Ruby</name>
+ </contributor>
+ <contributor>
+ <name>Sean Legassick</name>
+ </contributor>
+ <contributor>
+ <name>Serge Knystautas</name>
+ </contributor>
+ <contributor>
+ <name>Stephane Bailliez</name>
+ </contributor>
+ <contributor>
+ <name>Stephen Habermann</name>
+ </contributor>
+ <contributor>
+ <name>Sylwester Lachiewicz</name>
+ </contributor>
+ </contributors>
</project>
Modified: velocity/engine/trunk/velocity-engine-core/pom.xml
URL:
http://svn.apache.org/viewvc/velocity/engine/trunk/velocity-engine-core/pom.xml?rev=1865687&r1=1865686&r2=1865687&view=diff
==============================================================================
--- velocity/engine/trunk/velocity-engine-core/pom.xml (original)
+++ velocity/engine/trunk/velocity-engine-core/pom.xml Thu Aug 22 14:22:58 2019
@@ -1,3 +1,4 @@
+<?xml version="1.0" encoding="UTF-8"?>
<!--
Licensed to the Apache Software Foundation (ASF) under one
@@ -19,235 +20,312 @@
-->
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/xsd/maven-4.0.0.xsd">
- <modelVersion>4.0.0</modelVersion>
- <parent>
- <groupId>org.apache.velocity</groupId>
- <artifactId>velocity-engine-parent</artifactId>
- <version>2.2-SNAPSHOT</version>
- </parent>
-
- <artifactId>velocity-engine-core</artifactId>
- <name>Apache Velocity - Engine</name>
-
- <properties>
- <!-- command line switch -Dparser.create=true generates the parser files
-->
- <parser.create>false</parser.create>
-
- <!-- command line switch -Dparser.nodefiles=true generates AST Node
classes (new structures added to parser) -->
- <parser.nodefiles>false</parser.nodefiles>
-
- <parser.debug>false</parser.debug>
-
- <!-- You can modify those properties locally to test
- the DataSourceResourceLoader against other engines.
- Please note that you may have to also alter the file
- src/test/resources/ds/create-db.sql for specific engine SQL grammars.
- -->
- <test.jdbc.driver.groupId>org.hsqldb</test.jdbc.driver.groupId>
- <test.jdbc.driver.artifactId>hsqldb</test.jdbc.driver.artifactId>
- <test.jdbc.driver.version>2.3.5</test.jdbc.driver.version>
-
<test.jdbc.driver.className>org.hsqldb.jdbcDriver</test.jdbc.driver.className>
- <test.jdbc.uri>jdbc:hsqldb:.</test.jdbc.uri>
- <test.jdbc.login>sa</test.jdbc.login>
- <test.jdbc.password />
- </properties>
-
- <build>
- <plugins>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-resources-plugin</artifactId>
- <version>3.1.0</version>
- <configuration>
- <useDefaultDelimiters>false</useDefaultDelimiters>
- <delimiters>
- <delimiter>${*}</delimiter>
- </delimiters>
- </configuration>
- </plugin>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-shade-plugin</artifactId>
- <version>3.2.1</version>
- <executions>
- <execution>
- <id>shade</id>
- <phase>package</phase>
- <goals>
- <goal>shade</goal>
- </goals>
- <configuration>
- <artifactSet>
- <includes>
- <include>commons-io:commons-io</include>
- </includes>
- <excludes>
- <exclude>org.slf4j:slf4j-api</exclude>
- </excludes>
- </artifactSet>
- <relocations>
- <relocation>
- <pattern>org.apache.commons.io</pattern>
-
<shadedPattern>org.apache.velocity.shaded.commons.io</shadedPattern>
- </relocation>
- </relocations>
- <minimizeJar>true</minimizeJar>
- </configuration>
- </execution>
- </executions>
- </plugin>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-surefire-plugin</artifactId>
- <version>${surefire.plugin.version}</version>
- <configuration>
- <skip>${maven.test.skip}</skip>
- <systemProperties>
- <property>
- <name>test</name>
- <value>${test}</value>
- </property>
- <property>
- <name>test.compare.dir</name>
- <value>${project.build.testOutputDirectory}</value>
- </property>
- <property>
- <name>test.result.dir</name>
- <value>${project.build.directory}/results</value>
- </property>
- <property>
- <name>org.slf4j.simpleLogger.defaultLogLevel</name>
- <value>warn</value>
- </property>
- <property>
- <name>org.slf4j.simpleLogger.logFile</name>
- <value>${project.build.directory}/velocity.log</value>
- </property>
- <property>
- <name>test.jdbc.driver.className</name>
- <value>${test.jdbc.driver.className}</value>
- </property>
- <property>
- <name>test.jdbc.uri</name>
- <value>${test.jdbc.uri}</value>
- </property>
- <property>
- <name>test.jdbc.login</name>
- <value>${test.jdbc.login}</value>
- </property>
- <property>
- <name>test.jdbc.password</name>
- <value>${test.jdbc.password}</value>
- </property>
- </systemProperties>
- </configuration>
- <executions>
- <execution>
- <id>integration-test</id>
- <phase>integration-test</phase>
- <goals>
- <goal>test</goal>
- </goals>
- <configuration>
- <skip>false</skip>
- </configuration>
- </execution>
- </executions>
- </plugin>
- <plugin>
- <groupId>org.codehaus.mojo</groupId>
- <artifactId>javacc-maven-plugin</artifactId>
- <version>2.6</version>
- <executions>
- <execution>
- <id>jjtree-javacc</id>
- <goals>
- <goal>jjtree-javacc</goal>
- </goals>
- </execution>
- </executions>
- <configuration>
- <isStatic>false</isStatic>
- <buildParser>true</buildParser>
- <buildNodeFiles>${parser.nodefiles}</buildNodeFiles>
- <multi>true</multi>
- <debugParser>${parser.debug}</debugParser>
- <debugLookAhead>${parser.debug}</debugLookAhead>
- <debugTokenManager>${parser.debug}</debugTokenManager>
- <jdkVersion>${maven.compiler.target}</jdkVersion>
- <nodeUsesParser>true</nodeUsesParser>
- <nodePackage>org.apache.velocity.runtime.parser.node</nodePackage>
- <sourceDirectory>${basedir}/src/main/parser</sourceDirectory>
- <tokenManagerUsesParser>true</tokenManagerUsesParser>
- </configuration>
- </plugin>
- <plugin>
- <groupId>org.apache.felix</groupId>
- <artifactId>maven-bundle-plugin</artifactId>
- <configuration>
- <instructions>
- <Export-Package>
- org.apache.velocity.*
- </Export-Package>
- <Import-Package>
- !org.apache.commons.io,
- *
- </Import-Package>
- </instructions>
- </configuration>
- </plugin>
- </plugins>
- </build>
- <dependencies>
- <dependency>
- <groupId>org.apache.commons</groupId>
- <artifactId>commons-lang3</artifactId>
- <version>3.8.1</version>
- </dependency>
- <dependency>
- <groupId>org.slf4j</groupId>
- <artifactId>slf4j-api</artifactId>
- <version>${slf4j.version}</version>
- </dependency>
- <dependency>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
- <version>${junit.version}</version>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>${test.jdbc.driver.groupId}</groupId>
- <artifactId>${test.jdbc.driver.artifactId}</artifactId>
- <version>${test.jdbc.driver.version}</version>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>commons-io</groupId>
- <artifactId>commons-io</artifactId>
- <version>2.6</version>
- </dependency>
- <dependency>
- <groupId>org.slf4j</groupId>
- <artifactId>slf4j-simple</artifactId>
- <version>${slf4j.version}</version>
- <scope>test</scope>
- </dependency>
- </dependencies>
-
- <reporting>
- <plugins>
- <plugin>
- <groupId>org.codehaus.mojo</groupId>
- <artifactId>findbugs-maven-plugin</artifactId>
- <version>3.0.4</version>
- <configuration>
- <xmlOutput>true</xmlOutput>
- <threshold>Low</threshold>
- <effort>Max</effort>
-
<excludeFilterFile>src/etc/build/findbugs-exclude.xml</excludeFilterFile>
- <xmlOutputDirectory>target/site</xmlOutputDirectory>
- </configuration>
- </plugin>
- </plugins>
- </reporting>
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.apache.velocity</groupId>
+ <artifactId>velocity-engine-parent</artifactId>
+ <version>2.2-SNAPSHOT</version>
+ </parent>
+
+ <artifactId>velocity-engine-core</artifactId>
+ <name>Apache Velocity - Engine</name>
+
+ <properties>
+ <!-- You should not directly modify those properties which define the
behavior of the parser.
+ Instead, you should customize the velocity-custom-parser-example
module to fit your own needs.
+ -->
+ <parser.debug>false</parser.debug>
+ <parser.package>org.apache.velocity.runtime.parser</parser.package>
+ <parser.basename>Standard</parser.basename>
+ <parser.char.asterisk>*</parser.char.asterisk>
+ <parser.char.at>@</parser.char.at>
+ <parser.char.dollar>$</parser.char.dollar>
+ <parser.char.hash>#</parser.char.hash>
+
+ <!-- You can modify those properties locally to test
+ the DataSourceResourceLoader against other engines.
+ Please note that you may have to also alter the file
+ src/test/resources/ds/create-db.sql for specific engine SQL
grammars.
+ -->
+ <test.jdbc.driver.groupId>org.hsqldb</test.jdbc.driver.groupId>
+ <test.jdbc.driver.artifactId>hsqldb</test.jdbc.driver.artifactId>
+ <test.jdbc.driver.version>2.3.5</test.jdbc.driver.version>
+
<test.jdbc.driver.className>org.hsqldb.jdbcDriver</test.jdbc.driver.className>
+ <test.jdbc.uri>jdbc:hsqldb:.</test.jdbc.uri>
+ <test.jdbc.login>sa</test.jdbc.login>
+ <test.jdbc.password />
+ </properties>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-resources-plugin</artifactId>
+ <executions>
+ <!-- prepare parser grammar file -->
+ <execution>
+ <id>generate-parser-grammar</id>
+ <phase>generate-sources</phase>
+ <goals>
+ <goal>copy-resources</goal>
+ </goals>
+ <configuration>
+ <useDefaultDelimiters>false</useDefaultDelimiters>
+
+ <delimiters>
+ <delimiter>${*}</delimiter>
+ </delimiters>
+ <resources>
+ <resource>
+ <directory>src/main/parser</directory>
+ <filtering>true</filtering>
+ </resource>
+ </resources>
+
<outputDirectory>${project.build.directory}/parser</outputDirectory>
+ </configuration>
+ </execution>
+ <!-- expose the raw grammar file for the custom parser
maven plugin -->
+ <execution>
+ <id>expose-parser-grammar</id>
+ <phase>process-resources</phase>
+ <goals>
+ <goal>copy-resources</goal>
+ </goals>
+ <configuration>
+ <resources>
+ <resource>
+ <directory>src/main/parser</directory>
+ <filtering>false</filtering>
+ </resource>
+ </resources>
+
<outputDirectory>${project.build.outputDirectory}/org/apache/velocity/runtime/parser</outputDirectory>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+
+ <!-- shading of commons-io -->
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-shade-plugin</artifactId>
+ <version>3.2.1</version>
+ <executions>
+ <execution>
+ <id>shade</id>
+ <phase>package</phase>
+ <goals>
+ <goal>shade</goal>
+ </goals>
+ <configuration>
+ <artifactSet>
+ <includes>
+ <include>commons-io:commons-io</include>
+ </includes>
+ <excludes>
+ <exclude>org.slf4j:slf4j-api</exclude>
+ </excludes>
+ </artifactSet>
+ <relocations>
+ <relocation>
+ <pattern>org.apache.commons.io</pattern>
+
<shadedPattern>org.apache.velocity.shaded.commons.io</shadedPattern>
+ </relocation>
+ </relocations>
+ <minimizeJar>true</minimizeJar>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+
+ <!-- parser -->
+ <plugin>
+ <groupId>org.codehaus.mojo</groupId>
+ <artifactId>javacc-maven-plugin</artifactId>
+ <version>2.6</version>
+ <configuration>
+ <isStatic>false</isStatic>
+ <buildParser>true</buildParser>
+ <buildNodeFiles>false</buildNodeFiles>
+ <multi>true</multi>
+ <debugParser>${parser.debug}</debugParser>
+ <debugLookAhead>${parser.debug}</debugLookAhead>
+ <debugTokenManager>${parser.debug}</debugTokenManager>
+ <jdkVersion>${maven.compiler.target}</jdkVersion>
+ <nodeUsesParser>true</nodeUsesParser>
+
<nodePackage>org.apache.velocity.runtime.parser.node</nodePackage>
+
<sourceDirectory>${project.build.directory}/parser</sourceDirectory>
+ <tokenManagerUsesParser>true</tokenManagerUsesParser>
+ </configuration>
+ <executions>
+ <!-- build the standard parser -->
+ <execution>
+ <id>jjtree-javacc</id>
+ <goals>
+ <goal>jjtree-javacc</goal>
+ </goals>
+ <configuration>
+ <includes>
+ <include>Parser.jjt</include>
+ </includes>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+
+ <!-- post-processing of parser genereted source files -->
+ <plugin>
+ <groupId>com.google.code.maven-replacer-plugin</groupId>
+ <artifactId>replacer</artifactId>
+ <executions>
+ <execution>
+ <id>patch-parser-files</id>
+ <phase>process-sources</phase>
+ <goals>
+ <goal>replace</goal>
+ </goals>
+ <configuration>
+
<file>${project.build.directory}/generated-sources/javacc/org/apache/velocity/runtime/parser/TokenMgrError.java</file>
+ <replacements>
+ <replacement>
+ <token>static final int</token>
+ <value>public static final int</value>
+ </replacement>
+ </replacements>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+
+ <!-- handle OSGi information -->
+ <plugin>
+ <groupId>org.apache.felix</groupId>
+ <artifactId>maven-bundle-plugin</artifactId>
+ <configuration>
+ <instructions>
+ <Export-Package>
+ org.apache.velocity.*
+ </Export-Package>
+ <Import-Package>
+ !org.apache.commons.io,
+ *
+ </Import-Package>
+ </instructions>
+ </configuration>
+ </plugin>
+
+ <!-- tests -->
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-surefire-plugin</artifactId>
+ <version>${surefire.plugin.version}</version>
+ <configuration>
+ <skip>${maven.test.skip}</skip>
+ <systemProperties>
+ <property>
+ <name>test</name>
+ <value>${test}</value>
+ </property>
+ <property>
+ <name>test.compare.dir</name>
+ <value>${project.build.testOutputDirectory}</value>
+ </property>
+ <property>
+ <name>test.result.dir</name>
+ <value>${project.build.directory}/results</value>
+ </property>
+ <property>
+ <name>org.slf4j.simpleLogger.defaultLogLevel</name>
+ <value>warn</value>
+ </property>
+ <property>
+ <name>org.slf4j.simpleLogger.logFile</name>
+
<value>${project.build.directory}/velocity.log</value>
+ </property>
+ <property>
+ <name>test.jdbc.driver.className</name>
+ <value>${test.jdbc.driver.className}</value>
+ </property>
+ <property>
+ <name>test.jdbc.uri</name>
+ <value>${test.jdbc.uri}</value>
+ </property>
+ <property>
+ <name>test.jdbc.login</name>
+ <value>${test.jdbc.login}</value>
+ </property>
+ <property>
+ <name>test.jdbc.password</name>
+ <value>${test.jdbc.password}</value>
+ </property>
+ </systemProperties>
+ </configuration>
+ <executions>
+ <execution>
+ <id>integration-test</id>
+ <phase>integration-test</phase>
+ <goals>
+ <goal>test</goal>
+ </goals>
+ <configuration>
+ <skip>false</skip>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+
+ </plugins>
+ </build>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.commons</groupId>
+ <artifactId>commons-lang3</artifactId>
+ <version>3.8.1</version>
+ </dependency>
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-api</artifactId>
+ <version>${slf4j.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>${junit.version}</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>${test.jdbc.driver.groupId}</groupId>
+ <artifactId>${test.jdbc.driver.artifactId}</artifactId>
+ <version>${test.jdbc.driver.version}</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>commons-io</groupId>
+ <artifactId>commons-io</artifactId>
+ <version>2.6</version>
+ </dependency>
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-simple</artifactId>
+ <version>${slf4j.version}</version>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+
+ <reporting>
+ <plugins>
+ <plugin>
+ <groupId>org.codehaus.mojo</groupId>
+ <artifactId>findbugs-maven-plugin</artifactId>
+ <version>3.0.4</version>
+ <configuration>
+ <xmlOutput>true</xmlOutput>
+ <threshold>Low</threshold>
+ <effort>Max</effort>
+
<excludeFilterFile>src/etc/build/findbugs-exclude.xml</excludeFilterFile>
+ <xmlOutputDirectory>target/site</xmlOutputDirectory>
+ </configuration>
+ </plugin>
+ </plugins>
+ </reporting>
</project>
Propchange: velocity/engine/trunk/velocity-engine-core/src/main/java/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Thu Aug 22 14:22:58 2019
@@ -3,4 +3,5 @@
/velocity/engine/branches/VELOCITY-892/velocity-engine-core/src/main/java:1844076-1854372
/velocity/engine/branches/VELOCITY-898/velocity-engine-core/src/main/java:1843220-1843786
/velocity/engine/branches/VELOCITY-909/velocity-engine-core/src/main/java:1854851-1855185
+/velocity/engine/branches/parser_experiments/velocity-engine-core/src/main/java:1860001-1865676
/velocity/engine/trunk/src/java:1032134
Modified:
velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/RuntimeConstants.java
URL:
http://svn.apache.org/viewvc/velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/RuntimeConstants.java?rev=1865687&r1=1865686&r2=1865687&view=diff
==============================================================================
---
velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/RuntimeConstants.java
(original)
+++
velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/RuntimeConstants.java
Thu Aug 22 14:22:58 2019
@@ -391,21 +391,21 @@ public interface RuntimeConstants extend
/*
* ----------------------------------------------------------------------
- * G E N E R A L R U N T I M E C O N F I G U R A T I O N
+ * P A R S E R C O N F I G U R A T I O N
* ----------------------------------------------------------------------
*/
- /** Whether to use string interning. */
- String RUNTIME_STRING_INTERNING = "runtime.string_interning";
-
- /** Switch for the interpolation facility for string literals. */
- String INTERPOLATE_STRINGLITERALS = "runtime.interpolate_string_literals";
-
- /** Switch for ignoring nulls in math equations vs throwing exceptions. */
- String STRICT_MATH = "runtime.strict_math";
+ /**
+ * Property specifying the parser class to use
+ * @since 2.2
+ */
+ String PARSER_CLASS = "parser.class";
- /** Key upon which a context should be accessible within itself */
- String CONTEXT_AUTOREFERENCE_KEY = "context.self_reference_key";
+ /**
+ * Default parser class
+ * @since 2.2
+ */
+ String DEFAULT_PARSER_CLASS =
"org.apache.velocity.runtime.parser.StandardParser";
/**
* The <code>parser.pool.class</code> property specifies the name of the
{@link org.apache.velocity.util.SimplePool}
@@ -424,6 +424,24 @@ public interface RuntimeConstants extend
*/
String PARSER_HYPHEN_ALLOWED = "parser.allow_hyphen_in_identifiers";
+ /*
+ * ----------------------------------------------------------------------
+ * G E N E R A L R U N T I M E C O N F I G U R A T I O N
+ * ----------------------------------------------------------------------
+ */
+
+ /** Whether to use string interning. */
+ String RUNTIME_STRING_INTERNING = "runtime.string_interning";
+
+ /** Switch for the interpolation facility for string literals. */
+ String INTERPOLATE_STRINGLITERALS = "runtime.interpolate_string_literals";
+
+ /** Switch for ignoring nulls in math equations vs throwing exceptions. */
+ String STRICT_MATH = "runtime.strict_math";
+
+ /** Key upon which a context should be accessible within itself */
+ String CONTEXT_AUTOREFERENCE_KEY = "context.self_reference_key";
+
/**
* Space gobbling mode
* @since 2.0
Modified:
velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/RuntimeInstance.java
URL:
http://svn.apache.org/viewvc/velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/RuntimeInstance.java?rev=1865687&r1=1865686&r2=1865687&view=diff
==============================================================================
---
velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/RuntimeInstance.java
(original)
+++
velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/RuntimeInstance.java
Thu Aug 22 14:22:58 2019
@@ -61,6 +61,9 @@ import java.io.InputStream;
import java.io.Reader;
import java.io.StringReader;
import java.io.Writer;
+import java.lang.reflect.Constructor;
+import java.lang.reflect.InvocationTargetException;
+import java.nio.charset.StandardCharsets;
import java.util.Enumeration;
import java.util.HashMap;
import java.util.HashSet;
@@ -226,6 +229,18 @@ public class RuntimeInstance implements
private LogContext logContext;
/**
+ * Configured parser class
+ * @since 2.2
+ */
+ private Constructor parserConstructor;
+
+ /**
+ * Configured replacement characters in parser grammar
+ * @since 2.2
+ */
+ private ParserConfiguration parserConfiguration;
+
+ /**
* Creates a new RuntimeInstance object.
*/
public RuntimeInstance()
@@ -320,6 +335,7 @@ public class RuntimeInstance implements
this.runtimeDirectivesShared = null;
this.uberSpect = null;
this.stringInterning = false;
+ this.parserConfiguration = new ParserConfiguration();
/*
* create a VM factory, introspector, and application attributes
@@ -384,6 +400,20 @@ public class RuntimeInstance implements
hyphenAllowedInIdentifiers = getBoolean(PARSER_HYPHEN_ALLOWED, false);
}
+ private char getConfiguredCharacter(String configKey, char defaultChar)
+ {
+ String configuredChar = getString(configKey);
+ if (configuredChar != null)
+ {
+ if (configuredChar.length() != 1)
+ {
+ throw new IllegalArgumentException(String.format("value of
'%s' must be a single character string, but is '%s'", configKey,
configuredChar));
+ }
+ return configuredChar.charAt(0);
+ }
+ return defaultChar;
+ }
+
/**
* Gets the classname for the Uberspect introspection package and
* instantiates an instance.
@@ -1142,6 +1172,29 @@ public class RuntimeInstance implements
private void initializeParserPool()
{
/*
+ * First initialize parser class. If it's not valid or not found, it
will generate an error
+ * later on in this method when parser creation is tester.
+ */
+ String parserClassName = getString(PARSER_CLASS, DEFAULT_PARSER_CLASS);
+ Class parserClass;
+ try
+ {
+ parserClass = ClassUtils.getClass(parserClassName);
+ }
+ catch (ClassNotFoundException cnfe)
+ {
+ throw new VelocityException("parser class not found: " +
parserClassName, cnfe);
+ }
+ try
+ {
+ parserConstructor =
parserClass.getConstructor(RuntimeServices.class);
+ }
+ catch (NoSuchMethodException nsme)
+ {
+ throw new VelocityException("parser class must provide a
constructor taking a RuntimeServices argument", nsme);
+ }
+
+ /*
* Which parser pool?
*/
String pp = getString(RuntimeConstants.PARSER_POOL_CLASS);
@@ -1190,6 +1243,17 @@ public class RuntimeInstance implements
parserPool = (ParserPool) o;
parserPool.initialize(this);
+
+ /*
+ * test parser creation and use generated parser to fill up
customized characters
+ */
+ Parser parser = parserPool.get();
+ parserConfiguration = new ParserConfiguration();
+ parserConfiguration.setDollarChar(parser.dollar());
+ parserConfiguration.setHashChar(parser.hash());
+ parserConfiguration.setAtChar(parser.at());
+ parserConfiguration.setAsteriskChar(parser.asterisk());
+ parserPool.put(parser);
}
else
{
@@ -1215,8 +1279,14 @@ public class RuntimeInstance implements
public Parser createNewParser()
{
requireInitialization();
-
- return new Parser(this);
+ try
+ {
+ return
(Parser)parserConstructor.newInstance((RuntimeServices)this);
+ }
+ catch (IllegalAccessException | InstantiationException |
InvocationTargetException e)
+ {
+ throw new VelocityException("could not build new parser class", e);
+ }
}
/**
@@ -1264,7 +1334,7 @@ public class RuntimeInstance implements
if (keepParser)
{
/* drop the parser Template reference to allow garbage
collection */
- parser.currentTemplate = null;
+ parser.resetCurrentTemplate();
parserPool.put(parser);
}
@@ -1530,7 +1600,7 @@ public class RuntimeInstance implements
}
/* now just create the VM call, and use evaluate */
- StringBuilder template = new StringBuilder("#");
+ StringBuilder template = new
StringBuilder(String.valueOf(parserConfiguration.getHashChar()));
template.append(vmName);
template.append("(");
for (String param : params)
@@ -1904,4 +1974,10 @@ public class RuntimeInstance implements
{
return enabledScopeControls.contains(scopeName);
}
+
+ @Override
+ public ParserConfiguration getParserConfiguration()
+ {
+ return parserConfiguration;
+ }
}
Modified:
velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/RuntimeServices.java
URL:
http://svn.apache.org/viewvc/velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/RuntimeServices.java?rev=1865687&r1=1865686&r2=1865687&view=diff
==============================================================================
---
velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/RuntimeServices.java
(original)
+++
velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/RuntimeServices.java
Thu Aug 22 14:22:58 2019
@@ -489,4 +489,11 @@ public interface RuntimeServices
* @since 2.1
*/
boolean isScopeControlEnabled(String scopeName);
+
+ /**
+ * Get the replacement characters configured for this runtime service's
parser
+ * @return configured replacement characters
+ * @since 2.2
+ */
+ ParserConfiguration getParserConfiguration();
}
Modified:
velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/directive/Macro.java
URL:
http://svn.apache.org/viewvc/velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/directive/Macro.java?rev=1865687&r1=1865686&r2=1865687&view=diff
==============================================================================
---
velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/directive/Macro.java
(original)
+++
velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/directive/Macro.java
Thu Aug 22 14:22:58 2019
@@ -21,8 +21,10 @@ package org.apache.velocity.runtime.dire
import org.apache.velocity.context.InternalContextAdapter;
import org.apache.velocity.exception.TemplateInitException;
+import org.apache.velocity.runtime.RuntimeConstants;
import org.apache.velocity.runtime.RuntimeServices;
import org.apache.velocity.runtime.parser.ParseException;
+import org.apache.velocity.runtime.parser.Parser;
import org.apache.velocity.runtime.parser.Token;
import org.apache.velocity.runtime.parser.node.Node;
import org.apache.velocity.runtime.parser.node.ParserTreeConstants;
@@ -218,9 +220,9 @@ public class Macro extends Directive
// trim off the leading $ for the args after the macro name.
// saves everyone else from having to do it
- if (i > 0 && macroArg.name.startsWith("$"))
+ if (i > 0 &&
macroArg.name.startsWith(String.valueOf(rsvc.getParserConfiguration().getDollarChar())))
{
- macroArg.name = macroArg.name.substring(1,
macroArg.name.length());
+ macroArg.name = macroArg.name.substring(1);
}
macroArgs.add(macroArg);
@@ -230,7 +232,7 @@ public class Macro extends Directive
{
StringBuilder msg = new StringBuilder("Macro.getArgArray():
nbrArgs=");
msg.append(numArgs).append(": ");
- macroToString(msg, macroArgs);
+ macroToString(msg, macroArgs, rsvc);
rsvc.getLog("macro").debug(msg.toString());
}
@@ -267,15 +269,14 @@ public class Macro extends Directive
* has passed in as buf, this method returns it.
* @since 1.5
*/
- public static StringBuilder macroToString(final StringBuilder buf,
- List<MacroArg> macroArgs)
+ public static StringBuilder macroToString(final StringBuilder buf,
List<MacroArg> macroArgs, RuntimeServices rsvc)
{
StringBuilder ret = (buf == null) ? new StringBuilder() : buf;
- ret.append('#').append(macroArgs.get(0).name).append("( ");
+
ret.append(rsvc.getParserConfiguration().getHashChar()).append(macroArgs.get(0).name).append("(
");
for (MacroArg marg : macroArgs)
{
- ret.append("$").append(marg.name);
+
ret.append(rsvc.getParserConfiguration().getDollarChar()).append(marg.name);
if (marg.defaultVal != null)
{
ret.append("=").append(marg.defaultVal);
Modified:
velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/directive/RuntimeMacro.java
URL:
http://svn.apache.org/viewvc/velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/directive/RuntimeMacro.java?rev=1865687&r1=1865686&r2=1865687&view=diff
==============================================================================
---
velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/directive/RuntimeMacro.java
(original)
+++
velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/directive/RuntimeMacro.java
Thu Aug 22 14:22:58 2019
@@ -30,6 +30,7 @@ import org.apache.velocity.runtime.Rende
import org.apache.velocity.runtime.RuntimeConstants;
import org.apache.velocity.runtime.RuntimeConstants.SpaceGobbling;
import org.apache.velocity.runtime.RuntimeServices;
+import org.apache.velocity.runtime.parser.Parser;
import org.apache.velocity.runtime.parser.Token;
import org.apache.velocity.runtime.parser.node.ASTDirective;
import org.apache.velocity.runtime.parser.node.Node;
@@ -140,7 +141,7 @@ public class RuntimeMacro extends Direct
*/
// Tokens can be used here since we are in init() and Tokens have not
been dropped yet
Token t = node.getLastToken();
- if (t.image.startsWith(")") || t.image.startsWith("#end"))
+ if (t.image.startsWith(")") ||
t.image.startsWith(rsvc.getParserConfiguration().getHashChar() + "end"))
{
strictRef =
rsvc.getBoolean(RuntimeConstants.RUNTIME_REFERENCES_STRICT, false);
}
@@ -194,7 +195,7 @@ public class RuntimeMacro extends Direct
int pos = -1;
while (t != null && t != node.getLastToken())
{
- if (pos == -1) pos = t.image.lastIndexOf('#');
+ if (pos == -1) pos =
t.image.lastIndexOf(rsvc.getParserConfiguration().getHashChar());
if (pos != -1)
{
buffer.append(t.image.substring(pos));
@@ -209,7 +210,7 @@ public class RuntimeMacro extends Direct
if (t != null)
{
- if (pos == -1) pos = t.image.lastIndexOf('#');
+ if (pos == -1) pos =
t.image.lastIndexOf(rsvc.getParserConfiguration().getHashChar());
if (pos != -1)
{
buffer.append(t.image.substring(pos));
Modified:
velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/directive/Scope.java
URL:
http://svn.apache.org/viewvc/velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/directive/Scope.java?rev=1865687&r1=1865686&r2=1865687&view=diff
==============================================================================
---
velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/directive/Scope.java
(original)
+++
velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/directive/Scope.java
Thu Aug 22 14:22:58 2019
@@ -20,6 +20,7 @@ package org.apache.velocity.runtime.dire
*/
import org.apache.velocity.Template;
+import org.apache.velocity.runtime.parser.Parser;
import java.util.AbstractMap;
import java.util.HashMap;
@@ -326,7 +327,7 @@ public class Scope extends AbstractMap
StringBuilder sb = new StringBuilder();
if (directive != null)
{
- sb.append('#');
+ sb.append('#'); // parser characters substitution is not
handled here
}
sb.append(getName());
sb.append("[type:").append(getType());
Modified:
velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/parser/node/ASTComment.java
URL:
http://svn.apache.org/viewvc/velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/parser/node/ASTComment.java?rev=1865687&r1=1865686&r2=1865687&view=diff
==============================================================================
---
velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/parser/node/ASTComment.java
(original)
+++
velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/parser/node/ASTComment.java
Thu Aug 22 14:22:58 2019
@@ -76,8 +76,8 @@ public class ASTComment extends SimpleNo
{
Token t = getFirstToken();
- int loc1 = t.image.indexOf("##");
- int loc2 = t.image.indexOf("#*");
+ int loc1 = t.image.indexOf(parser.lineComment());
+ int loc2 = t.image.indexOf(parser.blockComment());
if (loc1 == -1 && loc2 == -1)
{
Modified:
velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/parser/node/ASTDirective.java
URL:
http://svn.apache.org/viewvc/velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/parser/node/ASTDirective.java?rev=1865687&r1=1865686&r2=1865687&view=diff
==============================================================================
---
velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/parser/node/ASTDirective.java
(original)
+++
velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/parser/node/ASTDirective.java
Thu Aug 22 14:22:58 2019
@@ -29,10 +29,9 @@ import org.apache.velocity.runtime.Runti
import org.apache.velocity.runtime.directive.BlockMacro;
import org.apache.velocity.runtime.directive.Directive;
import org.apache.velocity.runtime.directive.RuntimeMacro;
-import org.apache.velocity.runtime.parser.LogContext;
import org.apache.velocity.runtime.parser.ParseException;
import org.apache.velocity.runtime.parser.Parser;
-import org.apache.velocity.runtime.parser.ParserConstants;
+import org.apache.velocity.runtime.parser.StandardParserConstants;
import org.apache.velocity.runtime.parser.Token;
import org.apache.velocity.util.introspection.Info;
@@ -113,7 +112,7 @@ public class ASTDirective extends Simple
*/
t = getFirstToken();
int pos = -1;
- while (t != null && (pos = t.image.lastIndexOf('#')) == -1)
+ while (t != null && (pos =
t.image.lastIndexOf(rsvc.getParserConfiguration().getHashChar())) == -1)
{
t = t.next;
}
@@ -144,11 +143,11 @@ public class ASTDirective extends Simple
}
t = getFirstToken();
- if (t.kind == ParserConstants.WHITESPACE) t = t.next;
+ if (t.kind == StandardParserConstants.WHITESPACE) t = t.next;
directive.setLocation(t.beginLine, t.beginColumn,
getTemplate());
directive.init(rsvc, context, this);
}
- else if( directiveName.startsWith("@") )
+ else if(
directiveName.startsWith(String.valueOf(rsvc.getParserConfiguration().getAtChar()))
)
{
if( this.jjtGetNumChildren() > 0 )
{
@@ -313,7 +312,7 @@ public class ASTDirective extends Simple
{
writer.write(prefix);
writer.write(morePrefix);
- writer.write( "#");
+ writer.write(rsvc.getParserConfiguration().getHashChar());
writer.write(directiveName);
writer.write(postfix);
}
Modified:
velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/parser/node/ASTIfStatement.java
URL:
http://svn.apache.org/viewvc/velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/parser/node/ASTIfStatement.java?rev=1865687&r1=1865686&r2=1865687&view=diff
==============================================================================
---
velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/parser/node/ASTIfStatement.java
(original)
+++
velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/parser/node/ASTIfStatement.java
Thu Aug 22 14:22:58 2019
@@ -93,7 +93,7 @@ public class ASTIfStatement extends Simp
*/
Token t = getFirstToken();
int pos = -1;
- while (t != null && (pos = t.image.lastIndexOf('#')) == -1)
+ while (t != null && (pos =
t.image.lastIndexOf(rsvc.getParserConfiguration().getHashChar())) == -1)
{
t = t.next;
}
Modified:
velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/parser/node/ASTReference.java
URL:
http://svn.apache.org/viewvc/velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/parser/node/ASTReference.java?rev=1865687&r1=1865686&r2=1865687&view=diff
==============================================================================
---
velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/parser/node/ASTReference.java
(original)
+++
velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/parser/node/ASTReference.java
Thu Aug 22 14:22:58 2019
@@ -322,7 +322,7 @@ public class ASTReference extends Simple
(!onlyTestingReference ||
warnInvalidTestedReferences)))
{
result = EventHandlerUtil.invalidGetMethod(rsvc, context,
- "$" + rootString, null, null, uberInfo);
+ rsvc.getParserConfiguration().getDollarChar() +
rootString, null, null, uberInfo);
}
return result;
@@ -388,7 +388,7 @@ public class ASTReference extends Simple
(!onlyTestingReference ||
warnInvalidTestedReferences || numChildren > 0))
{
result = EventHandlerUtil.invalidGetMethod(rsvc,
context,
- "$" + rootString, previousResult, null,
uberInfo);
+
rsvc.getParserConfiguration().getDollarChar() + rootString, previousResult,
null, uberInfo);
}
}
else
@@ -402,7 +402,7 @@ public class ASTReference extends Simple
(referenceType != QUIET_REFERENCE ||
warnInvalidQuietReferences) &&
(!onlyTestingReference ||
warnInvalidTestedReferences || failedChild < numChildren - 1))
{
- StringBuilder name = new
StringBuilder("$").append(rootString);
+ StringBuilder name = new
StringBuilder(String.valueOf(rsvc.getParserConfiguration().getDollarChar())).append(rootString);
for (int i = 0; i <= failedChild; i++)
{
Node node = jjtGetChild(i);
@@ -953,7 +953,7 @@ public class ASTReference extends Simple
int i = 0;
int len = t.image.length();
- i = t.image.indexOf('$');
+ i = t.image.indexOf(rsvc.getParserConfiguration().getDollarChar());
if (i == -1)
{
@@ -1037,7 +1037,7 @@ public class ASTReference extends Simple
* last $
*/
- int loc1 = t.image.lastIndexOf('$');
+ int loc1 =
t.image.lastIndexOf(rsvc.getParserConfiguration().getDollarChar());
/*
* if we have extra stuff, loc > 0
Modified:
velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/parser/node/ASTSetDirective.java
URL:
http://svn.apache.org/viewvc/velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/parser/node/ASTSetDirective.java?rev=1865687&r1=1865686&r2=1865687&view=diff
==============================================================================
---
velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/parser/node/ASTSetDirective.java
(original)
+++
velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/parser/node/ASTSetDirective.java
Thu Aug 22 14:22:58 2019
@@ -115,7 +115,7 @@ public class ASTSetDirective extends Sim
*/
Token t = getFirstToken();
int pos = -1;
- while (t != null && (pos = t.image.lastIndexOf('#')) == -1)
+ while (t != null && (pos =
t.image.lastIndexOf(rsvc.getParserConfiguration().getHashChar())) == -1)
{
t = t.next;
}
Modified:
velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/parser/node/ASTStringLiteral.java
URL:
http://svn.apache.org/viewvc/velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/parser/node/ASTStringLiteral.java?rev=1865687&r1=1865686&r2=1865687&view=diff
==============================================================================
---
velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/parser/node/ASTStringLiteral.java
(original)
+++
velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/parser/node/ASTStringLiteral.java
Thu Aug 22 14:22:58 2019
@@ -96,8 +96,8 @@ public class ASTStringLiteral extends Si
interpolate = rsvc.getBoolean(
RuntimeConstants.INTERPOLATE_STRINGLITERALS, true)
&& getFirstToken().image.startsWith("\"")
- && ((getFirstToken().image.indexOf('$') != -1) ||
(getFirstToken().image
- .indexOf('#') != -1));
+ &&
((getFirstToken().image.indexOf(rsvc.getParserConfiguration().getDollarChar())
!= -1) || (getFirstToken().image
+ .indexOf(rsvc.getParserConfiguration().getHashChar())
!= -1));
/*
* get the contents of the string, minus the '/" at each end
Modified:
velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/parser/node/ASTText.java
URL:
http://svn.apache.org/viewvc/velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/parser/node/ASTText.java?rev=1865687&r1=1865686&r2=1865687&view=diff
==============================================================================
---
velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/parser/node/ASTText.java
(original)
+++
velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/parser/node/ASTText.java
Thu Aug 22 14:22:58 2019
@@ -96,9 +96,9 @@ public class ASTText extends SimpleNode
Token t = getFirstToken();
for (; t != getLastToken(); t = t.next)
{
- builder.append(NodeUtils.tokenLiteral(t));
+ builder.append(NodeUtils.tokenLiteral(parser, t));
}
- builder.append(NodeUtils.tokenLiteral(t));
+ builder.append(NodeUtils.tokenLiteral(parser, t));
ctext = builder.toString();
cleanupParserAndTokens();
Modified:
velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/parser/node/ASTTextblock.java
URL:
http://svn.apache.org/viewvc/velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/parser/node/ASTTextblock.java?rev=1865687&r1=1865686&r2=1865687&view=diff
==============================================================================
---
velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/parser/node/ASTTextblock.java
(original)
+++
velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/parser/node/ASTTextblock.java
Thu Aug 22 14:22:58 2019
@@ -35,25 +35,19 @@ import java.io.Writer;
*/
public class ASTTextblock extends SimpleNode
{
- public static final String START = "#[[";
- public static final String END = "]]#";
+ public final String START;
+ public final String END;
private char[] ctext;
/**
- * @param id
- */
- public ASTTextblock(int id)
- {
- super(id);
- }
-
- /**
* @param p
* @param id
*/
public ASTTextblock(Parser p, int id)
{
super(p, id);
+ START = parser.hash() + "[[";
+ END = "]]" + parser.hash();
}
/**
Modified:
velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/parser/node/Node.java
URL:
http://svn.apache.org/viewvc/velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/parser/node/Node.java?rev=1865687&r1=1865686&r2=1865687&view=diff
==============================================================================
---
velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/parser/node/Node.java
(original)
+++
velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/parser/node/Node.java
Thu Aug 22 14:22:58 2019
@@ -26,6 +26,7 @@ import org.apache.velocity.exception.Par
import org.apache.velocity.exception.ResourceNotFoundException;
import org.apache.velocity.exception.TemplateInitException;
import org.apache.velocity.runtime.Renderable;
+import org.apache.velocity.runtime.parser.Parser;
import org.apache.velocity.runtime.parser.Token;
import java.io.IOException;
@@ -221,4 +222,10 @@ public interface Node extends Renderable
* @return the template this node belongs to
*/
Template getTemplate();
+
+ /**
+ * @return the parser which generated this node
+ * @since 2.2
+ */
+ Parser getParser();
}
Modified:
velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/parser/node/NodeUtils.java
URL:
http://svn.apache.org/viewvc/velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/parser/node/NodeUtils.java?rev=1865687&r1=1865686&r2=1865687&view=diff
==============================================================================
---
velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/parser/node/NodeUtils.java
(original)
+++
velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/parser/node/NodeUtils.java
Thu Aug 22 14:22:58 2019
@@ -19,7 +19,8 @@ package org.apache.velocity.runtime.pars
* under the License.
*/
-import org.apache.velocity.runtime.parser.ParserConstants;
+import org.apache.velocity.runtime.parser.Parser;
+import org.apache.velocity.runtime.parser.StandardParserConstants;
import org.apache.velocity.runtime.parser.Token;
/**
@@ -43,7 +44,7 @@ public class NodeUtils
* @return StrBuilder with the special tokens.
* @since 2.0.0
*/
- public static StringBuilder getSpecialText(Token t)
+ public static StringBuilder getSpecialText(Parser parser, Token t)
{
StringBuilder sb = new StringBuilder();
@@ -62,7 +63,7 @@ public class NodeUtils
{
char c = st.charAt(i);
- if ( c == '#' || c == '$' )
+ if ( c == parser.hash() || c == parser.dollar() )
{
sb.append( c );
}
@@ -90,7 +91,7 @@ public class NodeUtils
*/
continue;
}
- else if( cc == '$' )
+ else if( cc == parser.dollar() )
{
/*
* a $ ends it correctly
@@ -126,20 +127,20 @@ public class NodeUtils
* @param t
* @return A node literal.
*/
- public static String tokenLiteral( Token t )
+ public static String tokenLiteral( Parser parser, Token t )
{
- // Look at kind of token and return "" when it's a multiline comment
- if (t.kind == ParserConstants.MULTI_LINE_COMMENT)
+ // Look at kind of token and return "" when it's a block comment
+ if (t.kind == StandardParserConstants.MULTI_LINE_COMMENT)
{
return "";
}
- else if (t.specialToken == null ||
t.specialToken.image.startsWith("##"))
+ else if (t.specialToken == null ||
t.specialToken.image.startsWith(parser.lineComment()))
{
return t.image;
}
else
{
- StringBuilder special = getSpecialText(t);
+ StringBuilder special = getSpecialText(parser, t);
if (special.length() > 0)
{
return special.append(t.image).toString();
Modified:
velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/parser/node/SimpleNode.java
URL:
http://svn.apache.org/viewvc/velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/parser/node/SimpleNode.java?rev=1865687&r1=1865686&r2=1865687&view=diff
==============================================================================
---
velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/parser/node/SimpleNode.java
(original)
+++
velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/parser/node/SimpleNode.java
Thu Aug 22 14:22:58 2019
@@ -128,7 +128,7 @@ public class SimpleNode implements Node
{
this(i);
parser = p;
- template = parser.currentTemplate;
+ template = parser.getCurrentTemplate();
}
/**
@@ -352,16 +352,16 @@ public class SimpleNode implements Node
// buffer allocation. VELOCITY-606
if (first == last)
{
- literal = NodeUtils.tokenLiteral(first);
+ literal = NodeUtils.tokenLiteral(parser, first);
return literal;
}
Token t = first;
- StringBuilder sb = new StringBuilder(NodeUtils.tokenLiteral(t));
+ StringBuilder sb = new StringBuilder(NodeUtils.tokenLiteral(parser,
t));
while (t != last)
{
t = t.next;
- sb.append(NodeUtils.tokenLiteral(t));
+ sb.append(NodeUtils.tokenLiteral(parser, t));
}
literal = sb.toString();
return literal;
@@ -570,4 +570,13 @@ public class SimpleNode implements Node
}
public Template getTemplate() { return template; }
+
+ /**
+ * @return the parser which created this node
+ * @since 2.2
+ */
+ public Parser getParser()
+ {
+ return parser;
+ }
}
Modified:
velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/visitor/NodeViewMode.java
URL:
http://svn.apache.org/viewvc/velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/visitor/NodeViewMode.java?rev=1865687&r1=1865686&r2=1865687&view=diff
==============================================================================
---
velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/visitor/NodeViewMode.java
(original)
+++
velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/visitor/NodeViewMode.java
Thu Aug 22 14:22:58 2019
@@ -19,6 +19,7 @@ package org.apache.velocity.runtime.visi
* under the License.
*/
+import org.apache.velocity.runtime.parser.Parser;
import org.apache.velocity.runtime.parser.Token;
import org.apache.velocity.runtime.parser.node.*;
@@ -66,7 +67,7 @@ public class NodeViewMode extends BaseVi
// TODO: Token reference
t = node.getFirstToken();
- if (t.specialToken != null && !
t.specialToken.image.startsWith("##"))
+ if (t.specialToken != null && !
t.specialToken.image.startsWith(node.getParser().lineComment()))
special = t.specialToken.image;
tokens = " -> " + special + t.image;
Propchange: velocity/engine/trunk/velocity-engine-core/src/test/java/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Thu Aug 22 14:22:58 2019
@@ -3,5 +3,6 @@
/velocity/engine/branches/VELOCITY-892/velocity-engine-core/src/test/java:1844076-1854372
/velocity/engine/branches/VELOCITY-898/velocity-engine-core/src/test/java:1843220-1843786
/velocity/engine/branches/VELOCITY-909/velocity-engine-core/src/test/java:1854851-1855185
+/velocity/engine/branches/parser_experiments/velocity-engine-core/src/test/java:1860001-1865676
/velocity/engine/trunk/src/test:1032134
/velocity/engine/trunk/velocity-engine-core/src/test/java:992133,1032159
Modified:
velocity/engine/trunk/velocity-engine-core/src/test/java/org/apache/velocity/test/TextblockTestCase.java
URL:
http://svn.apache.org/viewvc/velocity/engine/trunk/velocity-engine-core/src/test/java/org/apache/velocity/test/TextblockTestCase.java?rev=1865687&r1=1865686&r2=1865687&view=diff
==============================================================================
---
velocity/engine/trunk/velocity-engine-core/src/test/java/org/apache/velocity/test/TextblockTestCase.java
(original)
+++
velocity/engine/trunk/velocity-engine-core/src/test/java/org/apache/velocity/test/TextblockTestCase.java
Thu Aug 22 14:22:58 2019
@@ -19,8 +19,12 @@ package org.apache.velocity.test;
* under the License.
*/
+import org.apache.velocity.runtime.RuntimeInstance;
+import org.apache.velocity.runtime.parser.Parser;
import org.apache.velocity.runtime.parser.node.ASTTextblock;
+import java.lang.reflect.Field;
+
/**
* This class tests the Textblock directive.
*/
@@ -28,12 +32,12 @@ public class TextblockTestCase extends B
{
// these are all here so that the test case adapts instantly
// to changes in the textblock start/end sequences
- private static final String START = ASTTextblock.START;
- private static final String END = ASTTextblock.END;
- private static final String PARTIAL_START = START.substring(0,
START.length() - 1);
- private static final String PARTIAL_END = END.substring(1, END.length());
- private static final String END_OF_START = START.substring(START.length()
- 1, START.length());
- private static final String START_OF_END = END.substring(0, 1);
+ private String START = null;
+ private String END = null;
+ private String PARTIAL_START = null;
+ private String PARTIAL_END = null;
+ private String END_OF_START = null;
+ private String START_OF_END = null;
public TextblockTestCase(String name)
{
@@ -41,6 +45,25 @@ public class TextblockTestCase extends B
//DEBUG = true;
}
+ @Override
+ protected void setUp() throws Exception
+ {
+ super.setUp();
+
+ // get a valid parser instance to initialize string constants
+ Field riField = engine.getClass().getDeclaredField("ri");
+ riField.setAccessible(true);
+ RuntimeInstance ri = (RuntimeInstance)riField.get(engine);
+ Parser parser = ri.createNewParser();
+ ASTTextblock astTextblock = new ASTTextblock(parser, 0);
+ START = astTextblock.START;
+ END = astTextblock.END;
+ PARTIAL_START = START.substring(0, START.length() - 1);
+ PARTIAL_END = END.substring(1);
+ END_OF_START = START.substring(START.length() - 1);
+ START_OF_END = END.substring(0, 1);
+ }
+
public String textblock(String s)
{
return START + s + END;