User: rinkrank
  Date: 02/03/10 09:56:01

  Modified:    javacc   Java1.2-b.jjt
  Log:
  -Modified grammar and core, so both plain JavaCC and JJTree is supported.
  JavaCC is faster, and will be used by XDoclet. The sources will be read-only. JJTree 
is slower,
  but enables svaing of (modified) sources.
  -Removed XTagParameter class for the sake of simpler API and implementation
  -Removed old benchmark tests
  -Fixed some more deadlock issues
  -Implemented wait/notify in interfaces too
  -And some more tests (I think)
  
  Revision  Changes    Path
  1.17      +98 -67    xjavadoc/javacc/Java1.2-b.jjt
  
  Index: Java1.2-b.jjt
  ===================================================================
  RCS file: /cvsroot/xdoclet/xjavadoc/javacc/Java1.2-b.jjt,v
  retrieving revision 1.16
  retrieving revision 1.17
  diff -u -w -r1.16 -r1.17
  --- Java1.2-b.jjt     1 Mar 2002 10:44:42 -0000       1.16
  +++ Java1.2-b.jjt     10 Mar 2002 17:56:01 -0000      1.17
  @@ -43,6 +43,7 @@
   
   options {
     JAVA_UNICODE_ESCAPE=false;
  +  UNICODE_INPUT=false;
     STATIC=false;
     MULTI=false;
     VISITOR=false;
  @@ -50,16 +51,16 @@
     CACHE_TOKENS=true;
   }
   
  -PARSER_BEGIN(JavaParser)
  +PARSER_BEGIN(<XDtAnt:property name="parser-class"/>)
   
   package xjavadoc;
   
   import java.lang.reflect.Modifier;
   import java.util.*;
   
  -public class JavaParser
  +public class <XDtAnt:property name="parser-class"/> implements JavaParser
   {
  -   private static org.apache.log4j.Category _log = 
org.apache.log4j.Category.getInstance(JavaParser.class.getName());
  +   private static org.apache.log4j.Category _log = 
org.apache.log4j.Category.getInstance(<XDtAnt:property 
name="parser-class"/>.class.getName());
   
      private static final void setToken(AbstractProgramElement element, Token token) {
          element.setToken( token );
  @@ -72,6 +73,22 @@
         }
      }
      
  +   private void notifyAndWait(SourceClass sourceClass) {
  +      if(sourceClass.isOuterClass()) {
  +              try {
  +                      synchronized(sourceClass.getParseLock()) {
  +                              // Tell xjavadoc that we're ready with class level 
parsing
  +                              _log.debug("notifyAndWait(): Done scanning class 
header of " + sourceClass.qualifiedName() + ". Notifying main thread waiting in 
scanAndPut()");
  +                              sourceClass.getParseLock().notify();
  +                              sourceClass.getParseLock().wait();
  +                              _log.debug("notifyAndWait() Continuing scanning class 
body of " + sourceClass.qualifiedName());
  +                      }
  +              } catch(InterruptedException e) {
  +                     e.printStackTrace();
  +              }
  +      }
  +   }   
  +
      private final StringBuffer _nameBuffer = new StringBuffer();
   
      private static class Parameter {
  @@ -80,9 +97,12 @@
         public int dimension;
      }
      private Parameter _parameter = new Parameter();
  +   
  +   // Reference to the first token in a Name() production.
  +   private Token _nameToken;
   }
   
  -PARSER_END(JavaParser)
  +PARSER_END(<XDtAnt:property name="parser-class"/>)
   
   
   /* WHITE SPACE */
  @@ -363,12 +383,12 @@
     {
         // sourceClass must know about ASTCompilationUnit
         // if it wants to mutate or print the code
  -      sourceClass.setCompilationUnit( jjtThis );      
  -      // wake up the sourceClass. It's waiting in complete()
  +      <XDtAnt:property name="set-compilation-unit"/>
         
  -      _log.debug("parse thread - in end of CompilationUnit for " + 
sourceClass.containingClass() + " entering synchronized block.");
  +      // wake up the sourceClass. It's waiting in complete()      
  +      _log.debug("parse thread - in end of CompilationUnit for " + 
sourceClass.qualifiedName() + " entering synchronized block.");
         synchronized( sourceClass.getParseLock() ) {
  -         _log.debug("parse thread is done. notifying main thread.");
  +         _log.debug("parse thread is done. notifying main thread waiting in 
complete().");
            sourceClass.getParseLock().notify();
         }
         
  @@ -470,38 +490,19 @@
      }
      [ "extends" superclass=Name() ]
      [ "implements" Interfaces_NameList(sourceClass) ]
  -   ClassBody(sourceClass, halt) {
  +   {
         if( superclass != null ) {
            sourceClass.setSuperclass(superclass);
         } else {
            sourceClass.setSuperclass("java.lang.Object");
         }
      }
  +   ClassBody(sourceClass, halt)
   }
   
   void ClassBody(SourceClass sourceClass, boolean halt) :
   {
  -      if(sourceClass.containingClass()==null) {
  -              try {
  -                      synchronized(sourceClass.getParseLock()) {
  -                              // Tell xjavadoc that we're ready with class level 
parsing
  -                              sourceClass.getParseLock().notify();
  -                              _log.debug("Done scanning class header of " + 
sourceClass.qualifiedName());
  -                     }
  -
  -                      synchronized(sourceClass.getParseLock()) {
  -                              // Wait here until we're woken up. That happens in 
SourceClass.complete()
  -                              sourceClass.getParseLock().wait();
  -                              _log.debug("Continuing scanning class body of " + 
sourceClass.qualifiedName());
  -                      }
  -              } catch(InterruptedException e) {
  -                     _log.debug("In thread + " + Thread.currentThread().getName() + 
" - The ClassBody() of " + sourceClass.qualifiedName() + " has been interrupted. 
Notifying waiters.");
  -                     synchronized(sourceClass.getParseLock()) {
  -                              sourceClass.getParseLock().notify();
  -                     }
  -                     _log.debug("Notified waiters.");
  -              }
  -      }
  +   notifyAndWait(sourceClass);
   }
   {
     "{" ( ClassBodyDeclaration(sourceClass) )* "}"
  @@ -607,6 +608,7 @@
          sourceClass.setToken( t );
       }
     )*
  +  
     UnmodifiedInterfaceDeclaration(sourceClass, halt)
   }
   
  @@ -631,9 +633,9 @@
         sourceClass.setName( t.image );
         sourceClass.setInterface( true );
         setToken(sourceClass,it);
  -      if( halt ) {
  -             //throw new AraException(true);
  -      }
  +
  +      notifyAndWait( sourceClass );
  +
     }
     ( InterfaceMemberDeclaration(sourceClass) )* 
     "}"
  @@ -847,10 +849,12 @@
        if( methodImpl != null ) {
           methodImpl.setName( t.image );
           methodImpl.setQualifiedName( t.image );
  -        setToken( methodImpl, t );
        }
     }
  -  FormalParameters(methodImpl) ( "[" "]" )*
  +  FormalParameters(methodImpl) ( "[" "]" {
  +     methodImpl.setReturnDimension( methodImpl.returnDimension() + 1 );
  +  }
  +  )*
   }
   
   void FormalParameters(AbstractExecutableMember member) :
  @@ -927,44 +931,76 @@
   
   void Field_Type(FieldImpl fieldImpl) :
   {
  +   Token typeToken;
      String type;
   }
   {
  -  ( type=PrimitiveType() | type=Name() ) 
  -  ( "[" "]" { 
  +  ( typeToken=PrimitiveType() 
  +    {
        if( fieldImpl != null ) {
  -        fieldImpl.setDimension(fieldImpl.getDimension() + 1); 
  +        fieldImpl.setType(typeToken.image);
  +        setToken( fieldImpl, typeToken );
        }
  -  } )*
  +    }
  +  | type=Name() 
     {
        if( fieldImpl != null ) {
           fieldImpl.setType(type);
  +        setToken( fieldImpl, _nameToken );
        }
     }
  +  ) 
  +  ( "[" "]" { 
  +     if( fieldImpl != null ) {
  +        fieldImpl.setDimension(fieldImpl.getDimension() + 1); 
  +     }
  +  } )*
   }
   
   void MethodResult_Type(MethodImpl methodImpl) :
   {
  +   Token typeToken;
      String type;
   }
   {
  -  ( type=PrimitiveType() | type=Name() ) 
  -  ( "[" "]" { 
  +  ( typeToken=PrimitiveType()
  +    {
        if( methodImpl != null ) {
  -        methodImpl.setReturnDimension(methodImpl.returnDimension() + 1); 
  +        methodImpl.setReturnType(typeToken.image);
  +        setToken( methodImpl, typeToken );
        }
  -  } )*
  +    }
  +  | type=Name() 
     {
        if( methodImpl != null ) {
           methodImpl.setReturnType(type);
  +        setToken( methodImpl, _nameToken );
        }
     }
  +
  +  ) 
  +  ( "[" "]" { 
  +     if( methodImpl != null ) {
  +        methodImpl.setReturnDimension(methodImpl.returnDimension() + 1); 
  +     }
  +  } )*
   }
   
   void Parameter_Type() :
  -{}
   {
  -  ( _parameter.type=PrimitiveType() | _parameter.type=Name() ) 
  +   Token primitive;
  +   String name;
  +}
  +{
  +  ( primitive=PrimitiveType() 
  +    {
  +       _parameter.type = primitive.image;
  +    }
  +  | name=Name() 
  +    {
  +       _parameter.type = name;
  +    }
  +  ) 
     ( "[" "]" { _parameter.dimension++; } )*
   }
   
  @@ -975,26 +1011,26 @@
     ( "[" "]" )*
   }
   
  -String PrimitiveType() :
  +Token PrimitiveType() :
   {
      Token t = null;
   }
   {
  -  t="boolean" { return t.image; }
  +  t="boolean" { return t; }
   |
  -  t="char" { return t.image; }
  +  t="char" { return t; }
   |
  -  t="byte" { return t.image; }
  +  t="byte" { return t; }
   |
  -  t="short" { return t.image; }
  +  t="short" { return t; }
   |
  -  t="int" { return t.image; }
  +  t="int" { return t; }
   |
  -  t="long" { return t.image; }
  +  t="long" { return t; }
   |
  -  t="float" { return t.image; }
  +  t="float" { return t; }
   |
  -  t="double" { return t.image; }
  +  t="double" { return t; }
   }
   
   void ResultType(MethodImpl methodImpl) :
  @@ -1011,11 +1047,6 @@
     }
   |
     MethodResult_Type(methodImpl)
  -  {
  -     if( methodImpl != null ) {
  -        setToken( methodImpl, t );
  -     }
  -  }
   }
   
   String Name() :
  @@ -1029,9 +1060,9 @@
      Token t = null;
   }
   {
  -  t=<IDENTIFIER> 
  +  _nameToken=<IDENTIFIER> 
     {
  -     _nameBuffer.append(t.image);
  +     _nameBuffer.append(_nameToken.image);
     }
     ( LOOKAHEAD(2) "." t=<IDENTIFIER>
     {
  
  
  

_______________________________________________
Xdoclet-devel mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/xdoclet-devel

Reply via email to