/** * Decodes a NEON string. * @param string * @return mixed */ public static function decode($input) { if (!is_string($input)) { throw new InvalidArgumentException("Argument must be a string, " . gettype($input) . " given."); } if (!self::$re) { self::$re = '~(' . implode(')|(', self::$patterns) . ')~Ami'; } $parser = new self(); $parser->tokenize($input); $res = $parser->parse(0); while (isset($parser->tokens[$parser->n])) { if ($parser->tokens[$parser->n][0] === "\n") { $parser->n++; } else { $parser->error(); } } return $res; }