summaryrefslogtreecommitdiff
path: root/poc/poc02-compiling-cake/src/php-weave/main.php
diff options
context:
space:
mode:
authorLudovic Pouzenc <ludovic@pouzenc.fr>2012-08-01 20:24:03 +0000
committerLudovic Pouzenc <ludovic@pouzenc.fr>2012-08-01 20:24:03 +0000
commit104ff522c43fabc7c284fc38a46d17c16fe114d1 (patch)
tree5d1369301bef4bb198172a5ff167006a3d3c3d0a /poc/poc02-compiling-cake/src/php-weave/main.php
parentf435a514cd0597108cec95b5febdc105b0e16302 (diff)
download2012-php-weave-104ff522c43fabc7c284fc38a46d17c16fe114d1.tar.gz
2012-php-weave-104ff522c43fabc7c284fc38a46d17c16fe114d1.tar.bz2
2012-php-weave-104ff522c43fabc7c284fc38a46d17c16fe114d1.zip
Ecriure d'un squelette de l'outil de compilation. Une première instance sera implémentée pour le framework CakePHP.
Pour l'instant les méthodes abstraites sont des bouchons qui ne permettent même pas de couvrir tout le code de la classe abstraite. git-svn-id: file:///var/svn/2012-php-weave/trunk@5 d972a294-176a-4cf9-8ea1-fcd5b0c30f5c
Diffstat (limited to 'poc/poc02-compiling-cake/src/php-weave/main.php')
-rw-r--r--poc/poc02-compiling-cake/src/php-weave/main.php62
1 files changed, 4 insertions, 58 deletions
diff --git a/poc/poc02-compiling-cake/src/php-weave/main.php b/poc/poc02-compiling-cake/src/php-weave/main.php
index 2a4df55..da94bbe 100644
--- a/poc/poc02-compiling-cake/src/php-weave/main.php
+++ b/poc/poc02-compiling-cake/src/php-weave/main.php
@@ -1,64 +1,10 @@
<?php
-require '../vendor/nikic/php-parser/lib/bootstrap.php';
-require './visitors.inc.php';
+require_once './cakephp_weaver.class.php';
ini_set('xdebug.max_nesting_level', 2000);
-function dbg($indent, $text) {
- for($i=0;$i<$indent;$i++) echo ".";
- echo "$text\n";
-}
-
-function recursive_parse($src_filepath, $stmts1_filepath, $stmts2_filepath, $level=0) {
- global $parser,$nodeDumper;
-
- try {
- dbg($level,"Parsing '$src_filepath'");
- $stmts = $parser->parse(file_get_contents($src_filepath));
-
- if (strlen($stmts1_filepath) > 0 ) {
- dbg($level,"Dumping1 '$src_filepath' AST to '$stmts1_filepath'");
- file_put_contents($stmts1_filepath, $nodeDumper->dump($stmts));
- }
-
- dbg($level,"Transforming '$src_filepath'");
- $traverser = new PHPParser_NodeTraverser;
-/*
- $traverser->addVisitor(new PHPParser_NodeVisitor_NameResolver);
- $traverser->addVisitor(new NodeVisitor_NamespaceConverter);
-*/
- // FIXME : getcwd is quick and dirty here
- $traverser->addVisitor(new NodeVisitor_PreprocessInclude($level, getcwd(), $src_filepath));
- $stmts = $traverser->traverse($stmts);
- $traverser=null; //Destroy
-
- if (strlen($stmts2_filepath) > 0) {
- dbg($level,"Dumping2 '$src_filepath' AST to '$stmts2_filepath'");
- file_put_contents($stmts2_filepath, $nodeDumper->dump($stmts));
- }
-
- } catch (PHPParser_Error $e) {
- echo 'Parse Error: ', $e->getMessage();
- }
- return $stmts;
-}
-
-
// Main
-$src_filepath = "./main.php";
-#$src_filepath = "./to_parse.php";
-$stmts1_filepath = "out/stmts1.ast";
-$stmts2_filepath = "out/stmts2.ast";
-$dest_filepath = "out/result.php";
-
-$parser = new PHPParser_Parser(new PHPParser_Lexer);
-$nodeDumper = new PHPParser_NodeDumper;
-
-$level=0;
-$stmts=recursive_parse($src_filepath, $stmts1_filepath, $stmts2_filepath);
-
-dbg(0,"Outputing '$dest_filepath'");
-$prettyPrinter = new PHPParser_PrettyPrinter_Zend;
-file_put_contents($dest_filepath, "<?php\n" . $prettyPrinter->prettyPrint($stmts) . "\n?>");
-
+$weaver=new CakePHPWeaver;
+$weaver->runAllSteps("../workdir/in", "../workdir/cache", "../workdir/out");
+
?>