jvanzyl 00/09/30 15:58:15
Modified: src/java/org/apache/velocity/runtime Runtime.java
src/java/org/apache/velocity/runtime/parser
ASTDirective.java Parser.java Parser.jj Parser.jjt
Log:
- update for velocity service in turbine.
Revision Changes Path
1.3 +1 -1
jakarta-velocity/src/java/org/apache/velocity/runtime/Runtime.java
Index: Runtime.java
===================================================================
RCS file:
/home/cvs/jakarta-velocity/src/java/org/apache/velocity/runtime/Runtime.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- Runtime.java 2000/09/30 22:34:00 1.2
+++ Runtime.java 2000/09/30 22:58:13 1.3
@@ -173,7 +173,7 @@
return parser.parse(inputStream);
}
- public void initTemplateLoader()
+ public static void initTemplateLoader()
{
templateLoader.init();
}
1.2 +5 -1
jakarta-velocity/src/java/org/apache/velocity/runtime/parser/ASTDirective.java
Index: ASTDirective.java
===================================================================
RCS file:
/home/cvs/jakarta-velocity/src/java/org/apache/velocity/runtime/parser/ASTDirective.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- ASTDirective.java 2000/09/30 17:04:24 1.1
+++ ASTDirective.java 2000/09/30 22:58:14 1.2
@@ -30,6 +30,10 @@
throws IOException
{
String directive = getFirstToken().image.substring(1);
- parser.getDirective(directive).render(context, writer, this);
+
+ if (parser.isDirective(directive))
+ parser.getDirective(directive).render(context, writer, this);
+ else
+ writer.write(getFirstToken().image);
}
}
1.2 +92 -77
jakarta-velocity/src/java/org/apache/velocity/runtime/parser/Parser.java
Index: Parser.java
===================================================================
RCS file:
/home/cvs/jakarta-velocity/src/java/org/apache/velocity/runtime/parser/Parser.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- Parser.java 2000/09/30 17:04:26 1.1
+++ Parser.java 2000/09/30 22:58:14 1.2
@@ -16,7 +16,7 @@
* what controls the generation of this class.
*
* @author <a href="mailto:[EMAIL PROTECTED]">Jason van Zyl</a>
- * @version $Id: Parser.java,v 1.1 2000/09/30 17:04:26 jvanzyl Exp $
+ * @version $Id: Parser.java,v 1.2 2000/09/30 22:58:14 jvanzyl Exp $
*/
public class Parser/*@bgen(jjtree)*/implements ParserTreeConstants, ParserConstants
{/*@bgen(jjtree)*/
protected JJTParserState jjtree = new JJTParserState();
@@ -67,6 +67,14 @@
return (Directive) directives.get(directive);
}
+ public boolean isDirective(String directive)
+ {
+ if (directives.containsKey(directive))
+ return true;
+ else
+ return false;
+ }
+
/**
* This method is what starts the whole parsing
* process. After the parsing is complete and
@@ -314,6 +322,13 @@
try {
t = jj_consume_token(WORD);
d = (Directive) directives.get(t.image.substring(1));
+
+ if (d == null)
+ {
+ token_source.SwitchTo(DEFAULT);
+ {if (true) return jjtn000;}
+ }
+
args = d.getArgs();
DirectiveArgs(args);
if (d.getType() == Directive.LINE)
@@ -1631,70 +1646,6 @@
return retval;
}
- final private boolean jj_3R_52() {
- if (jj_3R_55()) return true;
- if (jj_la == 0 && jj_scanpos == jj_lastpos) return false;
- Token xsp;
- while (true) {
- xsp = jj_scanpos;
- if (jj_3R_56()) { jj_scanpos = xsp; break; }
- if (jj_la == 0 && jj_scanpos == jj_lastpos) return false;
- }
- return false;
- }
-
- final private boolean jj_3_2() {
- if (jj_3R_17()) return true;
- if (jj_la == 0 && jj_scanpos == jj_lastpos) return false;
- return false;
- }
-
- final private boolean jj_3R_53() {
- if (jj_scan_token(LOGICAL_AND)) return true;
- if (jj_la == 0 && jj_scanpos == jj_lastpos) return false;
- if (jj_3R_52()) return true;
- if (jj_la == 0 && jj_scanpos == jj_lastpos) return false;
- return false;
- }
-
- final private boolean jj_3R_50() {
- if (jj_3R_52()) return true;
- if (jj_la == 0 && jj_scanpos == jj_lastpos) return false;
- Token xsp;
- while (true) {
- xsp = jj_scanpos;
- if (jj_3R_53()) { jj_scanpos = xsp; break; }
- if (jj_la == 0 && jj_scanpos == jj_lastpos) return false;
- }
- return false;
- }
-
- final private boolean jj_3R_20() {
- if (jj_3R_28()) return true;
- if (jj_la == 0 && jj_scanpos == jj_lastpos) return false;
- Token xsp;
- while (true) {
- xsp = jj_scanpos;
- if (jj_3R_54()) { jj_scanpos = xsp; break; }
- if (jj_la == 0 && jj_scanpos == jj_lastpos) return false;
- }
- return false;
- }
-
- final private boolean jj_3R_19() {
- if (jj_scan_token(IDENTIFIER)) return true;
- if (jj_la == 0 && jj_scanpos == jj_lastpos) return false;
- return false;
- }
-
- final private boolean jj_3R_51() {
- if (jj_scan_token(LOGICAL_OR)) return true;
- if (jj_la == 0 && jj_scanpos == jj_lastpos) return false;
- if (jj_3R_50()) return true;
- if (jj_la == 0 && jj_scanpos == jj_lastpos) return false;
- return false;
- }
-
final private boolean jj_3R_34() {
if (jj_scan_token(FALSE)) return true;
if (jj_la == 0 && jj_scanpos == jj_lastpos) return false;
@@ -1721,6 +1672,12 @@
return false;
}
+ final private boolean jj_3R_19() {
+ if (jj_scan_token(IDENTIFIER)) return true;
+ if (jj_la == 0 && jj_scanpos == jj_lastpos) return false;
+ return false;
+ }
+
final private boolean jj_3R_33() {
if (jj_scan_token(TRUE)) return true;
if (jj_la == 0 && jj_scanpos == jj_lastpos) return false;
@@ -1779,12 +1736,6 @@
return false;
}
- final private boolean jj_3R_29() {
- if (jj_scan_token(STRING_LITERAL)) return true;
- if (jj_la == 0 && jj_scanpos == jj_lastpos) return false;
- return false;
- }
-
final private boolean jj_3R_41() {
if (jj_scan_token(SHORTHAND)) return true;
if (jj_la == 0 && jj_scanpos == jj_lastpos) return false;
@@ -1817,12 +1768,6 @@
return false;
}
- final private boolean jj_3R_30() {
- if (jj_scan_token(NUMBER_LITERAL)) return true;
- if (jj_la == 0 && jj_scanpos == jj_lastpos) return false;
- return false;
- }
-
final private boolean jj_3R_17() {
if (jj_3R_19()) return true;
if (jj_la == 0 && jj_scanpos == jj_lastpos) return false;
@@ -1837,6 +1782,18 @@
return false;
}
+ final private boolean jj_3R_29() {
+ if (jj_scan_token(STRING_LITERAL)) return true;
+ if (jj_la == 0 && jj_scanpos == jj_lastpos) return false;
+ return false;
+ }
+
+ final private boolean jj_3R_30() {
+ if (jj_scan_token(NUMBER_LITERAL)) return true;
+ if (jj_la == 0 && jj_scanpos == jj_lastpos) return false;
+ return false;
+ }
+
final private boolean jj_3R_40() {
if (jj_3R_31()) return true;
if (jj_la == 0 && jj_scanpos == jj_lastpos) return false;
@@ -2205,6 +2162,64 @@
if (jj_scan_token(COMMA)) return true;
if (jj_la == 0 && jj_scanpos == jj_lastpos) return false;
if (jj_3R_28()) return true;
+ if (jj_la == 0 && jj_scanpos == jj_lastpos) return false;
+ return false;
+ }
+
+ final private boolean jj_3R_52() {
+ if (jj_3R_55()) return true;
+ if (jj_la == 0 && jj_scanpos == jj_lastpos) return false;
+ Token xsp;
+ while (true) {
+ xsp = jj_scanpos;
+ if (jj_3R_56()) { jj_scanpos = xsp; break; }
+ if (jj_la == 0 && jj_scanpos == jj_lastpos) return false;
+ }
+ return false;
+ }
+
+ final private boolean jj_3_2() {
+ if (jj_3R_17()) return true;
+ if (jj_la == 0 && jj_scanpos == jj_lastpos) return false;
+ return false;
+ }
+
+ final private boolean jj_3R_53() {
+ if (jj_scan_token(LOGICAL_AND)) return true;
+ if (jj_la == 0 && jj_scanpos == jj_lastpos) return false;
+ if (jj_3R_52()) return true;
+ if (jj_la == 0 && jj_scanpos == jj_lastpos) return false;
+ return false;
+ }
+
+ final private boolean jj_3R_50() {
+ if (jj_3R_52()) return true;
+ if (jj_la == 0 && jj_scanpos == jj_lastpos) return false;
+ Token xsp;
+ while (true) {
+ xsp = jj_scanpos;
+ if (jj_3R_53()) { jj_scanpos = xsp; break; }
+ if (jj_la == 0 && jj_scanpos == jj_lastpos) return false;
+ }
+ return false;
+ }
+
+ final private boolean jj_3R_20() {
+ if (jj_3R_28()) return true;
+ if (jj_la == 0 && jj_scanpos == jj_lastpos) return false;
+ Token xsp;
+ while (true) {
+ xsp = jj_scanpos;
+ if (jj_3R_54()) { jj_scanpos = xsp; break; }
+ if (jj_la == 0 && jj_scanpos == jj_lastpos) return false;
+ }
+ return false;
+ }
+
+ final private boolean jj_3R_51() {
+ if (jj_scan_token(LOGICAL_OR)) return true;
+ if (jj_la == 0 && jj_scanpos == jj_lastpos) return false;
+ if (jj_3R_50()) return true;
if (jj_la == 0 && jj_scanpos == jj_lastpos) return false;
return false;
}
1.2 +16 -1
jakarta-velocity/src/java/org/apache/velocity/runtime/parser/Parser.jj
Index: Parser.jj
===================================================================
RCS file:
/home/cvs/jakarta-velocity/src/java/org/apache/velocity/runtime/parser/Parser.jj,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- Parser.jj 2000/09/30 17:04:24 1.1
+++ Parser.jj 2000/09/30 22:58:14 1.2
@@ -97,7 +97,7 @@
* what controls the generation of this class.
*
* @author <a href="mailto:[EMAIL PROTECTED]">Jason van Zyl</a>
- * @version $Id: Parser.jj,v 1.1 2000/09/30 17:04:24 jvanzyl Exp $
+ * @version $Id: Parser.jj,v 1.2 2000/09/30 22:58:14 jvanzyl Exp $
*/
public class Parser/*@bgen(jjtree)*/implements ParserTreeConstants/*@egen*/
{/*@bgen(jjtree)*/
@@ -151,6 +151,14 @@
{
return (Directive) directives.get(directive);
}
+
+ public boolean isDirective(String directive)
+ {
+ if (directives.containsKey(directive))
+ return true;
+ else
+ return false;
+ }
}
PARSER_END(Parser)
@@ -676,6 +684,13 @@
t = <WORD>
{
d = (Directive) directives.get(t.image.substring(1));
+
+ if (d == null)
+ {
+ token_source.SwitchTo(DEFAULT);
+ return jjtn000;
+ }
+
args = d.getArgs();
}
1.2 +16 -1
jakarta-velocity/src/java/org/apache/velocity/runtime/parser/Parser.jjt
Index: Parser.jjt
===================================================================
RCS file:
/home/cvs/jakarta-velocity/src/java/org/apache/velocity/runtime/parser/Parser.jjt,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- Parser.jjt 2000/09/30 17:04:23 1.1
+++ Parser.jjt 2000/09/30 22:58:14 1.2
@@ -121,7 +121,7 @@
* what controls the generation of this class.
*
* @author <a href="mailto:[EMAIL PROTECTED]">Jason van Zyl</a>
- * @version $Id: Parser.jjt,v 1.1 2000/09/30 17:04:23 jvanzyl Exp $
+ * @version $Id: Parser.jjt,v 1.2 2000/09/30 22:58:14 jvanzyl Exp $
*/
public class Parser
{
@@ -172,6 +172,14 @@
{
return (Directive) directives.get(directive);
}
+
+ public boolean isDirective(String directive)
+ {
+ if (directives.containsKey(directive))
+ return true;
+ else
+ return false;
+ }
}
PARSER_END(Parser)
@@ -601,6 +609,13 @@
t = <WORD>
{
d = (Directive) directives.get(t.image.substring(1));
+
+ if (d == null)
+ {
+ token_source.SwitchTo(DEFAULT);
+ return jjtThis;
+ }
+
args = d.getArgs();
}