/** * Parses a character separated list of instructions or null if the * sequence is not valid * * @param callable $fn Parsing instruction function * @param array $args Arguments that will be passed to the function * @param string $char Separator * * @return array * * @throws Exception */ protected function charSeparatedListOf($fn, $args = array(), $char = ",") { $list = array(); $valid = true; while ($param = call_user_func_array(array($this, $fn), $args)) { $list[] = $param; $valid = true; if (!$this->scanner->consume($char)) { break; } else { $valid = false; } } if (!$valid) { return $this->error(); } return $list; }