/** * Generates the PHP Classes from a pcg file * * @param string $path * @param string $filename */ protected function generate($path, $filename) { $generator = new ClassGenerator(); $generator->generate(file_get_contents($filename)); $fqcn = $generator->getClassBuilder()->getClass(); $compiler = new Compiler(); $class = $compiler->parseClassName($fqcn); $path = $this->createDirFromNamespace($path, $class['namespace']); $output = $path . '/' . $class['classname'] . '.php'; $generator->write($output); }
/** * Generate a PHP class from .pcg content * * @param string $document * * @return ClassGenerator */ public function generate($document) { $lexer = new Lexer(); $tokenStream = $lexer->tokenize($document); $tokenParser = new TokenParser(); $nodeStream = $tokenParser->parse($tokenStream); $nodeParser = new NodeParser(); $this->classBuilder = $nodeParser->parse($nodeStream); $compiler = new Compiler($this->options); $this->streamWriter = $compiler->compile($this->classBuilder); return $this; }