protected void parseIntegerLists(TokenList tokens) {
        TokenList.Token t = tokens.getFirst();
        if( t == null || t.next == null )
            return;

        int state = 0;

        TokenList.Token start = null;
        TokenList.Token prev = t;

        boolean last = false;
        while( true ) {
            if( state == 0 ) {
                if( isVariableInteger(t) ) {
                    start = t;
                    state = 1;
                }
            } else if( state == 1 ) {
                // var ?
                if( isVariableInteger(t)) {                 // see if its explicit number sequence
                    state = 2;
                } else {  // just scalar integer, skip
                    state = 0;
                }
            } else if ( state == 2 ) {
                // var var ....
                if( !isVariableInteger(t) ) {
                    // create explicit list sequence
                    IntegerSequence sequence = new IntegerSequence.Explicit(start,prev);
                    VariableIntegerSequence varSequence = functions.getManagerTemp().createIntegerSequence(sequence);
                    replaceSequence(tokens, varSequence, start, prev);
                    state = 0;
                }
            }

            if( last ) {
                break;
            } else if( t.next == null ) {
                // handle the case where it is the last token in the sequence
                last = true;
            }
            prev = t;
            t = t.next;
        }
    }
protected void parseIntegerLists ( TokenList tokens ) { TokenList . Token t = tokens . getFirst ( ) ; if ( t == null || t . next == null ) return ; int state = 0 ; TokenList . Token start = null ; TokenList . Token prev = t ; boolean last = false ; while ( true ) { if ( state == 0 ) { if ( isVariableInteger ( t ) ) { start = t ; state = 1 ; } } else if ( state == 1 ) { if ( isVariableInteger ( t ) ) { state = 2 ; } else { state = 0 ; } } else if ( state == 2 ) { if ( ! isVariableInteger ( t ) ) { IntegerSequence sequence = new IntegerSequence . Explicit ( start , prev ) ; VariableIntegerSequence varSequence = functions . getManagerTemp ( ) . createIntegerSequence ( sequence ) ; replaceSequence ( tokens , varSequence , start , prev ) ; state = 0 ; } } if ( last ) { break ; } else if ( t . next == null ) { last = true ; } prev = t ; t = t . next ; } }
Searches for a sequence of integers

example:
1 2 3 4 6 7 -3