WeaselTreeGeneric generic = null;
while(iterator.hasNext()){
WeaselToken token = iterator.next();
if(Arrays.asList(end).contains(token.tokenType)){
if(generic!=null)
throw new WeaselCompilerException(token.line, "Expect Ident but got %s", token);
while(!tokenCache.isEmpty() && ((Properties)tokenCache.get(0).param).suffix!=null){
tokenSuffix.add(tokenCache.remove(0));
}
if(tokenCache.size()!=0){
throw new WeaselCompilerException(token.line, "Expect suffix but got %s", tokenCache.get(0));
}
if(!tokenSuffix.isEmpty()){
WeaselTreeAddResult wtar = bottom.add(tokenSuffix, null, null, null, iterator);
bottom = wtar.newTree;
}
tokenPrefix.clear();
tokenSuffix.clear();
tokenCache.clear();
break;
}else{
if(token.tokenType==WeaselTokenType.KEYWORD && token.param==WeaselKeyWord.INSTANCEOF){
WeaselToken t = iterator.next();
WeaselCompiler.expect(t, WeaselTokenType.IDENT);
String className = (String)t.param;
t = iterator.next();
while(t.tokenType==WeaselTokenType.OPERATOR && t.param==WeaselOperator.ELEMENT){
t = iterator.next();
WeaselCompiler.expect(t, WeaselTokenType.IDENT);
className += "."+(String)t.param;
t = iterator.next();
}
if(t.tokenType==WeaselTokenType.OPERATOR && t.param==WeaselOperator.LESS){
generic = new WeaselTreeGeneric(iterator);
if(generic.close)
throw new WeaselCompilerException(t.line, "To many >");
}else{
iterator.previous();
}
token = new WeaselInstanceofToken(token.line, className, generic);
generic = null;
}
if(token.tokenType==WeaselTokenType.COMMA){
token = new WeaselToken(WeaselTokenType.OPERATOR, token.line, WeaselOperator.COMMA);
}
if(token.tokenType==WeaselTokenType.QUESTIONMARK){
if(generic!=null)
throw new WeaselCompilerException(token.line, "Expect Ident but got ?:");
while(!tokenCache.isEmpty() && ((Properties)tokenCache.get(0).param).suffix!=null){
tokenSuffix.add(tokenCache.remove(0));
}
if(tokenCache.size()!=0){
throw new WeaselCompilerException(token.line, "Expect suffix but got %s", tokenCache.get(0));
}
if(!tokenSuffix.isEmpty()){
WeaselTreeAddResult wtar = bottom.add(tokenSuffix, null, null, null, iterator);
bottom = wtar.newTree;
}
WeaselTree tree = parse(iterator, WeaselTokenType.COLON);
WeaselTreeCondition wtc = new WeaselTreeCondition(tree, token);
WeaselTreeAddResult wtar = wtc.setLeft(bottom);
bottom = wtar.newTree;
start = true;
}else if(token.tokenType == WeaselTokenType.OPERATOR){
if(generic!=null)
throw new WeaselCompilerException(token.line, "Expect Ident but got %s", token);
tokenCache.add(token);
if(token.param == WeaselOperator.ELEMENT){
WeaselToken wtoken = iterator.next();
if(wtoken.tokenType == WeaselTokenType.OPERATOR && wtoken.param ==WeaselOperator.LESS) {
generic = new WeaselTreeGeneric(iterator);
token = iterator.previous();
if(generic.close){
throw new WeaselCompilerException(token.line, "Expect Ident but got >");
}
}else{
iterator.previous();
}
}
}else{
if(generic!=null && token.tokenType != WeaselTokenType.IDENT)
throw new WeaselCompilerException(token.line, "Expect ident after generic but got %s", token);
boolean isCast = false;
if(token.tokenType==WeaselTokenType.OPENBRACKET){
WeaselToken token2 = iterator.next();
String className = "";
if(token2.tokenType==WeaselTokenType.IDENT){
isCast = true;
className = (String)token2.param;
token2 = iterator.next();