private function ExtractEnumerations(\DOMDocument $document, $namespace = "")
    {
        $xpath = new DOMXPath($document);

        $entries = $xpath->evaluate(
            "//compound[@kind='file'] | //compound[@kind='namespace']", 
            $document
        );

        for($i = 0; $i < $entries->length; $i++)
        {
            $kind = $entries->item($i)->getAttribute("kind");
            $refid = $entries->item($i)->getAttribute("refid");
            $name = $entries->item($i)->childNodes->item(0)->nodeValue;

            if($kind == "namespace")
                $namespace = str_replace("::", "\\", $name);
            else
                $namespace = "\\";

            $file_doc = new DOMDocument();
            $file_doc->load($this->definitions_path . "/$refid.xml");

            $file_xpath = new DOMXPath($file_doc);

            $file_members = $file_xpath->evaluate(
                "//memberdef[@kind='enum']", 
                $file_doc
            );

            for($member = 0; $member < $file_members->length; $member++)
            {
                $location = str_replace(
                    $this->headers_path, 
                    "", 
                    str_replace(
                        "\\", 
                        "/", 
                        $file_xpath->evaluate(
                            "location", 
                            $file_members->item($member)
                        )->item(0)->getAttribute("file")
                    )
                );

                $enum_name = $file_xpath->evaluate(
                    "name", 
                    $file_members->item($member)
                )->item(0)->nodeValue;
                
                $enum_description = $file_xpath->evaluate(
                    "briefdescription", 
                    $file_members->item($member)
                )->item(0)->nodeValue;

                // Just extract named enumerations
                // Anonymous enumerations go on constants.json
                if($enum_name{0} != "@")
                {
                    $enum_values = $file_xpath->evaluate(
                        "enumvalue", 
                        $file_members->item($member)
                    );
                    
                    $enum_options = array();

                    for(
                        $enum_value = 0; 
                        $enum_value < $enum_values->length; 
                        $enum_value++
                    )
                    {
                        $enum_options[] = $file_xpath->evaluate(
                            "name", 
                            $enum_values->item($enum_value)
                        )->item(0)->nodeValue;
                    }
                    
                    $enumeration = new \Peg\Lib\Definitions\Element\Enumeration(
                        $enum_name,
                        $enum_options,
                        $enum_description
                    );
                    
                    $this->symbols->AddEnumeration(
                        $enumeration, 
                        $location, 
                        $namespace
                    );
                }
            }
        }
    }