forked from JavaTX/JavaCompilerCore
2388 lines
68 KiB
Plaintext
Executable File
2388 lines
68 KiB
Plaintext
Executable File
%{
|
||
|
||
/*
|
||
Backup von JavaParser.jay 10.April 17 Uhr
|
||
*/
|
||
|
||
package mycompiler.myparser;
|
||
|
||
import mycompiler.myclass.FieldDeclaration;
|
||
import mycompiler.myclass.Field;
|
||
import java.util.Vector;
|
||
import mycompiler.SourceFile;
|
||
import mycompiler.AClassOrInterface;
|
||
import mycompiler.myclass.Class;
|
||
import mycompiler.myclass.ClassBody;
|
||
import mycompiler.myclass.Constructor;
|
||
import mycompiler.myclass.Constant;
|
||
import mycompiler.myclass.ImportDeclarations;
|
||
import mycompiler.myclass.DeclId;
|
||
import mycompiler.myclass.ExceptionList;
|
||
import mycompiler.myclass.FormalParameter;
|
||
import mycompiler.myclass.Method;
|
||
import mycompiler.myclass.ParameterList;
|
||
import mycompiler.myclass.UsedId;
|
||
import mycompiler.myinterface.Interface;
|
||
import mycompiler.myinterface.InterfaceBody;
|
||
import mycompiler.mymodifier.Abstract;
|
||
import mycompiler.mymodifier.Final;
|
||
import mycompiler.mymodifier.Modifier;
|
||
import mycompiler.mymodifier.Modifiers;
|
||
import mycompiler.mymodifier.Private;
|
||
import mycompiler.mymodifier.Protected;
|
||
import mycompiler.mymodifier.Public;
|
||
import mycompiler.mymodifier.Static;
|
||
import mycompiler.myoperator.AndOp;
|
||
import mycompiler.myoperator.DivideOp;
|
||
import mycompiler.myoperator.EqualOp;
|
||
import mycompiler.myoperator.GreaterEquOp;
|
||
import mycompiler.myoperator.GreaterOp;
|
||
import mycompiler.myoperator.LessEquOp;
|
||
import mycompiler.myoperator.LessOp;
|
||
import mycompiler.myoperator.MinusOp;
|
||
import mycompiler.myoperator.ModuloOp;
|
||
import mycompiler.myoperator.NotEqualOp;
|
||
import mycompiler.myoperator.Operator;
|
||
import mycompiler.myoperator.OrOp;
|
||
import mycompiler.myoperator.PlusOp;
|
||
import mycompiler.myoperator.TimesOp;
|
||
import mycompiler.mystatement.ArgumentList;
|
||
import mycompiler.mystatement.Assign;
|
||
import mycompiler.mystatement.Binary;
|
||
import mycompiler.mystatement.Block;
|
||
import mycompiler.mystatement.BoolLiteral;
|
||
import mycompiler.mystatement.FloatLiteral;
|
||
import mycompiler.mystatement.DoubleLiteral;
|
||
import mycompiler.mystatement.LongLiteral;
|
||
import mycompiler.mystatement.CastExpr;
|
||
import mycompiler.mystatement.CharLiteral;
|
||
import mycompiler.mystatement.EmptyStmt;
|
||
import mycompiler.mystatement.Expr;
|
||
import mycompiler.mystatement.ExprStmt;
|
||
import mycompiler.mystatement.IfStmt;
|
||
import mycompiler.mystatement.InstanceOf;
|
||
import mycompiler.mystatement.IntLiteral;
|
||
import mycompiler.mystatement.Literal;
|
||
import mycompiler.mystatement.InstVar;
|
||
import mycompiler.mystatement.LocalOrFieldVar;
|
||
import mycompiler.mystatement.LocalVarDecl;
|
||
import mycompiler.mystatement.MethodCall;
|
||
import mycompiler.mystatement.NegativeExpr;
|
||
import mycompiler.mystatement.NewClass;
|
||
import mycompiler.mystatement.NotExpr;
|
||
import mycompiler.mystatement.Null;
|
||
import mycompiler.mystatement.PositivExpr;
|
||
import mycompiler.mystatement.PostDecExpr;
|
||
import mycompiler.mystatement.PostIncExpr;
|
||
import mycompiler.mystatement.PreDecExpr;
|
||
import mycompiler.mystatement.PreIncExpr;
|
||
import mycompiler.mystatement.Receiver;
|
||
import mycompiler.mystatement.Return;
|
||
import mycompiler.mystatement.Statement;
|
||
import mycompiler.mystatement.StringLiteral;
|
||
import mycompiler.mystatement.This;
|
||
import mycompiler.mystatement.UnaryMinus;
|
||
import mycompiler.mystatement.UnaryNot;
|
||
import mycompiler.mystatement.UnaryPlus;
|
||
import mycompiler.mystatement.WhileStmt;
|
||
import mycompiler.mystatement.ForStmt;
|
||
import mycompiler.mystatement.LambdaExpression;
|
||
import mycompiler.mytype.BaseType;
|
||
import mycompiler.mytype.BooleanType;
|
||
import mycompiler.mytype.CharacterType;
|
||
import mycompiler.mytype.GenericTypeVar;
|
||
import mycompiler.mytype.BoundedGenericTypeVar;
|
||
import mycompiler.mytype.IntegerType;
|
||
import mycompiler.mytype.ParaList;
|
||
import mycompiler.mytype.RefType;
|
||
import mycompiler.mytype.Type;
|
||
import mycompiler.mytype.TypePlaceholder;
|
||
import mycompiler.mytype.Void;
|
||
import mycompiler.mytype.WildcardType;
|
||
import mycompiler.mytype.ExtendsWildcardType;
|
||
import mycompiler.mytype.SuperWildcardType;
|
||
import mycompiler.mytype.Pair;
|
||
|
||
public class JavaParser{
|
||
public Vector path = new Vector();
|
||
|
||
//PL 05-07-30 eingefuegt. ANFANG
|
||
private Vector<Type> containedTypes = new Vector<Type>();
|
||
private Vector<UsedId> usedIdsToCheck = new Vector<UsedId>();
|
||
//Vektor aller Typdeklarationen die in aktueller Klasse vorkommen.
|
||
//wird nach Beendigung der Klasse des Attributs der jeweiligen
|
||
//Klasse zugeordnet
|
||
//nach dem Parsen wird mit wandleGeneric2RefType die
|
||
//die RefTypes gesetzt.
|
||
void initContainedTypes() {
|
||
this.containedTypes = new Vector<Type>();
|
||
}
|
||
void initUsedIdsToCheck() {
|
||
this.usedIdsToCheck = new Vector<UsedId>();
|
||
}
|
||
//PL 05-07-30 eingefuegt. ENDE
|
||
|
||
//LUAR 07-05-29 Anfang f<>r Wildcard Test
|
||
public Vector<Pair> testPair = new Vector<Pair>();
|
||
//LUAR 07-05-29 Ende
|
||
%}
|
||
|
||
%token <Token> ABSTRACT
|
||
%token <Token> BOOLEAN
|
||
%token BREAK
|
||
%token CASE
|
||
%token CATCH
|
||
%token <Token> CHAR
|
||
%token CLASS
|
||
%token CONTINUE
|
||
%token DEFAULT
|
||
%token DO
|
||
%token ELSE
|
||
%token <Token> EXTENDS
|
||
%token <Token> FINAL
|
||
%token FINALLY
|
||
%token FOR
|
||
%token IF
|
||
%token <Token> INSTANCEOF
|
||
%token <Token> INT
|
||
%token <Token> NEW
|
||
%token <Token> PRIVATE
|
||
%token <Token> PROTECTED
|
||
%token <Token> PUBLIC
|
||
%token PACKAGE
|
||
%token IMPORT
|
||
%token INTERFACE
|
||
%token IMPLEMENTS
|
||
%token RETURN
|
||
%token <Token> STATIC
|
||
%token <Token> SUPER
|
||
%token SWITCH
|
||
%token <Token> THIS
|
||
%token THROW
|
||
%token <Token> THROWS
|
||
%token TRY
|
||
%token <Token> VOID
|
||
%token WHILE
|
||
%token <Token> INTLITERAL
|
||
%token <Token> LONGLITERAL
|
||
%token <Token> DOUBLELITERAL
|
||
%token <Token> FLOATLITERAL
|
||
%token <Token> BOOLLITERAL
|
||
%token JNULL
|
||
%token <Token> CHARLITERAL
|
||
%token <Token> STRINGLITERAL
|
||
%token <Token> IDENTIFIER
|
||
%token EQUAL
|
||
%token LESSEQUAL
|
||
%token GREATEREQUAL
|
||
%token NOTEQUAL
|
||
%token LOGICALOR
|
||
%token LOGICALAND
|
||
%token <Token> INCREMENT
|
||
%token <Token> DECREMENT
|
||
%token SHIFTLEFT
|
||
%token SHIFTRIGHT
|
||
%token UNSIGNEDSHIFTRIGHT
|
||
%token SIGNEDSHIFTRIGHT
|
||
%token PLUSEQUAL
|
||
%token MINUSEQUAL
|
||
%token TIMESEQUAL
|
||
%token DIVIDEEQUAL
|
||
%token ANDEQUAL
|
||
%token OREQUAL
|
||
%token XOREQUAL
|
||
%token MODULOEQUAL
|
||
%token SHIFTLEFTEQUAL
|
||
%token SIGNEDSHIFTRIGHTEQUAL
|
||
%token UNSIGNEDSHIFTRIGHTEQUAL
|
||
%token BRACE
|
||
%token RELOP
|
||
%token OP
|
||
%token EOF
|
||
%token LAMBDAASSIGNMENT
|
||
|
||
%type <Class> classdeclaration
|
||
%type <Interface> interfacedeclaration
|
||
%type <InterfaceBody> interfacebody
|
||
%type <InterfaceBody> interfacememberdeclarations
|
||
%type <Field> interfacememberdeclaration
|
||
%type <Method> abstractmethoddeclaration
|
||
%type <ClassBody> classbody
|
||
%type <ClassAndParameter> classidentifier
|
||
%type <InterfaceAndParameter> interfaceidentifier
|
||
%type <Constant> constantdeclaration
|
||
%type <Field> fielddeclaration
|
||
%type <Method> methodheader
|
||
%type <Method> methoddeclaration
|
||
%type <Method> methoddeclarator
|
||
%type <ClassBody> classbodydeclarations
|
||
%type <Field> classbodydeclaration
|
||
%type <Field> classmemberdeclaration
|
||
%type <FieldDeclaration> variabledeclarators
|
||
%type <FieldDeclaration> fielddeclarator;
|
||
%type <DeclId> variabledeclarator
|
||
%type <DeclId> variabledeclaratorid
|
||
%type <UsedId> simplename
|
||
%type <UsedId> qualifiedname
|
||
%type <UsedId> importqualifiedname
|
||
%type <UsedId> importdeclaration
|
||
%type <ImportDeclarations> importdeclarations
|
||
%type <UsedId> name
|
||
%type <UsedId> super
|
||
%type <UsedId> classtype
|
||
%type <UsedId> classorinterfacetype
|
||
%type <UsedId> interfacetype
|
||
%type <InterfaceList> interfaces
|
||
%type <InterfaceList> extendsinterfaces
|
||
%type <BaseType> integraltype
|
||
%type <BaseType> numerictype
|
||
%type <BaseType> primitivetype
|
||
%type <RefType> referencetype
|
||
%type <RefType> classtypelist
|
||
%type <Type> type
|
||
%type <Modifiers> modifiers
|
||
%type <Modifier> modifier
|
||
%type <Block> block
|
||
%type <Block> methodbody
|
||
%type <Block> blockstatements
|
||
%type <Block> lambdabody
|
||
%type <LocalVarDecl> localvariabledeclarationstatement
|
||
%type <LocalVarDecl> localvariabledeclaration
|
||
%type <ExceptionList> throws
|
||
%type <FormalParameter> formalparameter
|
||
%type <ParameterList> formalparameterlist
|
||
%type <ParameterList> lambdaexpressionparameter
|
||
%type <Literal> literal
|
||
%type <Expr> primarynonewarray
|
||
%type <Expr> primary
|
||
%type <Expr> postfixexpression
|
||
%type <Expr> unaryexpressionnotplusminus
|
||
%type <Expr> unaryexpression
|
||
%type <Expr> multiplicativeexpression
|
||
%type <Expr> additiveexpression
|
||
%type <Expr> shiftexpression
|
||
%type <Expr> relationalexpression
|
||
%type <Expr> equalityexpression
|
||
%type <Expr> andexpression
|
||
%type <Expr> exclusiveorexpression
|
||
%type <Expr> inclusiveorexpression
|
||
%type <Expr> conditionalandexpression
|
||
%type <Expr> conditionalorexpression
|
||
%type <Expr> conditionalexpression
|
||
%type <Expr> assignmentexpression
|
||
%type <Expr> lambdaexpression /*added by Andreas Stadelmeier*/
|
||
%type <Expr> expression
|
||
%type <Expr> statementexpression
|
||
%type <Expr> preincrementexpression
|
||
%type <Expr> predecrementexpression
|
||
%type <Expr> postincrementexpression
|
||
%type <Expr> postdecrementexpression
|
||
%type <ExprStmt> expressionstatement
|
||
%type <ExprStmt> variableinitializer
|
||
%type <Statement> statementwithouttrailingsubstatement
|
||
%type <Statement> blockstatement
|
||
%type <Statement> statement
|
||
%type <Statement> statementnoshortif
|
||
%type <WhileStmt> whilestatement
|
||
%type <ForStmt> forstatement
|
||
%type <WhileStmt> whilestatementnoshortif
|
||
%type <IfStmt> ifthenstatement
|
||
%type <IfStmt> ifthenelsestatement
|
||
%type <IfStmt> ifthenelsestatementnoshortif
|
||
%type <EmptyStmt> emptystatement
|
||
%type <Return> returnstatement
|
||
%type <NewClass> classinstancecreationexpression
|
||
%type <SourceFile> compilationunit
|
||
%type <SourceFile> typedeclarations
|
||
%type <GenericTypeVar> boundedMethodParameter;
|
||
%type <GenericTypeVar> boundedClassParameter;
|
||
%type <Vector> boundedclassidentifierlist //Vector<Type>
|
||
%type <Vector> boundedMethodParameters; // Vector<GenericTypeVar>
|
||
%type <ParaList> boundedClassParameters; // ParaList
|
||
%type <UsedId> packagedeclaration
|
||
%type <Assign> assignment
|
||
%type <Operator> assignmentoperator
|
||
%type <Operator> lambdaassignmentoperator /*added by Andreas Stadelmeier*/
|
||
%type <UsedId> lefthandside
|
||
%type <ArgumentList> argumentlist
|
||
%type <MethodCall> methodinvocation
|
||
%type <AClassOrInterface> typedeclaration
|
||
%type <Field> constructordeclaration
|
||
%type <Constructor> constructordeclarator
|
||
%type <Block> constructorbody
|
||
%type <Statement> explicitconstructorinvocation
|
||
%type <Method> staticinitializer
|
||
%type <CastExpr> castexpression
|
||
%type <ParaList> paralist parameter
|
||
%type <WildcardType> wildcardparameter
|
||
%left ','
|
||
%%
|
||
|
||
compilationunit : typedeclarations
|
||
{
|
||
$$=$1;
|
||
}
|
||
/* |importdeclarations typedeclarations
|
||
{
|
||
$2.addImports($1);
|
||
$$=$2;
|
||
}
|
||
| packagedeclaration importdeclarations typedeclarations
|
||
{
|
||
// SCJU: Package
|
||
$3.setPackageName($1);
|
||
$3.addImports($2);
|
||
$$=$3;
|
||
}
|
||
| packagedeclaration typedeclarations
|
||
{
|
||
// SCJU: Package
|
||
$2.setPackageName($1);
|
||
$$=$2;
|
||
}
|
||
| type type compilationunit
|
||
{
|
||
this.testPair.add(new Pair($1,$2));
|
||
$$=$3;
|
||
}
|
||
*/
|
||
packagedeclaration : PACKAGE name ';' ;
|
||
{
|
||
// SCJU: Package
|
||
$$ = $2;
|
||
}
|
||
|
||
importdeclarations :importdeclaration
|
||
{
|
||
ImportDeclarations declarations=new ImportDeclarations();
|
||
declarations.addElement($1);
|
||
$$=declarations;
|
||
}
|
||
|importdeclarations importdeclaration
|
||
{
|
||
$1.addElement($2);
|
||
$$=$1;
|
||
}
|
||
|
||
importdeclaration : IMPORT importqualifiedname ';'
|
||
{
|
||
$$=$2;
|
||
}
|
||
|
||
typedeclarations :typedeclaration
|
||
{
|
||
SourceFile Scfile = new SourceFile();
|
||
Scfile.addElement($1);
|
||
$$=Scfile;
|
||
}
|
||
|typedeclarations typedeclaration
|
||
{
|
||
$1.addElement($2);
|
||
$$=$1;
|
||
}
|
||
|
||
name :qualifiedname
|
||
{
|
||
$$=$1;
|
||
}
|
||
|simplename
|
||
{
|
||
$$=$1;
|
||
}
|
||
|
||
typedeclaration :classdeclaration
|
||
{
|
||
$$=$1;
|
||
}
|
||
/* | interfacedeclaration
|
||
{
|
||
// SCJU: Interface
|
||
$$=$1;
|
||
}
|
||
*/
|
||
|
||
qualifiedname : name '.' IDENTIFIER
|
||
{
|
||
$1.set_Name($3.getLexem());
|
||
$1.setOffset($1.getOffset());
|
||
$$=$1;
|
||
}
|
||
|
||
importqualifiedname : name '.' IDENTIFIER
|
||
{
|
||
$1.set_Name($3.getLexem());
|
||
$1.setOffset($1.getOffset());
|
||
$$=$1;
|
||
}
|
||
| name '.' '*'
|
||
{
|
||
$1.set_Name("*");
|
||
$1.setOffset($1.getOffset());
|
||
$$=$1;
|
||
}
|
||
|
||
|
||
simplename : IDENTIFIER
|
||
{
|
||
UsedId UI = new UsedId($1.getOffset());
|
||
UI.set_Name( $1.getLexem() );
|
||
UI.setOffset($1.getOffset());//hinzugef<65>gt hoth: 07.04.2006
|
||
$$ = UI;
|
||
}
|
||
|
||
classdeclaration : CLASS classidentifier classbody
|
||
{
|
||
// SCJU: Um das hier uebersichtlicher zu halten,
|
||
// gibt es einen allumfassenden Konstruktor fuer Class
|
||
// Parameter:
|
||
// String name,
|
||
// Modifiers mod,
|
||
// ClassBody classbody,
|
||
// Vector<Type> containedtypes,
|
||
// UsedId superclass,
|
||
// Vector<UsedId> SuperInterfaces,
|
||
// Vector<Type> Parameterliste
|
||
|
||
$$ = new Class($2.getName(), null, $3, containedTypes, usedIdsToCheck, null, null, $2.getParaVector());
|
||
this.initContainedTypes();
|
||
this.initUsedIdsToCheck();
|
||
}
|
||
| modifiers CLASS classidentifier classbody
|
||
{
|
||
$$ = new Class($3.getName(), $1, $4, containedTypes,usedIdsToCheck, null, null, $3.getParaVector());
|
||
this.initContainedTypes();
|
||
this.initUsedIdsToCheck();
|
||
}
|
||
| CLASS classidentifier super classbody
|
||
{
|
||
$$ = new Class($2.getName(), null, $4, containedTypes,usedIdsToCheck, $3, null, $2.getParaVector());
|
||
this.initContainedTypes();
|
||
this.initUsedIdsToCheck();
|
||
}
|
||
| modifiers CLASS classidentifier super classbody
|
||
{
|
||
$$ = new Class($3.getName(), $1, $5, containedTypes, usedIdsToCheck, $4, null, $3.getParaVector());
|
||
this.initContainedTypes();
|
||
this.initUsedIdsToCheck();
|
||
}
|
||
///* auskommentiert von Andreas Stadelmeier A10023
|
||
| CLASS classidentifier interfaces classbody
|
||
{
|
||
$$ = new Class($2.getName(), null, $4, containedTypes, usedIdsToCheck, null, $3.getVector(), $2.getParaVector());
|
||
this.initContainedTypes();
|
||
this.initUsedIdsToCheck();
|
||
}
|
||
| modifiers CLASS classidentifier interfaces classbody
|
||
{
|
||
$$ = new Class($3.getName(), $1, $5, containedTypes, usedIdsToCheck, null, $4.getVector(), $3.getParaVector());
|
||
this.initContainedTypes();
|
||
this.initUsedIdsToCheck();
|
||
}
|
||
| CLASS classidentifier super interfaces classbody
|
||
{
|
||
$$ = new Class($2.getName(), null, $5, containedTypes,usedIdsToCheck, $3, $4.getVector(), $2.getParaVector());
|
||
this.initContainedTypes();
|
||
this.initUsedIdsToCheck();
|
||
}
|
||
| modifiers CLASS classidentifier super interfaces classbody
|
||
{
|
||
$$ = new Class($3.getName(), $1, $6, containedTypes, usedIdsToCheck, $4, $5.getVector(), $3.getParaVector());
|
||
this.initContainedTypes();
|
||
this.initUsedIdsToCheck();
|
||
}
|
||
//*/
|
||
interfaceidentifier : IDENTIFIER
|
||
{
|
||
// HOTI
|
||
// Verbindet den Namen eines Interfaces mit einer optionalen Parameterliste
|
||
$$ = new InterfaceAndParameter($1.getLexem());
|
||
}
|
||
| IDENTIFIER '<' boundedClassParameters '>'
|
||
{
|
||
$$ = new InterfaceAndParameter($1.getLexem(), $3);
|
||
}
|
||
|
||
classidentifier : IDENTIFIER
|
||
{
|
||
// SCJU: Hilfskonstrukt, um die Grammatik ueberschaubar zu halten
|
||
// Verbindet den Namen einer Klasse mit einer optionalen Parameterliste
|
||
$$ = new ClassAndParameter($1.getLexem());
|
||
}
|
||
| IDENTIFIER '<' boundedClassParameters '>'
|
||
{
|
||
$$ = new ClassAndParameter($1.getLexem(), $3);
|
||
}
|
||
|
||
interfacedeclaration: INTERFACE interfaceidentifier interfacebody
|
||
{
|
||
// SCJU: Interface
|
||
Interface ic = new Interface($2.getName());
|
||
ic.setParaList($2.getParaVector());
|
||
ic.setInterfaceBody($3);
|
||
ic.setContainedTypes(containedTypes);
|
||
initContainedTypes();
|
||
$$ = ic;
|
||
}
|
||
| modifiers INTERFACE interfaceidentifier interfacebody
|
||
{
|
||
Interface ic = new Interface($3.getName(), $1);
|
||
ic.setInterfaceBody($4);
|
||
ic.setParaList($3.getParaVector());
|
||
ic.setContainedTypes(containedTypes);
|
||
initContainedTypes();
|
||
$$ = ic;
|
||
}
|
||
| INTERFACE interfaceidentifier extendsinterfaces interfacebody
|
||
{
|
||
Interface ic = new Interface($2.getName());
|
||
ic.setParaList($2.getParaVector());
|
||
ic.setSuperInterfaces($3.getVector());
|
||
ic.setInterfaceBody($4);
|
||
ic.setContainedTypes(containedTypes);
|
||
initContainedTypes();
|
||
$$ = ic;
|
||
}
|
||
| modifiers INTERFACE interfaceidentifier extendsinterfaces interfacebody ;
|
||
{
|
||
Interface ic = new Interface($3.getName(), $1);
|
||
ic.setParaList($3.getParaVector());
|
||
ic.setSuperInterfaces($4.getVector());
|
||
ic.setInterfaceBody($5);
|
||
ic.setContainedTypes(containedTypes);
|
||
initContainedTypes();
|
||
$$ = ic;
|
||
}
|
||
|
||
paralist : IDENTIFIER
|
||
{
|
||
ParaList pl = new ParaList();
|
||
/* #JB# 05.04.2005 */
|
||
/* ########################################################### */
|
||
pl.getParalist().addElement(new GenericTypeVar($1.getLexem(), $1.getOffset()));
|
||
//pl.getParalist().addElement( new TypePlaceholder($1.getLexem()) );
|
||
/* ########################################################### */
|
||
org.apache.log4j.Logger.getLogger("parser").debug( "IDENTIFIER --> Paralist f<>r " + $1.getLexem() + " TV");
|
||
$$ = pl;
|
||
}
|
||
| IDENTIFIER '<' paralist '>'
|
||
{
|
||
ParaList pl = new ParaList();
|
||
RefType t = new RefType( $1.getLexem(),$1.getOffset() );
|
||
t.set_ParaList( $3.get_ParaList() );
|
||
pl.getParalist().addElement(t);
|
||
org.apache.log4j.Logger.getLogger("parser").debug( "IDENTIFIER '<' paralist '>' --> Paralist f<>r " + $1.getLexem() + ": RefType");
|
||
$$ = pl;
|
||
}
|
||
| wildcardparameter
|
||
{
|
||
ParaList pl = new ParaList();
|
||
pl.getParalist().addElement($1);
|
||
$$ = pl;
|
||
}
|
||
| paralist ',' IDENTIFIER
|
||
{
|
||
|
||
/* #JB# 05.04.2005 */
|
||
/* ########################################################### */
|
||
$1.getParalist().addElement(new GenericTypeVar($3.getLexem(),$3.getOffset()));
|
||
//$1.getParalist().addElement(new TypePlaceholder($3.getLexem()));
|
||
/* ########################################################### */
|
||
org.apache.log4j.Logger.getLogger("parser").debug( "paralist ',' IDENTIFIER --> Paralist f<>r " + $3.getLexem() + ": TV");
|
||
org.apache.log4j.Logger.getLogger("parser").debug( "paralist: " + $1.getParalist());
|
||
$$=$1;
|
||
}
|
||
|
||
| paralist ',' IDENTIFIER '<' paralist '>'
|
||
{
|
||
RefType t = new RefType( $3.getLexem() ,$3.getOffset() );
|
||
t.set_ParaList( $5.get_ParaList() );
|
||
$1.getParalist().addElement(t);
|
||
org.apache.log4j.Logger.getLogger("parser").debug( "paralist ',' IDENTIFIER '<' paralist '>' --> Paralist f<>r " + $3.getLexem() + ": RefType");
|
||
$$=$1;
|
||
}
|
||
| paralist ',' wildcardparameter
|
||
{
|
||
$1.getParalist().addElement($3);
|
||
$$=$1;
|
||
}
|
||
|
||
wildcardparameter : '?'
|
||
{
|
||
//Luar 29.11.06 Offset auf -1, da keine Angabe vorhanden
|
||
WildcardType wc = new WildcardType(-1);
|
||
$$ = wc;
|
||
}
|
||
| '?' EXTENDS referencetype
|
||
{
|
||
ExtendsWildcardType ewc = new ExtendsWildcardType($2.getOffset(),$3);
|
||
$$ = ewc;
|
||
}
|
||
| '?' SUPER referencetype
|
||
{
|
||
SuperWildcardType swc = new SuperWildcardType($2.getOffset(),$3);
|
||
$$ = swc;
|
||
}
|
||
|
||
classbody : '{' '}'
|
||
{
|
||
ClassBody CB = new ClassBody();
|
||
$$ = CB;
|
||
}
|
||
|
||
| '{' classbodydeclarations '}'
|
||
{
|
||
$$ = $2;
|
||
}
|
||
|
||
modifiers :modifier
|
||
{
|
||
Modifiers Mod = new Modifiers();
|
||
Mod.addModifier($1);
|
||
$$ = Mod;
|
||
}
|
||
|modifiers modifier
|
||
{
|
||
$1.addModifier($2);
|
||
$$ = $1;
|
||
}
|
||
|
||
super :EXTENDS classtype
|
||
{
|
||
$$ = $2;
|
||
}
|
||
|
||
interfaces : IMPLEMENTS interfacetype
|
||
{
|
||
// SCJU: Interface
|
||
InterfaceList il = new InterfaceList();
|
||
il.addInterface($2);
|
||
$$ = il;
|
||
}
|
||
| interfaces ',' interfacetype ;
|
||
{
|
||
$1.addInterface($3);
|
||
$$ = $1;
|
||
}
|
||
|
||
interfacebody : '{' '}'
|
||
{
|
||
// SCJU: Interface
|
||
$$ = new InterfaceBody();
|
||
}
|
||
| '{' interfacememberdeclarations '}'
|
||
{
|
||
$$ = $2;
|
||
}
|
||
|
||
|
||
|
||
extendsinterfaces : EXTENDS interfacetype
|
||
{
|
||
// SCJU: Interface
|
||
InterfaceList il = new InterfaceList();
|
||
il.addInterface($2);
|
||
$$ = il;
|
||
}
|
||
| extendsinterfaces ',' interfacetype ;
|
||
{
|
||
$1.addInterface($3);
|
||
$$ = $1;
|
||
}
|
||
|
||
|
||
classbodydeclarations : classbodydeclaration
|
||
{
|
||
ClassBody CB = new ClassBody();
|
||
CB.addField( $1 );
|
||
$$=CB;
|
||
}
|
||
| classbodydeclarations classbodydeclaration
|
||
{
|
||
$1.addField($2);
|
||
$$ = $1;
|
||
}
|
||
|
||
|
||
modifier : PUBLIC
|
||
{
|
||
Public Pub = new Public();
|
||
$$=Pub;
|
||
}
|
||
| PROTECTED
|
||
{
|
||
Protected Pro = new Protected();
|
||
$$=Pro;
|
||
}
|
||
| PRIVATE
|
||
{
|
||
Private Pri = new Private();
|
||
$$=Pri;
|
||
}
|
||
| STATIC
|
||
{
|
||
Static Sta = new Static();
|
||
$$=Sta;
|
||
}
|
||
| ABSTRACT
|
||
{
|
||
Abstract Abs = new Abstract();
|
||
$$=Abs;
|
||
}
|
||
| FINAL
|
||
{ Final fin = new Final();
|
||
$$ = fin;
|
||
}
|
||
|
||
|
||
classtype : classorinterfacetype
|
||
{
|
||
//PL 05-07-30 eingefuegt containedTypes ANFANG
|
||
RefType RT = new RefType(-1);
|
||
//RT.set_UsedId($1);
|
||
//RT.setName(RT.get_UsedId().get_Name_1Element());
|
||
RT.set_ParaList($1.get_RealParaList());
|
||
RT.setName($1.get_Name_1Element());
|
||
containedTypes.addElement(RT);
|
||
//PL 05-07-30 eingefuegt containedTypes ENDE
|
||
|
||
$$ = $1;
|
||
}
|
||
|
||
|
||
interfacememberdeclarations : interfacememberdeclaration
|
||
{
|
||
// SCJU: Interface
|
||
InterfaceBody ib = new InterfaceBody();
|
||
ib.addElement($1);
|
||
$$ = ib;
|
||
}
|
||
| interfacememberdeclarations interfacememberdeclaration ;
|
||
{
|
||
$1.addElement($2);
|
||
$$ = $1;
|
||
}
|
||
|
||
interfacetype : classorinterfacetype ;
|
||
{
|
||
// SCJU: Interfaces
|
||
$$ = $1;
|
||
}
|
||
|
||
classbodydeclaration : classmemberdeclaration
|
||
{
|
||
$$=$1;
|
||
}
|
||
///* auskommentiert von Andreas Stadelmeier a10023
|
||
| staticinitializer
|
||
{
|
||
$$=$1;
|
||
}
|
||
| constructordeclaration
|
||
{
|
||
$$=$1;
|
||
}
|
||
//*/
|
||
classorinterfacetype : simplename parameter
|
||
{
|
||
if ($2 != null) {
|
||
$1.set_ParaList($2.get_ParaList());
|
||
|
||
/* otth: originale (also diese) Parameterliste retten */
|
||
((UsedId)$1).vParaOrg = new Vector<Type>( $2.get_ParaList() );
|
||
}
|
||
$$=$1;
|
||
}
|
||
|
||
/* PL 05-07-28 erg<72>nzt, weil jeder classorinterfacetype auch parametrisiert sein kann */
|
||
parameter : { $$ = null; }
|
||
| '<'paralist'>'
|
||
{
|
||
$$ = $2;
|
||
}
|
||
|
||
interfacememberdeclaration : constantdeclaration
|
||
{
|
||
// SCJU: Interfaces, Spezialform Konstantendef.
|
||
$$ = $1;
|
||
}
|
||
| abstractmethoddeclaration
|
||
{
|
||
$$ = $1;
|
||
}
|
||
|
||
classmemberdeclaration : fielddeclaration
|
||
{
|
||
$$=$1;
|
||
}
|
||
| methoddeclaration
|
||
{
|
||
$$=$1;
|
||
}
|
||
|
||
staticinitializer : STATIC block
|
||
{
|
||
Method STAT = new Method($1.getOffset());
|
||
DeclId DST = new DeclId();
|
||
DST.set_Name($1.getLexem());
|
||
STAT.set_DeclId(DST);
|
||
Static ST = new Static();
|
||
Modifiers MOD = new Modifiers();
|
||
MOD.addModifier(ST);
|
||
STAT.set_Modifiers(MOD);
|
||
STAT.set_Block($2);
|
||
$$=STAT;
|
||
}
|
||
|
||
constructordeclaration : constructordeclarator constructorbody
|
||
{
|
||
$1.set_Block($2);
|
||
$$ = $1;
|
||
}
|
||
| modifiers constructordeclarator constructorbody
|
||
{
|
||
$2.set_Block($3);
|
||
$2.set_Modifiers($1);
|
||
$$ = $2;
|
||
}
|
||
|
||
constantdeclaration : modifiers type IDENTIFIER '=' expression';' ;
|
||
{
|
||
// SCJU: Interface
|
||
Constant c = new Constant($3.getLexem(), $1);
|
||
c.setType($2);
|
||
c.setValue($5);
|
||
$$ = c;
|
||
}
|
||
|
||
abstractmethoddeclaration : methodheader ';' ;
|
||
{
|
||
// SCJU: Interface
|
||
$$ = $1;
|
||
}
|
||
|
||
/*
|
||
added by Andreas Stadelmeier, a10023
|
||
Bei Lokalen Variablen ist eine initialisierung der Variablen w<>hrend der Deklarisierung nicht erlaubt.
|
||
Beispiel: var = 2;
|
||
Bei einer lokalen Variable l<>sst sich hier nicht ermitteln ob die Variable deklariert werden soll oder bereits deklariert wurde und ihr nur ein Wert zugewiesen werden soll.
|
||
Dieses Problem ist bei Feldern nicht der Fall.
|
||
*/
|
||
fielddeclarator : variabledeclarator '=' expression
|
||
{
|
||
FieldDeclaration ret = new FieldDeclaration($1.getOffset());
|
||
ret.set_DeclId($1);
|
||
ret.setWert($3);
|
||
$$=ret;
|
||
}
|
||
|
||
fielddeclaration : fielddeclarator ';'
|
||
{
|
||
$$=$1;
|
||
}
|
||
| type fielddeclarator
|
||
{
|
||
$2.setType($1);
|
||
$$=$2;
|
||
}
|
||
|
|
||
variabledeclarators ';'
|
||
{
|
||
$$=$1;
|
||
}
|
||
|
|
||
type variabledeclarators ';'
|
||
{
|
||
org.apache.log4j.Logger.getLogger("parser").debug("T->Parser->fielddeclaration ...: type " + $1);
|
||
$2.setType($1);
|
||
$$ = $2;
|
||
}
|
||
|
||
| modifiers type variabledeclarators ';'
|
||
{
|
||
$3.setType($2);
|
||
for(int i=0;i<($3.getDeclIdVector().size());i++)
|
||
{
|
||
$3.getDeclIdVector().elementAt(i).modifiers=$1;
|
||
}
|
||
$$ = $3;
|
||
}
|
||
|
||
methoddeclaration : methodheader methodbody
|
||
{
|
||
$1.set_Block($2);
|
||
$$=$1;
|
||
}
|
||
|
||
block : '{' '}'
|
||
|
||
{
|
||
Block Bl = new Block();
|
||
$$=Bl;
|
||
}
|
||
|
||
| '{' blockstatements '}'
|
||
{
|
||
$$=$2;
|
||
}
|
||
|
||
constructordeclarator : simplename '(' ')'
|
||
{
|
||
Constructor CON = new Constructor(null); //TODO: Der Parser kann sowieso nicht zwischen einem Konstruktor und einer Methode unterscheiden. Das hier kann wegfallen...
|
||
DeclId DIDCon = new DeclId();
|
||
DIDCon.set_Name($1.get_Name_1Element());
|
||
CON.set_DeclId(DIDCon);
|
||
$$=CON;
|
||
}
|
||
| simplename '('formalparameterlist')'
|
||
{
|
||
Constructor CONpara = new Constructor(null);
|
||
DeclId DIconpara = new DeclId();
|
||
DIconpara.set_Name($1.get_Name_1Element());
|
||
CONpara.set_DeclId(DIconpara);
|
||
CONpara.setParameterList($3);
|
||
$$=CONpara;
|
||
}
|
||
|
||
constructorbody : '{' '}'
|
||
{
|
||
Block CBL = new Block();
|
||
$$=CBL;
|
||
}
|
||
| '{' explicitconstructorinvocation '}'
|
||
{
|
||
Block CBLexpl = new Block();
|
||
CBLexpl.set_Statement($2);
|
||
$$=CBLexpl;
|
||
}
|
||
| '{' blockstatements '}'
|
||
{
|
||
$$=$2;
|
||
}
|
||
| '{'explicitconstructorinvocation blockstatements '}'
|
||
{
|
||
Block CBes = new Block();
|
||
CBes.set_Statement($2);
|
||
for(int j=0;j<$3.statements.size();j++)
|
||
{
|
||
CBes.set_Statement((Statement)$3.statements.elementAt(j));
|
||
}
|
||
$$=CBes;
|
||
}
|
||
|
||
throws : THROWS classtypelist
|
||
{
|
||
ExceptionList EL = new ExceptionList();
|
||
EL.set_addElem($2);
|
||
$$=EL;
|
||
}
|
||
|
||
boundedClassParameter : boundedMethodParameter
|
||
{
|
||
$$ = $1;
|
||
}
|
||
|
||
boundedClassParameters : boundedClassParameter
|
||
{
|
||
ParaList p = new ParaList();
|
||
p.add_ParaList($1);
|
||
$$=p;
|
||
}
|
||
| boundedClassParameters ',' boundedClassParameter
|
||
{
|
||
$1.add_ParaList($3);
|
||
$$=$1;
|
||
}
|
||
|
||
// returns GenericTypeVar
|
||
boundedMethodParameter : IDENTIFIER
|
||
{
|
||
$$=new GenericTypeVar($1.getLexem(),$1.getOffset());
|
||
}
|
||
| IDENTIFIER EXTENDS boundedclassidentifierlist
|
||
{
|
||
BoundedGenericTypeVar gtv=new BoundedGenericTypeVar($1.getLexem(),$1.getOffset());
|
||
gtv.setBounds($3);
|
||
$$=gtv;
|
||
}
|
||
// returns Vector<Type>
|
||
boundedclassidentifierlist : referencetype
|
||
{
|
||
Vector<Type> vec=new Vector<Type>();
|
||
vec.addElement($1);
|
||
containedTypes.addElement($1);
|
||
$$=vec;
|
||
}
|
||
| boundedclassidentifierlist '&' referencetype
|
||
{
|
||
$1.addElement($3);
|
||
containedTypes.addElement($3);
|
||
$$=$1;
|
||
}
|
||
// returns Vector<Type>
|
||
boundedMethodParameters : boundedMethodParameter
|
||
{
|
||
Vector<Type> vec=new Vector<Type>();
|
||
vec.addElement($1);
|
||
$$=vec;
|
||
}
|
||
| boundedMethodParameters ',' boundedMethodParameter
|
||
{
|
||
$1.addElement($3);
|
||
$$=$1;
|
||
}
|
||
|
||
|
||
// returns Method
|
||
methodheader :'<' boundedMethodParameters '>' type methoddeclarator
|
||
{
|
||
$5.setType($4);
|
||
$5.setGenericMethodParameters($2);
|
||
$$=$5;
|
||
}
|
||
| type methoddeclarator
|
||
{
|
||
$2.setType($1);
|
||
$$=$2;
|
||
}
|
||
| modifiers type methoddeclarator
|
||
{
|
||
$3.set_Modifiers($1);
|
||
$3.setType($2);
|
||
$$=$3;
|
||
}
|
||
| modifiers '<' boundedMethodParameters '>' type methoddeclarator
|
||
{
|
||
$6.set_Modifiers($1);
|
||
$6.setGenericMethodParameters($3);
|
||
$6.setType($5);
|
||
$$=$6;
|
||
}
|
||
| type methoddeclarator throws
|
||
{
|
||
$2.setType($1);
|
||
$2.set_ExceptionList($3);
|
||
$$=$2;
|
||
}
|
||
| '<' boundedMethodParameters '>' type methoddeclarator throws
|
||
{
|
||
$5.setGenericMethodParameters($2);
|
||
$5.setType($4);
|
||
$5.set_ExceptionList($6);
|
||
$$=$5;
|
||
}
|
||
| modifiers type methoddeclarator throws
|
||
{
|
||
$3.set_Modifiers($1);
|
||
$3.setType($2);
|
||
$3.set_ExceptionList($4);
|
||
$$=$3;
|
||
}
|
||
| modifiers '<' boundedMethodParameters '>' type methoddeclarator throws
|
||
{
|
||
$6.set_Modifiers($1);
|
||
$6.setGenericMethodParameters($3);
|
||
$6.setType($5);
|
||
$6.set_ExceptionList($7);
|
||
$$=$6;
|
||
}
|
||
| VOID methoddeclarator
|
||
{
|
||
Void Voit = new Void($1.getOffset());
|
||
$2.setType(Voit);
|
||
$$=$2;
|
||
}
|
||
| modifiers VOID methoddeclarator
|
||
{
|
||
Void voit = new Void($2.getOffset());
|
||
$3.set_Modifiers($1);
|
||
$3.setType(voit);
|
||
$$=$3;
|
||
}
|
||
| VOID methoddeclarator throws
|
||
{
|
||
Void voyt = new Void($1.getOffset());
|
||
$2.setType(voyt);
|
||
$2.set_ExceptionList($3);
|
||
$$=$2;
|
||
}
|
||
| modifiers VOID methoddeclarator throws
|
||
{
|
||
Void voyd = new Void($2.getOffset());
|
||
$3.set_Modifiers($1);
|
||
$3.setType(voyd);
|
||
$3.set_ExceptionList($4);
|
||
$$=$3;
|
||
}
|
||
| '<' boundedMethodParameters '>' VOID methoddeclarator
|
||
{
|
||
Void Voit = new Void($4.getOffset());
|
||
$5.setType(Voit);
|
||
$5.setGenericMethodParameters($2);
|
||
$$=$5;
|
||
}
|
||
| modifiers '<' boundedMethodParameters '>' VOID methoddeclarator
|
||
{
|
||
Void voit = new Void($5.getOffset());
|
||
$6.set_Modifiers($1);
|
||
$6.setType(voit);
|
||
$6.setGenericMethodParameters($3);
|
||
$$=$6;
|
||
}
|
||
| '<' boundedMethodParameters '>' VOID methoddeclarator throws
|
||
{
|
||
Void voyt = new Void($4.getOffset());
|
||
$5.setType(voyt);
|
||
$5.set_ExceptionList($6);
|
||
$5.setGenericMethodParameters($2);
|
||
$$=$5;
|
||
}
|
||
| modifiers '<' boundedMethodParameters '>' VOID methoddeclarator throws
|
||
{
|
||
Void voyd = new Void($5.getOffset());
|
||
$6.set_Modifiers($1);
|
||
$6.setType(voyd);
|
||
$6.set_ExceptionList($7);
|
||
$6.setGenericMethodParameters($3);
|
||
$$=$6;
|
||
}
|
||
|
||
| methoddeclarator
|
||
{
|
||
//auskommentiert von Andreas Stadelmeier (a10023) $1.setType(TypePlaceholder.fresh());
|
||
$$=$1;
|
||
}
|
||
| '<' boundedMethodParameters '>' methoddeclarator
|
||
{
|
||
//auskommentiert von Andreas Stadelmeier (a10023) $4.setType(TypePlaceholder.fresh());
|
||
$4.setGenericMethodParameters($2);
|
||
$$=$4;
|
||
}
|
||
|
||
| modifiers methoddeclarator
|
||
{
|
||
$2.set_Modifiers($1);
|
||
//auskommentiert von Andreas Stadelmeier (a10023) $2.setType(TypePlaceholder.fresh());
|
||
$$=$2;
|
||
}
|
||
| methoddeclarator throws
|
||
{
|
||
//auskommentiert von Andreas Stadelmeier (a10023) $1.setType(TypePlaceholder.fresh());
|
||
$1.set_ExceptionList($2);
|
||
$$=$1;
|
||
}
|
||
| modifiers methoddeclarator throws
|
||
{
|
||
$2.set_Modifiers($1);
|
||
//auskommentiert von Andreas Stadelmeier (a10023) $2.setType(TypePlaceholder.fresh());
|
||
$2.set_ExceptionList($3);
|
||
$$=$2;
|
||
}
|
||
|
||
|
||
type : primitivetype
|
||
{
|
||
$$=$1;
|
||
}
|
||
|primitivetype '[' ']'
|
||
{
|
||
$1.setArray(true);
|
||
}
|
||
|referencetype
|
||
{
|
||
$$=$1;
|
||
}
|
||
|referencetype '[' ']'
|
||
{
|
||
$1.setArray(true);
|
||
}
|
||
variabledeclarators : variabledeclarator
|
||
{
|
||
FieldDeclaration IVD = new FieldDeclaration($1.getOffset());
|
||
IVD.getDeclIdVector().addElement( $1 );
|
||
IVD.setOffset($1.getOffset());
|
||
$$ = IVD;
|
||
}
|
||
| variabledeclarators ',' variabledeclarator
|
||
{
|
||
$1.getDeclIdVector().addElement($3);
|
||
$$=$1;
|
||
}
|
||
|
||
methodbody : block
|
||
{
|
||
$$=$1;
|
||
}
|
||
|
||
blockstatements : blockstatement
|
||
{
|
||
Block Blstat = new Block();
|
||
Blstat.set_Statement($1);
|
||
$$=Blstat;
|
||
}
|
||
|
||
| blockstatements blockstatement
|
||
{
|
||
$1.set_Statement($2);
|
||
$$=$1;
|
||
}
|
||
|
||
formalparameterlist :formalparameter
|
||
{
|
||
ParameterList PL = new ParameterList();
|
||
PL.set_AddParameter($1);
|
||
$$ = PL;
|
||
}
|
||
|formalparameterlist ',' formalparameter
|
||
{
|
||
$1.set_AddParameter($3);
|
||
$$ = $1;
|
||
}
|
||
|
||
explicitconstructorinvocation : THIS '(' ')' ';'
|
||
{
|
||
This THCON = new This($1.getOffset(),$1.getLexem().length());
|
||
$$=THCON;
|
||
}
|
||
|THIS '(' argumentlist ')' ';'
|
||
{
|
||
This THCONargl = new This($1.getOffset(),$1.getLexem().length());
|
||
THCONargl.set_ArgumentList($3);
|
||
$$=THCONargl;
|
||
}
|
||
// |SUPER '(' ')' ';'
|
||
// |SUPER '(' argumentlist ')' ';'
|
||
|
||
classtypelist : classtype
|
||
{
|
||
RefType RT = new RefType(-1);
|
||
RT.set_UsedId($1);
|
||
RT.setName(RT.get_UsedId().get_Name_1Element());
|
||
$$=RT;
|
||
}
|
||
| classtypelist ',' classtype
|
||
{
|
||
$1.set_UsedId($3);
|
||
$1.setName($1.get_UsedId().get_Name_1Element());
|
||
$$=$1;
|
||
}
|
||
|
||
methoddeclarator :IDENTIFIER '(' ')'
|
||
{
|
||
Method met = new Method($1.getOffset());
|
||
/* #JB# 10.04.2005 */
|
||
/* ########################################################### */
|
||
met.setLineNumber($1.getLineNumber());
|
||
met.setOffset($1.getOffset());//hinzugef<65>gt hoth: 07.04.2006
|
||
/* ########################################################### */
|
||
DeclId DImethod = new DeclId();
|
||
DImethod.set_Name($1.getLexem());
|
||
met.set_DeclId(DImethod);
|
||
$$ = met;
|
||
}
|
||
|IDENTIFIER '(' formalparameterlist ')'
|
||
{
|
||
Method met_para = new Method($1.getOffset());
|
||
/* #JB# 10.04.2005 */
|
||
/* ########################################################### */
|
||
met_para.setLineNumber($1.getLineNumber());
|
||
met_para.setOffset($1.getOffset());//hinzugef<65>gt hoth: 07.04.2006
|
||
/* ########################################################### */
|
||
DeclId Dimet_para = new DeclId();
|
||
Dimet_para.set_Name($1.getLexem());
|
||
met_para.set_DeclId(Dimet_para);
|
||
met_para.setParameterList($3);
|
||
$$ = met_para;
|
||
}
|
||
|
||
primitivetype :BOOLEAN
|
||
{
|
||
BooleanType BT = new BooleanType();
|
||
/* #JB# 05.04.2005 */
|
||
/* ########################################################### */
|
||
//BT.setName($1.getLexem());
|
||
/* ########################################################### */
|
||
$$=BT;
|
||
}
|
||
|numerictype
|
||
{
|
||
$$=$1;
|
||
}
|
||
|
||
|
||
referencetype :classorinterfacetype
|
||
{
|
||
org.apache.log4j.Logger.getLogger("parser").debug("T->Parser->referenctype: " + $1);
|
||
RefType RT = new RefType($1.getOffset());
|
||
|
||
//ausgetauscht PL 05-07-30
|
||
//RT.set_UsedId($1);
|
||
//RT.setName(RT.get_UsedId().get_Name_1Element());
|
||
RT.set_ParaList($1.get_RealParaList());
|
||
RT.setName($1.getQualifiedName());
|
||
|
||
|
||
//PL 05-07-30 eingefuegt containedTypes ANFANG
|
||
containedTypes.addElement(RT);
|
||
//PL 05-07-30 eingefuegt containedTypes ENDE
|
||
|
||
$$=RT;
|
||
}
|
||
/* 05-07-28 PL Parameterdeklarationen zur classorinterfacetype verschoben */
|
||
|
||
variabledeclarator : variabledeclaratorid
|
||
{
|
||
$$=$1;
|
||
}
|
||
/* auskommentiert von Andreas Stadelmeier, a10023:
|
||
eine Variable mit Initialisierung wird sowieso nicht geparst.
|
||
| variabledeclaratorid '=' variableinitializer
|
||
{
|
||
$1.set_Wert($3);
|
||
$$=$1;
|
||
}
|
||
*/
|
||
/* 05-07-28 PL auskommentiert
|
||
wird nicht ben<65>tigt aufgrund neuer classorinterfacetype declaration
|
||
| '<' paralist'>' variabledeclaratorid '=' variableinitializer
|
||
{
|
||
$4.set_Wert($6);
|
||
$4.set_Paratyp($2.get_ParaList());
|
||
$$=$4;
|
||
}
|
||
*/
|
||
blockstatement :localvariabledeclarationstatement
|
||
{
|
||
$$=$1;
|
||
}
|
||
|statement
|
||
{
|
||
$$=$1;
|
||
}
|
||
|
||
formalparameter : type variabledeclaratorid
|
||
{
|
||
FormalParameter FP = new FormalParameter();
|
||
FP.setType($1);
|
||
FP.set_DeclId($2);
|
||
$$=FP;
|
||
}
|
||
|
||
/* otth: Methodenargumente koennen hiermit auch polymorph sein. */
|
||
/* 05-07-28 PL auskommentiert
|
||
wird nicht ben<65>tigt aufgrund neuer classorinterfacetype declaration
|
||
| type '<'paralist'>' variabledeclaratorid
|
||
{
|
||
Parameterliste setzen
|
||
$5.set_Paratyp($3.get_ParaList());
|
||
|
||
FormalParameter FP = new FormalParameter();
|
||
FP.setType($1);
|
||
FP.set_DeclId($5);
|
||
$$=FP;
|
||
|
||
org.apache.log4j.Logger.getLogger("parser").debug("P->Polymorphes Methodenargument hinzugefuegt: Name = " + $5.get_Name() + " Typ = " + $1.getName());
|
||
}
|
||
*/
|
||
|
||
| variabledeclaratorid
|
||
{
|
||
org.apache.log4j.Logger.getLogger("parser").debug("\nFunktionsdeklaration mit typlosen Parametern: " + $1.name);
|
||
|
||
FormalParameter FP = new FormalParameter();
|
||
|
||
// #JB# 31.03.2005
|
||
// ###########################################################
|
||
//Type T = TypePlaceholder.fresh(); //auskommentiert von Andreas Stadelmeier
|
||
// Type T = new TypePlaceholder(""); /* otth: Name wird automatisch berechnet */
|
||
// ###########################################################
|
||
//org.apache.log4j.Logger.getLogger("parser").debug("\n--> berechneter Name: " + T.getName());
|
||
|
||
//auskommentiert von Andreas Stadelmeier (a10023) FP.setType( T );
|
||
FP.set_DeclId($1);
|
||
|
||
$$=FP;
|
||
}
|
||
|
||
argumentlist : expression
|
||
{
|
||
ArgumentList AL = new ArgumentList();
|
||
AL.expr.addElement($1);
|
||
$$=AL;
|
||
}
|
||
|argumentlist ',' expression
|
||
{
|
||
$1.expr.addElement($3);
|
||
$$=$1;
|
||
}
|
||
|
||
numerictype :integraltype
|
||
{
|
||
$$=$1;
|
||
}
|
||
|
||
variabledeclaratorid : IDENTIFIER
|
||
{
|
||
DeclId DI = new DeclId();
|
||
/* #JB# 10.04.2005 */
|
||
/* ########################################################### */
|
||
DI.setLineNumber($1.getLineNumber());
|
||
DI.setOffset($1.getOffset());//hinzugef<65>gt hoth: 07.04.2006
|
||
/* ########################################################### */
|
||
DI.set_Name($1.getLexem());
|
||
$$=DI;
|
||
}
|
||
|
||
variableinitializer :expression
|
||
{
|
||
$$=$1;
|
||
}
|
||
|
||
localvariabledeclarationstatement :localvariabledeclaration ';'
|
||
{
|
||
$$=$1;
|
||
}
|
||
|
||
statement :statementwithouttrailingsubstatement
|
||
{
|
||
$$=$1;
|
||
}
|
||
|ifthenstatement
|
||
{
|
||
$$=$1;
|
||
}
|
||
|ifthenelsestatement
|
||
{
|
||
$$=$1;
|
||
}
|
||
|whilestatement
|
||
{
|
||
$$=$1;
|
||
}
|
||
|forstatement
|
||
{
|
||
$$=$1;
|
||
}
|
||
|
||
expression :assignmentexpression
|
||
{
|
||
$$=$1;
|
||
}
|
||
|classinstancecreationexpression
|
||
{
|
||
$$=$1;
|
||
}
|
||
|
||
integraltype :INT
|
||
{
|
||
IntegerType IT = new IntegerType();
|
||
/* #JB# 05.04.2005 */
|
||
/* ########################################################### */
|
||
//IT.setName($1.getLexem());
|
||
/* ########################################################### */
|
||
$$=IT;
|
||
}
|
||
| CHAR
|
||
{
|
||
CharacterType CT = new CharacterType();
|
||
/* #JB# 05.04.2005 */
|
||
/* ########################################################### */
|
||
//CT.setName($1.getLexem());
|
||
/* ########################################################### */
|
||
$$=CT;
|
||
}
|
||
|
||
localvariabledeclaration : type variabledeclarators
|
||
{
|
||
org.apache.log4j.Logger.getLogger("parser").debug("P -> Lokale Variable angelegt!");
|
||
LocalVarDecl LVD = new LocalVarDecl($1.getOffset(),$1.getVariableLength());
|
||
LVD.setType($1);
|
||
LVD.setDeclidVector($2.getDeclIdVector());
|
||
$$ = LVD;
|
||
}
|
||
|
||
/* #JB# 31.03.2005 */
|
||
/* ########################################################### */
|
||
|variabledeclarators
|
||
{
|
||
org.apache.log4j.Logger.getLogger("parser").debug("P -> Lokale Variable angelegt!");
|
||
LocalVarDecl LVD = new LocalVarDecl($1.getOffset(),$1.getVariableLength());
|
||
//auskommentiert von Andreas Stadelmeier (a10023) LVD.setType(TypePlaceholder.fresh());
|
||
LVD.setDeclidVector($1.getDeclIdVector());
|
||
$$ = LVD;
|
||
}
|
||
/* ########################################################### */
|
||
|
||
statementwithouttrailingsubstatement : block
|
||
{
|
||
$$=$1;
|
||
}
|
||
| emptystatement
|
||
{
|
||
$$=$1;
|
||
}
|
||
| expressionstatement
|
||
{
|
||
$$=$1;
|
||
}
|
||
| returnstatement
|
||
{
|
||
$$=$1;
|
||
}
|
||
|
||
ifthenstatement : IF '(' expression ')' statement
|
||
{
|
||
IfStmt Ifst = new IfStmt($3.getOffset(),$3.getVariableLength());
|
||
Ifst.set_Expr($3);
|
||
Ifst.set_Then_block($5);
|
||
$$=Ifst;
|
||
}
|
||
|
||
ifthenelsestatement : IF '('expression ')'statementnoshortif ELSE statement
|
||
{
|
||
IfStmt IfstElst = new IfStmt($3.getOffset(),$3.getVariableLength());
|
||
IfstElst.set_Expr($3);
|
||
IfstElst.set_Then_block($5);
|
||
IfstElst.set_Else_block($7);
|
||
$$=IfstElst;
|
||
}
|
||
|
||
whilestatement : WHILE '(' expression ')' statement
|
||
{
|
||
WhileStmt Whlst = new WhileStmt($3.getOffset(),$3.getVariableLength());
|
||
Whlst.set_Expr($3);
|
||
Whlst.set_Loop_block($5);
|
||
$$=Whlst;
|
||
}
|
||
|
||
//forschleife
|
||
forstatement
|
||
//Bsp: for(i=0 ; i<10 ; i++){System.out.println(i)}
|
||
: FOR '(' expression ';' expression ';' expression ')' statement
|
||
{
|
||
ForStmt Fst = new ForStmt($3.getOffset(),$3.getVariableLength());
|
||
Fst.set_head_Initializer($3);
|
||
Fst.set_head_Condition($5);
|
||
Fst.set_head_Loop_expr($7);
|
||
Fst.set_body_Loop_block($9);
|
||
|
||
//Typannahme
|
||
$$ = Fst;
|
||
}
|
||
//Bsp: for(i=0 ; i<10 ; ){System.out.println(i)}
|
||
| FOR '(' expression ';' expression ';' ')' statement
|
||
{
|
||
ForStmt Fst = new ForStmt($3.getOffset(),$3.getVariableLength());
|
||
Fst.set_head_Initializer($3);
|
||
Fst.set_head_Condition($5);
|
||
Fst.set_body_Loop_block($8);
|
||
|
||
//Typannahme
|
||
$$ = Fst;
|
||
}
|
||
//Bsp: for(i=0 ; ; i++){System.out.println(i)}
|
||
| FOR '(' expression ';' ';' expression ')' statement
|
||
{
|
||
ForStmt Fst = new ForStmt($3.getOffset(),$3.getVariableLength());
|
||
Fst.set_head_Initializer($3);
|
||
Fst.set_head_Loop_expr($6);
|
||
Fst.set_body_Loop_block($8);
|
||
|
||
//Typannahme
|
||
$$ = Fst;
|
||
}
|
||
//Bsp: for( ; i<10 ; i++){System.out.println(i)}
|
||
| FOR '(' ';' expression ';' expression ')' statement
|
||
{
|
||
ForStmt Fst = new ForStmt($4.getOffset(),$4.getVariableLength());
|
||
Fst.set_head_Condition($4);
|
||
Fst.set_head_Loop_expr($6);
|
||
Fst.set_body_Loop_block($8);
|
||
|
||
//Typannahme
|
||
$$ = Fst;
|
||
}
|
||
//Bsp: for(i=0 ; ; ){System.out.println(i)}
|
||
| FOR '(' expression ';' ';' ')' statement
|
||
{
|
||
ForStmt Fst = new ForStmt($3.getOffset(),$3.getVariableLength());
|
||
Fst.set_head_Initializer($3);
|
||
Fst.set_body_Loop_block($7);
|
||
|
||
//Typannahme
|
||
$$ = Fst;
|
||
}
|
||
//Bsp: for( ; i<10 ; ){System.out.println(i)}
|
||
| FOR '(' ';' expression ';' ')' statement
|
||
{
|
||
ForStmt Fst = new ForStmt($4.getOffset(),$4.getVariableLength());
|
||
Fst.set_head_Condition($4);
|
||
Fst.set_body_Loop_block($7);
|
||
|
||
//Typannahme
|
||
$$ = Fst;
|
||
}
|
||
//Bsp: for( ; ; i++){System.out.println(i)}
|
||
| FOR '(' ';' ';' expression ')' statement
|
||
{
|
||
ForStmt Fst = new ForStmt($5.getOffset(),$5.getVariableLength());
|
||
Fst.set_head_Loop_expr($5);
|
||
Fst.set_body_Loop_block($7);
|
||
|
||
//Typannahme
|
||
$$ = Fst;
|
||
}
|
||
//Bsp: for( ; ; ){System.out.println(i)}
|
||
| FOR '(' ';' ';' ')' statement
|
||
{
|
||
ForStmt Fst = new ForStmt($6.getOffset(),$6.getVariableLength());
|
||
Fst.set_body_Loop_block($6);
|
||
|
||
//Typannahme
|
||
$$ = Fst;
|
||
}
|
||
|
||
assignmentexpression : conditionalexpression
|
||
{
|
||
org.apache.log4j.Logger.getLogger("parser").debug("conditionalexpression");
|
||
$$=$1;
|
||
}
|
||
| assignment
|
||
{
|
||
$$=$1;
|
||
}
|
||
|
||
|
||
emptystatement : ';'
|
||
{
|
||
EmptyStmt Empst = new EmptyStmt();
|
||
$$=Empst;
|
||
}
|
||
|
||
expressionstatement : statementexpression ';'
|
||
{
|
||
$$=$1;
|
||
}
|
||
|
||
returnstatement : RETURN ';'
|
||
{
|
||
Return ret = new Return(-1,-1);
|
||
$$= ret;
|
||
}
|
||
| RETURN expression ';'
|
||
{
|
||
Return retexp = new Return($2.getOffset(),$2.getVariableLength());
|
||
retexp.set_ReturnExpr($2);
|
||
$$=retexp;
|
||
}
|
||
|
||
statementnoshortif :statementwithouttrailingsubstatement
|
||
{
|
||
$$=$1;
|
||
}
|
||
| ifthenelsestatementnoshortif
|
||
{
|
||
$$=$1;
|
||
}
|
||
| whilestatementnoshortif
|
||
{
|
||
$$=$1;
|
||
}
|
||
|
||
conditionalexpression :conditionalorexpression
|
||
{
|
||
$$=$1;
|
||
}
|
||
// | conditionalorexpression '?' expression ':' conditionalexpression
|
||
|
||
assignment :lefthandside assignmentoperator assignmentexpression
|
||
{
|
||
org.apache.log4j.Logger.getLogger("parser").debug("\nParser --> Zuweisung1!\n");
|
||
Assign Ass = new Assign($1.getOffset(),$1.getVariableLength());
|
||
LocalOrFieldVar LOFV = new LocalOrFieldVar($1.getOffset(),$1.getVariableLength());
|
||
LOFV.set_UsedId($1);
|
||
//auskommentiert von Andreas Stadelmeier (a10023) LOFV.setType(TypePlaceholder.fresh());
|
||
//auskommentiert von Andreas Stadelmeier (a10023) Ass.setType(TypePlaceholder.fresh());
|
||
if( $2 == null )
|
||
{
|
||
org.apache.log4j.Logger.getLogger("parser").debug("\nParser --> Zuweisung1 --> " + $3 + " \n");
|
||
Ass.set_Expr( LOFV,$3 );
|
||
}
|
||
else
|
||
{
|
||
Binary Bin = new Binary($3.getOffset(),$3.getVariableLength());
|
||
Bin.set_Expr1(LOFV);
|
||
Bin.set_Operator($2);
|
||
Bin.set_Expr2($3);
|
||
org.apache.log4j.Logger.getLogger("parser").debug("\nParser --> Zuweisung1 --> Binary\n");
|
||
//auskommentiert von Andreas Stadelmeier (a10023) Bin.setType(TypePlaceholder.fresh());
|
||
Ass.set_Expr( LOFV, Bin );
|
||
}
|
||
$$=Ass;
|
||
}
|
||
| lefthandside assignmentoperator classinstancecreationexpression
|
||
{
|
||
Assign Ass =new Assign($1.getOffset(),$1.getVariableLength());
|
||
LocalOrFieldVar LOFV = new LocalOrFieldVar($1.getOffset(),$1.getVariableLength());
|
||
LOFV.set_UsedId($1);
|
||
//auskommentiert von Andreas Stadelmeier (a10023) LOFV.setType(TypePlaceholder.fresh());
|
||
//auskommentiert von Andreas Stadelmeier (a10023) Ass.setType(TypePlaceholder.fresh());
|
||
if($2==null)
|
||
{
|
||
Ass.set_Expr(LOFV,$3);
|
||
}
|
||
else
|
||
{
|
||
Binary Bin = new Binary($3.getOffset(),$3.getVariableLength());
|
||
Bin.set_Expr1(LOFV);
|
||
Bin.set_Operator($2);
|
||
//auskommentiert von Andreas Stadelmeier (a10023) Bin.setType(TypePlaceholder.fresh());
|
||
Bin.set_Expr2($3);
|
||
Ass.set_Expr(LOFV,Bin);
|
||
}
|
||
$$=Ass;
|
||
}
|
||
|
||
statementexpression :assignment
|
||
{
|
||
$$=$1;
|
||
}
|
||
| preincrementexpression
|
||
{
|
||
$$=$1;
|
||
}
|
||
| predecrementexpression
|
||
{
|
||
$$=$1;
|
||
}
|
||
| postincrementexpression
|
||
{
|
||
$$=$1;
|
||
}
|
||
| postdecrementexpression
|
||
{
|
||
$$=$1;
|
||
}
|
||
| methodinvocation
|
||
{
|
||
$$=$1;
|
||
}
|
||
/* | classinstancecreationexpression
|
||
{
|
||
$$=$1;
|
||
}
|
||
*/
|
||
|
||
ifthenelsestatementnoshortif :IF '(' expression ')' statementnoshortif
|
||
ELSE statementnoshortif
|
||
{
|
||
IfStmt IfElno = new IfStmt($3.getOffset(),$3.getVariableLength());
|
||
IfElno.set_Expr($3);
|
||
IfElno.set_Then_block($5);
|
||
IfElno.set_Else_block($7);
|
||
$$=IfElno;
|
||
}
|
||
|
||
whilestatementnoshortif :WHILE '(' expression ')' statementnoshortif
|
||
{
|
||
WhileStmt Whstno = new WhileStmt($3.getOffset(),$3.getVariableLength());
|
||
Whstno.set_Expr($3);
|
||
Whstno.set_Loop_block($5);
|
||
$$=Whstno;
|
||
}
|
||
|
||
conditionalorexpression : conditionalandexpression
|
||
{
|
||
$$=$1;
|
||
}
|
||
| conditionalorexpression LOGICALOR conditionalandexpression
|
||
{
|
||
Binary LogOr = new Binary($1.getOffset(),$1.getVariableLength());
|
||
OrOp OrO = new OrOp($1.getOffset(),$1.getVariableLength());
|
||
LogOr.set_Expr1($1);
|
||
LogOr.set_Expr2($3);
|
||
LogOr.set_Operator(OrO);
|
||
//auskommentiert von Andreas Stadelmeier (a10023) LogOr.setType(TypePlaceholder.fresh());
|
||
$$=LogOr;
|
||
}
|
||
|
||
// LambdaExpression eingef<65>gt von Andreas Stadelmeier, a10023:
|
||
|
||
lambdaassignmentoperator : LAMBDAASSIGNMENT
|
||
{
|
||
$$=null;
|
||
}
|
||
|
||
lambdabody : block
|
||
{
|
||
$$=$1;
|
||
}
|
||
| expression
|
||
{
|
||
//Lambdabody kann auch nur aus einer Expression bestehen. In diesem Fall wird ein Block erstellt, welcher als einziges Statement ein return statment mit der expression hat.
|
||
//Bsp.: Aus der Expression |var=="hallo"| wird: |{return var=="hallo";}|
|
||
Block ret=new Block();
|
||
ret.statements.add((Statement)new Return(0,0).set_ReturnExpr($1));
|
||
//ret.statements.add((ExprStmt)$1);
|
||
$$=ret;
|
||
}
|
||
|
||
lambdaexpressionparameter : '(' ')'
|
||
{
|
||
$$=null;
|
||
}
|
||
| '(' formalparameterlist ')'
|
||
{
|
||
$$=$2;
|
||
}
|
||
|
||
lambdaexpression : lambdaexpressionparameter lambdaassignmentoperator lambdabody
|
||
{
|
||
LambdaExpression lambda = new LambdaExpression(/*((ParameSterList)$2).getOffset(),((ParameterList)$2).getVariableLength()*/0,0);
|
||
if($1!=null)lambda.setParameterList($1);
|
||
lambda.setBody((Block)$3);
|
||
$$=lambda;
|
||
}
|
||
|
||
/*
|
||
| '(' ')' lambdaassignmentoperator lambdabody
|
||
{
|
||
LambdaExpression lambda = new LambdaExpression(0,0); //hier noch fixen
|
||
lambda.setBody((Block)$4);
|
||
$$=lambda;
|
||
}
|
||
*/
|
||
|
||
|
||
|
||
lefthandside :name
|
||
{
|
||
$$=$1;
|
||
}
|
||
|
||
assignmentoperator : '='
|
||
{
|
||
$$=null;
|
||
}
|
||
| TIMESEQUAL
|
||
{
|
||
TimesOp TEO = new TimesOp(-1,-1);
|
||
$$=TEO;
|
||
}
|
||
| DIVIDEEQUAL
|
||
{
|
||
DivideOp DEO = new DivideOp(-1,-1);
|
||
$$=DEO;
|
||
}
|
||
| MODULOEQUAL
|
||
{
|
||
ModuloOp MEO = new ModuloOp(-1,-1);
|
||
$$=MEO;
|
||
}
|
||
| PLUSEQUAL
|
||
{
|
||
PlusOp PEO = new PlusOp(-1,-1);
|
||
$$=PEO;
|
||
}
|
||
| MINUSEQUAL
|
||
{
|
||
MinusOp MEO = new MinusOp(-1,-1);
|
||
$$=MEO;
|
||
}
|
||
// | SHIFTLEFTEQUAL
|
||
// | SIGNEDSHIFTRIGHTEQUAL
|
||
// | UNSIGNEDSHIFTRIGHTEQUAL
|
||
// | ANDEQUAL
|
||
// | XOREQUAL
|
||
// | OREQUAL
|
||
|
||
preincrementexpression :INCREMENT unaryexpression
|
||
{
|
||
PreIncExpr PRINC = new PreIncExpr($2.getOffset(),$2.getVariableLength());
|
||
PRINC.set_Expr($2);
|
||
$$=PRINC;
|
||
}
|
||
|
||
predecrementexpression :DECREMENT unaryexpression
|
||
{
|
||
PreDecExpr PRDEC = new PreDecExpr($2.getOffset(),$2.getVariableLength());
|
||
PRDEC.set_Expr($2);
|
||
$$=PRDEC;
|
||
}
|
||
|
||
postincrementexpression :postfixexpression INCREMENT
|
||
{
|
||
PostIncExpr PIE = new PostIncExpr($1.getOffset(),$1.getVariableLength());
|
||
PIE.set_Expr($1);
|
||
$$=PIE;
|
||
}
|
||
|
||
postdecrementexpression :postfixexpression DECREMENT
|
||
{
|
||
PostDecExpr PDE = new PostDecExpr($1.getOffset(),$1.getVariableLength());
|
||
PDE.set_Expr($1);
|
||
$$=PDE;
|
||
}
|
||
|
||
methodinvocation:
|
||
name '(' ')'
|
||
{
|
||
org.apache.log4j.Logger.getLogger("parser").debug("M1");
|
||
MethodCall MC = new MethodCall($1.getOffset(),$1.getVariableLength());
|
||
UsedId udidmeth = new UsedId($1.getOffset());
|
||
udidmeth.set_Name((String)(($1.get_Name()).elementAt($1.get_Name().size()-1)));
|
||
MC.set_UsedId(udidmeth);
|
||
Receiver rec = null;
|
||
if ($1.get_Name().size() > 2) {
|
||
|
||
$1.removeLast();
|
||
|
||
//macht aus der Liste von Strings
|
||
//in usedid.name einen InstVar
|
||
InstVar INSTVA = new InstVar($1,$1.getOffset(),$1.getVariableLength());
|
||
|
||
//auskommentiert von Andreas Stadelmeier (a10023) INSTVA.setType(TypePlaceholder.fresh());
|
||
rec = new Receiver(INSTVA);
|
||
}
|
||
else if ($1.get_Name().size() == 2) {
|
||
LocalOrFieldVar LOFV = new LocalOrFieldVar($1.getOffset(),$1.getVariableLength());
|
||
$1.removeLast();
|
||
LOFV.set_UsedId($1);
|
||
//auskommentiert von Andreas Stadelmeier (a10023) LOFV.setType(TypePlaceholder.fresh());
|
||
rec = new Receiver(LOFV);
|
||
}
|
||
MC.set_Receiver(rec);
|
||
//auskommentiert von Andreas Stadelmeier (a10023) MC.setType(TypePlaceholder.fresh());
|
||
$$=MC;
|
||
}
|
||
| name '('argumentlist')'
|
||
{
|
||
org.apache.log4j.Logger.getLogger("parser").debug("M2");
|
||
MethodCall MCarg = new MethodCall($1.getOffset(),$1.getVariableLength());
|
||
UsedId udidmeth = new UsedId($1.getOffset());
|
||
udidmeth.set_Name((String)(($1.get_Name()).elementAt($1.get_Name().size()-1)));
|
||
MCarg.set_UsedId(udidmeth);
|
||
Receiver rec = null;
|
||
if ($1.get_Name().size() > 2) {
|
||
|
||
$1.removeLast();
|
||
|
||
//macht aus der Liste von Strings
|
||
//in usedid.name einen InstVar
|
||
InstVar INSTVA = new InstVar($1,$1.getOffset(),$1.getVariableLength());
|
||
|
||
//auskommentiert von Andreas Stadelmeier (a10023) INSTVA.setType(TypePlaceholder.fresh());
|
||
rec = new Receiver(INSTVA);
|
||
}
|
||
else if ($1.get_Name().size() == 2) {
|
||
LocalOrFieldVar LOFV = new LocalOrFieldVar($1.getOffset(),$1.getVariableLength());
|
||
$1.removeLast();
|
||
LOFV.set_UsedId($1);
|
||
//auskommentiert von Andreas Stadelmeier (a10023) LOFV.setType(TypePlaceholder.fresh());
|
||
rec = new Receiver(LOFV);
|
||
}
|
||
MCarg.set_Receiver(rec);
|
||
MCarg.set_ArgumentList($3);
|
||
//auskommentiert von Andreas Stadelmeier (a10023) MCarg.setType(TypePlaceholder.fresh());
|
||
$$=MCarg;
|
||
}
|
||
| primary '.' IDENTIFIER '(' ')'
|
||
{
|
||
org.apache.log4j.Logger.getLogger("parser").debug("M3");
|
||
MethodCall MCpr = new MethodCall($1.getOffset(),$1.getVariableLength());
|
||
|
||
// PL 05-08-21 primary ist kein UsedId
|
||
//$1.usedid.set_Name($3.getLexem());
|
||
//MCpr.set_UsedId($1.get_UsedId());
|
||
UsedId udidmeth = new UsedId($1.getOffset());
|
||
udidmeth.set_Name($3.getLexem());
|
||
MCpr.set_UsedId(udidmeth);
|
||
|
||
/* #JB# 04.06.2005 */
|
||
/* ########################################################### */
|
||
MCpr.set_Receiver(new Receiver($1));
|
||
/* ########################################################### */
|
||
//auskommentiert von Andreas Stadelmeier (a10023) MCpr.setType(TypePlaceholder.fresh());
|
||
$$=MCpr;
|
||
}
|
||
| primary '.' IDENTIFIER '('argumentlist ')'
|
||
{
|
||
org.apache.log4j.Logger.getLogger("parser").debug("M4");
|
||
MethodCall MCPA = new MethodCall($1.getOffset(),$1.getVariableLength());
|
||
|
||
// PL 05-08-21 primary ist kein UsedId
|
||
//$1.usedid.set_Name($3.getLexem());
|
||
//MCPA.set_UsedId($1.get_UsedId());
|
||
UsedId udidmeth = new UsedId($3.getOffset());
|
||
udidmeth.set_Name($3.getLexem());
|
||
MCPA.set_UsedId(udidmeth);
|
||
|
||
/* #JB# 04.06.2005 */
|
||
/* ########################################################### */
|
||
MCPA.set_Receiver(new Receiver($1));
|
||
/* ########################################################### */
|
||
MCPA.set_ArgumentList($5);
|
||
//auskommentiert von Andreas Stadelmeier (a10023) MCPA.setType(TypePlaceholder.fresh());
|
||
$$=MCPA;
|
||
}
|
||
// | SUPER '.' IDENTIFIER '(' ')'
|
||
// | SUPER '.' IDENTIFIER '('argumentlist')'
|
||
|
||
classinstancecreationexpression : NEW classtype '(' ')'
|
||
{
|
||
NewClass NC = new NewClass($2.getOffset(),$2.getVariableLength());
|
||
NC.set_UsedId($2);
|
||
usedIdsToCheck.addElement($2);
|
||
//auskommentiert von Andreas Stadelmeier (a10023) NC.setType(TypePlaceholder.fresh());
|
||
$$=NC;
|
||
}
|
||
| NEW classtype '(' argumentlist ')'
|
||
{
|
||
NewClass NCarg = new NewClass($2.getOffset(),$2.getVariableLength());
|
||
NCarg.set_UsedId($2);
|
||
usedIdsToCheck.addElement($2);
|
||
NCarg.set_ArgumentList($4);
|
||
//auskommentiert von Andreas Stadelmeier (a10023) NCarg.setType(TypePlaceholder.fresh());
|
||
$$=NCarg;
|
||
}
|
||
|
||
conditionalandexpression : inclusiveorexpression
|
||
{
|
||
$$=$1;
|
||
}
|
||
| conditionalandexpression LOGICALAND inclusiveorexpression
|
||
{
|
||
Binary And = new Binary($1.getOffset(),$1.getVariableLength());
|
||
AndOp AndO = new AndOp($1.getOffset(),$1.getVariableLength());
|
||
And.set_Expr1($1);
|
||
And.set_Expr2($3);
|
||
And.set_Operator(AndO);
|
||
//auskommentiert von Andreas Stadelmeier (a10023) And.setType(TypePlaceholder.fresh());
|
||
$$=And;
|
||
}
|
||
|
||
/*
|
||
fieldaccess :primary '.' IDENTIFIER
|
||
| SUPER '.' IDENTIFIER
|
||
*/
|
||
|
||
unaryexpression : preincrementexpression
|
||
{
|
||
$$=$1;
|
||
}
|
||
| predecrementexpression
|
||
{
|
||
$$=$1;
|
||
}
|
||
| '+' unaryexpression
|
||
{
|
||
PositivExpr POSEX=new PositivExpr($2.getOffset(),$2.getVariableLength());
|
||
UnaryPlus UP= new UnaryPlus();
|
||
POSEX.set_UnaryPlus(UP);
|
||
POSEX.set_Expr($2);
|
||
$$=POSEX;
|
||
}
|
||
| '-' unaryexpression
|
||
{
|
||
NegativeExpr NEGEX=new NegativeExpr($2.getOffset(),$2.getVariableLength());
|
||
UnaryMinus UM=new UnaryMinus();
|
||
NEGEX.set_UnaryMinus(UM);
|
||
NEGEX.set_Expr($2);
|
||
$$=NEGEX;
|
||
}
|
||
| unaryexpressionnotplusminus
|
||
{
|
||
$$=$1;
|
||
}
|
||
|
||
postfixexpression :primary
|
||
{
|
||
$$=$1;
|
||
}
|
||
| name
|
||
{
|
||
if ($1.get_Name().size() > 1) {
|
||
|
||
//macht aus der Liste von Strings
|
||
//in usedid.name einen InstVar
|
||
InstVar INSTVA = new InstVar($1,$1.getOffset(),$1.getVariableLength());
|
||
|
||
//auskommentiert von Andreas Stadelmeier (a10023) INSTVA.setType(TypePlaceholder.fresh());
|
||
$$ = INSTVA;
|
||
}
|
||
else {
|
||
LocalOrFieldVar Postincexpr = new LocalOrFieldVar($1.getOffset(),$1.getVariableLength());
|
||
Postincexpr.set_UsedId($1);
|
||
//auskommentiert von Andreas Stadelmeier (a10023) Postincexpr.setType(TypePlaceholder.fresh());
|
||
$$=Postincexpr;
|
||
}
|
||
}
|
||
| postincrementexpression
|
||
{
|
||
$$=$1;
|
||
}
|
||
| postdecrementexpression
|
||
{
|
||
$$=$1;
|
||
}
|
||
|
||
primary : primarynonewarray
|
||
{
|
||
$$=$1;
|
||
}
|
||
|
||
inclusiveorexpression : exclusiveorexpression
|
||
{
|
||
$$=$1;
|
||
}
|
||
| inclusiveorexpression '|' exclusiveorexpression
|
||
|
||
primarynonewarray : literal
|
||
{
|
||
$$=$1;
|
||
}
|
||
| THIS
|
||
{
|
||
This T = new This($1.getOffset(),$1.getLexem().length());
|
||
UsedId UT = new UsedId($1.getOffset());
|
||
UT.set_Name($1.getLexem());
|
||
T.set_UsedId(UT);
|
||
$$=T;
|
||
}
|
||
/* auskommentiert von Andreas Stadelmeier
|
||
| '('expression')'
|
||
{
|
||
$$=$2;
|
||
}
|
||
*/
|
||
/*
|
||
| classinstancecreationexpression
|
||
{
|
||
$$=$1;
|
||
}
|
||
| fieldaccess
|
||
*/
|
||
| methodinvocation
|
||
{
|
||
$$=$1;
|
||
}
|
||
|lambdaexpression
|
||
{
|
||
$$=$1;
|
||
}
|
||
|
||
|
||
unaryexpressionnotplusminus : postfixexpression {$$=$1;}
|
||
// | '~' unaryexpression
|
||
| '!' unaryexpression {NotExpr NE=new NotExpr($2.getOffset(),$2.getVariableLength());
|
||
UnaryNot UN=new UnaryNot();
|
||
NE.set_UnaryNot(UN);
|
||
NE.set_Expr($2);
|
||
$$=NE;
|
||
}
|
||
| castexpression {$$=$1;}
|
||
|
||
exclusiveorexpression :andexpression {$$=$1;}
|
||
| exclusiveorexpression '^' andexpression //{
|
||
//
|
||
//}
|
||
|
||
literal : INTLITERAL {IntLiteral IL = new IntLiteral();
|
||
IL.set_Int($1.String2Int());
|
||
$$ = IL;
|
||
}
|
||
|
||
| BOOLLITERAL {BoolLiteral BL = new BoolLiteral();
|
||
BL.set_Bool($1.String2Bool());
|
||
$$ = BL;
|
||
}
|
||
| CHARLITERAL {CharLiteral CL = new CharLiteral();
|
||
CL.set_Char($1.CharInString());
|
||
$$=CL;
|
||
}
|
||
| STRINGLITERAL
|
||
{
|
||
StringLiteral ST = new StringLiteral();
|
||
ST.set_String($1.get_String());
|
||
$$=ST;
|
||
}
|
||
| LONGLITERAL { LongLiteral LL = new LongLiteral();
|
||
LL.set_Long($1.String2Long());
|
||
$$ = LL;
|
||
}
|
||
| FLOATLITERAL {
|
||
FloatLiteral FL = new FloatLiteral();
|
||
FL.set_Float($1.String2Float());
|
||
$$ = FL;
|
||
}
|
||
| DOUBLELITERAL {
|
||
DoubleLiteral DL = new DoubleLiteral();
|
||
DL.set_Double($1.String2Double());
|
||
$$ = DL;
|
||
}
|
||
| JNULL;
|
||
{
|
||
Null NN = new Null();
|
||
$$=NN;
|
||
}
|
||
|
||
castexpression : '(' primitivetype ')' unaryexpression
|
||
{
|
||
CastExpr CaEx=new CastExpr($4.getOffset(),$4.getVariableLength());
|
||
CaEx.set_Type($2);
|
||
CaEx.set_Expr($4);
|
||
$$=CaEx;
|
||
}
|
||
//| '(' expression ')' unaryexpressionnotplusminus
|
||
|
||
andexpression :equalityexpression
|
||
{
|
||
$$=$1;
|
||
}
|
||
| andexpression '&' equalityexpression
|
||
{
|
||
}
|
||
|
||
equalityexpression : relationalexpression
|
||
{
|
||
$$=$1;
|
||
}
|
||
| equalityexpression EQUAL relationalexpression
|
||
{
|
||
Binary EQ = new Binary($1.getOffset(),$1.getVariableLength());
|
||
EqualOp EO = new EqualOp($1.getOffset(),$1.getVariableLength());
|
||
EQ.set_Expr1($1);
|
||
EQ.set_Expr2($3);
|
||
EQ.set_Operator(EO);
|
||
//auskommentiert von Andreas Stadelmeier (a10023) EQ.setType(TypePlaceholder.fresh());
|
||
$$=EQ;
|
||
}
|
||
| equalityexpression NOTEQUAL relationalexpression
|
||
{
|
||
Binary NEQ = new Binary($1.getOffset(),$1.getVariableLength());
|
||
NotEqualOp NEO = new NotEqualOp($1.getOffset(),$1.getVariableLength());
|
||
NEQ.set_Expr1($1);
|
||
NEQ.set_Expr2($3);
|
||
NEQ.set_Operator(NEO);
|
||
//auskommentiert von Andreas Stadelmeier (a10023) NEQ.setType(TypePlaceholder.fresh());
|
||
$$=NEQ;
|
||
}
|
||
|
||
relationalexpression : shiftexpression
|
||
{
|
||
$$=$1;
|
||
}
|
||
| relationalexpression '<' shiftexpression
|
||
{
|
||
Binary LO = new Binary($1.getOffset(),$1.getVariableLength());
|
||
LessOp LOO = new LessOp($1.getOffset(),$1.getVariableLength());
|
||
LO.set_Expr1($1);
|
||
LO.set_Expr2($3);
|
||
LO.set_Operator(LOO);
|
||
//auskommentiert von Andreas Stadelmeier (a10023) LO.setType(TypePlaceholder.fresh());
|
||
$$=LO;
|
||
}
|
||
| relationalexpression '>' shiftexpression
|
||
{
|
||
Binary GO = new Binary($1.getOffset(),$1.getVariableLength());
|
||
GreaterOp GOO = new GreaterOp($1.getOffset(),$1.getVariableLength());
|
||
GO.set_Expr1($1);
|
||
GO.set_Expr2($3);
|
||
GO.set_Operator( GOO );
|
||
//auskommentiert von Andreas Stadelmeier (a10023) GO.setType(TypePlaceholder.fresh());
|
||
$$=GO;
|
||
}
|
||
| relationalexpression LESSEQUAL shiftexpression
|
||
{
|
||
Binary LE = new Binary($1.getOffset(),$1.getVariableLength());
|
||
LessEquOp LEO = new LessEquOp($1.getOffset(),$1.getVariableLength());
|
||
LE.set_Expr1($1);
|
||
LE.set_Expr2($3);
|
||
LE.set_Operator(LEO);
|
||
//auskommentiert von Andreas Stadelmeier (a10023) LE.setType(TypePlaceholder.fresh());
|
||
$$=LE;
|
||
}
|
||
| relationalexpression GREATEREQUAL shiftexpression
|
||
{
|
||
Binary GE = new Binary($1.getOffset(),$1.getVariableLength());
|
||
GreaterEquOp GEO = new GreaterEquOp($1.getOffset(),$1.getVariableLength());
|
||
GE.set_Expr1($1);
|
||
GE.set_Expr2($3);
|
||
GE.set_Operator(GEO);
|
||
//auskommentiert von Andreas Stadelmeier (a10023) GE.setType(TypePlaceholder.fresh());
|
||
$$=GE;
|
||
}
|
||
| relationalexpression INSTANCEOF referencetype
|
||
{
|
||
InstanceOf ISO=new InstanceOf($1.getOffset(),$1.getVariableLength());
|
||
ISO.set_Expr($1);
|
||
ISO.set_Type($3);
|
||
$$=ISO;
|
||
}
|
||
|
||
shiftexpression : additiveexpression
|
||
{
|
||
$$=$1;
|
||
}
|
||
|
||
additiveexpression :multiplicativeexpression
|
||
{
|
||
$$=$1;
|
||
}
|
||
| additiveexpression '+' multiplicativeexpression
|
||
{
|
||
Binary AD = new Binary($1.getOffset(),$1.getVariableLength());
|
||
PlusOp PO = new PlusOp($1.getOffset(),$1.getVariableLength());
|
||
AD.set_Expr1($1);
|
||
AD.set_Expr2($3);
|
||
AD.set_Operator(PO);
|
||
//auskommentiert von Andreas Stadelmeier (a10023) AD.setType(TypePlaceholder.fresh());
|
||
$$=AD;
|
||
}
|
||
| additiveexpression '-' multiplicativeexpression
|
||
{
|
||
Binary MI = new Binary($1.getOffset(),$1.getVariableLength());
|
||
MinusOp MO = new MinusOp($1.getOffset(),$1.getVariableLength());
|
||
MI.set_Expr1($1);
|
||
MI.set_Expr2($3);
|
||
MI.set_Operator(MO);
|
||
//auskommentiert von Andreas Stadelmeier (a10023) MI.setType(TypePlaceholder.fresh());
|
||
$$=MI;
|
||
}
|
||
|
||
multiplicativeexpression : unaryexpression
|
||
{
|
||
$$=$1;
|
||
}
|
||
| multiplicativeexpression '*' unaryexpression
|
||
{
|
||
Binary ML = new Binary($1.getOffset(),$1.getVariableLength());
|
||
TimesOp TO = new TimesOp($1.getOffset(),$1.getVariableLength());
|
||
ML.set_Expr1($1);
|
||
ML.set_Expr2($3);
|
||
ML.set_Operator(TO);
|
||
//auskommentiert von Andreas Stadelmeier (a10023) ML.setType(TypePlaceholder.fresh());
|
||
$$=ML;
|
||
}
|
||
| multiplicativeexpression '/' unaryexpression
|
||
{
|
||
Binary DV = new Binary($1.getOffset(),$1.getVariableLength());
|
||
DivideOp DO = new DivideOp($1.getOffset(),$1.getVariableLength());
|
||
DV.set_Expr1($1);
|
||
DV.set_Expr2($3);
|
||
DV.set_Operator(DO);
|
||
//auskommentiert von Andreas Stadelmeier (a10023) DV.setType(TypePlaceholder.fresh());
|
||
$$ = DV;
|
||
}
|
||
| multiplicativeexpression '%' unaryexpression
|
||
{
|
||
Binary MD = new Binary($1.getOffset(),$1.getVariableLength());
|
||
ModuloOp MO = new ModuloOp($1.getOffset(),$1.getVariableLength());
|
||
MD.set_Expr1($1);
|
||
MD.set_Expr2($3);
|
||
MD.set_Operator(MO);
|
||
//auskommentiert von Andreas Stadelmeier (a10023) MD.setType(TypePlaceholder.fresh());
|
||
$$ =MD;
|
||
}
|
||
|
||
|
||
%% |