User: rinkrank
Date: 02/02/23 20:38:57
Modified: javacc Java1.2-b.jjt Java1.2-b-benchmark.jjt
Log:
No class variables. The variables are passed to the productions that need to modify
them. This solves innerclass problem too.
Added new production rules (with underscore in the name) which are only used in
special cases
-Added complete() method to AbstractClass. This will fill in a class' members, but
not before it's needed. BIG optimizer!
-Using wait() (Thanks for this incredibly fantastic idea Ara!!!!!!!!!!!!!!!!!!!!!)
-Changed back to methodNameWithSignature for the sake of a simpler API
-xjavadoc is 4-5 times faster if only class level docs are accessed ;-)))
Revision Changes Path
1.11 +390 -285 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.10
retrieving revision 1.11
diff -u -w -r1.10 -r1.11
--- Java1.2-b.jjt 22 Feb 2002 22:50:28 -0000 1.10
+++ Java1.2-b.jjt 24 Feb 2002 04:38:57 -0000 1.11
@@ -43,10 +43,10 @@
options {
JAVA_UNICODE_ESCAPE=false;
- STATIC=true;
+ STATIC=false;
MULTI=false;
VISITOR=false;
- NODE_USES_PARSER=false;
+ NODE_USES_PARSER=true;
CACHE_TOKENS=true;
}
@@ -61,17 +61,18 @@
{
private static org.apache.log4j.Category _log =
org.apache.log4j.Category.getInstance(JavaParser.class.getName());
- private static SourceClass _sourceClass;
- private static MethodImpl _methodImpl;
- private static AbstractExecutableMember _executableMember;
- private static FieldImpl _fieldImpl;
-
private static final String[] NULL_STRING_ARRAY = new String[0];
- protected static ArrayList _importedClasses = new ArrayList();
- protected static ArrayList _importedPackages = new ArrayList();
+ private static final void setToken(AbstractProgramElement element, Token token) {
+ element.setToken( token );
+ //element.setDoc(getJavaDocSpecialToken( token ));
+ }
- private static Token getJavaDocSpecialToken(Token t) {
+/*
+ private static final Token getJavaDocSpecialToken(Token t) {
+ if( t == null ) {
+ return null;
+ }
Token result = null;
Token tt = t.specialToken;
@@ -95,39 +96,15 @@
}
return result;
}
+*/
+ private final StringBuffer _nameBuffer = new StringBuffer();
- private static void addImportedClass( String clazz ) {
- _importedClasses.add(clazz);
- }
-
- private static void addImportedPackage( String packaj ) {
- _importedPackages.add(packaj);
- }
-
- private static void setInterfaces(String nameList) {
- if( nameList != null ) {
- _sourceClass.setInterfaces(nameList);
- }
- }
-
- private static void setExceptions( String nameList) {
- if( nameList != null ) {
- StringTokenizer st = new StringTokenizer(nameList, ",");
- while( st.hasMoreTokens() ) {
- _executableMember.addThrownException( st.nextToken() );
- }
- }
- }
-
- private static class Type {
+ private static class Parameter {
public String type;
+ public String name;
public int dimension;
-
- public Type( String t, int d ) {
- type = t;
- dimension = d;
- }
}
+ private Parameter _parameter = new Parameter();
}
PARSER_END(JavaParser)
@@ -400,33 +377,35 @@
*/
void CompilationUnit( SourceClass sourceClass ) :
+{}
{
- _sourceClass = sourceClass;
-}
-{
- [ PackageDeclaration() ]
- ( ImportDeclaration() )*
- ( TypeDeclaration() )*
+ [ PackageDeclaration(sourceClass) ]
+ ( ImportDeclaration(sourceClass) )*
+ ( TypeDeclaration(sourceClass) )*
<EOF>
{
- // _sourceClass must know about ASTCompilationUnit
+ // sourceClass must know about ASTCompilationUnit
// if it wants to mutate or print the code
- _sourceClass.setCompilationUnit( jjtThis );
+ sourceClass.setCompilationUnit( jjtThis );
+ // wake up the sourceClass. It's waiting in complete()
+ synchronized( sourceClass.getParseLock() ) {
+ sourceClass.getParseLock().notify();
+ }
}
}
-void PackageDeclaration() :
+void PackageDeclaration(SourceClass sourceClass) :
{
String packageName;
}
{
"package" packageName=Name() ";"
{
- _sourceClass.setContainingPackage( packageName );
+ sourceClass.setContainingPackage( packageName );
}
}
-void ImportDeclaration() :
+void ImportDeclaration(SourceClass sourceClass) :
{
String importedElement;
boolean isPackage = false;
@@ -440,20 +419,20 @@
";"
{
if( isPackage ) {
- addImportedPackage(importedElement);
+ sourceClass.addImportedPackage(importedElement);
} else {
- addImportedClass(importedElement);
+ sourceClass.addImportedClass(importedElement);
}
}
}
-void TypeDeclaration() :
+void TypeDeclaration(SourceClass sourceClass) :
{}
{
LOOKAHEAD( ( "abstract" | "final" | "public" | "strictfp" )* "class" )
- ClassDeclaration()
+ ClassDeclaration(sourceClass)
|
- InterfaceDeclaration()
+ InterfaceDeclaration(sourceClass)
|
";"
}
@@ -468,113 +447,133 @@
attached to the first modifier token (if there are any modifiers)
or to the first token in UnmodifiedClassDeclaration
*/
-void ClassDeclaration() :
+void ClassDeclaration(SourceClass sourceClass) :
{
- Token t;
+ Token t = null;
}
{
(
t="abstract" {
- _sourceClass.setToken( t );
- _sourceClass.addModifier( Modifier.ABSTRACT );
- _sourceClass.setDoc(getJavaDocSpecialToken( t ));
- _sourceClass.setImportedClasses(
(String[])_importedClasses.toArray(NULL_STRING_ARRAY) );
- _sourceClass.setImportedPackages(
(String[])_importedPackages.toArray(NULL_STRING_ARRAY) );
- _importedClasses.clear();
- _importedPackages.clear();
+ setToken(sourceClass, t);
+ sourceClass.addModifier( Modifier.ABSTRACT );
}
| t="final" {
- _sourceClass.setToken( t );
- _sourceClass.addModifier( Modifier.FINAL );
- _sourceClass.setDoc(getJavaDocSpecialToken( t ));
- _sourceClass.setImportedClasses(
(String[])_importedClasses.toArray(NULL_STRING_ARRAY) );
- _sourceClass.setImportedPackages(
(String[])_importedPackages.toArray(NULL_STRING_ARRAY) );
- _importedClasses.clear();
- _importedPackages.clear();
+ setToken(sourceClass, t);
+ sourceClass.addModifier( Modifier.FINAL );
}
| t="public" {
- _sourceClass.setToken( t );
- _sourceClass.addModifier( Modifier.PUBLIC );
- _sourceClass.setDoc(getJavaDocSpecialToken( t ));
- _sourceClass.setImportedClasses(
(String[])_importedClasses.toArray(NULL_STRING_ARRAY) );
- _sourceClass.setImportedPackages(
(String[])_importedPackages.toArray(NULL_STRING_ARRAY) );
- _importedClasses.clear();
- _importedPackages.clear();
+ setToken(sourceClass, t);
+ sourceClass.addModifier( Modifier.PUBLIC );
}
| t="strictfp" {
- _sourceClass.setToken( t );
- _sourceClass.addModifier( Modifier.STRICT );
- _sourceClass.setDoc(getJavaDocSpecialToken( t ));
- _sourceClass.setImportedClasses(
(String[])_importedClasses.toArray(NULL_STRING_ARRAY) );
- _sourceClass.setImportedPackages(
(String[])_importedPackages.toArray(NULL_STRING_ARRAY) );
- _importedClasses.clear();
- _importedPackages.clear();
+ setToken(sourceClass, t);
+ sourceClass.addModifier( Modifier.STRICT );
}
)*
- UnmodifiedClassDeclaration()
+ UnmodifiedClassDeclaration(sourceClass)
}
-void UnmodifiedClassDeclaration() :
+void UnmodifiedClassDeclaration(SourceClass sourceClass) :
{
Token ct;
- Token t;
+ Token name = null;
String superclass = null;
- String interfaces = null;
}
{
ct="class" {
- _sourceClass.setToken( ct );
- _sourceClass.setDoc(getJavaDocSpecialToken( ct ));
- _sourceClass.setInterface( false );
+ setToken( sourceClass, ct );
+ sourceClass.setInterface( false );
}
- t=<IDENTIFIER> {
- _sourceClass.setName(t.image);
+ name=<IDENTIFIER> {
+ sourceClass.setName(name.image);
}
[ "extends" superclass=Name() ]
- [ "implements" interfaces=NameList() ] {
- setInterfaces(interfaces);
- }
- ClassBody() {
+ [ "implements" Interfaces_NameList(sourceClass) ]
+ ClassBody(sourceClass) {
if( superclass != null ) {
- _sourceClass.setSuperclass(superclass);
+ sourceClass.setSuperclass(superclass);
} else {
- _sourceClass.setSuperclass("java.lang.Object");
+ sourceClass.setSuperclass("java.lang.Object");
}
}
}
-void ClassBody() :
-{}
+void ClassBody(SourceClass sourceClass) :
{
- "{" ( ClassBodyDeclaration() )* "}"
+ try {
+ synchronized(sourceClass.getParseLock()) {
+ // Tell xjavadoc that we're ready with class level parsing
+ sourceClass.getParseLock().notify();
+
+ // Wait here until we're woken up. That happens in SourceClass.complete()
+ sourceClass.getParseLock().wait();
+ }
+ } catch(InterruptedException e) {
+ e.printStackTrace();
+ }
+}
+{
+ "{" ( ClassBodyDeclaration(sourceClass) )* "}"
}
-void NestedClassDeclaration() :
-{}
+void NestedClassDeclaration(SourceClass sourceClass) :
{
- ( "static" | "abstract" | "final" | "public" | "protected" | "private" |
"strictfp")*
- UnmodifiedClassDeclaration()
+ Token t;
+ SourceClass innerClass = new SourceClass(sourceClass,
sourceClass.qualifiedName() + "$" + "FIXME", null );
+}
+{
+ (
+ t="static" {
+ innerClass.addModifier( Modifier.STATIC );
+ innerClass.setToken( t );
+ }
+ | t="abstract" {
+ innerClass.addModifier( Modifier.ABSTRACT );
+ innerClass.setToken( t );
+ }
+ | t="final" {
+ innerClass.addModifier( Modifier.FINAL );
+ innerClass.setToken( t );
+ }
+ | t="public" {
+ innerClass.addModifier( Modifier.PUBLIC );
+ innerClass.setToken( t );
+ }
+ | t="protected" {
+ innerClass.addModifier( Modifier.PROTECTED );
+ innerClass.setToken( t );
+ }
+ | t="private" {
+ innerClass.addModifier( Modifier.PRIVATE );
+ innerClass.setToken( t );
+ }
+ | t="strictfp" {
+ innerClass.addModifier( Modifier.STRICT );
+ innerClass.setToken( t );
+ }
+ )*
+ UnmodifiedClassDeclaration(innerClass)
}
-void ClassBodyDeclaration() :
+void ClassBodyDeclaration(SourceClass sourceClass) :
{}
{
LOOKAHEAD(2)
Initializer()
|
LOOKAHEAD( ( "static" | "abstract" | "final" | "public" | "protected" | "private"
| "strictfp")* "class" )
- NestedClassDeclaration()
+ NestedClassDeclaration(sourceClass)
|
LOOKAHEAD( ( "static" | "abstract" | "final" | "public" | "protected" | "private"
| "strictfp")* "interface" )
- NestedInterfaceDeclaration()
+ NestedInterfaceDeclaration(sourceClass)
|
LOOKAHEAD( [ "public" | "protected" | "private" ] Name() "(" )
- ConstructorDeclaration()
+ ConstructorDeclaration(sourceClass)
|
LOOKAHEAD( MethodDeclarationLookahead() )
- MethodDeclaration()
+ MethodDeclaration(sourceClass)
|
- FieldDeclaration()
+ FieldDeclaration(sourceClass)
}
// This production is to determine lookahead only.
@@ -582,138 +581,122 @@
{}
{
( "public" | "protected" | "private" | "static" | "abstract" | "final" | "native"
| "synchronized" | "strictfp")*
- ResultType() <IDENTIFIER> "("
+ ResultType(null) <IDENTIFIER> "("
}
-void InterfaceDeclaration() :
+void InterfaceDeclaration(SourceClass sourceClass) :
{
- Token t;
+ Token t = null;
}
{
(
t="abstract" {
- _sourceClass.setToken( t );
- _sourceClass.setDoc(getJavaDocSpecialToken( t ));
+ sourceClass.addModifier( Modifier.ABSTRACT );
+ sourceClass.setToken( t );
}
| t="public" {
- _sourceClass.setToken( t );
- _sourceClass.addModifier( Modifier.PUBLIC );
- _sourceClass.setDoc(getJavaDocSpecialToken( t ));
+ sourceClass.addModifier( Modifier.PUBLIC );
+ sourceClass.setToken( t );
}
| t="strictfp" {
- _sourceClass.setToken( t );
- _sourceClass.addModifier( Modifier.STRICT );
- _sourceClass.setDoc(getJavaDocSpecialToken( t ));
+ sourceClass.addModifier( Modifier.STRICT );
+ sourceClass.setToken( t );
}
)*
- UnmodifiedInterfaceDeclaration()
+ UnmodifiedInterfaceDeclaration(sourceClass)
}
-void NestedInterfaceDeclaration() :
+void NestedInterfaceDeclaration(SourceClass sourceClass) :
{}
{
( "static" | "abstract" | "final" | "public" | "protected" | "private" |
"strictfp")*
- UnmodifiedInterfaceDeclaration()
+ UnmodifiedInterfaceDeclaration(sourceClass)
}
-void UnmodifiedInterfaceDeclaration() :
+void UnmodifiedInterfaceDeclaration(SourceClass sourceClass) :
{
Token it;
- Token t;
- String extendedInterfaces = null;
+ Token t = null;
}
{
- it="interface" t=<IDENTIFIER> [ "extends" extendedInterfaces=NameList() ]
- "{" ( InterfaceMemberDeclaration() )* "}"
+ it="interface" t=<IDENTIFIER> [ "extends" Interfaces_NameList(sourceClass) ]
+ "{" ( InterfaceMemberDeclaration(sourceClass) )* "}"
{
- _sourceClass.setToken( it );
- _sourceClass.addModifier( Modifier.ABSTRACT );
- _sourceClass.setName( t.image );
- _sourceClass.setInterface( true );
- _sourceClass.setDoc(getJavaDocSpecialToken( t ));
-
- if( extendedInterfaces != null ) {
- setInterfaces(extendedInterfaces);
- }
+ // interfaces are always abstract
+ sourceClass.addModifier( Modifier.ABSTRACT );
+ sourceClass.setName( t.image );
+ sourceClass.setInterface( true );
+ setToken(sourceClass,it);
}
}
-void InterfaceMemberDeclaration() :
+void InterfaceMemberDeclaration(SourceClass sourceClass) :
{}
{
LOOKAHEAD( ( "static" | "abstract" | "final" | "public" | "protected" | "private"
| "strictfp")* "class" )
- NestedClassDeclaration()
+ NestedClassDeclaration(sourceClass)
|
LOOKAHEAD( ( "static" | "abstract" | "final" | "public" | "protected" | "private"
| "strictfp")* "interface" )
- NestedInterfaceDeclaration()
+ NestedInterfaceDeclaration(sourceClass)
|
LOOKAHEAD( MethodDeclarationLookahead() )
- MethodDeclaration()
+ MethodDeclaration(sourceClass)
|
- FieldDeclaration()
+ FieldDeclaration(sourceClass)
}
-void FieldDeclaration() :
+void FieldDeclaration(SourceClass sourceClass) :
{
- Token t;
- Type type;
- _fieldImpl = new FieldImpl(_sourceClass, null);
+ /* TODO: support lame style like
+
+ private static int a,b,c,d;
+
+ They should share the same javadoc, type and modifiers
+ */
+ Token t = null;
+ FieldImpl fieldImpl = null;
+ fieldImpl = new FieldImpl(sourceClass, null);
+ sourceClass.addField(fieldImpl);
}
{
(
t="public" {
- _fieldImpl.addModifier( Modifier.PUBLIC );
- _fieldImpl.setToken( t );
- _fieldImpl.setDoc(getJavaDocSpecialToken( t ));
+ fieldImpl.addModifier( Modifier.PUBLIC );
+ setToken(fieldImpl,t);
}
| t="protected" {
- _fieldImpl.addModifier( Modifier.PROTECTED );
- _fieldImpl.setToken( t );
- _fieldImpl.setDoc(getJavaDocSpecialToken( t ));
+ fieldImpl.addModifier( Modifier.PROTECTED );
+ setToken(fieldImpl,t);
}
| t="private" {
- _fieldImpl.addModifier( Modifier.PRIVATE );
- _fieldImpl.setToken( t );
- _fieldImpl.setDoc(getJavaDocSpecialToken( t ));
+ fieldImpl.addModifier( Modifier.PRIVATE );
+ setToken(fieldImpl,t);
}
| t="static" {
- _fieldImpl.addModifier( Modifier.STATIC );
- _fieldImpl.setToken( t );
- _fieldImpl.setDoc(getJavaDocSpecialToken( t ));
+ fieldImpl.addModifier( Modifier.STATIC );
+ setToken(fieldImpl,t);
}
| t="final" {
- _fieldImpl.addModifier( Modifier.FINAL );
- _fieldImpl.setToken( t );
- _fieldImpl.setDoc(getJavaDocSpecialToken( t ));
+ fieldImpl.addModifier( Modifier.FINAL );
+ setToken(fieldImpl,t);
}
| t="transient" {
- _fieldImpl.addModifier( Modifier.TRANSIENT );
- _fieldImpl.setToken( t );
- _fieldImpl.setDoc(getJavaDocSpecialToken( t ));
+ fieldImpl.addModifier( Modifier.TRANSIENT );
+ setToken(fieldImpl,t);
}
| t="volatile" {
- _fieldImpl.addModifier( Modifier.VOLATILE );
- _fieldImpl.setToken( t );
- _fieldImpl.setDoc(getJavaDocSpecialToken( t ));
+ fieldImpl.addModifier( Modifier.VOLATILE );
+ setToken(fieldImpl,t);
}
)*
- type=Type() FieldDeclarator(type) ( "," FieldDeclarator(type) )* ";"
- {
- _fieldImpl.setType(type.type);
- _fieldImpl.setDimension(type.dimension);
- _sourceClass.addField(_fieldImpl);
- }
+ Field_Type(fieldImpl) FieldDeclarator(fieldImpl) ( "," FieldDeclarator(fieldImpl)
)* ";"
}
-void FieldDeclarator(Type type) :
+void FieldDeclarator(FieldImpl fieldImpl) :
{
- Type variable;
}
{
- variable=VariableDeclaratorId() [ "=" VariableInitializer() ] {
- _fieldImpl.setName( variable.type );
- _fieldImpl.setDimension( type.dimension + variable.dimension );
- }
+ Field_VariableDeclaratorId(fieldImpl) [ "=" VariableInitializer() ]
}
void VariableDeclarator() :
@@ -722,18 +705,34 @@
VariableDeclaratorId() [ "=" VariableInitializer() ]
}
-Type VariableDeclaratorId() :
+void Field_VariableDeclaratorId(FieldImpl fieldImpl) :
{
- Token t;
- int dimension = 0;
+ Token t = null;
}
{
- t=<IDENTIFIER> ( "[" "]" { dimension++; } )*
+ t=<IDENTIFIER> ( "[" "]" { fieldImpl.setDimension(fieldImpl.getDimension() + 1);
} )*
{
- return new Type(t.image, dimension);
+ fieldImpl.setName( t.image );
}
}
+void Parameter_VariableDeclaratorId() :
+{
+ Token t = null;
+}
+{
+ t=<IDENTIFIER> ( "[" "]" { _parameter.dimension++; } )*
+ {
+ _parameter.name = t.image;
+ }
+}
+
+void VariableDeclaratorId() :
+{}
+{
+ <IDENTIFIER> ( "[" "]" )*
+}
+
void VariableInitializer() :
{}
{
@@ -748,132 +747,126 @@
"{" [ VariableInitializer() ( LOOKAHEAD(2) "," VariableInitializer() )* ] [ "," ]
"}"
}
-void MethodDeclaration() :
+void MethodDeclaration(SourceClass sourceClass) :
{
- Token t;
- _methodImpl = new MethodImpl(_sourceClass, null);
- _executableMember = _methodImpl;
+ Token t = null;
String exceptions = null;
+ MethodImpl methodImpl = null;
+ methodImpl = new MethodImpl(sourceClass, null);
}
{
(
t="public" {
- _methodImpl.addModifier( Modifier.PUBLIC );
- _methodImpl.setToken( t );
- _methodImpl.setDoc(getJavaDocSpecialToken( t ));
+ methodImpl.addModifier( Modifier.PUBLIC );
+ setToken( methodImpl, t );
}
| t="protected" {
- _methodImpl.addModifier( Modifier.PROTECTED );
- _methodImpl.setToken( t );
- _methodImpl.setDoc(getJavaDocSpecialToken( t ));
+ methodImpl.addModifier( Modifier.PROTECTED );
+ setToken( methodImpl, t );
}
| t="private" {
- _methodImpl.addModifier( Modifier.PRIVATE );
- _methodImpl.setToken( t );
- _methodImpl.setDoc(getJavaDocSpecialToken( t ));
+ methodImpl.addModifier( Modifier.PRIVATE );
+ setToken( methodImpl, t );
}
| t="static" {
- _methodImpl.addModifier( Modifier.STATIC );
- _methodImpl.setToken( t );
- _methodImpl.setDoc(getJavaDocSpecialToken( t ));
+ methodImpl.addModifier( Modifier.STATIC );
+ setToken( methodImpl, t );
}
| t="abstract" {
- _methodImpl.addModifier( Modifier.ABSTRACT );
- _methodImpl.setToken( t );
- _methodImpl.setDoc(getJavaDocSpecialToken( t ));
+ methodImpl.addModifier( Modifier.ABSTRACT );
+ setToken( methodImpl, t );
}
| t="final" {
- _methodImpl.addModifier( Modifier.FINAL );
- _methodImpl.setToken( t );
- _methodImpl.setDoc(getJavaDocSpecialToken( t ));
+ methodImpl.addModifier( Modifier.FINAL );
+ setToken( methodImpl, t );
}
| t="native" {
- _methodImpl.addModifier( Modifier.NATIVE );
- _methodImpl.setToken( t );
- _methodImpl.setDoc(getJavaDocSpecialToken( t ));
+ methodImpl.addModifier( Modifier.NATIVE );
+ setToken( methodImpl, t );
}
| t="synchronized" {
- _methodImpl.addModifier( Modifier.SYNCHRONIZED );
- _methodImpl.setToken( t );
- _methodImpl.setDoc(getJavaDocSpecialToken( t ));
+ methodImpl.addModifier( Modifier.SYNCHRONIZED );
+ setToken( methodImpl, t );
}
| t="strictfp" {
- _methodImpl.addModifier( Modifier.STRICT );
- _methodImpl.setToken( t );
- _methodImpl.setDoc(getJavaDocSpecialToken( t ));
+ methodImpl.addModifier( Modifier.STRICT );
+ setToken( methodImpl, t );
}
)*
- ResultType() MethodDeclarator() [ "throws" exceptions=NameList() ]
+ ResultType(methodImpl)
+ MethodDeclarator(methodImpl)
+ [ "throws" ExecutableMemberThrows_NameList(methodImpl) ]
+ ( Method_Block(sourceClass) | ";" )
{
- setExceptions( exceptions );
- _sourceClass.addMethod(_methodImpl);
+ // we must add the method after the fields are in, because the
+ // signature must be complete when adding
+ sourceClass.addMethod(methodImpl);
}
- ( Block() | ";" )
}
-void MethodDeclarator() :
+void MethodDeclarator(MethodImpl methodImpl) :
{
- Token t;
+ Token t = null;
}
{
t=<IDENTIFIER> {
- _methodImpl.setName( t.image );
+ if( methodImpl != null ) {
+ methodImpl.setName( t.image );
+ setToken( methodImpl, t );
+ }
}
- FormalParameters() ( "[" "]" )*
+ FormalParameters(methodImpl) ( "[" "]" )*
}
-void FormalParameters() :
+void FormalParameters(AbstractExecutableMember member) :
{}
{
- "(" [ FormalParameter() ( "," FormalParameter() )* ] ")"
+ "(" [ FormalParameter(member) ( "," FormalParameter(member) )* ] ")"
}
-void FormalParameter() :
+void FormalParameter(AbstractExecutableMember member) :
{
- Type type;
- Type variable;
+ if(member != null) {
+ // reset the _parameter helper's dimension
+ _parameter.dimension = 0;
+ }
}
{
- [ "final" ] type=Type() variable=VariableDeclaratorId()
+ [ "final" ] Parameter_Type() Parameter_VariableDeclaratorId()
{
- _executableMember.addParameterData(type.type,variable.type,type.dimension +
variable.dimension);
+ if( member != null ) {
+ member.addParameterData(_parameter.type, _parameter.name,
_parameter.dimension);
+ }
}
}
-void ConstructorDeclaration() :
+void ConstructorDeclaration(SourceClass sourceClass) :
{
- Token t;
- ConstructorImpl constructor = new ConstructorImpl(_sourceClass, null);
- _executableMember = constructor;
- String exceptions = null;
+ Token t = null;
+ ConstructorImpl constructor = null;
+ constructor = new ConstructorImpl(sourceClass, null);
+ sourceClass.addConstructor(constructor);
}
{
[
t="public" {
constructor.addModifier( Modifier.PUBLIC );
- constructor.setToken( t );
- constructor.setDoc(getJavaDocSpecialToken( t ));
+ setToken( constructor, t );
}
| t="protected" {
constructor.addModifier( Modifier.PROTECTED );
- constructor.setToken( t );
- constructor.setDoc(getJavaDocSpecialToken( t ));
+ setToken( constructor, t );
}
| t="private" {
constructor.addModifier( Modifier.PRIVATE );
- constructor.setToken( t );
- constructor.setDoc(getJavaDocSpecialToken( t ));
+ setToken( constructor, t );
}
]
- <IDENTIFIER> FormalParameters() [ "throws" exceptions=NameList() ]
+ <IDENTIFIER> FormalParameters(constructor) [ "throws"
ExecutableMemberThrows_NameList(constructor) ]
"{"
[ LOOKAHEAD(ExplicitConstructorInvocation()) ExplicitConstructorInvocation() ]
( BlockStatement() )*
"}"
- {
- setExceptions( exceptions );
- _sourceClass.addConstructor(constructor);
- }
}
void ExplicitConstructorInvocation() :
@@ -896,22 +889,59 @@
* Type, name and expression syntax follows.
*/
-Type Type() :
+void Field_Type(FieldImpl fieldImpl) :
+{
+ String type;
+}
+{
+ ( type=PrimitiveType() | type=Name() )
+ ( "[" "]" {
+ if( fieldImpl != null ) {
+ fieldImpl.setDimension(fieldImpl.getDimension() + 1);
+ }
+ } )*
+ {
+ if( fieldImpl != null ) {
+ fieldImpl.setType(type);
+ }
+ }
+}
+
+void MethodResult_Type(MethodImpl methodImpl) :
{
String type;
- int dimension = 0;
}
{
( type=PrimitiveType() | type=Name() )
- ( "[" "]" { dimension++; } )*
+ ( "[" "]" {
+ if( methodImpl != null ) {
+ methodImpl.setReturnDimension(methodImpl.returnDimension() + 1);
+ }
+ } )*
{
- return new Type( type, dimension );
+ if( methodImpl != null ) {
+ methodImpl.setReturnType(type);
+ }
}
}
+void Parameter_Type() :
+{}
+{
+ ( _parameter.type=PrimitiveType() | _parameter.type=Name() )
+ ( "[" "]" { _parameter.dimension++; } )*
+}
+
+void Type() :
+{}
+{
+ ( PrimitiveType() | Name() )
+ ( "[" "]" )*
+}
+
String PrimitiveType() :
{
- Token t;
+ Token t = null;
}
{
t="boolean" { return t.image; }
@@ -931,23 +961,24 @@
t="double" { return t.image; }
}
-void ResultType() :
+void ResultType(MethodImpl methodImpl) :
{
- Token t;
- Type type;
+ Token t = null;
}
{
t="void" {
- _methodImpl.setReturnType( "void" );
- _methodImpl.setReturnDimension( 0 );
- _methodImpl.setToken( t );
+ if( methodImpl != null ) {
+ methodImpl.setReturnType( "void" );
+ methodImpl.setReturnDimension( 0 );
+ setToken( methodImpl, t );
+ }
}
|
- type=Type()
+ MethodResult_Type(methodImpl)
{
- _methodImpl.setReturnType( type.type );
- _methodImpl.setReturnDimension( type.dimension );
- _methodImpl.setToken( ((SimpleNode)jjtThis).first );
+ if( methodImpl != null ) {
+ setToken( methodImpl, t );
+ }
}
}
@@ -957,42 +988,89 @@
* by a ".*" when used in the context of an "ImportDeclaration".
*/
{
- StringBuffer sb = new StringBuffer();
- Token t;
+ // reset the buffer
+ _nameBuffer.delete(0, _nameBuffer.length());
+ Token t = null;
}
{
t=<IDENTIFIER>
{
- sb.append(t.image);
+ _nameBuffer.append(t.image);
}
( LOOKAHEAD(2) "." t=<IDENTIFIER>
{
- sb.append(".").append(t.image);
+ _nameBuffer.append(".").append(t.image);
+ }
+ )*
+ {
+ return _nameBuffer.toString();
+ }
+}
+
+void ExecutableMemberThrows_Name(AbstractExecutableMember member) :
+{
+ // reset the buffer
+ _nameBuffer.delete(0, _nameBuffer.length() - 1);
+ Token t = null;
+}
+{
+ t=<IDENTIFIER>
+ {
+ _nameBuffer.append(t.image);
+ }
+ ( "." t=<IDENTIFIER>
+ {
+ _nameBuffer.append(".").append(t.image);
}
)*
{
- return sb.toString();
+ if( member != null ) {
+ member.addThrownException( _nameBuffer.toString() );
+ }
}
}
-String NameList() :
+void Interfaces_Name(SourceClass sourceClass) :
{
- String s;
- StringBuffer sb = new StringBuffer();
+ // reset the buffer
+ _nameBuffer.delete(0, _nameBuffer.length() - 1);
+ Token t = null;
}
{
- s=Name() {
- sb.append(s);
+ t=<IDENTIFIER>
+ {
+ _nameBuffer.append(t.image);
}
- ( "," s=Name() {
- sb.append(",").append(s);
+ ( "." t=<IDENTIFIER>
+ {
+ _nameBuffer.append(".").append(t.image);
}
)*
{
- return sb.toString();
+ sourceClass.addInterface( _nameBuffer.toString() );
}
}
+void NameList() :
+{}
+{
+ Name() ( "," Name() )*
+}
+
+void ExecutableMemberThrows_NameList(AbstractExecutableMember member) :
+{}
+{
+ ExecutableMemberThrows_Name(member)
+ ( "," ExecutableMemberThrows_Name(member) )*
+}
+
+void Interfaces_NameList(SourceClass sourceClass) :
+{}
+{
+ Interfaces_Name(sourceClass)
+ ( "," Interfaces_Name(sourceClass) )*
+}
+
/*
* Expression syntax follows.
@@ -1179,8 +1257,8 @@
|
AllocationExpression()
|
- LOOKAHEAD( ResultType() "." "class" )
- ResultType() "." "class"
+ LOOKAHEAD( ResultType(null) "." "class" )
+ ResultType(null) "." "class"
|
Name()
}
@@ -1243,6 +1321,9 @@
Expression() ( "," Expression() )*
}
+/**
+ * @todo Anonymous classes will cause NPE. Need to check for nullity in a lot of
places
+ */
void AllocationExpression() :
{}
{
@@ -1253,7 +1334,7 @@
(
ArrayDimsAndInits()
|
- Arguments() [ ClassBody() ]
+ Arguments() [ ClassBody(null) ]
)
}
@@ -1322,6 +1403,16 @@
"{" ( BlockStatement() )* "}"
}
+void Method_Block(SourceClass sourceClass) :
+{}
+{
+ "{" ( Method_BlockStatement(sourceClass) )* "}"
+}
+
+/**
+ * @todo not sure if the UnmodifiedClassDeclaration/UnmodifiedInterfaceDeclaration
+ * ever get called, now that we have two different blocks. It would be nice to
remove them
+ */
void BlockStatement() :
{}
{
@@ -1330,10 +1421,24 @@
|
Statement()
|
- UnmodifiedClassDeclaration()
+ UnmodifiedClassDeclaration(null)
+|
+// added this choice point to handle inner interfaces. DW, 7/99
+ UnmodifiedInterfaceDeclaration(null)
+}
+
+void Method_BlockStatement(SourceClass sourceClass) :
+{}
+{
+ LOOKAHEAD([ "final" ] Type() <IDENTIFIER>)
+ LocalVariableDeclaration() ";"
+|
+ Statement()
+|
+ UnmodifiedClassDeclaration(sourceClass)
|
// added this choice point to handle inner interfaces. DW, 7/99
- UnmodifiedInterfaceDeclaration()
+ UnmodifiedInterfaceDeclaration(sourceClass)
}
void LocalVariableDeclaration() :
@@ -1474,6 +1579,6 @@
{}
{
"try" Block()
- ( "catch" "(" FormalParameter() ")" Block() )*
+ ( "catch" "(" FormalParameter(null) ")" Block() )*
[ "finally" Block() ]
}
1.2 +3 -1 xjavadoc/javacc/Java1.2-b-benchmark.jjt
Index: Java1.2-b-benchmark.jjt
===================================================================
RCS file: /cvsroot/xdoclet/xjavadoc/javacc/Java1.2-b-benchmark.jjt,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -w -r1.1 -r1.2
--- Java1.2-b-benchmark.jjt 22 Feb 2002 00:30:41 -0000 1.1
+++ Java1.2-b-benchmark.jjt 24 Feb 2002 04:38:57 -0000 1.2
@@ -358,7 +358,9 @@
[ PackageDeclaration() ]
( ImportDeclaration() )*
( TypeDeclaration() )*
- <EOF>
+ <EOF> {
+ SimpleNode compilationUnit = jjtThis;
+ }
}
void PackageDeclaration() :
_______________________________________________
Xdoclet-devel mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/xdoclet-devel