Source:
private IDeclaration parseTypeDeclarator(CommonTree typeDeclarator, CommonTree typeSpecifierList, StringBuilder identifierSB) throws ParseException { IDeclaration declaration = null; List<CommonTree> children = null; List<CommonTree> pointers = new LinkedList<CommonTree>(); List<CommonTree> lengths = new LinkedList<CommonTree>(); CommonTree identifier = null; if (typeDeclarator != null) { children = typeDeclarator.getChildren(); for (CommonTree child : children) { switch (child.getType()) { case CTFParser.POINTER: pointers.add(child); break; case CTFParser.IDENTIFIER: identifier = child; break; case CTFParser.LENGTH: lengths.add(child); break; default: childTypeError(child); break; } } } declaration = parseTypeSpecifierList(typeSpecifierList, pointers); if (lengths.size() > 0) { Collections.reverse(lengths); for (CommonTree length : lengths) { List<CommonTree> lengthChildren = length.getChildren(); CommonTree first = lengthChildren.get(0); if (isUnaryInteger(first)) { int arrayLength = (int) parseUnaryInteger(first); if (arrayLength < 1) { throw new ParseException("Array length is negative"); } declaration = new ArrayDeclaration(arrayLength, declaration); } else if (isAnyUnaryString(first)) { String lengthName = concatenateUnaryStrings(lengthChildren); if (!isIsUnsignedIntegerField(lengthName)) { throw new ParseException("Sequnce declared with length that is not an unsigned integer"); } declaration = new SequenceDeclaration(lengthName, declaration); } else { childTypeError(first); } } } if (identifier != null) { identifierSB.append(identifier.getText()); } return declaration; }

Target:
private IDeclaration parseTypeDeclarator(CommonTree typeDeclarator, CommonTree typeSpecifierList, StringBuilder identifierSB) throws ParseException { IDeclaration declaration = null; List<CommonTree> children = null; List<CommonTree> pointers = new LinkedList<CommonTree>(); List<CommonTree> lengths = new LinkedList<CommonTree>(); CommonTree identifier = null; if (typeDeclarator != null) { children = typeDeclarator.getChildren(); for (CommonTree child : children) { switch (child.getType()) { case CTFParser.POINTER: pointers.add(child); break; case CTFParser.IDENTIFIER: identifier = child; break; case CTFParser.LENGTH: lengths.add(child); break; default: childTypeError(child); break; } } } declaration = parseTypeSpecifierList(typeSpecifierList, pointers); if (lengths.size() > 0) { Collections.reverse(lengths); for (CommonTree length : lengths) { List<CommonTree> lengthChildren = length.getChildren(); CommonTree first = lengthChildren.get(0); if (isUnaryInteger(first)) { int arrayLength = (int) parseUnaryInteger(first); if (arrayLength < 1) { throw new ParseException("Array length is negative"); } declaration = new ArrayDeclaration(arrayLength, declaration); } else if (isAnyUnaryString(first)) { String lengthName = concatenateUnaryStrings(lengthChildren); if (!isIsUnsignedIntegerField(lengthName)) { throw new ParseException("Sequence declared with length that is not an unsigned integer"); } declaration = new SequenceDeclaration(lengthName, declaration); } else { childTypeError(first); } } } if (identifier != null) { identifierSB.append(identifier.getText()); } return declaration; }