public static Argument merge(int symbol, List<Argument> arguments) {
        AgBuffer buffer;
        List<AgBuffer> argBuffers;
        int i;
        int max;
        Attribute start;
        Argument arg;
        Type mergedType;
        int card;
        List<Definition> resultingSources;

        max = arguments.size();
        if (max == 0) {
            throw new IllegalArgumentException();
        }
        argBuffers = new ArrayList<>();
        mergedType = null;
        resultingSources = new ArrayList<>();
        for (i = 0; i < max; i++) {
            arg = arguments.get(i);
            resultingSources.addAll(arg.sources);
            if (arg == null) {
                throw new IllegalStateException();
            }
            argBuffers.add(arg.copyBuffer);
            if (mergedType == null) {
                mergedType = arg.attr.type;
            } else {
                mergedType = mergedType.alternate(arg.attr.type);
            }
        }
        if (mergedType == null) {
            throw new IllegalStateException();
        }
        // compute with card SEQUENCE. TODO: very expensive
        buffer = new AgBuffer((Attribute) null);
        start = buffer.merge(argBuffers, symbol, new Type(mergedType.type, Type.SEQUENCE));
        card = buffer.calcCard(start);
        buffer = new AgBuffer((Attribute) null);
        // TODO: duplicate computation ...
        start = buffer.merge(argBuffers, symbol, new Type(mergedType.type, card));
        buffer.setStart(start);
        return new Argument(Path.ISOLATED, buffer, resultingSources);
    }
public static Argument merge ( int symbol , List < Argument > arguments ) { AgBuffer buffer ; List < AgBuffer > argBuffers ; int i ; int max ; Attribute start ; Argument arg ; Type mergedType ; int card ; List < Definition > resultingSources ; max = arguments . size ( ) ; if ( max == 0 ) { throw new IllegalArgumentException ( ) ; } argBuffers = new ArrayList < > ( ) ; mergedType = null ; resultingSources = new ArrayList < > ( ) ; for ( i = 0 ; i < max ; i ++ ) { arg = arguments . get ( i ) ; resultingSources . addAll ( arg . sources ) ; if ( arg == null ) { throw new IllegalStateException ( ) ; } argBuffers . add ( arg . copyBuffer ) ; if ( mergedType == null ) { mergedType = arg . attr . type ; } else { mergedType = mergedType . alternate ( arg . attr . type ) ; } } if ( mergedType == null ) { throw new IllegalStateException ( ) ; } buffer = new AgBuffer ( ( Attribute ) null ) ; start = buffer . merge ( argBuffers , symbol , new Type ( mergedType . type , Type . SEQUENCE ) ) ; card = buffer . calcCard ( start ) ; buffer = new AgBuffer ( ( Attribute ) null ) ; start = buffer . merge ( argBuffers , symbol , new Type ( mergedType . type , card ) ) ; buffer . setStart ( start ) ; return new Argument ( Path . ISOLATED , buffer , resultingSources ) ; }
Merge list of arguments.
pre: list.size() &gt; 0 and all arguments have to start with the same attribute