public Token peek ( ) { if ( ! splitTokens . isEmpty ( ) ) { return splitTokens . peek ( ) ; } final var value = stringIterator . peek ( ) ; if ( argumentEscapeEncountered ) { return new ArgumentToken ( value ) ; } if ( Objects . equals ( value , argumentTerminator ) ) { return new ArgumentToken ( value ) ; } if ( argumentTerminator != null ) { return new ArgumentToken ( value ) ; } if ( isArgumentEscape ( value ) ) { argumentEscapeEncountered = true ; return peek ( ) ; } if ( isSwitch ( value ) ) { if ( isShortSwitchList ( value ) ) { var tokens = splitSwitchTokens ( value ) ; return tokens . get ( 0 ) ; } else { return new SwitchToken ( value . substring ( 2 ) , value ) ; } } else { return new ArgumentToken ( value ) ; } }
this is a mess - need to be cleaned up