You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@velocity.apache.org by cb...@apache.org on 2019/06/01 10:47:34 UTC
svn commit: r1860475 - in
/velocity/engine/branches/parser_experiments/velocity-engine-core: pom.xml
src/main/java/org/apache/velocity/runtime/parser/ParserTokenManager.java
src/main/parser/StandardParser.jjt
Author: cbrisson
Date: Sat Jun 1 10:47:34 2019
New Revision: 1860475
URL: http://svn.apache.org/viewvc?rev=1860475&view=rev
Log:
[engine][VELOCITY-917] Patching javacc generated sources so that they use the ParserTokenManager interface
Modified:
velocity/engine/branches/parser_experiments/velocity-engine-core/pom.xml
velocity/engine/branches/parser_experiments/velocity-engine-core/src/main/java/org/apache/velocity/runtime/parser/ParserTokenManager.java
velocity/engine/branches/parser_experiments/velocity-engine-core/src/main/parser/StandardParser.jjt
Modified: velocity/engine/branches/parser_experiments/velocity-engine-core/pom.xml
URL: http://svn.apache.org/viewvc/velocity/engine/branches/parser_experiments/velocity-engine-core/pom.xml?rev=1860475&r1=1860474&r2=1860475&view=diff
==============================================================================
--- velocity/engine/branches/parser_experiments/velocity-engine-core/pom.xml (original)
+++ velocity/engine/branches/parser_experiments/velocity-engine-core/pom.xml Sat Jun 1 10:47:34 2019
@@ -181,6 +181,71 @@
<tokenManagerUsesParser>true</tokenManagerUsesParser>
</configuration>
</plugin>
+ <!--
+ patch generated parser and token managers files, so that
+ + StandardParserTokenManager implements the ParserTokenManager interface
+ + StandardParser uses the ParserTokenManager interface
+ -->
+ <plugin>
+ <groupId>com.google.code.maven-replacer-plugin</groupId>
+ <artifactId>replacer</artifactId>
+ <version>1.5.3</version>
+ <executions>
+ <execution>
+ <id>patch-token-manager</id>
+ <phase>process-sources</phase>
+ <goals>
+ <goal>replace</goal>
+ </goals>
+ <configuration>
+ <file>${project.build.directory}/generated-sources/javacc/org/apache/velocity/runtime/parser/StandardParser.java</file>
+ <replacements>
+ <replacement>
+ <token>(?<!new )StandardParserTokenManager</token>
+ <value>ParserTokenManager</value>
+ </replacement>
+ </replacements>
+ </configuration>
+ </execution>
+ <execution>
+ <phase>process-sources</phase>
+ <goals>
+ <goal>replace</goal>
+ </goals>
+ <configuration>
+ <file>${project.build.directory}/generated-sources/javacc/org/apache/velocity/runtime/parser/StandardParserTokenManager.java</file>
+ <replacements>
+ <replacement>
+ <token>class StandardParserTokenManager implements StandardParserConstants</token>
+ <value>class StandardParserTokenManager implements StandardParserConstants, ParserTokenManager</value>
+ </replacement>
+ </replacements>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ <plugin>
+ <groupId>com.google.code.maven-replacer-plugin</groupId>
+ <artifactId>replacer</artifactId>
+ <version>1.5.3</version>
+ <executions>
+ <execution>
+ <phase>process-sources</phase>
+ <goals>
+ <goal>replace</goal>
+ </goals>
+ </execution>
+ </executions>
+ <configuration>
+ <file>${project.build.directory}/generated-sources/javacc/org/apache/velocity/runtime/parser/StandardParser.java</file>
+ <replacements>
+ <replacement>
+ <token>(?<!new )StandardParserTokenManager</token>
+ <value>ParserTokenManager</value>
+ </replacement>
+ </replacements>
+ </configuration>
+ </plugin>
<plugin>
<groupId>org.apache.felix</groupId>
<artifactId>maven-bundle-plugin</artifactId>
Modified: velocity/engine/branches/parser_experiments/velocity-engine-core/src/main/java/org/apache/velocity/runtime/parser/ParserTokenManager.java
URL: http://svn.apache.org/viewvc/velocity/engine/branches/parser_experiments/velocity-engine-core/src/main/java/org/apache/velocity/runtime/parser/ParserTokenManager.java?rev=1860475&r1=1860474&r2=1860475&view=diff
==============================================================================
--- velocity/engine/branches/parser_experiments/velocity-engine-core/src/main/java/org/apache/velocity/runtime/parser/ParserTokenManager.java (original)
+++ velocity/engine/branches/parser_experiments/velocity-engine-core/src/main/java/org/apache/velocity/runtime/parser/ParserTokenManager.java Sat Jun 1 10:47:34 2019
@@ -2,5 +2,14 @@ package org.apache.velocity.runtime.pars
public interface ParserTokenManager
{
-
+ void clearStateVars();
+ void switchTo(int lexState);
+ int getCurrentLexicalState();
+ boolean stateStackPop();
+ boolean stateStackPush();
+ public Token getNextToken();
+ void setDebugStream(java.io.PrintStream ds);
+ boolean isInSet();
+ void setInSet(boolean value);
+ void ReInit(CharStream charStream);
}
Modified: velocity/engine/branches/parser_experiments/velocity-engine-core/src/main/parser/StandardParser.jjt
URL: http://svn.apache.org/viewvc/velocity/engine/branches/parser_experiments/velocity-engine-core/src/main/parser/StandardParser.jjt?rev=1860475&r1=1860474&r2=1860475&view=diff
==============================================================================
--- velocity/engine/branches/parser_experiments/velocity-engine-core/src/main/parser/StandardParser.jjt (original)
+++ velocity/engine/branches/parser_experiments/velocity-engine-core/src/main/parser/StandardParser.jjt Sat Jun 1 10:47:34 2019
@@ -480,7 +480,7 @@ public class StandardParser implements P
private boolean isAssignment()
{
// Basically if the last character read was not '$' then false
- if (token_source.curLexState != REFERENCE) return false;
+ if (token_source.getCurrentLexicalState() != REFERENCE) return false;
char c = ' ';
int backup = 0;
@@ -561,7 +561,7 @@ TOKEN_MGR_DECLS:
List stateStack = new ArrayList(50);
private boolean inComment;
- public boolean inSet;
+ private boolean inSet;
public char dollar = '$';
public char hash = '#';
@@ -586,6 +586,11 @@ TOKEN_MGR_DECLS:
SwitchTo(lexState);
}
+ public int getCurrentLexicalState()
+ {
+ return curLexState;
+ }
+
/**
* pops a state off the stack, and restores paren counts
*
@@ -660,6 +665,16 @@ TOKEN_MGR_DECLS:
return;
}
+ public void setInSet(boolean value)
+ {
+ inSet = value;
+ }
+
+ public boolean isInSet()
+ {
+ return inSet;
+ }
+
/**
* Holds the state of the parsing process.
*/
@@ -922,7 +937,7 @@ TOKEN:
trace(" #set : going to DIRECTIVE" );
stateStackPush();
- inSet = true;
+ setInSet(true);
switchTo(DIRECTIVE);
}
@@ -1185,8 +1200,8 @@ TOKEN:
{
trace(" NEWLINE :");
- if (inSet)
- inSet = false;
+ /* if (isInSet()) */
+ setInSet(false);
}
}
@@ -1238,7 +1253,7 @@ TOKEN :
* - finally, if we are in REFMOD2 (remember : $foo.bar( ) then " is ok!
*/
- if( curLexState == DIRECTIVE && !inSet && lparen == 0)
+ if( curLexState == DIRECTIVE && !isInSet() && lparen == 0)
stateStackPop();
}
}
@@ -1324,7 +1339,7 @@ TOKEN:
* because we want to handle the \n after
*/
- if ( lparen == 0 && !inSet && curLexState != REFMOD2 && curLexState != REFINDEX && curLexState != ALT_VAL)
+ if ( lparen == 0 && !isInSet() && curLexState != REFMOD2 && curLexState != REFINDEX && curLexState != ALT_VAL)
{
stateStackPop();
}
@@ -1342,7 +1357,7 @@ TOKEN:
* because we want to handle the \n after
*/
- if ( lparen == 0 && !inSet && curLexState != REFMOD2 && curLexState != ALT_VAL)
+ if ( lparen == 0 && !isInSet() && curLexState != REFMOD2 && curLexState != ALT_VAL)
{
stateStackPop();
}
@@ -2379,7 +2394,7 @@ boolean SetDirective(boolean afterNewlin
* ensure that inSet is false. Leads to some amusing bugs...
*/
- token_source.inSet = false;
+ token_source.setInSet(false);
}
[
LOOKAHEAD(2, { afterNewline || rsvc.getSpaceGobbling() == SpaceGobbling.BC } )