function extractSignature( str ) {
	var optional;
	var params;
	var param;
	var state;
	var name;
	var ch;
	var i;

	state = 'name';
	name = '';
	params = [];
	optional = false;
	for ( i = 0; i < str.length; i++ ) {
		ch = str.charAt( i );
		switch ( state ) {
		default:
		case 'name':
			if ( ch === '(' ) {
				state = 'params';
			} else {
				name += ch;
			}
			break;
		case 'params':
			if ( ch === ')' ) {
				if ( param && param.name !== '' ) {
					if ( startsWith( param.name, '...' ) ) {
						param.multiple = true;
						param.name = param.name.substr( 3 );
					}
					params.push( param );
				}
			}
			else if ( ch === '[' ) {
				optional = true;
			}
			else if ( ch === ']' ) {
				optional = false;
			}
			else if ( ch === ',' ) {
				if ( startsWith( param.name, '...' ) ) {
					param.multiple = true;
					param.name = param.name.substr( 3 );
				}
				params.push( param );
				param = null;
			} else if ( ch !== ' ' ) {
				if ( param ) {
					param.name += ch;
				} else {
					param = {
						'name': ch,
						'optional': optional
					};
				}
			}
		}
	}

	return {
		'name': name,
		'parameters': params,
		'raw': str
	};
}
Extracts the first function signature from the supplied string.

@private
@param {string} str - first line of a `repl.txt` function documentation
@returns {Object} function signature object with `name`, `parameters`, and `raw` keys