data = [ "oid" => null, "names" => [], "desc" => null, "sups" => [], "type" => null, "musts" => null, "mays" => null, ]; } function parse(?string $s=null): array { if ($s !== null) $this->s = $s; $data = $this->reset(); $this->skipLiteral('('); $data["oid"] = self::fix_oid($this->parseName()); while ($this->isName()) { $okey = $this->parseName(); $key = str_replace("-", "_", strtolower($okey)); switch ($key) { case "name": $data["${key}s"] = $this->parseStrings(); break; case "sup": case "must": case "may": $data["${key}s"] = $this->parseNames(); break; case "desc": $data[$key] = $this->parseString(); break; case "abstract": case "structural": case "auxiliary": $data["type"] = $key; break; default: log::warning("unknown key $okey in |$s|"); $data["unknown_keys"][] = $okey; break; } } $this->skipLiteral(')'); # puis mettre à jour les valeurs booléennes foreach (self::BOOL_ATTRS as $name) { $data[$name] = boolval($data[$name]); } return $data; } }