You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@velocity.apache.org by jv...@locus.apache.org on 2000/09/21 04:34:50 UTC

cvs commit: jakarta-velocity/src/java/org/apache/velocity/processor/javacc/parser/webmacro Parser.java Parser.jj Parser.jjt

jvanzyl     00/09/20 19:34:49

  Modified:    src/java/org/apache/velocity/processor/javacc/parser
                        ASTBlock.java ASTForeachStatement.java
                        ASTIfStatement.java ASTReference.java
                        ASTSetStatement.java ASTText.java ASTprocess.java
                        Node.java SimpleNode.java
               src/java/org/apache/velocity/processor/javacc/parser/webmacro
                        Parser.java Parser.jj Parser.jjt
  Log:
  - made the tree self-walking so that a visitor is not required
    for output. after the parsing the root node is captured and
    it can walk itself. a visitor can still be used to transform
    the node structure but it's no longer required for output.
  
  Revision  Changes    Path
  1.2       +14 -0     jakarta-velocity/src/java/org/apache/velocity/processor/javacc/parser/ASTBlock.java
  
  Index: ASTBlock.java
  ===================================================================
  RCS file: /home/cvs/jakarta-velocity/src/java/org/apache/velocity/processor/javacc/parser/ASTBlock.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- ASTBlock.java	2000/09/19 01:58:43	1.1
  +++ ASTBlock.java	2000/09/21 02:34:39	1.2
  @@ -2,6 +2,11 @@
   
   package org.apache.velocity.processor.javacc.parser;
   
  +import java.io.Writer;
  +import java.io.IOException;
  +
  +import org.apache.velocity.Context;
  +
   public class ASTBlock extends SimpleNode
   {
       public ASTBlock(int id)
  @@ -18,5 +23,14 @@
       public Object jjtAccept(ParserVisitor visitor, Object data)
       {
           return visitor.visit(this, data);
  +    }
  +
  +    public void render(Context context, Writer writer)
  +        throws IOException
  +    {
  +        int i, k = jjtGetNumChildren();
  +
  +        for (i = 0; i < k; i++)
  +            jjtGetChild(i).render(context, writer);
       }
   }
  
  
  
  1.3       +13 -4     jakarta-velocity/src/java/org/apache/velocity/processor/javacc/parser/ASTForeachStatement.java
  
  Index: ASTForeachStatement.java
  ===================================================================
  RCS file: /home/cvs/jakarta-velocity/src/java/org/apache/velocity/processor/javacc/parser/ASTForeachStatement.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- ASTForeachStatement.java	2000/09/19 05:16:35	1.2
  +++ ASTForeachStatement.java	2000/09/21 02:34:40	1.3
  @@ -2,6 +2,9 @@
   
   package org.apache.velocity.processor.javacc.parser;
   
  +import java.io.Writer;
  +import java.io.IOException;
  +
   import java.util.Collection;
   import java.util.Enumeration;
   import java.util.Iterator;
  @@ -29,8 +32,10 @@
           return visitor.visit(this, data);
       }
   
  -    public void process(Context context, ParserVisitor visitor)
  +    public void render(Context context, Writer writer)
  +        throws IOException
       {
  +    
           // tokens 2,4
           Object data = null;
           Object listObject = null;
  @@ -71,7 +76,7 @@
               for (int i = 0; i < length; i++)
               {
                   context.put(elementKey,((Object[])listObject)[i]);
  -                data = ((SimpleNode) jjtGetChild(2)).childrenAccept(visitor, data);
  +                jjtGetChild(2).render(context, writer);
               }
               context.remove(elementKey);
           }
  @@ -85,7 +90,7 @@
               while (i.hasNext())
               {
                   context.put(elementKey,i.next());
  -                data = ((SimpleNode) jjtGetChild(2)).childrenAccept(visitor, data);
  +                jjtGetChild(2).render(context, writer);
               }
               context.remove(elementKey);
           }
  @@ -96,7 +101,7 @@
               while (e.hasMoreElements())
               {
                   context.put(elementKey,e.nextElement());
  -                data = ((SimpleNode) jjtGetChild(2)).childrenAccept(visitor, data);
  +                jjtGetChild(2).render(context, writer);
               }
               context.remove(elementKey);
           }
  @@ -105,5 +110,9 @@
           // the iterator.
           if (tmp != null)
               context.put(elementKey, tmp);
  +    }
  +
  +    public void process(Context context, ParserVisitor visitor)
  +    {
       }
   }
  
  
  
  1.2       +12 -4     jakarta-velocity/src/java/org/apache/velocity/processor/javacc/parser/ASTIfStatement.java
  
  Index: ASTIfStatement.java
  ===================================================================
  RCS file: /home/cvs/jakarta-velocity/src/java/org/apache/velocity/processor/javacc/parser/ASTIfStatement.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- ASTIfStatement.java	2000/09/19 01:58:46	1.1
  +++ ASTIfStatement.java	2000/09/21 02:34:40	1.2
  @@ -2,6 +2,9 @@
   
   package org.apache.velocity.processor.javacc.parser;
   
  +import java.io.Writer;
  +import java.io.IOException;
  +
   import org.apache.velocity.Context;
   
   public class ASTIfStatement extends SimpleNode
  @@ -23,7 +26,8 @@
           return visitor.visit(this, data);
       }
   
  -    public void process(Context context, ParserVisitor visitor)
  +    public void render(Context context, Writer writer)
  +        throws IOException
       {
           Object data = null;
           Node expression;
  @@ -36,7 +40,7 @@
           expression = jjtGetChild(0);
           if (expression.evaluate(context))
           {
  -            data = ((SimpleNode) jjtGetChild(1)).childrenAccept(visitor, data);
  +            jjtGetChild(1).render(context, writer);
           }
           else
           {
  @@ -55,15 +59,19 @@
                       expression = child.jjtGetChild(0);
                       if (expression.evaluate(context))
                       {
  -                        data = ((SimpleNode) child.jjtGetChild(1)).childrenAccept(visitor, data);
  +                        jjtGetChild(1).render(context, writer);
                           break;
                       }
                   }
                   else
                   {
  -                    data = ((SimpleNode) child.jjtGetChild(0)).childrenAccept(visitor, data);
  +                    jjtGetChild(0).render(context, writer);
                   }
               }
           }            
  +    }
  +
  +    public void process(Context context, ParserVisitor visitor)
  +    {
       }
   }
  
  
  
  1.2       +15 -0     jakarta-velocity/src/java/org/apache/velocity/processor/javacc/parser/ASTReference.java
  
  Index: ASTReference.java
  ===================================================================
  RCS file: /home/cvs/jakarta-velocity/src/java/org/apache/velocity/processor/javacc/parser/ASTReference.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- ASTReference.java	2000/09/19 01:58:48	1.1
  +++ ASTReference.java	2000/09/21 02:34:40	1.2
  @@ -2,6 +2,9 @@
   
   package org.apache.velocity.processor.javacc.parser;
   
  +import java.io.Writer;
  +import java.io.IOException;
  +
   import java.util.Map;
   
   import org.apache.velocity.Context;
  @@ -25,6 +28,18 @@
       public Object jjtAccept(ParserVisitor visitor, Object data)
       {
           return visitor.visit(this, data);
  +    }
  +
  +    public void render(Context context, Writer writer)
  +        throws IOException
  +    {
  +        String content = (String) value(context);
  +        Token t = getFirstToken();
  +         
  +        if (content == null)
  +            writer.write(NodeUtils.specialText(t) + t.image);
  +        else
  +            writer.write(NodeUtils.specialText(t) + content);
       }
   
       public boolean evaluate(Context context)
  
  
  
  1.2       +157 -0    jakarta-velocity/src/java/org/apache/velocity/processor/javacc/parser/ASTSetStatement.java
  
  Index: ASTSetStatement.java
  ===================================================================
  RCS file: /home/cvs/jakarta-velocity/src/java/org/apache/velocity/processor/javacc/parser/ASTSetStatement.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- ASTSetStatement.java	2000/09/19 01:58:48	1.1
  +++ ASTSetStatement.java	2000/09/21 02:34:40	1.2
  @@ -2,8 +2,18 @@
   
   package org.apache.velocity.processor.javacc.parser;
   
  +import java.util.Map;
  +
  +import java.io.Writer;
  +import java.io.IOException;
  +
  +import org.apache.velocity.Context;
  +import org.apache.velocity.util.ClassUtils;
  +
   public class ASTSetStatement extends SimpleNode
   {
  +    protected String property;
  +    
       public ASTSetStatement(int id)
       {
           super(id);
  @@ -18,5 +28,152 @@
       public Object jjtAccept(ParserVisitor visitor, Object data)
       {
           return visitor.visit(this, data);
  +    }
  +
  +    public void render(Context context, Writer writer)
  +        throws IOException
  +    {
  +        // tokens 2,4
  +        Object value = null;
  +        Node right = jjtGetChild(1).jjtGetChild(0);
  +
  +        value = right.value(context);
  +        
  +        Node left = jjtGetChild(0);
  +        if (left.jjtGetNumChildren() == 0)
  +            context.put(left.getFirstToken().image.substring(1), value);
  +        else            
  +            setReferenceValue(context, (ASTReference) left, value);
  +    
  +    }
  +
  +    protected void setReferenceValue(Context context, ASTReference node, Object value)
  +    {
  +        Object result = getReferenceValue(context, node, 1);
  +        Object[] args = { value };
  +        ClassUtils.invoke(result, "set" + property, args);
  +    }
  +
  +    // Put this in the base visitor.
  +    protected  Object getReferenceValue(Context context, ASTReference node, int tailChildrenToIgnore)
  +    {
  +        // The rootOfIntrospection is the object we will
  +        // retrieve from the Context. This is the base
  +        // object we will apply reflection to.
  +        
  +        String rootOfIntrospection = node.getFirstToken().image;
  +        Object result = getVariableValue(context, rootOfIntrospection);
  +        Object newResult;
  +        String method;
  +        String identifier;
  +        
  +        String signature = "";
  +        
  +        // How many child nodes do we have?
  +        int children = node.jjtGetNumChildren();
  +        
  +        for (int i = 0; i < children - tailChildrenToIgnore; i++)
  +        {
  +            Node n = node.jjtGetChild(i);
  +            
  +            // Change this to use polymorphism!
  +            
  +            switch(n.getType())
  +            {
  +                case ParserTreeConstants.JJTIDENTIFIER:
  +                    identifier = n.getFirstToken().image;
  +                    method = "get" + identifier;
  +
  +                    newResult = ClassUtils.invoke(result, method);
  +                    if (newResult == null)
  +                    {
  +                        method = "get";
  +                        Object[] args = { identifier };
  +                        Class[] ptypes = null;
  +                        
  +                        // Have to make sure class types are
  +                        // correct for a proper signature match.
  +                        
  +                        if (result instanceof Map)
  +                        {
  +                            // This can be created once.
  +                            ptypes = new Class[1];
  +                            ptypes[0] = new Object().getClass();
  +                            signature = signature + "Map.";
  +                        }                            
  +                        
  +                        result = ClassUtils.invoke(result, method, args, ptypes);
  +                    }
  +                    else
  +                    {
  +                        result = newResult;
  +                        signature = signature + "Property.";
  +                    }                        
  +                    
  +                    break;
  +            
  +                case ParserTreeConstants.JJTMETHOD:
  +
  +                    // node 1: method name
  +                    // The rest of the nodes are parameters
  +                    // to the method. They may be references
  +                    // or string literals. If they are
  +                    // references then we just use a little
  +                    // recursion.
  +
  +                    method = n.jjtGetChild(0).getFirstToken().image;
  +                    int parameters = n.jjtGetNumChildren() - 1;
  +                
  +                    Object[] params = new Object[parameters];
  +                
  +                    for (int j = 0; j < parameters; j++)
  +                    {
  +                        Node p = n.jjtGetChild(j + 1);
  +                    
  +                        // Again use polymorphism. Wait until
  +                        // the nodes settle down.
  +                        
  +                        switch(p.getType())
  +                        {
  +                            case ParserTreeConstants.JJTREFERENCE:
  +                                params[j] = getReferenceValue(context, (ASTReference)p, 0);
  +                                break;
  +                            
  +                            case ParserTreeConstants.JJTSTRINGLITERAL:
  +                                params[j] = getStringLiteralValue(p.getFirstToken().image);
  +                                break;
  +                        }
  +                    }                        
  +                
  +                result = ClassUtils.invoke(result, method, params);
  +                
  +                signature = signature + "Method.";
  +                
  +                break;                    
  +            }
  +        }
  +        
  +        if (tailChildrenToIgnore == 1)
  +            property = node.jjtGetChild(children - 1).getFirstToken().image;
  +
  +        //System.out.println("signature: " + signature);
  +        return result;
  +    }
  +
  +    protected  Object getVariableValue(Context context, String variable)
  +    {
  +        if (context.containsKey(variable.substring(1)))
  +        {
  +            return context.get(variable.substring(1));
  +        }            
  +        else
  +        {
  +            return null;
  +        }            
  +    }
  +
  +    protected  Object getStringLiteralValue(String s)
  +    {
  +        return s.substring(1, s.length() - 1);
       }
   }
  
  
  
  1.2       +12 -0     jakarta-velocity/src/java/org/apache/velocity/processor/javacc/parser/ASTText.java
  
  Index: ASTText.java
  ===================================================================
  RCS file: /home/cvs/jakarta-velocity/src/java/org/apache/velocity/processor/javacc/parser/ASTText.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- ASTText.java	2000/09/19 01:58:47	1.1
  +++ ASTText.java	2000/09/21 02:34:41	1.2
  @@ -2,6 +2,11 @@
   
   package org.apache.velocity.processor.javacc.parser;
   
  +import java.io.Writer;
  +import java.io.IOException;
  +
  +import org.apache.velocity.Context;
  +
   public class ASTText extends SimpleNode
   {
       public ASTText(int id)
  @@ -19,4 +24,11 @@
       {
           return visitor.visit(this, data);
       }
  +
  +    public void render(Context context, Writer writer)
  +        throws IOException
  +    {
  +        writer.write(NodeUtils.specialText(getFirstToken()) +
  +            getFirstToken().image);
  +    }    
   }
  
  
  
  1.2       +15 -0     jakarta-velocity/src/java/org/apache/velocity/processor/javacc/parser/ASTprocess.java
  
  Index: ASTprocess.java
  ===================================================================
  RCS file: /home/cvs/jakarta-velocity/src/java/org/apache/velocity/processor/javacc/parser/ASTprocess.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- ASTprocess.java	2000/09/19 01:58:48	1.1
  +++ ASTprocess.java	2000/09/21 02:34:41	1.2
  @@ -2,6 +2,11 @@
   
   package org.apache.velocity.processor.javacc.parser;
   
  +import java.io.Writer;
  +import java.io.IOException;
  +
  +import org.apache.velocity.Context;
  +
   public class ASTprocess extends SimpleNode
   {
       public ASTprocess(int id)
  @@ -19,4 +24,14 @@
       {
           return visitor.visit(this, data);
       }
  +
  +    public void render(Context context, Writer writer)
  +        throws IOException
  +    {
  +        int i, k = jjtGetNumChildren();
  +
  +        for (i = 0; i < k; i++)
  +            jjtGetChild(i).render(context, writer);
  +    }
  +
   }
  
  
  
  1.2       +5 -0      jakarta-velocity/src/java/org/apache/velocity/processor/javacc/parser/Node.java
  
  Index: Node.java
  ===================================================================
  RCS file: /home/cvs/jakarta-velocity/src/java/org/apache/velocity/processor/javacc/parser/Node.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- Node.java	2000/09/19 01:58:48	1.1
  +++ Node.java	2000/09/21 02:34:41	1.2
  @@ -2,6 +2,9 @@
   
   package org.apache.velocity.processor.javacc.parser;
   
  +import java.io.Writer;
  +import java.io.IOException;
  +
   import org.apache.velocity.Context;
   
   /* All AST nodes must implement this interface.  It provides basic
  @@ -48,4 +51,6 @@
       public boolean evaluate(Context context);
       public Object value(Context context);
       public void process(Node node, Context context, ParserVisitor visitor);
  +    public void render(Context context, Writer writer)
  +        throws IOException;
   }
  
  
  
  1.2       +8 -0      jakarta-velocity/src/java/org/apache/velocity/processor/javacc/parser/SimpleNode.java
  
  Index: SimpleNode.java
  ===================================================================
  RCS file: /home/cvs/jakarta-velocity/src/java/org/apache/velocity/processor/javacc/parser/SimpleNode.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- SimpleNode.java	2000/09/19 01:58:47	1.1
  +++ SimpleNode.java	2000/09/21 02:34:41	1.2
  @@ -2,6 +2,9 @@
   
   package org.apache.velocity.processor.javacc.parser;
   
  +import java.io.Writer;
  +import java.io.IOException;
  +
   import org.apache.velocity.Context;
   
   public class SimpleNode implements Node
  @@ -55,6 +58,11 @@
       }        
   
       public void process(Node node, Context context, ParserVisitor visitor)
  +    {
  +    }
  +
  +    public void render(Context context, Writer writer)
  +        throws IOException
       {
       }
   
  
  
  
  1.3       +127 -206  jakarta-velocity/src/java/org/apache/velocity/processor/javacc/parser/webmacro/Parser.java
  
  Index: Parser.java
  ===================================================================
  RCS file: /home/cvs/jakarta-velocity/src/java/org/apache/velocity/processor/javacc/parser/webmacro/Parser.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- Parser.java	2000/09/19 19:49:58	1.2
  +++ Parser.java	2000/09/21 02:34:47	1.3
  @@ -16,7 +16,7 @@
    * what controls the generation of this class.
    *
    * @author <a href="mailto:jvanzyl@periapt.com">Jason van Zyl</a>
  - * @version $Id: Parser.java,v 1.2 2000/09/19 19:49:58 jvanzyl Exp $ 
  + * @version $Id: Parser.java,v 1.3 2000/09/21 02:34:47 jvanzyl Exp $ 
   */
   public class Parser implements/*@bgen(jjtree)*/ ParserTreeConstants,org.apache.velocity.processor.javacc.parser.Parser, ParserConstants {/*@bgen(jjtree)*/
     protected JJTParserState jjtree = new JJTParserState();
  @@ -91,8 +91,6 @@
           case ELSE_DIRECTIVE:
           case FOREACH_DIRECTIVE:
           case SET_DIRECTIVE:
  -        case PARAM_DIRECTIVE:
  -        case USE_DIRECTIVE:
           case STOP_DIRECTIVE:
           case IDENTIFIER:
           case DIDENTIFIER:
  @@ -186,12 +184,6 @@
       case PARSE_DIRECTIVE:
         ParseStatement();
         break;
  -    case USE_DIRECTIVE:
  -      UseStatement();
  -      break;
  -    case PARAM_DIRECTIVE:
  -      ParamStatement();
  -      break;
       case STOP_DIRECTIVE:
         StopStatement();
         break;
  @@ -466,8 +458,6 @@
           case ELSE_DIRECTIVE:
           case FOREACH_DIRECTIVE:
           case SET_DIRECTIVE:
  -        case PARAM_DIRECTIVE:
  -        case USE_DIRECTIVE:
           case STOP_DIRECTIVE:
           case IDENTIFIER:
           case DIDENTIFIER:
  @@ -789,75 +779,6 @@
     }
   
   /**
  - * This method corresponds to a #use
  - * directive in a Velocity template. The
  - * following are examples of #use
  - * constructs that are acceptable in
  - * a template:
  - *
  - * This has not been implemented and may
  - * not need to be because the Velocity
  - * parser doesn't have any problem with
  - * normal text that isn't part of Velocity's
  - * grammar.
  - *
  - */
  -  final public void UseStatement() throws ParseException {
  -                       /*@bgen(jjtree) UseStatement */
  -  ASTUseStatement jjtn000 = new ASTUseStatement(this, JJTUSESTATEMENT);
  -  boolean jjtc000 = true;
  -  jjtree.openNodeScope(jjtn000);
  -    try {
  -      jj_consume_token(USE_DIRECTIVE);
  -    } finally {
  -    if (jjtc000) {
  -      jjtree.closeNodeScope(jjtn000, true);
  -    }
  -    }
  -  }
  -
  -/**
  - * This method corresponds to a #param
  - * directive in a Velocity template. The
  - * following are examples of #param
  - * constructs that are acceptable in
  - * a template:
  - *
  - * #param $language = "en"
  - *
  - */
  -  final public void ParamStatement() throws ParseException {
  -                         /*@bgen(jjtree) ParamStatement */
  -  ASTParamStatement jjtn000 = new ASTParamStatement(this, JJTPARAMSTATEMENT);
  -  boolean jjtc000 = true;
  -  jjtree.openNodeScope(jjtn000);
  -    try {
  -      jj_consume_token(PARAM_DIRECTIVE);
  -      Reference();
  -      jj_consume_token(EQUALS);
  -      jj_consume_token(STRING_LITERAL);
  -    } catch (Throwable jjte000) {
  -    if (jjtc000) {
  -      jjtree.clearNodeScope(jjtn000);
  -      jjtc000 = false;
  -    } else {
  -      jjtree.popNode();
  -    }
  -    if (jjte000 instanceof RuntimeException) {
  -      {if (true) throw (RuntimeException)jjte000;}
  -    }
  -    if (jjte000 instanceof ParseException) {
  -      {if (true) throw (ParseException)jjte000;}
  -    }
  -    {if (true) throw (Error)jjte000;}
  -    } finally {
  -    if (jjtc000) {
  -      jjtree.closeNodeScope(jjtn000, true);
  -    }
  -    }
  -  }
  -
  -/**
    * This method corresponds to the #stop
    * directive which just simulates and EOF
    * so that parsing stops. The #stop directive
  @@ -1557,58 +1478,127 @@
       return false;
     }
   
  -  final private boolean jj_3R_38() {
  -    if (jj_scan_token(LOGICAL_OR)) return true;
  -    if (jj_la == 0 && jj_scanpos == jj_lastpos) return false;
  -    if (jj_3R_37()) return true;
  -    if (jj_la == 0 && jj_scanpos == jj_lastpos) return false;
  -    return false;
  -  }
  -
     final private boolean jj_3R_27() {
       if (jj_scan_token(IDENTIFIER)) return true;
       if (jj_la == 0 && jj_scanpos == jj_lastpos) return false;
       return false;
     }
   
  -  final private boolean jj_3R_36() {
  -    if (jj_3R_37()) return true;
  -    if (jj_la == 0 && jj_scanpos == jj_lastpos) return false;
  +  final private boolean jj_3R_23() {
       Token xsp;
  +    xsp = jj_scanpos;
  +    if (jj_3R_27()) {
  +    jj_scanpos = xsp;
  +    if (jj_3R_28()) return true;
  +    if (jj_la == 0 && jj_scanpos == jj_lastpos) return false;
  +    } else if (jj_la == 0 && jj_scanpos == jj_lastpos) return false;
       while (true) {
         xsp = jj_scanpos;
  -      if (jj_3R_38()) { jj_scanpos = xsp; break; }
  +      if (jj_3_1()) { 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(LPAREN)) return true;
  +  final private boolean jj_3R_26() {
  +    if (jj_3R_21()) return true;
       if (jj_la == 0 && jj_scanpos == jj_lastpos) return false;
  -    if (jj_3R_24()) return true;
  +    return false;
  +  }
  +
  +  final private boolean jj_3R_12() {
  +    if (jj_3R_14()) return true;
       if (jj_la == 0 && jj_scanpos == jj_lastpos) return false;
  +    if (jj_scan_token(LPAREN)) return true;
  +    if (jj_la == 0 && jj_scanpos == jj_lastpos) return false;
  +    Token xsp;
  +    xsp = jj_scanpos;
  +    if (jj_3R_15()) jj_scanpos = xsp;
  +    else if (jj_la == 0 && jj_scanpos == jj_lastpos) return false;
       if (jj_scan_token(RPAREN)) return true;
       if (jj_la == 0 && jj_scanpos == jj_lastpos) return false;
       return false;
     }
   
  -  final private boolean jj_3R_23() {
  +  final private boolean jj_3R_20() {
       Token xsp;
       xsp = jj_scanpos;
  -    if (jj_3R_27()) {
  +    if (jj_3R_25()) {
       jj_scanpos = xsp;
  -    if (jj_3R_28()) return true;
  +    if (jj_3R_26()) return true;
       if (jj_la == 0 && jj_scanpos == jj_lastpos) return false;
       } else if (jj_la == 0 && jj_scanpos == jj_lastpos) return false;
  +    return false;
  +  }
  +
  +  final private boolean jj_3R_25() {
  +    if (jj_3R_23()) return true;
  +    if (jj_la == 0 && jj_scanpos == jj_lastpos) return false;
  +    return false;
  +  }
  +
  +  final private boolean jj_3R_11() {
  +    if (jj_3R_14()) return true;
  +    if (jj_la == 0 && jj_scanpos == jj_lastpos) return false;
  +    return false;
  +  }
  +
  +  final private boolean jj_3R_40() {
  +    if (jj_scan_token(LOGICAL_AND)) return true;
  +    if (jj_la == 0 && jj_scanpos == jj_lastpos) return false;
  +    if (jj_3R_39()) return true;
  +    if (jj_la == 0 && jj_scanpos == jj_lastpos) return false;
  +    return false;
  +  }
  +
  +  final private boolean jj_3R_14() {
  +    if (jj_scan_token(IDENTIFIER)) return true;
  +    if (jj_la == 0 && jj_scanpos == jj_lastpos) return false;
  +    return false;
  +  }
  +
  +  final private boolean jj_3R_37() {
  +    if (jj_3R_39()) return true;
  +    if (jj_la == 0 && jj_scanpos == jj_lastpos) return false;
  +    Token xsp;
       while (true) {
         xsp = jj_scanpos;
  -      if (jj_3_1()) { jj_scanpos = xsp; break; }
  +      if (jj_3R_40()) { jj_scanpos = xsp; break; }
  +      if (jj_la == 0 && jj_scanpos == jj_lastpos) return false;
  +    }
  +    return false;
  +  }
  +
  +  final private boolean jj_3R_38() {
  +    if (jj_scan_token(LOGICAL_OR)) return true;
  +    if (jj_la == 0 && jj_scanpos == jj_lastpos) return false;
  +    if (jj_3R_37()) return true;
  +    if (jj_la == 0 && jj_scanpos == jj_lastpos) return false;
  +    return false;
  +  }
  +
  +  final private boolean jj_3R_36() {
  +    if (jj_3R_37()) return true;
  +    if (jj_la == 0 && jj_scanpos == jj_lastpos) return false;
  +    Token xsp;
  +    while (true) {
  +      xsp = jj_scanpos;
  +      if (jj_3R_38()) { 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(LPAREN)) return true;
  +    if (jj_la == 0 && jj_scanpos == jj_lastpos) return false;
  +    if (jj_3R_24()) return true;
  +    if (jj_la == 0 && jj_scanpos == jj_lastpos) return false;
  +    if (jj_scan_token(RPAREN)) return true;
  +    if (jj_la == 0 && jj_scanpos == jj_lastpos) return false;
  +    return false;
  +  }
  +
     final private boolean jj_3R_35() {
       if (jj_3R_13()) return true;
       if (jj_la == 0 && jj_scanpos == jj_lastpos) return false;
  @@ -1625,12 +1615,6 @@
       return false;
     }
   
  -  final private boolean jj_3R_26() {
  -    if (jj_3R_21()) return true;
  -    if (jj_la == 0 && jj_scanpos == jj_lastpos) return false;
  -    return false;
  -  }
  -
     final private boolean jj_3R_17() {
       if (jj_3R_22()) return true;
       if (jj_la == 0 && jj_scanpos == jj_lastpos) return false;
  @@ -1660,16 +1644,14 @@
       return false;
     }
   
  -  final private boolean jj_3R_12() {
  -    if (jj_3R_14()) return true;
  -    if (jj_la == 0 && jj_scanpos == jj_lastpos) return false;
  -    if (jj_scan_token(LPAREN)) return true;
  +  final private boolean jj_3R_21() {
  +    if (jj_scan_token(STRING_LITERAL)) return true;
       if (jj_la == 0 && jj_scanpos == jj_lastpos) return false;
  -    Token xsp;
  -    xsp = jj_scanpos;
  -    if (jj_3R_15()) jj_scanpos = xsp;
  -    else if (jj_la == 0 && jj_scanpos == jj_lastpos) return false;
  -    if (jj_scan_token(RPAREN)) return true;
  +    return false;
  +  }
  +
  +  final private boolean jj_3_2() {
  +    if (jj_3R_12()) return true;
       if (jj_la == 0 && jj_scanpos == jj_lastpos) return false;
       return false;
     }
  @@ -1707,27 +1689,16 @@
       return false;
     }
   
  -  final private boolean jj_3R_62() {
  -    if (jj_scan_token(MODULUS)) return true;
  -    if (jj_la == 0 && jj_scanpos == jj_lastpos) return false;
  -    if (jj_3R_54()) return true;
  +  final private boolean jj_3R_22() {
  +    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_20() {
  -    Token xsp;
  -    xsp = jj_scanpos;
  -    if (jj_3R_25()) {
  -    jj_scanpos = xsp;
  -    if (jj_3R_26()) return true;
  +  final private boolean jj_3R_62() {
  +    if (jj_scan_token(MODULUS)) return true;
       if (jj_la == 0 && jj_scanpos == jj_lastpos) return false;
  -    } else if (jj_la == 0 && jj_scanpos == jj_lastpos) return false;
  -    return false;
  -  }
  -
  -  final private boolean jj_3R_25() {
  -    if (jj_3R_23()) return true;
  +    if (jj_3R_54()) return true;
       if (jj_la == 0 && jj_scanpos == jj_lastpos) return false;
       return false;
     }
  @@ -1762,12 +1733,6 @@
       return false;
     }
   
  -  final private boolean jj_3R_11() {
  -    if (jj_3R_14()) return true;
  -    if (jj_la == 0 && jj_scanpos == jj_lastpos) return false;
  -    return false;
  -  }
  -
     final private boolean jj_3R_32() {
       if (jj_3R_36()) return true;
       if (jj_la == 0 && jj_scanpos == jj_lastpos) return false;
  @@ -1848,8 +1813,23 @@
       return false;
     }
   
  -  final private boolean jj_3R_14() {
  -    if (jj_scan_token(IDENTIFIER)) return true;
  +  final private boolean jj_3_1() {
  +    if (jj_scan_token(DOT)) return true;
  +    if (jj_la == 0 && jj_scanpos == jj_lastpos) return false;
  +    Token xsp;
  +    xsp = jj_scanpos;
  +    if (jj_3_2()) {
  +    jj_scanpos = xsp;
  +    if (jj_3R_11()) return true;
  +    if (jj_la == 0 && jj_scanpos == jj_lastpos) return false;
  +    } else if (jj_la == 0 && jj_scanpos == jj_lastpos) return false;
  +    return false;
  +  }
  +
  +  final private boolean jj_3R_41() {
  +    if (jj_scan_token(COMMA)) return true;
  +    if (jj_la == 0 && jj_scanpos == jj_lastpos) return false;
  +    if (jj_3R_20()) return true;
       if (jj_la == 0 && jj_scanpos == jj_lastpos) return false;
       return false;
     }
  @@ -1954,57 +1934,6 @@
       return false;
     }
   
  -  final private boolean jj_3R_21() {
  -    if (jj_scan_token(STRING_LITERAL)) return true;
  -    if (jj_la == 0 && jj_scanpos == jj_lastpos) return false;
  -    return false;
  -  }
  -
  -  final private boolean jj_3_2() {
  -    if (jj_3R_12()) return true;
  -    if (jj_la == 0 && jj_scanpos == jj_lastpos) return false;
  -    return false;
  -  }
  -
  -  final private boolean jj_3R_22() {
  -    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_39() {
  -    if (jj_3R_42()) return true;
  -    if (jj_la == 0 && jj_scanpos == jj_lastpos) return false;
  -    Token xsp;
  -    while (true) {
  -      xsp = jj_scanpos;
  -      if (jj_3R_43()) { jj_scanpos = xsp; break; }
  -      if (jj_la == 0 && jj_scanpos == jj_lastpos) return false;
  -    }
  -    return false;
  -  }
  -
  -  final private boolean jj_3_1() {
  -    if (jj_scan_token(DOT)) return true;
  -    if (jj_la == 0 && jj_scanpos == jj_lastpos) return false;
  -    Token xsp;
  -    xsp = jj_scanpos;
  -    if (jj_3_2()) {
  -    jj_scanpos = xsp;
  -    if (jj_3R_11()) return true;
  -    if (jj_la == 0 && jj_scanpos == jj_lastpos) return false;
  -    } else if (jj_la == 0 && jj_scanpos == jj_lastpos) return false;
  -    return false;
  -  }
  -
  -  final private boolean jj_3R_41() {
  -    if (jj_scan_token(COMMA)) return true;
  -    if (jj_la == 0 && jj_scanpos == jj_lastpos) return false;
  -    if (jj_3R_20()) return true;
  -    if (jj_la == 0 && jj_scanpos == jj_lastpos) return false;
  -    return false;
  -  }
  -
     final private boolean jj_3R_15() {
       if (jj_3R_20()) return true;
       if (jj_la == 0 && jj_scanpos == jj_lastpos) return false;
  @@ -2023,11 +1952,15 @@
       return false;
     }
   
  -  final private boolean jj_3R_40() {
  -    if (jj_scan_token(LOGICAL_AND)) return true;
  -    if (jj_la == 0 && jj_scanpos == jj_lastpos) return false;
  -    if (jj_3R_39()) return true;
  +  final private boolean jj_3R_39() {
  +    if (jj_3R_42()) return true;
       if (jj_la == 0 && jj_scanpos == jj_lastpos) return false;
  +    Token xsp;
  +    while (true) {
  +      xsp = jj_scanpos;
  +      if (jj_3R_43()) { jj_scanpos = xsp; break; }
  +      if (jj_la == 0 && jj_scanpos == jj_lastpos) return false;
  +    }
       return false;
     }
   
  @@ -2037,18 +1970,6 @@
       return false;
     }
   
  -  final private boolean jj_3R_37() {
  -    if (jj_3R_39()) return true;
  -    if (jj_la == 0 && jj_scanpos == jj_lastpos) return false;
  -    Token xsp;
  -    while (true) {
  -      xsp = jj_scanpos;
  -      if (jj_3R_40()) { jj_scanpos = xsp; break; }
  -      if (jj_la == 0 && jj_scanpos == jj_lastpos) return false;
  -    }
  -    return false;
  -  }
  -
     public ParserTokenManager token_source;
     ASCII_CharStream jj_input_stream;
     public Token token, jj_nt;
  @@ -2060,7 +1981,7 @@
     private int jj_gen;
     final private int[] jj_la1 = new int[23];
     final private int[] jj_la1_0 = {0x80000182,0x80000182,0x2,0x0,0x2,0x0,0x0,0x80000182,0x182,0x60000000,0x4000006,0x80000,0x40000,0x3000000,0x3000000,0xf00000,0xf00000,0x6000,0x6000,0x38000,0x38000,0x4000006,0x6,};
  -  final private int[] jj_la1_1 = {0xe07fe,0xe07fe,0x60000,0x100000,0x60000,0x60000,0x20000,0xe07fe,0x80000,0x0,0x61000,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x61000,0x61000,};
  +  final private int[] jj_la1_1 = {0xe04fe,0xe04fe,0x60000,0x100000,0x60000,0x60000,0x20000,0xe04fe,0x80000,0x0,0x61000,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x61000,0x61000,};
     final private JJCalls[] jj_2_rtns = new JJCalls[3];
     private boolean jj_rescan = false;
     private int jj_gc = 0;
  
  
  
  1.3       +1 -75     jakarta-velocity/src/java/org/apache/velocity/processor/javacc/parser/webmacro/Parser.jj
  
  Index: Parser.jj
  ===================================================================
  RCS file: /home/cvs/jakarta-velocity/src/java/org/apache/velocity/processor/javacc/parser/webmacro/Parser.jj,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- Parser.jj	2000/09/19 19:49:58	1.2
  +++ Parser.jj	2000/09/21 02:34:47	1.3
  @@ -100,7 +100,7 @@
    * what controls the generation of this class.
    *
    * @author <a href="mailto:jvanzyl@periapt.com">Jason van Zyl</a>
  - * @version $Id: Parser.jj,v 1.2 2000/09/19 19:49:58 jvanzyl Exp $ 
  + * @version $Id: Parser.jj,v 1.3 2000/09/21 02:34:47 jvanzyl Exp $ 
   */
   public class Parser implements/*@bgen(jjtree)*/ ParserTreeConstants, /*@egen*/ org.apache.velocity.processor.javacc.parser.Parser
   {/*@bgen(jjtree)*/
  @@ -535,8 +535,6 @@
       }
       
   |   ParseStatement()
  -|   UseStatement()
  -|   ParamStatement()
   |   StopStatement()
   |   Reference()
   
  @@ -1080,78 +1078,6 @@
   void ParseStatement()      : {}
   {
     <PARSE_DIRECTIVE> <STRING_LITERAL>
  -}
  -
  -/**
  - * This method corresponds to a #use
  - * directive in a Velocity template. The
  - * following are examples of #use
  - * constructs that are acceptable in
  - * a template:
  - *
  - * This has not been implemented and may
  - * not need to be because the Velocity
  - * parser doesn't have any problem with
  - * normal text that isn't part of Velocity's
  - * grammar.
  - *
  - */
  -void UseStatement() : {/*@bgen(jjtree) UseStatement */
  -  ASTUseStatement jjtn000 = new ASTUseStatement(this, JJTUSESTATEMENT);
  -  boolean jjtc000 = true;
  -  jjtree.openNodeScope(jjtn000);
  -/*@egen*/}
  -{/*@bgen(jjtree) UseStatement */
  -  try {
  -/*@egen*/
  -  <USE_DIRECTIVE>/*@bgen(jjtree)*/
  -  } finally {
  -    if (jjtc000) {
  -      jjtree.closeNodeScope(jjtn000, true);
  -    }
  -  }
  -/*@egen*/
  -}
  -
  -/**
  - * This method corresponds to a #param
  - * directive in a Velocity template. The
  - * following are examples of #param
  - * constructs that are acceptable in
  - * a template:
  - *
  - * #param $language = "en"
  - *
  - */
  -void ParamStatement() : {/*@bgen(jjtree) ParamStatement */
  -  ASTParamStatement jjtn000 = new ASTParamStatement(this, JJTPARAMSTATEMENT);
  -  boolean jjtc000 = true;
  -  jjtree.openNodeScope(jjtn000);
  -/*@egen*/}
  -{/*@bgen(jjtree) ParamStatement */
  -  try {
  -/*@egen*/
  -  <PARAM_DIRECTIVE> Reference() <EQUALS> <STRING_LITERAL>/*@bgen(jjtree)*/
  -  } catch (Throwable jjte000) {
  -    if (jjtc000) {
  -      jjtree.clearNodeScope(jjtn000);
  -      jjtc000 = false;
  -    } else {
  -      jjtree.popNode();
  -    }
  -    if (jjte000 instanceof RuntimeException) {
  -      throw (RuntimeException)jjte000;
  -    }
  -    if (jjte000 instanceof ParseException) {
  -      throw (ParseException)jjte000;
  -    }
  -    throw (Error)jjte000;
  -  } finally {
  -    if (jjtc000) {
  -      jjtree.closeNodeScope(jjtn000, true);
  -    }
  -  }
  -/*@egen*/
   }
   
   /**
  
  
  
  1.3       +1 -37     jakarta-velocity/src/java/org/apache/velocity/processor/javacc/parser/webmacro/Parser.jjt
  
  Index: Parser.jjt
  ===================================================================
  RCS file: /home/cvs/jakarta-velocity/src/java/org/apache/velocity/processor/javacc/parser/webmacro/Parser.jjt,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- Parser.jjt	2000/09/19 19:49:59	1.2
  +++ Parser.jjt	2000/09/21 02:34:48	1.3
  @@ -124,7 +124,7 @@
    * what controls the generation of this class.
    *
    * @author <a href="mailto:jvanzyl@periapt.com">Jason van Zyl</a>
  - * @version $Id: Parser.jjt,v 1.2 2000/09/19 19:49:59 jvanzyl Exp $ 
  + * @version $Id: Parser.jjt,v 1.3 2000/09/21 02:34:48 jvanzyl Exp $ 
   */
   public class Parser implements org.apache.velocity.processor.javacc.parser.Parser
   {
  @@ -525,8 +525,6 @@
       }
       
   |   ParseStatement()
  -|   UseStatement()
  -|   ParamStatement()
   |   StopStatement()
   |   Reference()
   
  @@ -790,40 +788,6 @@
   void ParseStatement() #void: {}
   {
     <PARSE_DIRECTIVE> <STRING_LITERAL>
  -}
  -
  -/**
  - * This method corresponds to a #use
  - * directive in a Velocity template. The
  - * following are examples of #use
  - * constructs that are acceptable in
  - * a template:
  - *
  - * This has not been implemented and may
  - * not need to be because the Velocity
  - * parser doesn't have any problem with
  - * normal text that isn't part of Velocity's
  - * grammar.
  - *
  - */
  -void UseStatement() : {}
  -{
  -  <USE_DIRECTIVE>
  -}
  -
  -/**
  - * This method corresponds to a #param
  - * directive in a Velocity template. The
  - * following are examples of #param
  - * constructs that are acceptable in
  - * a template:
  - *
  - * #param $language = "en"
  - *
  - */
  -void ParamStatement() : {}
  -{
  -  <PARAM_DIRECTIVE> Reference() <EQUALS> <STRING_LITERAL>
   }
   
   /**