for (int j = 0; j < appl.getArity(); j++) {
result.append(genNestedComparison(appl.getArgument(j),
termName, j, true));
}
} else if (pattern.getType() == ATerm.LIST) {
ATermList list = (ATermList) pattern;
if (list.isEmpty()) {
result.append(genIndentation() + "if (ATisEmpty((ATermList)"
+ termName + ")) " + genCompareFunctOpenBracket());
} else {
result.append(genIndentation() + "if (ATgetType((ATerm)"
+ termName + ") == AT_LIST && ATisEmpty((ATermList)"
+ termName + ") == ATfalse) "
+ genCompareFunctOpenBracket());
StringBuffer headName = new StringBuffer(termName + "_head");
StringBuffer tailName = new StringBuffer(termName + "_list");
StringBuffer headDecl = new StringBuffer(genIndentation()
+ "ATerm " + headName + ";" + newLine);
StringBuffer headDef = new StringBuffer(headName
+ " = ATgetFirst(" + tailName + ");" + newLine);
StringBuffer tailDecl = new StringBuffer(genIndentation()
+ "ATermList " + tailName + " = (ATermList)" + termName /* JURGEN */
+ ";" + newLine);
StringBuffer tailDef = new StringBuffer(tailName
+ " = ATgetNext(" + tailName + ");" + newLine);
StringBuffer tempResult = new StringBuffer();
StringBuffer checkHeadCode = new StringBuffer();
boolean headDeclared = false;
for (int j = 0; !list.isEmpty(); j++) {
String getHeadCode = genIndentation() + headDef;
String getTailCode = genIndentation() + tailDef;
checkHeadCode = genNestedComparison(list.getFirst(),
headName, j, false);
/*
* If the head contains a predefined type, it can be
* checked.
*/
if (checkHeadCode.length() > 0) {
if (!headDeclared) {
result.append(headDecl);
headDeclared = true;
}
tempResult.append(getHeadCode);
tempResult.append(getTailCode);
tempResult.append(checkHeadCode);
list = list.getNext();
/*
* If the last element of the list is a list placeholder
* then don't do any additional checking.
*/
if (!list.isEmpty()
&& list.getFirst().getType() == ATerm.PLACEHOLDER
&& (((ATermPlaceholder) list.getFirst())
.getPlaceholder()).getType() == ATerm.LIST
&& (list.getNext()).isEmpty()) {
break;
} else if (!list.isEmpty()) {
tempResult.append(genIndentation()
+ "if (ATgetType((ATerm)" + tailName
+ ") == AT_LIST && ATisEmpty((ATermList)"
+ tailName + ") == ATfalse) "
+ genCompareFunctOpenBracket());
} else { /* the list must be empty */
tempResult.append(genIndentation()
+ "if (ATgetType((ATerm)" + tailName
+ ") == AT_LIST && ATisEmpty((ATermList)"
+ tailName + ") == ATtrue) "
+ genCompareFunctOpenBracket());
}
} else {
list = list.getNext();
/*
* If the last element of the list is a list placeholder
* then don't do any additional checking.
*/
if (!list.isEmpty()
&& list.getFirst().getType() == ATerm.PLACEHOLDER
&& (((ATermPlaceholder) list.getFirst())
.getPlaceholder()).getType() == ATerm.LIST
&& (list.getNext()).isEmpty()) {
break;
} else if (!list.isEmpty()) {
tempResult.append(getTailCode);
tempResult.append(genIndentation()
+ "if (ATgetType((ATerm)" + tailName
+ ") == AT_LIST && ATisEmpty((ATermList)"