com.thoughtworks.qdox.parser.impl.Parser Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of qdox Show documentation
Show all versions of qdox Show documentation
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.
//### This file created by BYACC 1.8(/Java extension 1.13)
//### Java capabilities added 7 Jan 97, Bob Jamison
//### Updated : 27 Nov 97 -- Bob Jamison, Joe Nieten
//### 01 Jan 98 -- Bob Jamison -- fixed generic semantic constructor
//### 01 Jun 99 -- Bob Jamison -- added Runnable support
//### 06 Aug 00 -- Bob Jamison -- made state variables class-global
//### 03 Jan 01 -- Bob Jamison -- improved flags, tracing
//### 16 May 01 -- Bob Jamison -- added custom stack sizing
//### 04 Mar 02 -- Yuval Oren -- improved java performance, added options
//### 14 Mar 02 -- Tomas Hurka -- -d support, static initializer workaround
//### Please send bug reports to [email protected]
//### static char yysccsid[] = "@(#)yaccpar 1.8 (Berkeley) 01/20/90";
package com.thoughtworks.qdox.parser.impl;
//#line 2 "/scm/oss/qdox/trunk/qdox/target/checkout/src/grammar/parser.y"
import com.thoughtworks.qdox.parser.*;
import com.thoughtworks.qdox.parser.structs.*;
import com.thoughtworks.qdox.model.*;
import com.thoughtworks.qdox.model.annotation.*;
import java.io.IOException;
import java.util.LinkedList;
import java.util.ArrayList;
import java.util.List;
//#line 26 "Parser.java"
public class Parser
{
boolean yydebug; //do I want debug output?
int yynerrs; //number of errors so far
int yyerrflag; //was there an error?
int yychar; //the current working character
//########## MESSAGES ##########
//###############################################################
// method: debug
//###############################################################
void debug(String msg)
{
if (yydebug)
System.out.println(msg);
}
//########## STATE STACK ##########
final static int YYSTACKSIZE = 500; //maximum stack size
int statestk[] = new int[YYSTACKSIZE]; //state stack
int stateptr;
int stateptrmax; //highest index of stackptr
int statemax; //state when highest index reached
//###############################################################
// methods: state stack push,pop,drop,peek
//###############################################################
final void state_push(int state)
{
try {
stateptr++;
statestk[stateptr]=state;
}
catch (ArrayIndexOutOfBoundsException e) {
int oldsize = statestk.length;
int newsize = oldsize * 2;
int[] newstack = new int[newsize];
System.arraycopy(statestk,0,newstack,0,oldsize);
statestk = newstack;
statestk[stateptr]=state;
}
}
final int state_pop()
{
return statestk[stateptr--];
}
final void state_drop(int cnt)
{
stateptr -= cnt;
}
final int state_peek(int relative)
{
return statestk[stateptr-relative];
}
//###############################################################
// method: init_stacks : allocate and prepare stacks
//###############################################################
final boolean init_stacks()
{
stateptr = -1;
val_init();
return true;
}
//###############################################################
// method: dump_stacks : show n levels of the stacks
//###############################################################
void dump_stacks(int count)
{
int i;
System.out.println("=index==state====value= s:"+stateptr+" v:"+valptr);
for (i=0;i 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(Lexer lexer, Builder builder) {
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;
AnnotationValue annoval;
}
private void makeField(TypeDef field, String body) {
FieldDef fd = new FieldDef();
fd.lineNumber = line;
fd.modifiers.addAll(modifiers);
fd.type = fieldType.name;
fd.dimensions = fieldType.dimensions + field.dimensions;
fd.name = field.name;
fd.body = body;
builder.addField(fd);
}
private String convertString(String str) {
StringBuffer buf = new StringBuffer();
boolean escaped = false;
int unicode = 0;
int value = 0;
int octal = 0;
boolean consumed = false;
for(int i = 0; i < str.length(); ++ i) {
char ch = str.charAt( i );
if(octal > 0) {
if( value >= '0' && value <= '7' ) {
value = ( value << 3 ) | Character.digit( ch, 8 );
-- octal;
consumed = true;
}
else {
octal = 0;
}
if( octal == 0 ) {
buf.append( (char) value );
value = 0;
}
}
if(!consumed) {
if(unicode > 0) {
value = ( value << 4 ) | Character.digit( ch, 16 );
-- unicode;
if(unicode == 0) {
buf.append( (char)value );
value = 0;
}
}
else if(ch == '\\') {
escaped = true;
}
else if(escaped) {
if(ch == 'u' || ch == 'U') {
unicode = 4;
}
else if(ch >= '0' && ch <= '7') {
octal = (ch > '3') ? 1 : 2;
value = Character.digit( ch, 8 );
}
else {
switch( ch ) {
case 'b':
buf.append('\b');
break;
case 'f':
buf.append('\f');
break;
case 'n':
buf.append('\n');
break;
case 'r':
buf.append('\r');
break;
case 't':
buf.append('\t');
break;
case '\'':
buf.append('\'');
break;
case '\"':
buf.append('\"');
break;
case '\\':
buf.append('\\');
break;
default:
yyerror( "Illegal escape character '" + ch + "'" );
}
}
escaped = false;
}
else {
buf.append( ch );
}
}
}
return buf.toString();
}
private Boolean toBoolean(String str) {
str = str.trim();
return new Boolean( str );
}
private Integer toInteger(String str) {
str = str.trim();
Integer result;
if(str.startsWith("0x") || str.startsWith( "0X" ) ) {
result = new Integer( Integer.parseInt( str.substring( 2 ), 16 ) );
}
else if(str.length() > 1 && str.startsWith("0") ) {
result = new Integer( Integer.parseInt( str.substring( 1 ), 8 ) );
}
else {
result = new Integer( str );
}
return result;
}
private Long toLong(String str) {
str = str.trim();
Long result;
if( !str.endsWith("l") && !str.endsWith("L") ) {
yyerror( "Long literal must end with 'l' or 'L'." );
}
int len = str.length() - 1;
if(str.startsWith("0x") || str.startsWith( "0X" ) ) {
result = new Long( Long.parseLong( str.substring( 2, len ), 16 ) );
}
else if(str.startsWith("0") ) {
result = new Long( Long.parseLong( str.substring( 1, len ), 8 ) );
}
else {
result = new Long( str.substring( 0, len ) );
}
return result;
}
private Float toFloat(String str) {
str = str.trim();
return new Float( str );
}
private Double toDouble(String str) {
str = str.trim();
if( !str.endsWith("d") && !str.endsWith("D") ) {
yyerror( "Double literal must end with 'd' or 'D'." );
}
return new Double( str.substring( 0, str.length() - 1 ) );
}
/**
* Convert a character literal into a character.
*/
private Character toChar(String str) {
str = str.trim();
if( !str.startsWith("'") && !str.endsWith("'") ) {
yyerror("Character must be single quoted.");
}
String str2 = convertString( str.substring( 1, str.length() - 1 ) );
if( str2.length() != 1) {
yyerror("Only one character allowed in character constants.");
}
return new Character( str2.charAt( 0 ) );
}
/**
* Convert a string literal into a string.
*/
private String toString(String str) {
str = str.trim();
if( str.length() < 2 && !str.startsWith("\"") && !str.endsWith("\"") ) {
yyerror("String must be double quoted.");
}
String str2 = convertString( str.substring( 1, str.length() - 1 ) );
return str2;
}
//#line 1146 "Parser.java"
//###############################################################
// method: yylexdebug : check lexer state
//###############################################################
void yylexdebug(int state,int ch)
{
String s=null;
if (ch < 0) ch=0;
if (ch <= YYMAXTOKEN) //check index bounds
s = yyname[ch]; //now get it
if (s==null)
s = "illegal-symbol";
debug("state "+state+", reading "+ch+" ("+s+")");
}
//The following are now global, to aid in error reporting
int yyn; //next next thing to do
int yym; //
int yystate; //current parsing state from state table
String yys; //current token string
//###############################################################
// method: yyparse : parse input and execute indicated items
//###############################################################
int yyparse()
{
boolean doaction;
init_stacks();
yynerrs = 0;
yyerrflag = 0;
yychar = -1; //impossible char forces a read
yystate=0; //initial state
state_push(yystate); //save it
while (true) //until parsing is done, either correctly, or w/error
{
doaction=true;
if (yydebug) debug("loop");
//#### NEXT ACTION (from reduction table)
for (yyn=yydefred[yystate];yyn==0;yyn=yydefred[yystate])
{
if (yydebug) debug("yyn:"+yyn+" state:"+yystate+" yychar:"+yychar);
if (yychar < 0) //we want a char?
{
yychar = yylex(); //get next token
if (yydebug) debug(" next yychar:"+yychar);
//#### ERROR CHECK ####
if (yychar < 0) //it it didn't work/error
{
yychar = 0; //change it to default string (no -1!)
if (yydebug)
yylexdebug(yystate,yychar);
}
}//yychar<0
yyn = yysindex[yystate]; //get amount to shift by (shift index)
if ((yyn != 0) && (yyn += yychar) >= 0 &&
yyn <= YYTABLESIZE && yycheck[yyn] == yychar)
{
if (yydebug)
debug("state "+yystate+", shifting to state "+yytable[yyn]);
//#### NEXT STATE ####
yystate = yytable[yyn];//we are in a new state
state_push(yystate); //save it
val_push(yylval); //push our lval as the input for next rule
yychar = -1; //since we have 'eaten' a token, say we need another
if (yyerrflag > 0) //have we recovered an error?
--yyerrflag; //give ourselves credit
doaction=false; //but don't process yet
break; //quit the yyn=0 loop
}
yyn = yyrindex[yystate]; //reduce
if ((yyn !=0 ) && (yyn += yychar) >= 0 &&
yyn <= YYTABLESIZE && yycheck[yyn] == yychar)
{ //we reduced!
if (yydebug) debug("reduce");
yyn = yytable[yyn];
doaction=true; //get ready to execute
break; //drop down to actions
}
else //ERROR RECOVERY
{
if (yyerrflag==0)
{
yyerror("syntax error");
yynerrs++;
}
if (yyerrflag < 3) //low error count?
{
yyerrflag = 3;
while (true) //do until break
{
if (stateptr<0) //check for under & overflow here
{
yyerror("stack underflow. aborting..."); //note lower case 's'
return 1;
}
yyn = yysindex[state_peek(0)];
if ((yyn != 0) && (yyn += YYERRCODE) >= 0 &&
yyn <= YYTABLESIZE && yycheck[yyn] == YYERRCODE)
{
if (yydebug)
debug("state "+state_peek(0)+", error recovery shifting to state "+yytable[yyn]+" ");
yystate = yytable[yyn];
state_push(yystate);
val_push(yylval);
doaction=false;
break;
}
else
{
if (yydebug)
debug("error recovery discarding state "+state_peek(0)+" ");
if (stateptr<0) //check for under & overflow here
{
yyerror("Stack underflow. aborting..."); //capital 'S'
return 1;
}
state_pop();
val_pop();
}
}
}
else //discard this token
{
if (yychar == 0)
return 1; //yyabort
if (yydebug)
{
yys = null;
if (yychar <= YYMAXTOKEN) yys = yyname[yychar];
if (yys == null) yys = "illegal-symbol";
debug("state "+yystate+", error recovery discards token "+yychar+" ("+yys+")");
}
yychar = -1; //read another
}
}//end error recovery
}//yyn=0 loop
if (!doaction) //any reason not to proceed?
continue; //skip action
yym = yylen[yyn]; //get count of terminals on rhs
if (yydebug)
debug("state "+yystate+", reducing "+yym+" by rule "+yyn+" ("+yyrule[yyn]+")");
if (yym>0) //if count of rhs not 'nil'
yyval = val_peek(yym-1); //get current semantic value
switch(yyn)
{
//########## USER-SUPPLIED ACTIONS ##########
case 2:
//#line 55 "/scm/oss/qdox/trunk/qdox/target/checkout/src/grammar/parser.y"
{ line = lexer.getLine(); }
break;
case 10:
//#line 61 "/scm/oss/qdox/trunk/qdox/target/checkout/src/grammar/parser.y"
{ builder.addPackage(val_peek(1).sval); }
break;
case 11:
//#line 64 "/scm/oss/qdox/trunk/qdox/target/checkout/src/grammar/parser.y"
{ builder.addImport(val_peek(1).sval); }
break;
case 12:
//#line 65 "/scm/oss/qdox/trunk/qdox/target/checkout/src/grammar/parser.y"
{ builder.addImport(val_peek(1).sval); }
break;
case 14:
//#line 73 "/scm/oss/qdox/trunk/qdox/target/checkout/src/grammar/parser.y"
{
builder.addJavaDoc(buffer());
}
break;
case 17:
//#line 80 "/scm/oss/qdox/trunk/qdox/target/checkout/src/grammar/parser.y"
{
appendToBuffer(val_peek(0).sval);
}
break;
case 18:
//#line 83 "/scm/oss/qdox/trunk/qdox/target/checkout/src/grammar/parser.y"
{
textBuffer.append('\n');
}
break;
case 21:
//#line 90 "/scm/oss/qdox/trunk/qdox/target/checkout/src/grammar/parser.y"
{ line = lexer.getLine(); }
break;
case 22:
//#line 91 "/scm/oss/qdox/trunk/qdox/target/checkout/src/grammar/parser.y"
{
builder.addJavaDocTag(new TagDef(val_peek(2).sval.substring(1), buffer(), line));
}
break;
case 23:
//#line 100 "/scm/oss/qdox/trunk/qdox/target/checkout/src/grammar/parser.y"
{ yyval.sval = val_peek(0).sval; }
break;
case 24:
//#line 101 "/scm/oss/qdox/trunk/qdox/target/checkout/src/grammar/parser.y"
{ yyval.sval = val_peek(2).sval + '.' + val_peek(0).sval; }
break;
case 25:
//#line 102 "/scm/oss/qdox/trunk/qdox/target/checkout/src/grammar/parser.y"
{ yyval.sval = val_peek(2).sval + ".*"; }
break;
case 26:
//#line 105 "/scm/oss/qdox/trunk/qdox/target/checkout/src/grammar/parser.y"
{
yyval.type = new TypeDef(val_peek(1).sval,val_peek(0).ival);
}
break;
case 27:
//#line 110 "/scm/oss/qdox/trunk/qdox/target/checkout/src/grammar/parser.y"
{ yyval.ival = 0; }
break;
case 28:
//#line 111 "/scm/oss/qdox/trunk/qdox/target/checkout/src/grammar/parser.y"
{
yyval.ival = val_peek(2).ival + 1;
}
break;
case 29:
//#line 117 "/scm/oss/qdox/trunk/qdox/target/checkout/src/grammar/parser.y"
{ yyval.sval = "public"; }
break;
case 30:
//#line 118 "/scm/oss/qdox/trunk/qdox/target/checkout/src/grammar/parser.y"
{ yyval.sval = "protected"; }
break;
case 31:
//#line 119 "/scm/oss/qdox/trunk/qdox/target/checkout/src/grammar/parser.y"
{ yyval.sval = "private"; }
break;
case 32:
//#line 120 "/scm/oss/qdox/trunk/qdox/target/checkout/src/grammar/parser.y"
{ yyval.sval = "static"; }
break;
case 33:
//#line 121 "/scm/oss/qdox/trunk/qdox/target/checkout/src/grammar/parser.y"
{ yyval.sval = "final"; }
break;
case 34:
//#line 122 "/scm/oss/qdox/trunk/qdox/target/checkout/src/grammar/parser.y"
{ yyval.sval = "abstract"; }
break;
case 35:
//#line 123 "/scm/oss/qdox/trunk/qdox/target/checkout/src/grammar/parser.y"
{ yyval.sval = "native"; }
break;
case 36:
//#line 124 "/scm/oss/qdox/trunk/qdox/target/checkout/src/grammar/parser.y"
{ yyval.sval = "synchronized"; }
break;
case 37:
//#line 125 "/scm/oss/qdox/trunk/qdox/target/checkout/src/grammar/parser.y"
{ yyval.sval = "volatile"; }
break;
case 38:
//#line 126 "/scm/oss/qdox/trunk/qdox/target/checkout/src/grammar/parser.y"
{ yyval.sval = "transient"; }
break;
case 39:
//#line 127 "/scm/oss/qdox/trunk/qdox/target/checkout/src/grammar/parser.y"
{ yyval.sval = "strictfp"; }
break;
case 40:
//#line 130 "/scm/oss/qdox/trunk/qdox/target/checkout/src/grammar/parser.y"
{ modifiers.add(val_peek(0).sval); }
break;
case 41:
//#line 131 "/scm/oss/qdox/trunk/qdox/target/checkout/src/grammar/parser.y"
{ builder.addAnnotation((Annotation) val_peek(0).annoval); }
break;
case 43:
//#line 141 "/scm/oss/qdox/trunk/qdox/target/checkout/src/grammar/parser.y"
{
annotationStack.add(annotation);
annotation = new Annotation(builder.createType(val_peek(0).sval, 0), lexer.getLine());
}
break;
case 44:
//#line 146 "/scm/oss/qdox/trunk/qdox/target/checkout/src/grammar/parser.y"
{
yyval.annoval = annotation;
annotation = (Annotation)annotationStack.remove(annotationStack.size() - 1);
}
break;
case 46:
//#line 153 "/scm/oss/qdox/trunk/qdox/target/checkout/src/grammar/parser.y"
{ annotation.setProperty("value", val_peek(1).annoval); }
break;
case 51:
//#line 162 "/scm/oss/qdox/trunk/qdox/target/checkout/src/grammar/parser.y"
{ annotation.setProperty(val_peek(2).sval, val_peek(0).annoval); }
break;
case 52:
//#line 165 "/scm/oss/qdox/trunk/qdox/target/checkout/src/grammar/parser.y"
{
annoValueListStack.add(annoValueList);
annoValueList = new ArrayList();
}
break;
case 53:
//#line 170 "/scm/oss/qdox/trunk/qdox/target/checkout/src/grammar/parser.y"
{
yyval.annoval = new AnnotationValueList(annoValueList);
annoValueList = (List)annoValueListStack.remove(annoValueListStack.size() - 1);
}
break;
case 56:
//#line 180 "/scm/oss/qdox/trunk/qdox/target/checkout/src/grammar/parser.y"
{ annoValueList.add(val_peek(0).annoval); }
break;
case 57:
//#line 181 "/scm/oss/qdox/trunk/qdox/target/checkout/src/grammar/parser.y"
{ annoValueList.add(val_peek(0).annoval); }
break;
case 58:
//#line 184 "/scm/oss/qdox/trunk/qdox/target/checkout/src/grammar/parser.y"
{ yyval.annoval = val_peek(0).annoval; }
break;
case 59:
//#line 185 "/scm/oss/qdox/trunk/qdox/target/checkout/src/grammar/parser.y"
{ yyval.annoval = val_peek(0).annoval; }
break;
case 60:
//#line 186 "/scm/oss/qdox/trunk/qdox/target/checkout/src/grammar/parser.y"
{ yyval.annoval = val_peek(0).annoval; }
break;
case 61:
//#line 189 "/scm/oss/qdox/trunk/qdox/target/checkout/src/grammar/parser.y"
{ yyval.annoval = val_peek(0).annoval; }
break;
case 62:
//#line 192 "/scm/oss/qdox/trunk/qdox/target/checkout/src/grammar/parser.y"
{ yyval.annoval = val_peek(0).annoval; }
break;
case 63:
//#line 193 "/scm/oss/qdox/trunk/qdox/target/checkout/src/grammar/parser.y"
{ yyval.annoval = new AnnotationQuery(val_peek(4).annoval, val_peek(2).annoval, val_peek(0).annoval); }
break;
case 64:
//#line 196 "/scm/oss/qdox/trunk/qdox/target/checkout/src/grammar/parser.y"
{ yyval.annoval = val_peek(0).annoval; }
break;
case 65:
//#line 197 "/scm/oss/qdox/trunk/qdox/target/checkout/src/grammar/parser.y"
{ yyval.annoval = new AnnotationLogicalOr(val_peek(2).annoval, val_peek(0).annoval); }
break;
case 66:
//#line 200 "/scm/oss/qdox/trunk/qdox/target/checkout/src/grammar/parser.y"
{ yyval.annoval = val_peek(0).annoval; }
break;
case 67:
//#line 201 "/scm/oss/qdox/trunk/qdox/target/checkout/src/grammar/parser.y"
{ yyval.annoval = new AnnotationLogicalAnd(val_peek(2).annoval, val_peek(0).annoval); }
break;
case 68:
//#line 204 "/scm/oss/qdox/trunk/qdox/target/checkout/src/grammar/parser.y"
{ yyval.annoval = val_peek(0).annoval; }
break;
case 69:
//#line 205 "/scm/oss/qdox/trunk/qdox/target/checkout/src/grammar/parser.y"
{ yyval.annoval = new AnnotationOr(val_peek(2).annoval, val_peek(0).annoval); }
break;
case 70:
//#line 208 "/scm/oss/qdox/trunk/qdox/target/checkout/src/grammar/parser.y"
{ yyval.annoval = val_peek(0).annoval; }
break;
case 71:
//#line 209 "/scm/oss/qdox/trunk/qdox/target/checkout/src/grammar/parser.y"
{ yyval.annoval = new AnnotationExclusiveOr(val_peek(2).annoval, val_peek(0).annoval); }
break;
case 72:
//#line 212 "/scm/oss/qdox/trunk/qdox/target/checkout/src/grammar/parser.y"
{ yyval.annoval = val_peek(0).annoval; }
break;
case 73:
//#line 213 "/scm/oss/qdox/trunk/qdox/target/checkout/src/grammar/parser.y"
{ yyval.annoval = new AnnotationAnd(val_peek(2).annoval, val_peek(0).annoval); }
break;
case 74:
//#line 216 "/scm/oss/qdox/trunk/qdox/target/checkout/src/grammar/parser.y"
{ yyval.annoval = val_peek(0).annoval; }
break;
case 75:
//#line 217 "/scm/oss/qdox/trunk/qdox/target/checkout/src/grammar/parser.y"
{ yyval.annoval = new AnnotationEquals(val_peek(2).annoval, val_peek(0).annoval); }
break;
case 76:
//#line 218 "/scm/oss/qdox/trunk/qdox/target/checkout/src/grammar/parser.y"
{ yyval.annoval = new AnnotationNotEquals(val_peek(2).annoval, val_peek(0).annoval); }
break;
case 77:
//#line 221 "/scm/oss/qdox/trunk/qdox/target/checkout/src/grammar/parser.y"
{ yyval.annoval = val_peek(0).annoval; }
break;
case 78:
//#line 222 "/scm/oss/qdox/trunk/qdox/target/checkout/src/grammar/parser.y"
{ yyval.annoval = new AnnotationLessEquals(val_peek(2).annoval, val_peek(0).annoval); }
break;
case 79:
//#line 223 "/scm/oss/qdox/trunk/qdox/target/checkout/src/grammar/parser.y"
{ yyval.annoval = new AnnotationGreaterEquals(val_peek(2).annoval, val_peek(0).annoval); }
break;
case 80:
//#line 224 "/scm/oss/qdox/trunk/qdox/target/checkout/src/grammar/parser.y"
{ yyval.annoval = new AnnotationLessThan(val_peek(2).annoval, val_peek(0).annoval); }
break;
case 81:
//#line 225 "/scm/oss/qdox/trunk/qdox/target/checkout/src/grammar/parser.y"
{ yyval.annoval = new AnnotationGreaterThan(val_peek(2).annoval, val_peek(0).annoval); }
break;
case 82:
//#line 228 "/scm/oss/qdox/trunk/qdox/target/checkout/src/grammar/parser.y"
{ yyval.annoval = val_peek(0).annoval; }
break;
case 83:
//#line 229 "/scm/oss/qdox/trunk/qdox/target/checkout/src/grammar/parser.y"
{ yyval.annoval = new AnnotationShiftLeft(val_peek(2).annoval, val_peek(0).annoval); }
break;
case 84:
//#line 230 "/scm/oss/qdox/trunk/qdox/target/checkout/src/grammar/parser.y"
{ yyval.annoval = new AnnotationUnsignedShiftRight(val_peek(2).annoval, val_peek(0).annoval); }
break;
case 85:
//#line 231 "/scm/oss/qdox/trunk/qdox/target/checkout/src/grammar/parser.y"
{ yyval.annoval = new AnnotationShiftRight(val_peek(2).annoval, val_peek(0).annoval); }
break;
case 86:
//#line 234 "/scm/oss/qdox/trunk/qdox/target/checkout/src/grammar/parser.y"
{ yyval.annoval = val_peek(0).annoval; }
break;
case 87:
//#line 235 "/scm/oss/qdox/trunk/qdox/target/checkout/src/grammar/parser.y"
{ yyval.annoval = new AnnotationAdd(val_peek(2).annoval, val_peek(0).annoval); }
break;
case 88:
//#line 236 "/scm/oss/qdox/trunk/qdox/target/checkout/src/grammar/parser.y"
{ yyval.annoval = new AnnotationSubtract(val_peek(2).annoval, val_peek(0).annoval); }
break;
case 89:
//#line 239 "/scm/oss/qdox/trunk/qdox/target/checkout/src/grammar/parser.y"
{ yyval.annoval = val_peek(0).annoval; }
break;
case 90:
//#line 240 "/scm/oss/qdox/trunk/qdox/target/checkout/src/grammar/parser.y"
{ yyval.annoval = new AnnotationMultiply(val_peek(2).annoval, val_peek(0).annoval); }
break;
case 91:
//#line 241 "/scm/oss/qdox/trunk/qdox/target/checkout/src/grammar/parser.y"
{ yyval.annoval = new AnnotationDivide(val_peek(2).annoval, val_peek(0).annoval); }
break;
case 92:
//#line 242 "/scm/oss/qdox/trunk/qdox/target/checkout/src/grammar/parser.y"
{ yyval.annoval = new AnnotationRemainder(val_peek(2).annoval, val_peek(0).annoval); }
break;
case 93:
//#line 245 "/scm/oss/qdox/trunk/qdox/target/checkout/src/grammar/parser.y"
{ yyval.annoval = new AnnotationPlusSign(val_peek(0).annoval); }
break;
case 94:
//#line 246 "/scm/oss/qdox/trunk/qdox/target/checkout/src/grammar/parser.y"
{ yyval.annoval = new AnnotationMinusSign(val_peek(0).annoval); }
break;
case 95:
//#line 247 "/scm/oss/qdox/trunk/qdox/target/checkout/src/grammar/parser.y"
{ yyval.annoval = val_peek(0).annoval; }
break;
case 96:
//#line 250 "/scm/oss/qdox/trunk/qdox/target/checkout/src/grammar/parser.y"
{ yyval.annoval = new AnnotationNot(val_peek(0).annoval); }
break;
case 97:
//#line 251 "/scm/oss/qdox/trunk/qdox/target/checkout/src/grammar/parser.y"
{ yyval.annoval = new AnnotationLogicalNot(val_peek(0).annoval); }
break;
case 99:
//#line 255 "/scm/oss/qdox/trunk/qdox/target/checkout/src/grammar/parser.y"
{ yyval.annoval = new AnnotationCast(builder.createType(val_peek(2).sval, 0), val_peek(0).annoval); }
break;
case 100:
//#line 256 "/scm/oss/qdox/trunk/qdox/target/checkout/src/grammar/parser.y"
{ yyval.annoval = new AnnotationCast(builder.createType(val_peek(3).sval, val_peek(2).ival), val_peek(0).annoval); }
break;
case 101:
//#line 257 "/scm/oss/qdox/trunk/qdox/target/checkout/src/grammar/parser.y"
{ yyval.annoval = new AnnotationCast(builder.createType(val_peek(3).sval, val_peek(2).ival), val_peek(0).annoval); }
break;
case 102:
//#line 258 "/scm/oss/qdox/trunk/qdox/target/checkout/src/grammar/parser.y"
{ yyval.annoval = new AnnotationCast(builder.createType(val_peek(2).sval, 0), val_peek(0).annoval); }
break;
case 103:
//#line 259 "/scm/oss/qdox/trunk/qdox/target/checkout/src/grammar/parser.y"
{ yyval.annoval = new AnnotationParenExpression(val_peek(1).annoval); }
break;
case 104:
//#line 260 "/scm/oss/qdox/trunk/qdox/target/checkout/src/grammar/parser.y"
{ yyval.annoval = val_peek(0).annoval; }
break;
case 105:
//#line 261 "/scm/oss/qdox/trunk/qdox/target/checkout/src/grammar/parser.y"
{ yyval.annoval = new AnnotationTypeRef(builder.createType(val_peek(3).sval, 0)); }
break;
case 106:
//#line 262 "/scm/oss/qdox/trunk/qdox/target/checkout/src/grammar/parser.y"
{ yyval.annoval = new AnnotationTypeRef(builder.createType(val_peek(2).sval, 0)); }
break;
case 107:
//#line 263 "/scm/oss/qdox/trunk/qdox/target/checkout/src/grammar/parser.y"
{ yyval.annoval = new AnnotationTypeRef(builder.createType(val_peek(2).sval, 0)); }
break;
case 108:
//#line 264 "/scm/oss/qdox/trunk/qdox/target/checkout/src/grammar/parser.y"
{ yyval.annoval = new AnnotationTypeRef(builder.createType(val_peek(3).sval, 0)); }
break;
case 109:
//#line 265 "/scm/oss/qdox/trunk/qdox/target/checkout/src/grammar/parser.y"
{ yyval.annoval = new AnnotationFieldRef(val_peek(0).sval); }
break;
case 110:
//#line 268 "/scm/oss/qdox/trunk/qdox/target/checkout/src/grammar/parser.y"
{ yyval.ival = 1; }
break;
case 111:
//#line 269 "/scm/oss/qdox/trunk/qdox/target/checkout/src/grammar/parser.y"
{ yyval.ival = val_peek(2).ival + 1; }
break;
case 112:
//#line 272 "/scm/oss/qdox/trunk/qdox/target/checkout/src/grammar/parser.y"
{ yyval.sval = val_peek(0).sval; }
break;
case 113:
//#line 273 "/scm/oss/qdox/trunk/qdox/target/checkout/src/grammar/parser.y"
{ yyval.sval = val_peek(2).sval + "." + val_peek(0).sval; }
break;
case 114:
//#line 276 "/scm/oss/qdox/trunk/qdox/target/checkout/src/grammar/parser.y"
{ yyval.annoval = new AnnotationConstant(toDouble(val_peek(0).sval), val_peek(0).sval); }
break;
case 115:
//#line 277 "/scm/oss/qdox/trunk/qdox/target/checkout/src/grammar/parser.y"
{ yyval.annoval = new AnnotationConstant(toFloat(val_peek(0).sval), val_peek(0).sval); }
break;
case 116:
//#line 278 "/scm/oss/qdox/trunk/qdox/target/checkout/src/grammar/parser.y"
{ yyval.annoval = new AnnotationConstant(toLong(val_peek(0).sval), val_peek(0).sval); }
break;
case 117:
//#line 279 "/scm/oss/qdox/trunk/qdox/target/checkout/src/grammar/parser.y"
{ yyval.annoval = new AnnotationConstant(toInteger(val_peek(0).sval), val_peek(0).sval); }
break;
case 118:
//#line 280 "/scm/oss/qdox/trunk/qdox/target/checkout/src/grammar/parser.y"
{ yyval.annoval = new AnnotationConstant(toBoolean(val_peek(0).sval), val_peek(0).sval); }
break;
case 119:
//#line 281 "/scm/oss/qdox/trunk/qdox/target/checkout/src/grammar/parser.y"
{ String s = lexer.getCodeBody(); yyval.annoval = new AnnotationConstant(toChar(s), s); }
break;
case 120:
//#line 282 "/scm/oss/qdox/trunk/qdox/target/checkout/src/grammar/parser.y"
{ String s = lexer.getCodeBody(); yyval.annoval = new AnnotationConstant(toString(s), s); }
break;
case 121:
//#line 285 "/scm/oss/qdox/trunk/qdox/target/checkout/src/grammar/parser.y"
{ yyval.sval = "boolean"; }
break;
case 122:
//#line 286 "/scm/oss/qdox/trunk/qdox/target/checkout/src/grammar/parser.y"
{ yyval.sval = "byte"; }
break;
case 123:
//#line 287 "/scm/oss/qdox/trunk/qdox/target/checkout/src/grammar/parser.y"
{ yyval.sval = "short"; }
break;
case 124:
//#line 288 "/scm/oss/qdox/trunk/qdox/target/checkout/src/grammar/parser.y"
{ yyval.sval = "int"; }
break;
case 125:
//#line 289 "/scm/oss/qdox/trunk/qdox/target/checkout/src/grammar/parser.y"
{ yyval.sval = "long"; }
break;
case 126:
//#line 290 "/scm/oss/qdox/trunk/qdox/target/checkout/src/grammar/parser.y"
{ yyval.sval = "char"; }
break;
case 127:
//#line 291 "/scm/oss/qdox/trunk/qdox/target/checkout/src/grammar/parser.y"
{ yyval.sval = "float"; }
break;
case 128:
//#line 292 "/scm/oss/qdox/trunk/qdox/target/checkout/src/grammar/parser.y"
{ yyval.sval = "double"; }
break;
case 129:
//#line 298 "/scm/oss/qdox/trunk/qdox/target/checkout/src/grammar/parser.y"
{
yyval.type = new TypeDef(val_peek(2).sval,val_peek(0).ival);
}
break;
case 130:
//#line 303 "/scm/oss/qdox/trunk/qdox/target/checkout/src/grammar/parser.y"
{
yyval.sval = val_peek(1).sval;
}
break;
case 131:
//#line 308 "/scm/oss/qdox/trunk/qdox/target/checkout/src/grammar/parser.y"
{ yyval.sval = val_peek(0).sval; }
break;
case 132:
//#line 309 "/scm/oss/qdox/trunk/qdox/target/checkout/src/grammar/parser.y"
{ yyval.sval = val_peek(2).sval + '.' + val_peek(0).sval; }
break;
case 133:
//#line 312 "/scm/oss/qdox/trunk/qdox/target/checkout/src/grammar/parser.y"
{ yyval.sval = val_peek(0).sval; }
break;
case 134:
//#line 313 "/scm/oss/qdox/trunk/qdox/target/checkout/src/grammar/parser.y"
{ yyval.sval = val_peek(2).sval + '.' + val_peek(0).sval; }
break;
case 152:
//#line 345 "/scm/oss/qdox/trunk/qdox/target/checkout/src/grammar/parser.y"
{
builder.endClass();
fieldType = null;
modifiers.clear();
}
break;
case 153:
//#line 351 "/scm/oss/qdox/trunk/qdox/target/checkout/src/grammar/parser.y"
{
cls.lineNumber = line;
cls.modifiers.addAll(modifiers);
cls.name = val_peek(1).sval;
cls.type = ClassDef.ENUM;
builder.beginClass(cls);
cls = new ClassDef();
fieldType = new TypeDef(val_peek(1).sval, 0);
}
break;
case 161:
//#line 370 "/scm/oss/qdox/trunk/qdox/target/checkout/src/grammar/parser.y"
{ makeField(new TypeDef(val_peek(0).sval, 0), ""); }
break;
case 162:
//#line 371 "/scm/oss/qdox/trunk/qdox/target/checkout/src/grammar/parser.y"
{ makeField(new TypeDef(val_peek(1).sval, 0), ""); }
break;
case 163:
//#line 372 "/scm/oss/qdox/trunk/qdox/target/checkout/src/grammar/parser.y"
{ makeField(new TypeDef(val_peek(1).sval, 0), ""); }
break;
case 164:
//#line 373 "/scm/oss/qdox/trunk/qdox/target/checkout/src/grammar/parser.y"
{ makeField(new TypeDef(val_peek(2).sval, 0), ""); }
break;
case 165:
//#line 379 "/scm/oss/qdox/trunk/qdox/target/checkout/src/grammar/parser.y"
{
builder.endClass();
}
break;
case 166:
//#line 384 "/scm/oss/qdox/trunk/qdox/target/checkout/src/grammar/parser.y"
{
cls.lineNumber = line;
cls.modifiers.addAll(modifiers); modifiers.clear();
cls.name = val_peek(3).sval;
builder.beginClass(cls);
cls = new ClassDef();
}
break;
case 167:
//#line 393 "/scm/oss/qdox/trunk/qdox/target/checkout/src/grammar/parser.y"
{ cls.type = ClassDef.CLASS; }
break;
case 168:
//#line 394 "/scm/oss/qdox/trunk/qdox/target/checkout/src/grammar/parser.y"
{ cls.type = ClassDef.INTERFACE; }
break;
case 169:
//#line 395 "/scm/oss/qdox/trunk/qdox/target/checkout/src/grammar/parser.y"
{ cls.type = ClassDef.ANNOTATION_TYPE; }
break;
case 172:
//#line 400 "/scm/oss/qdox/trunk/qdox/target/checkout/src/grammar/parser.y"
{ cls.extendz.add(val_peek(0).sval); }
break;
case 173:
//#line 401 "/scm/oss/qdox/trunk/qdox/target/checkout/src/grammar/parser.y"
{ cls.extendz.add(val_peek(0).sval); }
break;
case 176:
//#line 406 "/scm/oss/qdox/trunk/qdox/target/checkout/src/grammar/parser.y"
{ cls.implementz.add(val_peek(0).sval); }
break;
case 177:
//#line 407 "/scm/oss/qdox/trunk/qdox/target/checkout/src/grammar/parser.y"
{ cls.implementz.add(val_peek(0).sval); }
break;
case 179:
//#line 409 "/scm/oss/qdox/trunk/qdox/target/checkout/src/grammar/parser.y"
{ line = lexer.getLine(); }
break;
case 189:
//#line 422 "/scm/oss/qdox/trunk/qdox/target/checkout/src/grammar/parser.y"
{
yyval.sval = "";
}
break;
case 190:
//#line 425 "/scm/oss/qdox/trunk/qdox/target/checkout/src/grammar/parser.y"
{
yyval.sval = lexer.getCodeBody();
}
break;
case 191:
//#line 430 "/scm/oss/qdox/trunk/qdox/target/checkout/src/grammar/parser.y"
{ modifiers.clear(); }
break;
case 192:
//#line 435 "/scm/oss/qdox/trunk/qdox/target/checkout/src/grammar/parser.y"
{
fieldType = val_peek(1).type;
makeField(val_peek(0).type, lexer.getCodeBody());
}
break;
case 193:
//#line 439 "/scm/oss/qdox/trunk/qdox/target/checkout/src/grammar/parser.y"
{
modifiers.clear();
}
break;
case 195:
//#line 444 "/scm/oss/qdox/trunk/qdox/target/checkout/src/grammar/parser.y"
{ line = lexer.getLine(); }
break;
case 196:
//#line 444 "/scm/oss/qdox/trunk/qdox/target/checkout/src/grammar/parser.y"
{
makeField(val_peek(0).type, lexer.getCodeBody());
}
break;
case 197:
//#line 452 "/scm/oss/qdox/trunk/qdox/target/checkout/src/grammar/parser.y"
{
mth.lineNumber = line;
mth.modifiers.addAll(modifiers); modifiers.clear();
mth.returns = val_peek(5).type.name;
mth.dimensions = val_peek(2).ival + val_peek(5).type.dimensions; /* return dimensions can be specified after return type OR after params*/
mth.name = val_peek(4).sval;
mth.body = val_peek(0).sval;
builder.addMethod(mth);
mth = new MethodDef();
}
break;
case 198:
//#line 462 "/scm/oss/qdox/trunk/qdox/target/checkout/src/grammar/parser.y"
{
mth.lineNumber = line;
mth.modifiers.addAll(modifiers); modifiers.clear();
mth.returns = val_peek(5).type.name;
mth.dimensions = val_peek(2).ival + val_peek(5).type.dimensions; /* return dimensions can be specified after return type OR after params*/
mth.name = val_peek(4).sval;
mth.body = val_peek(0).sval;
builder.addMethod(mth);
mth = new MethodDef();
}
break;
case 199:
//#line 474 "/scm/oss/qdox/trunk/qdox/target/checkout/src/grammar/parser.y"
{
mth.lineNumber = line;
mth.modifiers.addAll(modifiers); modifiers.clear();
mth.constructor = true; mth.name = val_peek(3).sval;
mth.body = val_peek(0).sval;
builder.addMethod(mth);
mth = new MethodDef();
}
break;
case 203:
//#line 488 "/scm/oss/qdox/trunk/qdox/target/checkout/src/grammar/parser.y"
{ mth.exceptions.add(val_peek(0).sval); }
break;
case 204:
//#line 489 "/scm/oss/qdox/trunk/qdox/target/checkout/src/grammar/parser.y"
{ mth.exceptions.add(val_peek(0).sval); }
break;
case 209:
//#line 498 "/scm/oss/qdox/trunk/qdox/target/checkout/src/grammar/parser.y"
{
param.name = val_peek(0).type.name;
param.type = val_peek(2).type.name;
param.dimensions = val_peek(2).type.dimensions + val_peek(0).type.dimensions;
param.isVarArgs = val_peek(1).bval;
mth.params.add(param);
param = new FieldDef();
}
break;
case 210:
//#line 508 "/scm/oss/qdox/trunk/qdox/target/checkout/src/grammar/parser.y"
{ yyval.bval = false; }
break;
case 211:
//#line 509 "/scm/oss/qdox/trunk/qdox/target/checkout/src/grammar/parser.y"
{ yyval.bval = true; }
break;
case 215:
//#line 514 "/scm/oss/qdox/trunk/qdox/target/checkout/src/grammar/parser.y"
{ param.modifiers.add(val_peek(0).sval); }
break;
//#line 1960 "Parser.java"
//########## END OF USER-SUPPLIED ACTIONS ##########
}//switch
//#### Now let's reduce... ####
if (yydebug) debug("reduce");
state_drop(yym); //we just reduced yylen states
yystate = state_peek(0); //get new state
val_drop(yym); //corresponding value drop
yym = yylhs[yyn]; //select next TERMINAL(on lhs)
if (yystate == 0 && yym == 0)//done? 'rest' state and at first TERMINAL
{
if (yydebug) debug("After reduction, shifting from state 0 to state "+YYFINAL+"");
yystate = YYFINAL; //explicitly say we're done
state_push(YYFINAL); //and save it
val_push(yyval); //also save the semantic value of parsing
if (yychar < 0) //we want another character?
{
yychar = yylex(); //get next character
if (yychar<0) yychar=0; //clean, if necessary
if (yydebug)
yylexdebug(yystate,yychar);
}
if (yychar == 0) //Good exit (if lex returns 0 ;-)
break; //quit the loop--all DONE
}//if yystate
else //else not done yet
{ //get next state and push, for next yydefred[]
yyn = yygindex[yym]; //find out where to go
if ((yyn != 0) && (yyn += yystate) >= 0 &&
yyn <= YYTABLESIZE && yycheck[yyn] == yystate)
yystate = yytable[yyn]; //get new state
else
yystate = yydgoto[yym]; //else go to new defred
if (yydebug) debug("after reduction, shifting from state "+state_peek(0)+" to state "+yystate+"");
state_push(yystate); //going again, so push state & val...
val_push(yyval); //for next action
}
}//main loop
return 0;//yyaccept!!
}
//## end of method parse() ######################################
//## run() --- for Thread #######################################
//## The -Jnorun option was used ##
//## end of method run() ########################################
//## Constructors ###############################################
//## The -Jnoconstruct option was used ##
//###############################################################
}
//################### END OF CLASS ##############################