private function SaveTypeDefToPHP()
    {
        $output_file = fopen(
            $this->definitions_path . "type_definitions.php", 
            "w"
        );
        
        fwrite($output_file, "<?php\n\n");
        
        fwrite($output_file, "use Peg\Lib\Definitions\Element\TypeDef;\n");
        
        foreach($this->symbols->headers as $header)
        {
            if(!$header->HasTypeDefs())
                continue;
            
            foreach($header->namespaces as $namespace)
            {
                if(!$namespace->HasTypeDefs())
                    continue;
                
                foreach($namespace->type_definitions as $typedef)
                {
                    $type = addslashes($typedef->original_type);
                    $description = addslashes($typedef->description);
                    $namespace_name = addslashes($namespace->name);
                    
                    $output = "\n";
                    $output .= '$symbols->AddTypeDef(' . "\n";
                    $output .= '    new TypeDef(' . "\n";
                    $output .= '        "'.$typedef->name.'",' . "\n";
                    $output .= '        "'.$type.'",' . "\n";
                    $output .= '        "'.$description.'"' . "\n";
                    $output .= '    ),' . "\n";
                    $output .= '    "'.$header->name.'",' . "\n";
                    $output .= '    "'.$namespace_name.'"' . "\n";
                    $output .= ');' . "\n";
                    
                    fwrite($output_file, $output);
                }
            }
        }
        
        fclose($output_file);
    }
private function SaveTypeDefToPHP()
    {
        $output_file = fopen(
            $this->definitions_path . "type_definitions.php", 
            "w"
        );
        
        fwrite($output_file, "<?php\n\n");
        
        fwrite($output_file, "use Peg\Lib\Definitions\Element\TypeDef;\n");
        
        foreach($this->symbols->headers as $header)
        {
            if(!$header->HasTypeDefs())
                continue;
            
            foreach($header->namespaces as $namespace)
            {
                if(!$namespace->HasTypeDefs())
                    continue;
                
                foreach($namespace->type_definitions as $typedef)
                {
                    $type = addslashes($typedef->original_type);
                    $description = addslashes($typedef->description);
                    $namespace_name = addslashes($namespace->name);
                    
                    $output = "\n";
                    $output .= '$symbols->AddTypeDef(' . "\n";
                    $output .= '    new TypeDef(' . "\n";
                    $output .= '        "'.$typedef->name.'",' . "\n";
                    $output .= '        "'.$type.'",' . "\n";
                    $output .= '        "'.$description.'"' . "\n";
                    $output .= '    ),' . "\n";
                    $output .= '    "'.$header->name.'",' . "\n";
                    $output .= '    "'.$namespace_name.'"' . "\n";
                    $output .= ');' . "\n";
                    
                    fwrite($output_file, $output);
                }
            }
        }
        
        fclose($output_file);
    }
private function SaveTypeDefToPHP ( ) { $ output_file = fopen ( $ this -> definitions_path . "type_definitions.php" , "w" ) ; fwrite ( $ output_file , "<?php\n\n" ) ; fwrite ( $ output_file , "use Peg\Lib\Definitions\Element\TypeDef;\n" ) ; foreach ( $ this -> symbols -> headers as $ header ) { if ( ! $ header -> HasTypeDefs ( ) ) continue ; foreach ( $ header -> namespaces as $ namespace ) { if ( ! $ namespace -> HasTypeDefs ( ) ) continue ; foreach ( $ namespace -> type_definitions as $ typedef ) { $ type = addslashes ( $ typedef -> original_type ) ; $ description = addslashes ( $ typedef -> description ) ; $ namespace_name = addslashes ( $ namespace -> name ) ; $ output = "\n" ; $ output .= '$symbols->AddTypeDef(' . "\n" ; $ output .= '    new TypeDef(' . "\n" ; $ output .= '        "' . $ typedef -> name . '",' . "\n" ; $ output .= '        "' . $ type . '",' . "\n" ; $ output .= '        "' . $ description . '"' . "\n" ; $ output .= '    ),' . "\n" ; $ output .= '    "' . $ header -> name . '",' . "\n" ; $ output .= '    "' . $ namespace_name . '"' . "\n" ; $ output .= ');' . "\n" ; fwrite ( $ output_file , $ output ) ; } } } fclose ( $ output_file ) ; }
Save typedef symbols into a type_definitions.php file.
Save typedef symbols into a type_definitions . php file .