qdox-qdox-2.0-M3/ 0000775 0000000 0000000 00000000000 12450313474 0013557 5 ustar 00root root 0000000 0000000 qdox-qdox-2.0-M3/LICENSE.txt 0000664 0000000 0000000 00000001101 12450313474 0015373 0 ustar 00root root 0000000 0000000 Copyright 2002-2009 Joe Walnes and QDox Project Team
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
qdox-qdox-2.0-M3/README.txt 0000664 0000000 0000000 00000002305 12450313474 0015255 0 ustar 00root root 0000000 0000000 To build QDox there are two prerequisites:
* Maven 2 (2.0.9 or later)
http://maven.apache.org
* BYacc/J (1.8 or later)
http://byaccj.sourceforge.net/
Paarser generator used to create an effective parser for JavaDoc.
If using Windows, Linux, Solaris or Mac OS X, no additional installation is
needed as yacc binaries are supplied in the bootstrap directory.
If using any other platform, download BYacc/J from the site or build it yourself, in which case
we would be grateful to receive a copy of your binary, so we can upgrade the bootstrap support.
Build goals:
mvn install - Create qdox jar
mvn generate-sources - Generate the Java parser code (allowing you to develop in an IDE).
mvn site - Build the QDox website
mvn release:prepare - Prepare release (confirm or change release version interactively)
mvn release:perform - Perform release (perform release from tag of prepare phase)
If you are releasing, remember to
1) Update src/site/content/download.html
2) Go to JIRA and release the applicable version for QDOX : http://jira.codehaus.org/secure/project/ManageVersions.jspa?pid=10103
3) Copy the contents of target/site/ to the DAV folder for QDox's website : https://dav.codehaus.org/qdox/ qdox-qdox-2.0-M3/bootstrap/ 0000775 0000000 0000000 00000000000 12450313474 0015574 5 ustar 00root root 0000000 0000000 qdox-qdox-2.0-M3/pom.xml 0000664 0000000 0000000 00000042271 12450313474 0015102 0 ustar 00root root 0000000 0000000
4.0.0
org.codehaus
codehaus-parent
4
QDox
com.thoughtworks.qdox
qdox
2.0-M3
jar
http://qdox.codehaus.org
QDox is a high speed, small footprint parser for extracting class/interface/method definitions from source files
complete with JavaDoc @tags. It is designed to be used by active code generators or documentation tools.
2002
The Apache Software License, Version 2.0
http://www.apache.org/licenses/LICENSE-2.0.txt
repo
announce at QDox
announce@qdox.codehaus.org
announce-subscribe@qdox.codehaus.org
announce-unsubscribe@qdox.codehaus.org
http://archive.codehaus.org/lists/org.codehaus.qdox.announce
dev at QDox
dev@qdox.codehaus.org
dev-subscribe@qdox.codehaus.org
dev-unsubscribe@qdox.codehaus.org
http://archive.codehaus.org/lists/org.codehaus.qdox.dev
scm at QDox
scm-subscribe@qdox.codehaus.org
scm-unsubscribe@qdox.codehaus.org
http://archive.codehaus.org/lists/org.codehaus.qdox.scm
user at QDox
user@qdox.codehaus.org
user-subscribe@qdox.codehaus.org
user-unsubscribe@qdox.codehaus.org
http://archive.codehaus.org/lists/org.codehaus.qdox.user
jira
http://jira.codehaus.org/browse/QDOX
bamboo
http://bamboo.ci.codehaus.org/browse/QDOX
scm:svn:https://svn.codehaus.org/qdox/tags/qdox-2.0-M3
scm:svn:https://svn.codehaus.org/qdox/tags/qdox-2.0-M3
http://svn.qdox.codehaus.org/browse/qdox/tags/qdox-2.0-M3
rfscholte
Robert Scholte
+1
project lead
joe
Joe Walnes
project founder
Aslak Hellesoy
rinkrank
developer
Paul Hammant
paul
developer
Mike Williams
mdub
developer
mauro
Mauro Talevi
developer
Mike Royle
Peter Donald
James Strachan
Nick Pomfret
Chris Stevenson
Ben Hogan
Laurent Etiemble
Shawn Chain
Brian Slesinsky
James Lee
Eric Redmond
org.apache.maven.wagon
wagon-webdav-jackrabbit
2.2
org.apache.maven.plugins
maven-clean-plugin
2.4.1
org.apache.maven.plugins
maven-compiler-plugin
2.3.2
org.apache.maven.plugins
maven-surefire-plugin
2.9
always
org.apache.maven.plugins
maven-jar-plugin
2.3.2
org.apache.maven.plugins
maven-install-plugin
2.3.1
org.apache.maven.plugins
maven-deploy-plugin
2.7
org.apache.maven.plugins
maven-site-plugin
3.0
${basedir}/src/site/templates/site.vm
org.apache.maven.plugins
maven-release-plugin
2.5.1
org.apache.maven.plugins
maven-enforcer-plugin
1.3.1
enforce-maven
enforce
3.0
de.jflex
maven-jflex-plugin
1.4.3
generate
${project.build.directory}/generated-sources/parser
${basedir}/src/grammar/lexer.flex
${basedir}/src/grammar/commentlexer.flex
org.codehaus.mojo
exec-maven-plugin
1.2.1
javacommentparser
generate-sources
exec
${qdox.byaccj.executable}
-v
-Jnorun
-Jnoconstruct
-Jclass=DefaultJavaCommentParser
-Jpackage=com.thoughtworks.qdox.parser.impl
${basedir}/src/grammar/commentparser.y
${project.build.directory}/generated-sources/parser/com/thoughtworks/qdox/parser/impl
javasourceparser
generate-sources
exec
${qdox.byaccj.executable}
-v
-Jnorun
-Jnoconstruct
-Jclass=Parser
-Jimplements=CommentHandler
-Jsemantic=Value
-Jpackage=com.thoughtworks.qdox.parser.impl
-Jstack=${qdox.javaparser.stack}
${basedir}/src/grammar/parser.y
${project.build.directory}/generated-sources/parser/com/thoughtworks/qdox/parser/impl
org.codehaus.mojo
animal-sniffer-maven-plugin
1.7
check-java15
process-classes
check
org.codehaus.mojo.signature
java15
1.0
org.apache.maven.plugins
maven-failsafe-plugin
2.9
integration-test
verify
org.apache.maven.plugins
maven-invoker-plugin
1.5
${project.build.directory}/it
verify
${project.build.directory}/local-repo
clean
test
src/it/settings.xml
true
integration-test
install
run
org.apache.maven.plugins
maven-assembly-plugin
2.2.2
project
gnu
make-assembly
package
single
junit
junit
4.8.2
test
org.mockito
mockito-core
1.8.5
test
codehaus.org
QDox Site
dav:https://dav.codehaus.org/qdox/
linux
Linux
i386
${basedir}/bootstrap/yacc.linux
linux64
Linux
amd64
${basedir}/bootstrap/yacc.linux.x86_64
solaris
SunOS
${basedir}/bootstrap/yacc.solaris
macosx
Mac
${basedir}/bootstrap/yacc.macosx
windows
Windows
${basedir}/bootstrap/yacc.exe
org.apache.maven.plugins
maven-project-info-reports-plugin
2.4
dependencies
project-team
mailing-list
issue-tracking
license
scm
summary
org.apache.maven.plugins
maven-jxr-plugin
2.3
jxr
org.codehaus.mojo
cobertura-maven-plugin
2.4
org.apache.maven.plugins
maven-javadoc-plugin
2.8
com.thoughtworks.qdox.*
javadoc
org.apache.maven.plugins
maven-changes-plugin
2.6
Key,Summary,Fix Version,Status,Resolution
Fix Version DESC, Priority DESC, Created DESC
Resolved, Closed
jira-report
yyyy-MM-dd
UTF-8
${maven.build.timestamp}
500
qdox-qdox-2.0-M3/src/ 0000775 0000000 0000000 00000000000 12450313474 0014346 5 ustar 00root root 0000000 0000000 qdox-qdox-2.0-M3/src/grammar/ 0000775 0000000 0000000 00000000000 12450313474 0015774 5 ustar 00root root 0000000 0000000 qdox-qdox-2.0-M3/src/grammar/commentlexer.flex 0000664 0000000 0000000 00000013540 12450313474 0021361 0 ustar 00root root 0000000 0000000 package com.thoughtworks.qdox.parser.impl;
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
import com.thoughtworks.qdox.parser.*;
%%
// class and lexer definitions
%class DefaultJavaCommentLexer
%public
%implements Lexer
%byaccj
%unicode
%line
%column
%{
private int lineOffset = 1;
private int columnOffset =1;
private int stateDepth = 0;
private int[] stateStack = new int[10];
private StringBuffer codeBody = new StringBuffer(8192);
private boolean appendingToCodeBody;
public int lex() throws java.io.IOException {
return yylex();
}
public String text() {
return yytext();
}
public int getLine() {
return yyline + lineOffset;
}
public void setLineOffset(int lineOffset) {
this.lineOffset = lineOffset;
}
public int getColumn() {
return yycolumn + columnOffset;
}
public void setColumnOffset(int columnOffset) {
this.columnOffset = columnOffset;
}
public String getCodeBody(){
String s = codeBody.toString();
codeBody = new StringBuffer(8192);
return s;
}
private void pushState(int newState) {
stateStack[stateDepth++] = zzLexicalState;
yybegin(newState);
}
private void popState() {
yybegin(stateStack[--stateDepth]);
}
private int peekState(int relative) {
if(relative > stateDepth) {
return -1;
}
else {
return stateStack[stateDepth - relative];
}
}
%}
Eol = \r|\n|\r\n
JavadocEnd = "*"+ "/"
%state JAVADOC JAVADOCCONTENT JAVADOCLINE JAVADOCTAG MULTILINECOMMENT SINGLELINECOMMENT
%%
{
"//" {
codeBody.append( "//" );
pushState( SINGLELINECOMMENT );
}
"/**/" {
codeBody.append( "/**/" );
}
"/*" [*]+ {
pushState( JAVADOC );
pushState( JAVADOCCONTENT );
return DefaultJavaCommentParser.JAVADOCSTART;
}
"/*" {
codeBody.append( "/*" );
pushState( MULTILINECOMMENT );
}
}
{
"*"+ [ \t]* / "@" {
pushState(JAVADOCTAG);
}
"*"+ [ \t]? {
pushState(JAVADOCLINE);
}
{JavadocEnd} {
popState();
return DefaultJavaCommentParser.JAVADOCEND;
}
"@" {
yypushback(1);
pushState(JAVADOCTAG);
}
[^ \t\r] {
yypushback(1);
pushState(JAVADOCLINE);
}
}
{
[ \t]* "@" {
yypushback(1);
popState();
pushState(JAVADOCTAG);
}
[^ \t] {
yypushback(1);
popState();
pushState(JAVADOCLINE);
}
{Eol} {
popState();
return DefaultJavaCommentParser.JAVADOCLINE;
}
}
{
~{Eol} {
popState();
return DefaultJavaCommentParser.JAVADOCLINE;
}
.* [^ \t*] / [ \t]* {JavadocEnd} {
popState();
return DefaultJavaCommentParser.JAVADOCLINE;
}
{JavadocEnd} {
popState();
popState();
return DefaultJavaCommentParser.JAVADOCEND;
}
}
{
"@" [^ \t\n\r]+ / {JavadocEnd} {
popState();
return DefaultJavaCommentParser.JAVADOCTAG;
}
"@" [^ \t\n\r]+ {
return DefaultJavaCommentParser.JAVADOCTAG;
}
[ \t]+ {
popState();
pushState(JAVADOCLINE);
}
{Eol} {
popState();
return DefaultJavaCommentParser.JAVADOCLINE;
}
}
{
"*/" {
codeBody.append("*/");
popState();
}
}
{
{Eol} {
codeBody.append(yytext());
popState();
}
}
.|\r|\n|\r\n {
codeBody.append(yytext());
} qdox-qdox-2.0-M3/src/grammar/commentparser.y 0000664 0000000 0000000 00000006705 12450313474 0021055 0 ustar 00root root 0000000 0000000 %{
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
import java.io.IOException;
import com.thoughtworks.qdox.builder.Builder;
import com.thoughtworks.qdox.parser.Lexer;
import com.thoughtworks.qdox.parser.ParseException;
import com.thoughtworks.qdox.parser.structs.TagDef;
%}
%token JAVADOCSTART JAVADOCEND
// strongly typed tokens/types
%token JAVADOCTAG JAVADOCLINE
%%
javadoc: JAVADOCSTART javadocdescription_opt javadoctags_opt JAVADOCEND;
javadocdescription_opt:
| javadocdescription;
javadocdescription: javadoctokens
{
builder.addJavaDoc(buffer());
};
javadoctokens_opt:
| javadoctokens;
javadoctokens: javadoctoken
| javadoctokens javadoctoken;
javadoctoken: JAVADOCLINE
{
appendToBuffer($1);
};
javadoctags_opt:
| javadoctags;
javadoctags: javadoctag
| javadoctags javadoctag;
javadoctag: JAVADOCTAG
{
line = lexer.getLine();
}
javadoctokens_opt
{
builder.addJavaDocTag(new TagDef($1.substring(1), buffer(), line));
};
%%
private Lexer lexer;
private Builder builder;
private int line;
private int column;
private boolean debugLexer;
private StringBuffer textBuffer = new StringBuffer();
public DefaultJavaCommentParser(Lexer lexer, Builder builder) {
this.lexer = lexer;
this.builder = builder;
}
public void setDebugParser(boolean debug) {
yydebug = debug;
}
public void setDebugLexer(boolean debug) {
debugLexer = debug;
}
private void appendToBuffer(String word) {
if (textBuffer.length() > 0) {
char lastChar = textBuffer.charAt(textBuffer.length() - 1);
if (!Character.isWhitespace(lastChar)) {
textBuffer.append(' ');
}
}
textBuffer.append(word);
}
private String buffer() {
String result = textBuffer.toString().trim();
textBuffer.setLength(0);
return result;
}
public boolean parse() {
return yyparse() == 0;
}
private int yylex() {
try {
final int result = lexer.lex();
yylval = new DefaultJavaCommentParserVal();
yylval.sval = lexer.text();
if (debugLexer) {
System.err.println("Token: " + yyname[result] + " \"" + yylval.sval + "\"");
}
return result;
}
catch(IOException e) {
return 0;
}
}
private void yyerror(String msg) {
throw new ParseException(msg, lexer.getLine(), lexer.getColumn());
}
qdox-qdox-2.0-M3/src/grammar/lexer.flex 0000664 0000000 0000000 00000044413 12450313474 0020001 0 ustar 00root root 0000000 0000000 package com.thoughtworks.qdox.parser.impl;
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
import com.thoughtworks.qdox.parser.*;
import java.util.*;
%%
// class and lexer definitions
%class JFlexLexer
%public
%implements JavaLexer
%byaccj
%unicode
%line
%column
%init{
java.io.InputStream qdoxProperties = this.getClass().getClassLoader().getResourceAsStream( "qdox.properties" );
if( qdoxProperties != null )
{
Properties props = new Properties();
try
{
props.load( qdoxProperties );
stateStack = new int[ parseValue( props.getProperty( "lexer.statestack.size" ), stateStack.length ) ];
}
catch ( java.io.IOException e )
{
// failed to load qdoxProperties
}
finally
{
try
{
qdoxProperties.close();
}
catch( java.io.IOException e )
{
// noop, we did our best
}
}
}
%init}
%{
private java.io.Writer writer;
private List commentHandlers = new ArrayList();
private int classDepth = 0;
private int parenDepth = 0;
private int nestingDepth = 0;
private int annotationDepth = 0;
private int assignmentDepth = 0;
private int stateDepth = 0;
private int codeblockDepth = 0;
private int[] stateStack = new int[10];
private int braceMode = CODEBLOCK;
private int parenMode = -1;
private StringBuffer codeBody = new StringBuffer(8192);
private boolean newMode;
private boolean bracketMode;
private boolean anonymousMode;
private boolean enumConstantMode;
private boolean appendingToCodeBody;
private void write() {
write( text() );
}
private void write( String text ) {
try {
if( writer != null ) {
writer.write( text );
}
}
catch( java.io.IOException ioe ) {}
}
public String text() {
return yytext();
}
public int lex() throws java.io.IOException {
// write();
return yylex();
}
public int getLine() {
return yyline + 1;
}
public int getColumn() {
return yycolumn + 1;
}
private void pushState(int newState) {
stateStack[stateDepth++] = zzLexicalState;
yybegin(newState);
}
private void popState() {
yybegin(stateStack[--stateDepth]);
}
public String getCodeBody(){
String s = codeBody.toString();
codeBody = new StringBuffer(8192);
return s;
}
public void addCommentHandler(CommentHandler handler) {
this.commentHandlers.add(handler);
}
private int parseValue( String value, int defaultValue )
{
int result;
try
{
result = Integer.parseInt( value );
}
catch( NumberFormatException e )
{
result = defaultValue;
}
return result;
}
public JFlexLexer( java.io.Reader reader, java.io.Writer writer ) {
this( reader );
this.writer = writer;
}
public JFlexLexer( java.io.InputStream stream, java.io.Writer writer ) {
this( stream );
this.writer = writer;
}
%}
Eol = \r|\n|\r\n
WhiteSpace = {Eol} | [ \t\f]
CommentChar = ( [^ \t\r\n*] | "*"+ [^ \t\r\n/*] )
DecimalNumeral = ( [0-9] | [1-9] [_0-9]* [0-9] )
Digits = ( [0-9] | [0-9] [_0-9]* [0-9] )
HexDigits = ( [0-9a-fA-F] | [0-9a-fA-F] [_0-9a-fA-F]* [0-9a-fA-F] )
HexNumeral = ( "0" [xX] {HexDigits} )
OctalNumeral = ( "0" [_0-7]* [0-7] )
BinaryNumeral = ( "0" [bB] ( [01] | [01] [_01]* [01] ) )
IntegerLiteral = ( {DecimalNumeral} | {BinaryNumeral} | {HexNumeral} | {OctalNumeral} ) ([lL])?
Exponent = [eE] [+-]? {DecimalNumeral}
FloatingPointLiteral = ( {DecimalFloatingPointLiteral} | {HexadecimalFloatingPointLiteral} )
DecimalFloatingPointLiteral = ( {Digits} ("." {Digits})? ({Exponent})? ([dDfF])? ) |
( "." {Digits} ({Exponent})? ([dDfF])?) |
( {Digits} {Exponent} ([dDfF])?) |
( {Digits} ({Exponent} )? ([dDfF]) )
BinaryExponent = [pP] [+-]? ({DecimalNumeral})+
HexSignificand = ( {HexNumeral} "."? ) |
( "0" [xX] ( {HexDigits} )? "." ( {HexDigits} ) )
HexadecimalFloatingPointLiteral = {HexSignificand} {BinaryExponent} ([dDfF])?
UnicodeChar = \\u[a-fA-F0-9]{4}
Id = ([:jletter:]|{UnicodeChar}) ([:jletterdigit:]|{UnicodeChar})*
Annotation = "@" {WhiteSpace}* {Id} ("."{Id})* {WhiteSpace}*
JavadocEnd = "*"+ "/"
%state JAVADOC JAVADOCTAG JAVADOCLINE CODEBLOCK PARENBLOCK ASSIGNMENT STRING CHAR SINGLELINECOMMENT MULTILINECOMMENT ANNOTATIONTYPE ANNOTATION ANNOSTRING ANNOCHAR ENUM ARGUMENTS
%%
{
"." { return Parser.DOT; }
"..." { return Parser.DOTDOTDOT; }
"," { return Parser.COMMA; }
"*" { return Parser.STAR; }
"package" { return Parser.PACKAGE; }
"import" { return Parser.IMPORT; }
"public" { return Parser.PUBLIC; }
"protected" { return Parser.PROTECTED; }
"private" { return Parser.PRIVATE; }
"static" { return Parser.STATIC; }
"final" { return Parser.FINAL; }
"abstract" { return Parser.ABSTRACT; }
"native" { return Parser.NATIVE; }
"strictfp" { return Parser.STRICTFP; }
"synchronized" { return Parser.SYNCHRONIZED; }
"transient" { return Parser.TRANSIENT; }
"volatile" { return Parser.VOLATILE; }
"throws" { return Parser.THROWS; }
"extends" { return Parser.EXTENDS; }
"implements" { return Parser.IMPLEMENTS; }
"super" { return Parser.SUPER; }
"new" { return Parser.NEW; }
"[" { nestingDepth++; return Parser.SQUAREOPEN; }
"]" { nestingDepth--; return Parser.SQUARECLOSE; }
")" { nestingDepth--; return Parser.PARENCLOSE; }
"<" { return Parser.LESSTHAN; }
">" { return Parser.GREATERTHAN; }
"&" { return Parser.AMPERSAND; }
"?" { return Parser.QUERY; }
"@" {WhiteSpace}* "interface" {
classDepth++;
braceMode = ANNOTATIONTYPE;
return Parser.ANNOINTERFACE;
}
"class" {
classDepth++;
braceMode = YYINITIAL;
return Parser.CLASS;
}
"interface" {
classDepth++;
braceMode = YYINITIAL;
return Parser.INTERFACE;
}
"enum" {
classDepth++;
braceMode = ENUM;
return Parser.ENUM;
}
{Annotation} "(" {
parenMode = ANNOTATION;
yypushback(text().length()-1);
getCodeBody(); /* reset codebody */
return Parser.AT;
}
"@" {
return Parser.AT;
}
"{" {
if(braceMode >= 0) {
if(braceMode == ENUM) {
enumConstantMode = true;
} else if (braceMode == CODEBLOCK) {
getCodeBody(); /* reset codebody */
appendingToCodeBody = true;
}
pushState(braceMode);
braceMode = -1;
yypushback(1); /* (re)enter brace in right mode */
}
else {
nestingDepth++;
if (enumConstantMode && yystate() == ENUM)
{
braceMode = YYINITIAL;
}
else
{
braceMode = CODEBLOCK;
}
return Parser.BRACEOPEN;
}
}
"}" {
nestingDepth--;
classDepth--;
popState();
if ( yystate() == ENUM && enumConstantMode)
{
braceMode = YYINITIAL;
}
else
{
braceMode = CODEBLOCK;
}
return Parser.BRACECLOSE;
}
"/**" ~"*/" {
for( CommentHandler handler: commentHandlers ) {
handler.onComment( text(), getLine(), getColumn() );
}
}
"=" {WhiteSpace}* {
assignmentDepth = nestingDepth;
getCodeBody(); /* reset codebody */
appendingToCodeBody = true;
pushState(ASSIGNMENT);
}
}
{
";" { return Parser.SEMI; }
"(" {
nestingDepth++;
if( parenMode >= 0 ) {
annotationDepth = nestingDepth;
pushState(parenMode);
parenMode = -1;
}
return Parser.PARENOPEN;
}
}
{
";" {
enumConstantMode = false;
braceMode = CODEBLOCK;
return Parser.SEMI;
}
"(" {
nestingDepth++;
if(parenMode >= 0) {
annotationDepth = nestingDepth;
pushState(parenMode);
parenMode = -1;
return Parser.PARENOPEN;
}
else if(enumConstantMode)
{
annotationDepth = nestingDepth;
pushState(ARGUMENTS);
return Parser.PARENOPEN;
}
else {
return Parser.PARENOPEN;
}
}
}
{
"default" { return Parser.DEFAULT; }
}
{
"default" { assignmentDepth = nestingDepth; appendingToCodeBody = true; pushState(ASSIGNMENT); }
}
{
{Id} {
return Parser.IDENTIFIER;
}
}
{
"{" {
if(codeblockDepth++ > 0 ) {
codeBody.append('{');
}
}
"}" {
if (--codeblockDepth == 0) {
popState();
appendingToCodeBody = false;
braceMode = CODEBLOCK;
return Parser.CODEBLOCK;
} else {
codeBody.append('}');
}
}
}
{
"(" { ++ nestingDepth; return Parser.PARENOPEN; }
")" { if( nestingDepth-- == annotationDepth) { popState(); } return Parser.PARENCLOSE; }
"," { return Parser.COMMA; }
"=" { return Parser.EQUALS; }
"*=" { return Parser.STAREQUALS; }
"/=" { return Parser.SLASHEQUALS; }
"%=" { return Parser.PERCENTEQUALS; }
"+=" { return Parser.PLUSEQUALS; }
"-=" { return Parser.MINUSEQUALS; }
"<<=" { return Parser.LESSTHAN2EQUALS; }
">>=" { return Parser.GREATERTHAN2EQUALS; }
">>>=" { return Parser.GREATERTHAN3EQUALS; }
"&=" { return Parser.AMPERSANDEQUALS; }
"^=" { return Parser.CIRCUMFLEXEQUALS; }
"|=" { return Parser.VERTLINEEQUALS; }
"++" { return Parser.PLUSPLUS; }
"--" { return Parser.MINUSMINUS; }
"{" { nestingDepth++; return Parser.BRACEOPEN; }
"}" { nestingDepth--; return Parser.BRACECLOSE; }
"\"" { appendingToCodeBody=true; codeBody.append("\""); pushState(ANNOSTRING); }
"\'" { appendingToCodeBody=true; codeBody.append("\'"); pushState(ANNOCHAR); }
"." { return Parser.DOT; }
"?" { return Parser.QUERY; }
":" { return Parser.COLON; }
"<<" { return Parser.LESSTHAN2; }
">>>" { return Parser.GREATERTHAN3; }
">>" { return Parser.GREATERTHAN2; }
"==" { return Parser.EQUALS2; }
"!=" { return Parser.NOTEQUALS; }
"<" { return Parser.LESSTHAN; }
">" { return Parser.GREATERTHAN; }
"<=" { return Parser.LESSEQUALS; }
">=" { return Parser.GREATEREQUALS; }
"*" { return Parser.STAR; }
"/" { return Parser.SLASH; }
"%" { return Parser.PERCENT; }
"+" { return Parser.PLUS; }
"-" { return Parser.MINUS; }
"byte" { return Parser.BYTE; }
"char" { return Parser.CHAR; }
"short" { return Parser.SHORT; }
"int" { return Parser.INT; }
"long" { return Parser.LONG; }
"float" { return Parser.FLOAT; }
"double" { return Parser.DOUBLE; }
"&&" { return Parser.AMPERSAND2; }
"||" { return Parser.VERTLINE2; }
"!" { return Parser.EXCLAMATION; }
"&" { return Parser.AMPERSAND; }
"|" { return Parser.VERTLINE; }
"^" { return Parser.CIRCUMFLEX; }
"~" { return Parser.TILDE; }
{IntegerLiteral} { return Parser.INTEGER_LITERAL; }
{FloatingPointLiteral} { return Parser.FLOAT_LITERAL; }
"true" | "false" { return Parser.BOOLEAN_LITERAL; }
"class" { return Parser.CLASS; }
"new" { return Parser.NEW; }
{Id} { return Parser.IDENTIFIER; }
"@" { return Parser.AT; }
}
{
"\"" { codeBody.append("\""); popState(); appendingToCodeBody=false; return Parser.STRING_LITERAL; }
"\\\"" { codeBody.append("\\\""); }
"\\\\" { codeBody.append("\\\\"); }
}
{
\' { codeBody.append("\'"); popState(); appendingToCodeBody=false; return Parser.CHAR_LITERAL; }
"\\'" { codeBody.append("\\'"); }
"\\\\" { codeBody.append("\\\\"); }
}
{
"(" {
nestingDepth++;
if (appendingToCodeBody) { codeBody.append("("); }
}
")" {
nestingDepth--;
if (appendingToCodeBody) { codeBody.append(")"); }
if (nestingDepth == parenDepth) {
popState();
}
}
}
{
";" {
if (nestingDepth == assignmentDepth) {
appendingToCodeBody = true;
newMode = false;
popState();
return Parser.SEMI;
} else {
codeBody.append(';');
}
}
"," {
if (nestingDepth == assignmentDepth) {
appendingToCodeBody = true;
popState();
return Parser.COMMA;
} else {
codeBody.append(',');
}
}
"{" {
codeBody.append('{');
anonymousMode = true;
nestingDepth++;
}
"}" {
codeBody.append('}');
nestingDepth--;
if (nestingDepth==assignmentDepth) {
anonymousMode=false;
}
}
"(" {
codeBody.append('(');
parenDepth = nestingDepth++;
pushState(PARENBLOCK);
}
")" {
codeBody.append(')');
nestingDepth--;
if (nestingDepth < assignmentDepth) {
appendingToCodeBody = true;
popState();
return Parser.PARENCLOSE;
}
}
"[" { codeBody.append('['); bracketMode = true; nestingDepth++; }
"]" { codeBody.append(']'); bracketMode = false; nestingDepth--; }
"new" {
codeBody.append("new");
if (nestingDepth==assignmentDepth) {
newMode=true;
}
}
"." [ \t\r\n]* / "<" {
codeBody.append('.');
newMode = true;
}
"<" {
codeBody.append('<');
if (!bracketMode && newMode && !anonymousMode) {
nestingDepth++;
}
}
">" {
codeBody.append('>');
if (!anonymousMode) {
if (!bracketMode && newMode) {
nestingDepth--;
if (nestingDepth==assignmentDepth) {
newMode=false;
}
}
}
}
}
{
"\"" { if (appendingToCodeBody) { codeBody.append('"'); } pushState(STRING); }
\' { if (appendingToCodeBody) { codeBody.append('\''); } pushState(CHAR); }
}
{
"//" { if (appendingToCodeBody) { codeBody.append("//"); } pushState(SINGLELINECOMMENT); }
"/*" { if (appendingToCodeBody) { codeBody.append("/*"); } pushState(MULTILINECOMMENT); }
"/**/" { if (appendingToCodeBody) { codeBody.append("/**/"); } }
}
{
.|{WhiteSpace} { codeBody.append(yytext()); }
}
{
"\"" { if (appendingToCodeBody) { codeBody.append('"'); } popState(); }
"\\\"" { if (appendingToCodeBody) { codeBody.append("\\\""); } }
"\\\\" { if (appendingToCodeBody) { codeBody.append("\\\\"); } }
}
{
\' { if (appendingToCodeBody) { codeBody.append('\''); } popState(); }
"\\'" { if (appendingToCodeBody) { codeBody.append("\\'"); } }
"\\\\" { if (appendingToCodeBody) { codeBody.append("\\\\"); } }
}
{
{Eol} { if (appendingToCodeBody) { codeBody.append(yytext()); } popState(); }
}
{
"*/" { if (appendingToCodeBody) { codeBody.append("*/"); } popState(); }
}
.|\r|\n|\r\n { if (appendingToCodeBody) { codeBody.append(yytext()); } }
qdox-qdox-2.0-M3/src/grammar/parser.y 0000664 0000000 0000000 00000157754 12450313474 0017505 0 ustar 00root root 0000000 0000000 %{
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
import com.thoughtworks.qdox.builder.Builder;
import com.thoughtworks.qdox.parser.*;
import com.thoughtworks.qdox.parser.expression.*;
import com.thoughtworks.qdox.parser.structs.*;
import java.io.IOException;
import java.util.LinkedList;
import java.util.List;
import java.util.Stack;
%}
%token SEMI DOT DOTDOTDOT COMMA STAR PERCENT EQUALS ANNOSTRING ANNOCHAR SLASH PLUS MINUS
%token STAREQUALS SLASHEQUALS PERCENTEQUALS PLUSEQUALS MINUSEQUALS LESSTHAN2EQUALS GREATERTHAN2EQUALS GREATERTHAN3EQUALS AMPERSANDEQUALS CIRCUMFLEXEQUALS VERTLINEEQUALS
%token PACKAGE IMPORT PUBLIC PROTECTED PRIVATE STATIC FINAL ABSTRACT NATIVE STRICTFP SYNCHRONIZED TRANSIENT VOLATILE DEFAULT
%token CLASS INTERFACE ENUM ANNOINTERFACE THROWS EXTENDS IMPLEMENTS SUPER DEFAULT NEW
%token BRACEOPEN BRACECLOSE SQUAREOPEN SQUARECLOSE PARENOPEN PARENCLOSE
%token LESSTHAN GREATERTHAN LESSEQUALS GREATEREQUALS
%token LESSTHAN2 GREATERTHAN2 GREATERTHAN3
%token EXCLAMATION AMPERSAND2 VERTLINE2 EQUALS2 NOTEQUALS
%token TILDE AMPERSAND VERTLINE CIRCUMFLEX
%token VOID
%token QUERY COLON AT
%token CODEBLOCK PARENBLOCK
%token BYTE SHORT INT LONG CHAR FLOAT DOUBLE BOOLEAN
// strongly typed tokens/types
%token IDENTIFIER
%token BOOLEAN_LITERAL
%token INTEGER_LITERAL
%token FLOAT_LITERAL
%token CHAR_LITERAL
%token STRING_LITERAL
%token VERTLINE2 AMPERSAND2 VERTLINE CIRCUMFLEX AMPERSAND EQUALS2 NOTEQUALS
%token LESSTHAN GREATERTHAN LESSEQUALS GREATEREQUALS LESSTHAN2 GREATERTHAN2 GREATERTHAN3
%token PLUS MINUS STAR SLASH PERCENT TILDE EXCLAMATION
%token PLUSPLUS MINUSMINUS
%token SUPER
%token EQUALS STAREQUALS SLASHEQUALS PERCENTEQUALS PLUSEQUALS MINUSEQUALS LESSTHAN2EQUALS GREATERTHAN2EQUALS GREATERTHAN3EQUALS AMPERSANDEQUALS CIRCUMFLEXEQUALS VERTLINEEQUALS
%type PrimitiveType ReferenceType ArrayType ClassOrInterfaceType
%type Expression Literal Annotation ElementValue ElementValueArrayInitializer
%type ConditionalExpression ConditionalOrExpression ConditionalAndExpression InclusiveOrExpression ExclusiveOrExpression AndExpression
%type EqualityExpression RelationalExpression ShiftExpression AdditiveExpression MultiplicativeExpression
%type UnaryExpression UnaryExpressionNotPlusMinus PreIncrementExpression PreDecrementExpression Primary PrimaryNoNewArray ArrayCreationExpression MethodInvocation ClassInstanceCreationExpression
%type PostfixExpression PostIncrementExpression PostDecrementExpression CastExpression Assignment LeftHandSide AssignmentExpression
%type Dims Dims_opt
%type QualifiedIdentifier TypeDeclSpecifier MethodBody AssignmentOperator
%type Type ReferenceType Wildcard WildcardBounds VariableDeclaratorId ClassOrInterfaceType TypeArgument
%%
// Source: Java Language Specification - Third Edition
// The Java(TM) Language Specification - Java SE 8 Edition ( Chapter 19. Syntax )
// ------------------------------
// Productions from �7 (Packages)
// ------------------------------
// CompilationUnit:
// [PackageDeclaration] {ImportDeclaration} {TypeDeclaration}
CompilationUnit: PackageDeclaration_opt ImportDeclarations_opt TypeDeclarations_opt
;
// PackageDeclaration:
// {PackageModifier} package Identifier {. Identifier} ;
// PackageModifier:
// Annotation
PackageDeclaration: package
| Annotation
;
PackageDeclaration_opt:
| PackageDeclaration_opt PackageDeclaration
;
package: PACKAGE
{
line = lexer.getLine();
}
QualifiedIdentifier /* =PackageName */SEMI
{
builder.addPackage(new PackageDef($3, line));
}
;
// ImportDeclaration:
// SingleTypeImportDeclaration
// TypeImportOnDemandDeclaration
// SingleStaticImportDeclaration
// StaticImportOnDemandDeclaration
ImportDeclaration: SingleTypeImportDeclaration
| TypeImportOnDemandDeclaration
| SingleStaticImportDeclaration
| StaticImportOnDemandDeclaration
;
ImportDeclarations_opt:
| ImportDeclarations_opt ImportDeclaration
;
// SingleTypeImportDeclaration:
// import TypeName ;
SingleTypeImportDeclaration: IMPORT QualifiedIdentifier SEMI
{
builder.addImport( $2 );
}
;
// TypeImportOnDemandDeclaration:
// import PackageOrTypeName . * ;
TypeImportOnDemandDeclaration: IMPORT QualifiedIdentifier DOT STAR SEMI
{
builder.addImport( $2 + ".*" );
}
;
// SingleStaticImportDeclaration:
// import static TypeName . Identifier ;
SingleStaticImportDeclaration: IMPORT STATIC QualifiedIdentifier SEMI
{
builder.addImport( "static " + $3);
}
;
// StaticImportOnDemandDeclaration:
// import static TypeName . * ;
StaticImportOnDemandDeclaration: IMPORT STATIC QualifiedIdentifier DOT STAR SEMI
{
builder.addImport( "static " + $3 + ".*" );
}
;
// TypeDeclaration:
// ClassDeclaration
// InterfaceDeclaration
// ;
TypeDeclaration: ClassDeclaration
| InterfaceDeclaration
| SEMI
;
TypeDeclarations_opt:
| TypeDeclarations_opt
{
line = lexer.getLine();
}
TypeDeclaration
;
// -----------------------------
// Productions from �8 (Classes)
// -----------------------------
// ClassDeclaration:
// NormalClassDeclaration
// EnumDeclaration
ClassDeclaration: NormalClassDeclaration
| EnumDeclaration
;
// NormalClassDeclaration:
// {ClassModifier} class Identifier [TypeParameters] [Superclass] [Superinterfaces] ClassBody
NormalClassDeclaration: Modifiers_opt CLASS IDENTIFIER TypeParameters_opt Superclass_opt Superinterfaces_opt
{
cls.setType(ClassDef.CLASS);
cls.setLineNumber(line);
cls.getModifiers().addAll(modifiers); modifiers.clear();
cls.setName( $3 );
cls.setTypeParameters(typeParams);
builder.beginClass(cls);
cls = new ClassDef();
}
ClassBody
{
builder.endClass();
}
;
// TypeParameters:
// < TypeParameterList >
TypeParameters: LESSTHAN
{
typeParams = new LinkedList();
}
TypeParameterList GREATERTHAN
;
TypeParameters_opt:
| TypeParameters
;
// TypeParameterList:
// TypeParameter {, TypeParameter}
TypeParameterList: TypeParameter
| TypeParameterList COMMA TypeParameter
;
// Superclass:
// extends ClassType
Superclass_opt:
| EXTENDS ReferenceType
{
cls.getExtends().add($2);
}
;
// Superinterfaces:
// implements InterfaceTypeList
Superinterfaces_opt:
| IMPLEMENTS TypeList
{
cls.getImplements().addAll( typeList );
}
;
// InterfaceTypeList:
// InterfaceType {, InterfaceType}
//// -> InterfaceTypeList is for QDox the same as TypeList
// ClassBody:
// { { ClassBodyDeclaration } }
ClassBody: BRACEOPEN ClassBodyDeclarations_opt BRACECLOSE
;
ClassBody_opt:
| ClassBody
;
// ClassBodyDeclaration:
// ClassMemberDeclaration
// InstanceInitializer
// StaticInitializer
// ConstructorDeclaration
// ## for now StaticInitializer includes InstanceInitializer due to parsing errors
ClassBodyDeclaration: StaticInitializer
| ClassMemberDeclaration
| ConstructorDeclaration
;
ClassBodyDeclarations_opt:
| ClassBodyDeclarations_opt
{
line = lexer.getLine();
}
ClassBodyDeclaration
;
// ClassMemberDeclaration:
// FieldDeclaration
// MethodDeclaration
// ClassDeclaration
// InterfaceDeclaration
// ;
ClassMemberDeclaration: FieldDeclaration
| MethodDeclaration
| ClassDeclaration
| InterfaceDeclaration
| SEMI
;
// FieldDeclaration:
// {FieldModifier} UnannType VariableDeclaratorList ;
FieldDeclaration: Modifiers_opt Type VariableDeclaratorId
{
fieldType = $2;
// we're doing some lexer magic: lexer.getCodeBody() contains [= VariableInitializer]
makeField($3, lexer.getCodeBody(), false);
builder.beginField(fd);
builder.endField();
}
extrafields SEMI
{
modifiers.clear();
}
;
extrafields:
| extrafields COMMA
{
line = lexer.getLine();
}
VariableDeclaratorId
{
// we're doing some lexer magic: lexer.getCodeBody() contains [= VariableInitializer]
makeField($4, lexer.getCodeBody(), false);
builder.beginField(fd);
builder.endField();
}
;
// VariableDeclaratorId:
// Identifier [Dims]
VariableDeclaratorId: IDENTIFIER Dims_opt
{
$$ = new TypeDef($1,$2);
}
;
// MethodDeclaration:
// {MethodModifier} MethodHeader MethodBody
MethodDeclaration: Modifiers_opt MethodHeader MethodBody
{
mth.setBody($3);
builder.endMethod(mth);
mth = new MethodDef();
}
;
// VariableInitializer:
// Expression
// ArrayInitializer
VariableInitializer: ArrayInitializer
| Expression
;
// MethodHeader:
// Result MethodDeclarator [Throws]
// TypeParameters {Annotation} Result MethodDeclarator [Throws]
// MethodDeclarator:
// Identifier ( [FormalParameterList] ) [Dims]
//## MethodDeclarator must be part of MethodHeader so Parser recognizes this as a Method
MethodHeader: TypeParameters Type /* =Result */ IDENTIFIER
{
builder.beginMethod();
mth.setLineNumber(lexer.getLine());
mth.getModifiers().addAll(modifiers); modifiers.clear();
mth.setTypeParams(typeParams);
mth.setReturnType($2);
mth.setName($3);
}
PARENOPEN FormalParameterList_opt PARENCLOSE Dims_opt Throws_opt
{
mth.setDimensions($8);
}
| Type /* =Result */ IDENTIFIER
{
builder.beginMethod();
mth.setLineNumber(lexer.getLine());
mth.getModifiers().addAll(modifiers); modifiers.clear();
mth.setReturnType($1);
mth.setName($2);
}
PARENOPEN FormalParameterList_opt PARENCLOSE Dims_opt Throws_opt
{
mth.setDimensions($7);
};
// FormalParameterList:
// FormalParameters , LastFormalParameter
// LastFormalParameter
FormalParameterList: FormalParameters COMMA LastFormalParameter
| LastFormalParameter
;
FormalParameterList_opt:
| FormalParameterList
;
// FormalParameters:
// FormalParameter {, FormalParameter}
// ReceiverParameter {, FormalParameter}
FormalParameters: FormalParameter
| FormalParameters COMMA FormalParameter
// | ReceiverParameter {, FormalParameter}
// | ReceiverParameter COMMA FormalParameter
;
// FormalParameter:
// {VariableModifier} UnannType VariableDeclaratorId
FormalParameter: Modifiers_opt Type VariableDeclaratorId
{
param.getModifiers().addAll(modifiers); modifiers.clear();
param.setType($2);
param.setName($3.getName());
param.setDimensions($3.getDimensions());
param.setVarArgs(false);
builder.addParameter(param);
param = new FieldDef();
}
;
// LastFormalParameter:
// {VariableModifier} UnannType {Annotation} ... VariableDeclaratorId
// FormalParameter
LastFormalParameter: Modifiers_opt Type DOTDOTDOT VariableDeclaratorId
{
param.getModifiers().addAll(modifiers); modifiers.clear();
param.setType($2);
param.setName($4.getName());
param.setDimensions($4.getDimensions());
param.setVarArgs(true);
builder.addParameter(param);
param = new FieldDef();
}
| FormalParameter
;
// ReceiverParameter:
// {Annotation} UnannType [Identifier .] this
// ## todo
// Throws:
// throws ExceptionTypeList
Throws_opt:
| THROWS ExceptionTypeList
;
// ExceptionTypeList:
// ExceptionType {, ExceptionType}
ExceptionTypeList: ClassOrInterfaceType /* =ExceptionType */
{
mth.getExceptions().add($1);
}
| ExceptionTypeList COMMA ClassOrInterfaceType /* =ExceptionType */
{
mth.getExceptions().add($3);
}
;
// MethodBody:
// Block
// ;
MethodBody: CODEBLOCK
{
$$ = lexer.getCodeBody();
}
| SEMI
{
$$ = "";
}
;
// InstanceInitializer:
// CODEBLOCK
// {
// InitDef def = new InitDef();
// def.setBlockContent(lexer.getCodeBody());
// builder.addInitializer(def);
// };
// StaticInitializer:
// static Block
StaticInitializer: Modifiers_opt CODEBLOCK
{
InitDef def = new InitDef();
def.setStatic(modifiers.contains("static"));modifiers.clear();
def.setBlockContent(lexer.getCodeBody());
builder.addInitializer(def);
}
;
// ConstructorDeclaration:
// {ConstructorModifier} ConstructorDeclarator [Throws] ConstructorBody
ConstructorDeclaration: Modifiers_opt IDENTIFIER
{
builder.beginConstructor();
mth.setLineNumber(lexer.getLine());
mth.getModifiers().addAll(modifiers); modifiers.clear();
mth.setConstructor(true);
mth.setName($2);
}
PARENOPEN FormalParameterList_opt PARENCLOSE Throws_opt MethodBody /* =ConstructorBody */
{
mth.setBody($8);
builder.endConstructor(mth);
mth = new MethodDef();
}
| Modifiers_opt TypeParameters IDENTIFIER
{
builder.beginConstructor();
mth.setLineNumber(lexer.getLine());
mth.setTypeParams(typeParams);
mth.getModifiers().addAll(modifiers); modifiers.clear();
mth.setConstructor(true);
mth.setName($3);
}
PARENOPEN FormalParameterList_opt PARENCLOSE Throws_opt CODEBLOCK
{
mth.setBody(lexer.getCodeBody());
builder.endConstructor(mth);
mth = new MethodDef();
}
;
// ConstructorDeclarator:
// [TypeParameters] SimpleTypeName ( [FormalParameterList] )
// ** ConstructorBody, ExplicitConstructorInvocation not used by QDox, out of scope
// ConstructorBody:
// { [ExplicitConstructorInvocation] [BlockStatements] }
// ExplicitConstructorInvocation:
// [TypeArguments] this ( [ArgumentList] ) ;
// [TypeArguments] super ( [ArgumentList] ) ;
// ExpressionName . [TypeArguments] super ( [ArgumentList] ) ;
// Primary . [TypeArguments] super ( [ArgumentList] ) ;
// EnumDeclaration:
// {ClassModifier} enum Identifier [Superinterfaces] EnumBody
EnumDeclaration: Modifiers_opt ENUM IDENTIFIER Superinterfaces_opt
{
cls.setLineNumber(line);
cls.getModifiers().addAll(modifiers);
cls.setName( $3 );
cls.setType(ClassDef.ENUM);
builder.beginClass(cls);
cls = new ClassDef();
fieldType = new TypeDef($3, 0);
}
EnumBody
;
// EnumBody:
// { [EnumConstantList] [,] [EnumBodyDeclarations] }
/* The optional COMMA causes trouble for the parser
For that reason the adjusted options of EnumConstants_opt, which will accept all cases
*/
EnumBody: BRACEOPEN EnumConstants_opt EnumBodyDeclarations_opt BRACECLOSE
{
builder.endClass();
fieldType = null;
modifiers.clear();
}
;
// EnumConstantList:
// EnumConstant {, EnumConstant}
// EnumConstants:
// EnumConstant
// EnumConstants , EnumConstant
EnumConstants_opt:
| EnumConstants_opt COMMA
| EnumConstants_opt EnumConstant
;
// EnumConstant:
// {EnumConstantModifier} Identifier [( [ArgumentList] )] [ClassBody]
EnumConstant: Annotations_opt IDENTIFIER
{
TypeDef td = new TypeDef($2, 0);
typeStack.push(td);
makeField( td, "", true );
builder.beginField( fd );
}
Arguments_opt ClassBody_opt
{
builder.endField();
typeStack.pop();
}
;
// EnumBodyDeclarations:
// ; {ClassBodyDeclaration}
EnumBodyDeclarations_opt:
| SEMI ClassBodyDeclarations_opt
;
// -----------------------------
// Productions from �9 (Interfaces)
// -----------------------------
// InterfaceDeclaration:
// NormalInterfaceDeclaration
// AnnotationTypeDeclaration
InterfaceDeclaration: NormalInterfaceDeclaration
| AnnotationTypeDeclaration
;
// NormalInterfaceDeclaration:
// {InterfaceModifier} interface Identifier [TypeParameters] [ExtendsInterfaces] InterfaceBody
NormalInterfaceDeclaration: Modifiers_opt INTERFACE IDENTIFIER TypeParameters_opt ExtendsInterfaces_opt
{
cls.setType(ClassDef.INTERFACE);
cls.setLineNumber(line);
cls.getModifiers().addAll(modifiers); modifiers.clear();
cls.setName( $3 );
cls.setTypeParameters(typeParams);
builder.beginClass(cls);
cls = new ClassDef();
}
ClassBody
{
builder.endClass();
}
;
// ExtendsInterfaces:
// extends InterfaceTypeList
ExtendsInterfaces: EXTENDS TypeList
{
cls.getExtends().addAll( typeList );
typeList.clear();
}
;
ExtendsInterfaces_opt:
| ExtendsInterfaces
;
// InterfaceBody:
// { {InterfaceMemberDeclaration} }
// InterfaceMemberDeclaration:
// ConstantDeclaration
// InterfaceMethodDeclaration
// ClassDeclaration
// InterfaceDeclaration
// ;
// ConstantDeclaration:
// {ConstantModifier} UnannType VariableDeclaratorList ;
// ConstantModifier:
// Annotation public
// static final
// InterfaceMethodDeclaration:
// {InterfaceMethodModifier} MethodHeader MethodBody
// InterfaceMethodModifier:
// Annotation public
// abstract default static strictfp
// AnnotationTypeDeclaration:
// {InterfaceModifier} @ interface Identifier AnnotationTypeBody
AnnotationTypeDeclaration: Modifiers_opt ANNOINTERFACE IDENTIFIER
{
cls.setType(ClassDef.ANNOTATION_TYPE);
cls.setLineNumber(line);
cls.getModifiers().addAll(modifiers); modifiers.clear();
cls.setName( $3 );
builder.beginClass(cls);
cls = new ClassDef();
}
ClassBody
{
builder.endClass();
}
;
// AnnotationTypeBody:
// { {AnnotationTypeMemberDeclaration} }
// AnnotationTypeMemberDeclaration:
// AnnotationTypeElementDeclaration
// ConstantDeclaration
// ClassDeclaration
// InterfaceDeclaration
// ;
// AnnotationTypeElementDeclaration:
// {AnnotationTypeElementModifier} UnannType Identifier ( ) [Dims] [DefaultValue] ;
// AnnotationTypeElementModifier:
// Annotation public
// abstract
// DefaultValue:
// default ElementValue
// Annotation:
// NormalAnnotation
// MarkerAnnotation
// SingleElementAnnotation
// NormalAnnotation:
// @ TypeName ( [ElementValuePairList] )
// MarkerAnnotation:
// @ TypeName
// SingleElementAnnotation:
// @ TypeName ( ElementValue )
Annotation: AT QualifiedIdentifier
{
AnnoDef annotation = new AnnoDef( new TypeDef($2) );
annotation.setLineNumber(lexer.getLine());
annotationStack.addFirst(annotation);
}
_AnnotationParens_opt
{
AnnoDef annotation = annotationStack.removeFirst();
if(annotationStack.isEmpty())
{
builder.addAnnotation(annotation);
}
$$ = annotation;
}
;
// ElementValuePairList:
// ElementValuePair { , ElementValuePair }
ElementValuePairList: ElementValuePair
| ElementValuePairList COMMA ElementValuePair
;
// ElementValuePair:
// Identifier = ElementValue
ElementValuePair: IDENTIFIER EQUALS ElementValue
{
annotationStack.getFirst().getArgs().put($1, $3);
}
;
// ElementValue:
// ConditionalExpression
// ElementValueArrayInitializer
// Annotation
ElementValue: ConditionalExpression
| Annotation
| ElementValueArrayInitializer
;
// ElementValueArrayInitializer:
// { [ElementValueList] [,] }
/* Specs say: { ElementValues_opt COMMA_opt }
The optional COMMA causes trouble for the parser
For that reason the adjusted options of ElementValues_opt, which will accept all cases
*/
ElementValueArrayInitializer: {
annoValueListStack.add(annoValueList);
annoValueList = new LinkedList();
}
BRACEOPEN ElementValues_opt BRACECLOSE
{
$$ = new ElemValueListDef(annoValueList);
annoValueList = annoValueListStack.remove(annoValueListStack.size() - 1);
}
;
// AnnotationElement:
// ElementValuePairList
// ElementValue
AnnotationElement_opt:
| ElementValuePairList
| ElementValue
{
annotationStack.getFirst().getArgs().put("value", $1);
}
;
ElementValues_opt:
| ElementValues_opt ElementValue
{
annoValueList.add($2);
}
| ElementValues_opt COMMA;
//--------------------------------------------------------
_AnnotationParens_opt:
| PARENOPEN AnnotationElement_opt PARENCLOSE
;
Annotations_opt:
| Annotations_opt Annotation;
// -----------------------------
// Productions from �10 (Arrays)
// -----------------------------
// ArrayInitializer:
// { [VariableInitializerList] [,] }
ArrayInitializer: BRACEOPEN VariableInitializerList_opt BRACECLOSE
;
// VariableInitializerList:
// VariableInitializer {, VariableInitializer}
VariableInitializerList: VariableInitializerList VariableInitializer
| VariableInitializerList COMMA
;
VariableInitializerList_opt:
| VariableInitializerList
;
// ----------------------------------
// Productions from �15 (Expressions)
// ----------------------------------
// Primary:
// PrimaryNoNewArray
// ArrayCreationExpression
Primary: PrimaryNoNewArray
| ArrayCreationExpression
;
// PrimaryNoNewArray:
// Literal
// TypeName {[ ]} . class
// void . class
// this
// TypeName . this
// ( Expression )
// ClassInstanceCreationExpression
// FieldAccess
// ArrayAccess
// MethodInvocation
// MethodReference
PrimaryNoNewArray: Literal
| PrimitiveType Dims_opt DOT CLASS
{
$$ = new TypeRefDef(new TypeDef($1.getName(), $2));
}
| PARENOPEN Expression PARENCLOSE
{
$$ = new ParenExpressionDef($2);
}
| ClassInstanceCreationExpression
| QualifiedIdentifier DOT CLASS
{
$$ = new TypeRefDef(new TypeDef($1, 0));
}
| QualifiedIdentifier Dims DOT CLASS
{
$$ = new TypeRefDef(new TypeDef($1, $2));
}
| QualifiedIdentifier
{
$$ = new FieldRefDef($1);
}
| MethodInvocation
;
// ClassInstanceCreationExpression:
// new [TypeArguments] {Annotation} Identifier [TypeArgumentsOrDiamond] ( [ArgumentList] ) [ClassBody]
// ExpressionName . new [TypeArguments] {Annotation} Identifier [TypeArgumentsOrDiamond] ( [ArgumentList] ) [ClassBody]
// Primary . new [TypeArguments] {Annotation} Identifier [TypeArgumentsOrDiamond] ( [ArgumentList] ) [ClassBody]
//// TypeArguments_opt confuses parser
ClassInstanceCreationExpression: NEW TypeArguments_opt IDENTIFIER TypeArgumentsOrDiamond_opt PARENOPEN ArgumentList_opt PARENCLOSE ClassBody_opt
{
CreatorDef creator = new CreatorDef();
creator.setCreatedName( $3 );
$$ = creator;
}
| NEW IDENTIFIER TypeArgumentsOrDiamond_opt PARENOPEN ArgumentList_opt PARENCLOSE ClassBody_opt
{
CreatorDef creator = new CreatorDef();
creator.setCreatedName( $2 );
$$ = creator;
}
;
// TypeArgumentsOrDiamond:
// TypeArguments
// <>
TypeArgumentsOrDiamond: TypeArguments
| LESSTHAN GREATERTHAN
;
TypeArgumentsOrDiamond_opt:
| TypeArgumentsOrDiamond
;
// FieldAccess:
// Primary . Identifier
// super . Identifier
// TypeName . super . Identifier
// ArrayAccess:
// ExpressionName [ Expression ]
// PrimaryNoNewArray [ Expression ]
// MethodInvocation:
// MethodName ( [ArgumentList] )
// TypeName . [TypeArguments] Identifier ( [ArgumentList] )
// ExpressionName . [TypeArguments] Identifier ( [ArgumentList] )
// Primary . [TypeArguments] Identifier ( [ArgumentList] )
// super . [TypeArguments] Identifier ( [ArgumentList] )
// TypeName . super . [TypeArguments] Identifier ( [ArgumentList] )
MethodInvocation: IDENTIFIER PARENOPEN ArgumentList_opt PARENCLOSE
{
$$ = new MethodInvocationDef($1, null);
}
| SUPER DOT TypeParameters_opt IDENTIFIER PARENOPEN ArgumentList_opt PARENCLOSE
{
$$ = new MethodInvocationDef($1, null);
}
| QualifiedIdentifier DOT SUPER DOT TypeParameters_opt IDENTIFIER PARENOPEN ArgumentList_opt PARENCLOSE
{
$$ = new MethodInvocationDef($1 + ".super", null);
}
| QualifiedIdentifier DOT TypeParameters_opt IDENTIFIER PARENOPEN ArgumentList_opt PARENCLOSE
{
$$ = new MethodInvocationDef($1, null);
}
;
// ArgumentList:
// Expression {, Expression}
ArgumentList: Expression
{
builder.addArgument( (ExpressionDef) $1);
}
| ArgumentList COMMA Expression
{
builder.addArgument( (ExpressionDef) $3);
}
;
ArgumentList_opt:
| ArgumentList
;
// MethodReference:
// ExpressionName :: [TypeArguments] Identifier
// ReferenceType :: [TypeArguments] Identifier
// Primary :: [TypeArguments] Identifier
// super :: [TypeArguments] Identifier
// TypeName . super :: [TypeArguments] Identifier
// ClassType :: [TypeArguments] new
// ArrayType :: new
// ArrayCreationExpression:
// new PrimitiveType DimExprs [Dims]
// new ClassOrInterfaceType DimExprs [Dims]
// new PrimitiveType Dims ArrayInitializer
// new ClassOrInterfaceType Dims ArrayInitializer
ArrayCreationExpression: NEW PrimitiveType DimExprs Dims_opt
{
CreatorDef creator = new CreatorDef();
creator.setCreatedName( $2.getName() );
$$ = creator;
}
| NEW ClassOrInterfaceType DimExprs Dims_opt
{
CreatorDef creator = new CreatorDef();
creator.setCreatedName( $2.getName() );
$$ = creator;
}
| NEW PrimitiveType Dims ArrayInitializer
{
CreatorDef creator = new CreatorDef();
creator.setCreatedName( $2.getName() );
$$ = creator;
}
| NEW ClassOrInterfaceType Dims ArrayInitializer
{
CreatorDef creator = new CreatorDef();
creator.setCreatedName( $2.getName() );
$$ = creator;
}
;
// DimExprs:
// DimExpr {DimExpr}
DimExprs: DimExpr
| DimExprs DimExpr
;
// DimExpr:
// {Annotation} [ Expression ]
DimExpr: SQUAREOPEN Expression SQUARECLOSE
;
// ConstantExpression:
// Expression
// Expression:
// LambdaExpression
// AssignmentExpression
Expression: AssignmentExpression
;
// LambdaExpression:
// LambdaParameters -> LambdaBody
// LambdaParameters:
// Identifier
// ( [FormalParameterList] )
// ( InferredFormalParameterList )
// InferredFormalParameterList:
// Identifier {, Identifier}
// LambdaBody:
// Expression
// Block
// AssignmentExpression:
// ConditionalExpression
// Assignment
AssignmentExpression: ConditionalExpression
| Assignment
;
// Assignment:
// LeftHandSide AssignmentOperator Expression
Assignment: LeftHandSide AssignmentOperator Expression
{
$$ = new AssignmentDef($1, $2, $3);
}
;
// LeftHandSide:
// ExpressionName
// FieldAccess
// ArrayAccess
LeftHandSide: QualifiedIdentifier
{
$$ = new FieldRefDef($1);
}
;
// AssignmentOperator:
// =
// *=
// /=
// %=
// +=
// -=
// <<=
// >>=
// >>>=
// &=
// ^=
// |=
AssignmentOperator: EQUALS
| STAREQUALS
| SLASHEQUALS
| PERCENTEQUALS
| PLUSEQUALS
| MINUSEQUALS
| LESSTHAN2EQUALS
| GREATERTHAN2EQUALS
| GREATERTHAN3EQUALS
| AMPERSANDEQUALS
| CIRCUMFLEXEQUALS
| VERTLINEEQUALS
;
// ConditionalExpression:
// ConditionalOrExpression
// ConditionalOrExpression ? Expression : ConditionalExpression
ConditionalExpression: ConditionalOrExpression
| ConditionalOrExpression QUERY Expression COLON ConditionalExpression
{
$$ = new QueryDef($1, $3, $5);
}
;
// ConditionalOrExpression:
// ConditionalAndExpression
// ConditionalOrExpression || ConditionalAndExpression
ConditionalOrExpression: ConditionalAndExpression
| ConditionalOrExpression VERTLINE2 ConditionalAndExpression
{
$$ = new LogicalOrDef($1, $3);
}
;
// ConditionalAndExpression:
// InclusiveOrExpression
// ConditionalAndExpression && InclusiveOrExpression
ConditionalAndExpression: InclusiveOrExpression
| ConditionalAndExpression AMPERSAND2 InclusiveOrExpression
{
$$ = new LogicalAndDef($1, $3);
}
;
// InclusiveOrExpression:
// ExclusiveOrExpression
// InclusiveOrExpression | ExclusiveOrExpression
InclusiveOrExpression: ExclusiveOrExpression
| InclusiveOrExpression VERTLINE ExclusiveOrExpression
{
$$ = new OrDef($1, $3);
}
;
// ExclusiveOrExpression:
// AndExpression
// ExclusiveOrExpression ^ AndExpression
ExclusiveOrExpression: AndExpression
| ExclusiveOrExpression CIRCUMFLEX AndExpression
{
$$ = new ExclusiveOrDef($1, $3);
}
;
// AndExpression:
// EqualityExpression
// AndExpression & EqualityExpression
AndExpression: EqualityExpression
| AndExpression AMPERSAND EqualityExpression
{
$$ = new AndDef($1, $3);
}
;
// EqualityExpression:
// RelationalExpression
// EqualityExpression == RelationalExpression
// EqualityExpression != RelationalExpression
EqualityExpression: RelationalExpression
| EqualityExpression EQUALS2 RelationalExpression
{
$$ = new EqualsDef($1, $3);
}
| EqualityExpression NOTEQUALS RelationalExpression
{
$$ = new NotEqualsDef($1, $3);
}
;
// RelationalExpression:
// ShiftExpression
// RelationalExpression < ShiftExpression
// RelationalExpression > ShiftExpression
// RelationalExpression <= ShiftExpression
// RelationalExpression >= ShiftExpression
// RelationalExpression instanceof ReferenceType
RelationalExpression: ShiftExpression
| RelationalExpression LESSTHAN ShiftExpression
{
$$ = new LessThanDef($1, $3);
}
| RelationalExpression GREATERTHAN ShiftExpression
{
$$ = new GreaterThanDef($1, $3);
}
| RelationalExpression LESSEQUALS ShiftExpression
{
$$ = new LessEqualsDef($1, $3);
}
| RelationalExpression GREATEREQUALS ShiftExpression
{
$$ = new GreaterEqualsDef($1, $3);
}
;
// ShiftExpression:
// AdditiveExpression
// ShiftExpression << AdditiveExpression
// ShiftExpression >> AdditiveExpression
// ShiftExpression >>> AdditiveExpression
ShiftExpression: AdditiveExpression
| ShiftExpression LESSTHAN2 AdditiveExpression
{
$$ = new ShiftLeftDef($1, $3);
}
| ShiftExpression GREATERTHAN2 AdditiveExpression
{
$$ = new ShiftRightDef($1, $3);
}
| ShiftExpression GREATERTHAN3 AdditiveExpression
{
$$ = new UnsignedShiftRightDef($1, $3);
}
;
// AdditiveExpression:
// MultiplicativeExpression
// AdditiveExpression + MultiplicativeExpression
// AdditiveExpression - MultiplicativeExpression
AdditiveExpression: MultiplicativeExpression
| AdditiveExpression PLUS MultiplicativeExpression
{
$$ = new AddDef($1, $3);
}
| AdditiveExpression MINUS MultiplicativeExpression
{
$$ = new SubtractDef($1, $3);
}
;
// MultiplicativeExpression:
// UnaryExpression
// MultiplicativeExpression * UnaryExpression
// MultiplicativeExpression / UnaryExpression
// MultiplicativeExpression % UnaryExpression
MultiplicativeExpression: UnaryExpression
| MultiplicativeExpression STAR UnaryExpression
{
$$ = new MultiplyDef($1, $3);
}
| MultiplicativeExpression SLASH UnaryExpression
{
$$ = new DivideDef($1, $3);
}
| MultiplicativeExpression PERCENT UnaryExpression
{
$$ = new RemainderDef($1, $3);
}
;
// UnaryExpression:
// PreIncrementExpression
// PreDecrementExpression
// + UnaryExpression
// - UnaryExpression
// UnaryExpressionNotPlusMinus
UnaryExpression: PreIncrementExpression
| PreDecrementExpression
| PLUS UnaryExpression
{
$$ = new PlusSignDef($2);
}
| MINUS UnaryExpression
{
$$ = new MinusSignDef($2);
}
| UnaryExpressionNotPlusMinus
;
// PreIncrementExpression:
// ++ UnaryExpression
PreIncrementExpression: PLUSPLUS UnaryExpression
{
$$ = new PreIncrementDef($2);
}
;
// PreDecrementExpression:
// -- UnaryExpression
PreDecrementExpression: MINUSMINUS UnaryExpression
{
$$ = new PreDecrementDef($2);
}
;
// UnaryExpressionNotPlusMinus:
// PostfixExpression
// ~ UnaryExpression
// ! UnaryExpression
// CastExpression
UnaryExpressionNotPlusMinus: PostfixExpression
| TILDE UnaryExpression
{
$$ = new NotDef($2);
}
| EXCLAMATION UnaryExpression
{
$$ = new LogicalNotDef($2);
}
| CastExpression
;
// PostfixExpression:
// Primary
// ExpressionName
// PostIncrementExpression
// PostDecrementExpression
PostfixExpression: Primary
| PostIncrementExpression
| PostDecrementExpression
;
// PostIncrementExpression:
// PostfixExpression ++
PostIncrementExpression: PostfixExpression PLUSPLUS
{
$$ = new PostIncrementDef($1);
}
;
// PostDecrementExpression:
// PostfixExpression --
PostDecrementExpression: PostfixExpression MINUSMINUS
{
$$ = new PostDecrementDef($1);
}
;
// CastExpression:
// ( PrimitiveType ) UnaryExpression
// ( ReferenceType {AdditionalBound} ) UnaryExpressionNotPlusMinus
// ( ReferenceType {AdditionalBound} ) LambdaExpression
CastExpression: PARENOPEN PrimitiveType Dims_opt PARENCLOSE UnaryExpression
{
$$ = new CastDef(new TypeDef($2.getName(), $3), $5);
}
| PARENOPEN QualifiedIdentifier PARENCLOSE UnaryExpressionNotPlusMinus
{
$$ = new CastDef(new TypeDef($2, 0), $4);
}
| PARENOPEN QualifiedIdentifier Dims PARENCLOSE UnaryExpressionNotPlusMinus
{
$$ = new CastDef(new TypeDef($2, $3), $5);
}
;
// --------------------------------------------------
// Productions from §4 (Types, Values, and Variables)
// --------------------------------------------------
// Type:
// PrimitiveType
// ReferenceType
Type: PrimitiveType
| ReferenceType
;
// PrimitiveType:
// {Annotation} NumericType
// {Annotation} boolean
// NumericType:
// IntegralType
// FloatingPointType
// IntegralType:
// byte short int long char
// FloatingPointType:
// float double
// ReferenceType:
// ClassOrInterfaceType
// TypeVariable
// ArrayType
ReferenceType: ArrayType
| ClassOrInterfaceType
;
// ClassOrInterfaceType:
// ClassType
// InterfaceType
// ClassType:
// {Annotation} Identifier [TypeArguments]
// ClassOrInterfaceType . {Annotation} Identifier [TypeArguments]
// InterfaceType:
// ClassType
// TypeVariable:
// {Annotation} Identifier
// ArrayType:
// PrimitiveType Dims
// ClassOrInterfaceType Dims
// TypeVariable Dims
ArrayType: ClassOrInterfaceType Dims
{
TypeDef td = $1;
td.setDimensions($2);
$$ = td;
}
| PrimitiveType Dims
{
TypeDef td = $1;
td.setDimensions($2);
$$ = td;
}
;
// Dims:
// {Annotation} [ ] {{Annotation} [ ]}
Dims: SQUAREOPEN SQUARECLOSE
{
$$ = 1;
}
| Dims SQUAREOPEN SQUARECLOSE
{
$$ = $1 + 1;
};
Dims_opt: {
$$ = 0;
}
| Dims
;
// TypeParameter:
// {TypeParameterModifier} Identifier [TypeBound]
TypeParameter: IDENTIFIER
{
typeVariable = new TypeVariableDef($1);
typeVariable.setBounds(new LinkedList());
}
TypeBound_opt
{
typeParams.add(typeVariable);
typeVariable = null;
};
// TypeBound:
// extends TypeVariable
// extends ClassOrInterfaceType {AdditionalBound}
TypeBound: EXTENDS ClassOrInterfaceType
{
typeVariable.setBounds(new LinkedList());
typeVariable.getBounds().add($2);
}
AdditionalBound_opts
;
TypeBound_opt:
| TypeBound
;
// AdditionalBound:
// & InterfaceType
AdditionalBound: AMPERSAND ClassOrInterfaceType
{
typeVariable.getBounds().add($2);
}
;
AdditionalBound_opts:
| AdditionalBound AdditionalBound_opts
;
// TypeArguments:
// < TypeArgumentList >
TypeArguments: LESSTHAN
{
typeStack.peek().setActualArgumentTypes(new LinkedList());
}
TypeArgumentList GREATERTHAN
;
TypeArguments_opt:
| TypeArguments
;
// TypeArgumentList:
// TypeArgument {, TypeArgument}
TypeArgumentList: TypeArgument
{
(typeStack.peek()).getActualArgumentTypes().add($1);
}
| TypeArgumentList COMMA TypeArgument
{
(typeStack.peek()).getActualArgumentTypes().add($3);
}
;
// TypeArgument:
// ReferenceType
// Wildcard
TypeArgument: ReferenceType
| Wildcard
;
// Wildcard:
// {Annotation} ? [WildcardBounds]
Wildcard: QUERY WildcardBounds
{
$$ = $2;
}
| QUERY
{
$$ = new WildcardTypeDef();
}
;
// WildcardBounds:
// extends ReferenceType
// super ReferenceType
WildcardBounds: EXTENDS ReferenceType
{
$$ = new WildcardTypeDef($2, "extends" );
}
| SUPER ReferenceType
{
$$ = new WildcardTypeDef($2, "super" );
}
;
//========================================================
// QualifiedIdentifier:
// Identifier { . Identifier }
QualifiedIdentifier: IDENTIFIER
| QualifiedIdentifier DOT IDENTIFIER
{
$$ = $1 + '.' + $3;
}
;
// TypeName:
// Identifier
// PackageOrTypeName . Identifier
// PackageOrTypeName:
// Identifier
// PackageOrTypeName . Identifier
//========================================================
// PrimitiveType:
// byte
// short
// char
// int
// long
// float
// double
// boolean
PrimitiveType: BYTE
{
$$ = new TypeDef("byte");
}
| SHORT
{
$$ = new TypeDef("short");
}
| CHAR
{
$$ = new TypeDef("char");
}
| INT
{
$$ = new TypeDef("int");
}
| LONG
{
$$ = new TypeDef("long");
}
| FLOAT
{
$$ = new TypeDef("float");
}
| DOUBLE
{
$$ = new TypeDef("double");
}
| BOOLEAN
{
$$ = new TypeDef("boolean");
}
;
// Actually
// ClassOrInterfaceType: ClassType | InterfaceType;
// ClassType: TypeDeclSpecifier TypeArguments_opt
// InterfaceType: TypeDeclSpecifier TypeArguments_opt
// Parser can't see the difference
ClassOrInterfaceType: TypeDeclSpecifier
{
TypeDef td = new TypeDef($1,0);
$$ = typeStack.push(td);
}
TypeArguments_opt
{
$$ = typeStack.pop();
};
// Actually
// TypeDeclSpecifier: TypeName | ClassOrInterfaceType . Identifier
// TypeName: Identifier | TypeName . Identifier
TypeDeclSpecifier: QualifiedIdentifier
| ClassOrInterfaceType DOT IDENTIFIER
{
$$ = $1.getName() + '.' + $3;
};
//========================================================
// TypeList:
// ReferenceType { , ReferenceType }
TypeList: ReferenceType
{
typeList.add( $1 );
}
| TypeList COMMA ReferenceType
{
typeList.add( $3 );
}
;
//========================================================
Modifiers_opt:
| Modifiers_opt Modifier;
// Modifier:
// Annotation
// public
// protected
// private
// static
// abstract
// final
// native
// synchronized
// transient
// volatile
// strictfp
Modifier: Annotation
| PUBLIC
{
modifiers.add("public");
}
| PROTECTED
{
modifiers.add("protected");
}
| PRIVATE
{
modifiers.add("private");
}
| STATIC
{
modifiers.add("static");
}
| FINAL
{
modifiers.add("final");
}
| ABSTRACT
{
modifiers.add("abstract");
}
| NATIVE
{
modifiers.add("native");
}
| SYNCHRONIZED
{
modifiers.add("synchronized");
}
| VOLATILE
{
modifiers.add("volatile");
}
| TRANSIENT
{
modifiers.add("transient");
}
| STRICTFP
{
modifiers.add("strictfp");
}
| DEFAULT
{
modifiers.add("default");
}
;
Arguments_opt:
| PARENOPEN ArgumentList_opt PARENCLOSE
;
//========================================================
// Literal:
// IntegerLiteral
// FloatingPointLiteral
// CharacterLiteral
// StringLiteral
// BooleanLiteral
// NullLiteral
Literal: INTEGER_LITERAL
{
$$ = new ConstantDef($1, Integer.class);
}
| FLOAT_LITERAL
{
$$ = new ConstantDef($1, Float.class);
}
| CHAR_LITERAL
{
String s = lexer.getCodeBody();
$$ = new ConstantDef(s, Character.class);
}
| STRING_LITERAL
{
String s = lexer.getCodeBody();
$$ = new ConstantDef(s, String.class);
}
| BOOLEAN_LITERAL
{
$$ = new ConstantDef($1, Boolean.class);
}
;
//========================================================
%%
private JavaLexer lexer;
private Builder builder;
private StringBuilder textBuffer = new StringBuilder();
private ClassDef cls = new ClassDef();
private MethodDef mth = new MethodDef();
private FieldDef fd;
private List typeParams = new LinkedList(); //for both JavaClass and JavaMethod
private LinkedList annotationStack = new LinkedList(); // Use LinkedList instead of Stack because it is unsynchronized
private List> annoValueListStack = new LinkedList>(); // Use LinkedList instead of Stack because it is unsynchronized
private List annoValueList = null;
private FieldDef param = new FieldDef();
private java.util.Set modifiers = new java.util.LinkedHashSet();
private TypeDef fieldType;
private TypeVariableDef typeVariable;
private Stack typeStack = new Stack();
private List typeList = new LinkedList();
private int line;
private int column;
private boolean debugLexer;
private void appendToBuffer(String word) {
if (textBuffer.length() > 0) {
char lastChar = textBuffer.charAt(textBuffer.length() - 1);
if (!Character.isWhitespace(lastChar)) {
textBuffer.append(' ');
}
}
textBuffer.append(word);
}
private String buffer() {
String result = textBuffer.toString().trim();
textBuffer.setLength(0);
return result;
}
public Parser( JavaLexer lexer, Builder builder )
{
lexer.addCommentHandler( this );
this.lexer = lexer;
this.builder = builder;
}
public void setDebugParser(boolean debug) {
yydebug = debug;
}
public void setDebugLexer(boolean debug) {
debugLexer = debug;
}
/**
* Parse file. Return true if successful.
*/
public boolean parse() {
return yyparse() == 0;
}
private int yylex() {
try {
final int result = lexer.lex();
yylval = new Value();
yylval.sval = lexer.text();
if (debugLexer) {
System.err.println("Token: " + yyname[result] + " \"" + yylval.sval + "\"");
}
return result;
}
catch(IOException e) {
return 0;
}
}
private void yyerror(String msg) {
throw new ParseException(msg, lexer.getLine(), lexer.getColumn());
}
private class Value {
Object oval;
String sval;
int ival;
boolean bval;
TypeDef type;
ElemValueDef annoval;
}
private void makeField(TypeDef field, String body, boolean enumConstant) {
fd = new FieldDef( field.getName() );
fd.setName(field.getName());
fd.setLineNumber(line);
fd.getModifiers().addAll(modifiers);
fd.setType( fieldType );
fd.setDimensions(field.getDimensions());
fd.setEnumConstant(enumConstant);
fd.setBody(body);
}
public void onComment( String comment, int line, int column ) {
DefaultJavaCommentLexer commentLexer = new DefaultJavaCommentLexer( new java.io.StringReader( comment ) );
commentLexer.setLineOffset( line );
commentLexer.setColumnOffset( column );
DefaultJavaCommentParser commentParser = new DefaultJavaCommentParser( commentLexer, builder);
commentParser.setDebugLexer( this.debugLexer );
commentParser.setDebugParser( this.yydebug );
commentParser.parse();
} qdox-qdox-2.0-M3/src/it/ 0000775 0000000 0000000 00000000000 12450313474 0014762 5 ustar 00root root 0000000 0000000 qdox-qdox-2.0-M3/src/it/lambda-examples/ 0000775 0000000 0000000 00000000000 12450313474 0020016 5 ustar 00root root 0000000 0000000 qdox-qdox-2.0-M3/src/it/lambda-examples/LambdaExamples01.zip 0000664 0000000 0000000 00000047231 12450313474 0023571 0 ustar 00root root 0000000 0000000 PK
zC LambdaExamples01/PK |C
LambdaExamples01/build.xmlVMo8W
A"mŢM{̈́"
Jwdɑԗ8&כ|*xDѫ]6ԕ^5bET;Zz頑
i[k(4B'gZ|VnxUi7$P.Vg6#5*5X4[`k=VOR2V)@vшNM~GBns9>>*+~Dcu/^',"ݢY(,01I&U<"4@gaWSdMӄ$U_W@n?C){$9멃RZ
eP"IТUhZR]G~/Q!UVdW'@ch B6T*e]Tt
ln'-$:6
k6SNPRx̩J`T u>c19~*jʥpHݹN(n`BDh