#-------------------------------------------------------------
#
# parse_format('format',$isis_row);
#

use isis_sf;

sub parse_format {
	my $format = shift;
	my $row = shift;

	my $out;
	my $out_swish;

	my $prefix = "";
	if ($format =~ s/^([^\d]+)//) {
		$prefix = "pre: $1";
	}

	my $display;
	my $swish;

	while ($format) {
#print STDERR "#### $format\n";
		if ($format =~ s/^(\d\d\d)(\w?)//) {
			my $isis_tmp = isis_sf($row,$1,$2);
			if ($isis_tmp) {
				$display .= $prefix . $isis_tmp;
				$swish .= $isis_tmp." ";
			}
			$prefix = "";
		} elsif ($format =~ s/^([^\d]+)(\d{0,3})/$2/) {
			$prefix .= $1;
		} elsif ($format =~ s/^([^\d]+\d{0,2})//) {
			$prefix .= $1;
		} elsif ($format =~ s/^(\d{1,2})//) {
			$prefix .= $1;
		} else {
			print STDERR "unparsed format: $format\n";
			$prefix .= $format;
			$format = "";
		}
	}
	# add suffix
	$display .= $prefix if ($display);

	return ($swish,$display);
}

#-------------------------------------------------------------
1;
