public function parse($resource, $output)
    {
        printf('file %s' . PHP_EOL, $resource);

        $pathinfo = pathinfo($resource);
        $extension = $pathinfo['extension'];

        $this->environment->setSourceFile($resource);

        $parser = $this->configuration->getParserForFileExtension($extension);

        if (!$parser instanceof ParserInterface) {
            throw new \Exception('No parser found. Have you initialized any plugins?');
        }

        if ($parser instanceof HasEnvironmentInterface) {
            $parser->setEnvironment($this->environment);
        }

        $content = $parser->parse($resource);
        $output  = $parser->getOutputFilename($output);
        file_put_contents($output, $content);
    }