1 * * 1 ------------------------[ , ]------------------------> 0 * 1 -----------------------[ else ]----------------------> (END) * * @var int */ $state = 0; for (; $list->idx < $list->count; ++$list->idx) { /** * Token parsed at this moment. * * @var Token */ $token = $list->tokens[$list->idx]; // End of statement. if ($token->type === Token::TYPE_DELIMITER) { break; } // Skipping whitespaces and comments. if (($token->type === Token::TYPE_WHITESPACE) || ($token->type === Token::TYPE_COMMENT)) { continue; } // No keyword is expected. if (($token->type === Token::TYPE_KEYWORD) && ($token->flags & Token::FLAG_KEYWORD_RESERVED)) { break; } if ($state === 0) { if ($token->value === '(') { $arr = ArrayObj::parse($parser, $list, $options); $arrCount = count($arr->values); if ($count === -1) { $count = $arrCount; } elseif ($arrCount != $count) { $parser->error( sprintf( Translator::gettext('%1$d values were expected, but found %2$d.'), $count, $arrCount ), $token ); } $ret[] = $arr; $state = 1; } else { break; } } elseif ($state === 1) { if ($token->value === ',') { $state = 0; } else { break; } } } if ($state === 0) { $parser->error( 'An opening bracket followed by a set of values was expected.', $list->tokens[$list->idx] ); } --$list->idx; return $ret; } /** * @param ArrayObj[] $component the component to be built * @param array $options parameters for building * * @return string */ public static function build($component, array $options = array()) { return ArrayObj::build($component); } }