This check-in is a clean up of the asterix code.
It gets rid of redundant classes (FunIdentifier, FunctionUtil etc) and also corrects comparisons made using == instead of a .equals.
git-svn-id: https://asterixdb.googlecode.com/svn/trunk/asterix@39 eaa15691-b419-025a-1212-ee371bd00084
diff --git a/asterix-aql/src/main/javacc/AQL.jj b/asterix-aql/src/main/javacc/AQL.jj
index 544e855..1fa40b8 100644
--- a/asterix-aql/src/main/javacc/AQL.jj
+++ b/asterix-aql/src/main/javacc/AQL.jj
@@ -37,6 +37,7 @@
import edu.uci.ics.asterix.aql.context.RootScopeFactory;
import edu.uci.ics.asterix.common.annotations.*;
import edu.uci.ics.asterix.common.exceptions.AsterixException;
+import edu.uci.ics.asterix.om.functions.AsterixFunction;
public class AQLParser extends ScopeChecker {
@@ -1027,7 +1028,8 @@
FunctionDecl FunctionDeclaration() throws ParseException:
{
FunctionDecl func = new FunctionDecl();
- FunIdentifier ident = new FunIdentifier();
+ AsterixFunction ident;
+ String functionName;
int arity = 0;
List<VarIdentifier> paramList = new ArrayList<VarIdentifier>();
Expression funcBody;
@@ -1039,7 +1041,7 @@
<IDENTIFIER>
{
Token t = getToken(0);
- ident.setValue(t.toString());
+ functionName = t.toString();
}
<LEFTPAREN> (<VARIABLE>
{
@@ -1059,7 +1061,7 @@
})*)? <RIGHTPAREN> "{" funcBody = Expression() "}"
{
- ident.setArity(arity);
+ ident = new AsterixFunction(functionName,arity);
getCurrentScope().addFunctionDescriptor(ident, false);
func.setIdent(ident);
func.setFuncBody(funcBody);
@@ -1071,7 +1073,8 @@
CreateFunctionStatement FunctionCreation() throws ParseException:
{
CreateFunctionStatement cfs = null;
- FunIdentifier ident = new FunIdentifier();
+ AsterixFunction ident;
+ String functionName;
int arity = 0;
boolean ifNotExists = false;
List<VarIdentifier> paramList = new ArrayList<VarIdentifier>();
@@ -1084,7 +1087,7 @@
<IDENTIFIER>
{
Token t = getToken(0);
- ident.setValue(t.toString());
+ functionName= t.toString();
}
(
@@ -1115,7 +1118,7 @@
}
"}"
{
- ident.setArity(arity);
+ ident = new AsterixFunction(functionName, arity);
getCurrentScope().addFunctionDescriptor(ident, false);
cfs = new CreateFunctionStatement(ident, paramList, funcBody, ifNotExists);
return cfs;
@@ -1728,10 +1731,10 @@
} ("," tmp = Expression() { argList.add(tmp); arity++; })*)? <RIGHTPAREN>
{
- FunIdentifier fd = lookupFunctionSignature(funcName.toString(), arity);
+ AsterixFunction fd = lookupFunctionSignature(funcName.toString(), arity);
if(fd == null)
{
- fd = new FunIdentifier(funcName.toString(), arity);
+ fd = new AsterixFunction(funcName.toString(), arity);
// notFoundFunctionList.add(fd);
}
// throw new ParseException("can't find function "+ funcName.toString() + "@" + arity);