Saturday, December 16, 2006

The new release of phpAspect is coming soon

Since the end of the Google Summer of Code, it was a crazy time at school so I didn't had time to do a release of my work.
I have two weeks of holidays very soon, there will be dedicated to the release of phpAspect.
Basically, I need to clean up some piece of code and finish to write the documentation.
I'm very excited about this new release, I can't wait that you can play with the new joinpoints we designed and the logical engine we introduced.

Google Code Hosting just released two new cool features: A wiki and a download tab.
I intend to get full benefits from these features for phpAspect ;-)

Happy hollidays everybody !

Saturday, November 11, 2006

The Parse Tree generator

I put this form online so you can try the parse tree extension without installing it:http://phpaspect.org/ast.
You can upload your own php script and get the xml tree or the tree visualization in png format.

I also put a mini documentation on a wiki page: http://phpaspect.org/wiki/doku.php?id=parse_tree.

If you have any question regarding parse_tree, you can ping the googlegroups associated to it:php_parse_tree@googlegroups.com.

Thursday, November 9, 2006

Picture of GSoCers


Uros Trebec posted on his blog the picture of all the GSoCers present during the London Googleplex visit.

Sunday, October 29, 2006

Visit of the London Googleplex

Last friday I went to London to visiting the Google office with other GSoCers.First of all, I went to London to visit Google and I had no idea how great it would be to met other GSoCers. Everybody were nice, funny and very excited about theirs projects.

We had a nice lunch (with sushis, I love sushis !!!) and we had a round table with Chris Di Bona and Zaheda Bhorat where everyone did an self-introduction. It was a chance to know a little bit more about everybody and it also was a chance to see in what kind of studies we're all involved. Then we did the lightning talk presentations and we had a big chat about the Google Summer of Code: what was great, what went wrong, what is next, what could be improved etc.
A Googler came to talk to us about being an engineer at Google and we did a visit of the Office.

It was very enriching at so many level. I learned more about the Google work environment, what kind of relationship Google has with the Open source world, how awesome GSoCers are and it was also a great opportunity to know more about being an engineers at Google.

You can get the pdf version here.

Tuesday, October 3, 2006

Visualize the parse tree of a PHP source code

 wrote this xslt stylesheet to visualize the parse tree of a PHP source code.
The stylesheet can actually convert any XML tree to a graph in the dot format interpreted by Graphviz.

The code to vizualize nice parse tree with the PECL extension is the following:

//Loading the parse tree into a DOMDocument
$xml = new DOMDocument;
$xml->loadXML(parse_tree_from_file('order.php'), XML_OPTIONS);
//Loading the stylesheet into a DOMDocument
$xsl = new DOMDocument;
$xsl->load('toDot.xsl', XML_OPTIONS);
//Stylesheet processing
$proc = new XSLTProcessor;
$proc->importStyleSheet($xsl);
//Generating the image with graphviz
file_put_contents('order.dot', trim($proc->transformToXML($xml)));
`dot -T png -o order.png order.dot`
So if order.php contains the following source code:
class Order{
    private $items = array();
    private $amount = 0;
 
    public function addItem($reference, $quantity){
        $this->items[] = array($reference, $quantity);
        $this->amount += $quantity*Catalog::getPrice($reference);
    }
 
    public function getAmount(){
        return $this->amount;
    }
}
class Catalog{
    private static $priceList = array('Largo Winch' => 9.31, 'Astérix' => 8.46, 'XIII' => 8.70);
 
    public static function getPrice($reference){
        return self::$priceList[$reference];
    }
}
$myOrder = new Order;
$myOrder->addItem('Largo Winch',2);
$myOrder->addItem('Astérix',2);
You'll get the following tree:
To test this example at home, you need the Parse Tree pecl extension, an xslt proc and graphviz:
order.php is the original php file.
order.xml is the xml generated with the parse_tree_from_file function.
order.dot is the parse tree in dot format.
order.png is the png generated by graphviz.
toDot.xsl isthe stylesheet generating dot from xml.

Thursday, September 28, 2006

A Logo for phpAspect.



Fabien Nicollet created a logo for phpAspect:







Fabien is also a student at Telecom Lille and he does freelance work in design and graphics.
So if you need any work done in this field, don't hesitate to hire his talents ;-)

Thank you, Fabien!

Thursday, August 31, 2006

phpAspect presented at the EPFL

Last week I was invited by Christelle Vangenot to talk about phpAspect with Philippe Rochat and some of the new features I developed during the Google Summer of code.

The slides are availables at this address: http://phpaspect.org/conferences/poa_epfl.pdf

I'll make a futher post on this blog to talk about the end of the Google soc and the new version of phpAspect which should be released soon.

Tuesday, June 20, 2006

PHP source code analysis: PHPCompiler versus Yaxx

The original PHP compiler doesn’t use AST representation of a source code so in the previous versions of phpAspect I had to fill the php grammar with my own AST constructions. It was a painful job and moreover I had to do it in each major version of PHP. For this new version, I'm using the yaxx project written by Dr. Yijun Yu. The yaxx tool is a yacc skeleton which build an xml ast representation of a source code according to his grammar.
For example, the following php source code:


We will obtain the following Tree (with the php lexer & grammar in input):


Using this compiler structure, the common visitors of a traditional compiler becomes xslt style sheet. A toEval visitor becomes a toEval xslt style sheet etc... I already wrote a very simple toWrite visitor which just take care of writing the text into tokens.

The hardest part is now to perform weaving using xslt and the main limitation is that xslt variables are constants.

I keep you in touch ;o)

Friday, June 16, 2006

Gregor Kiczales @ Google

I found on Google Video an very interesting conference about AOP given by Gregor Kiczales himself at Google.

Link for the video: http://video.google.com/videoplay?docid=8566923311315412414

For those which do not know Gregor Kiczales, he is one of the major founder of aspect-oriented programming

Popout

Thursday, June 8, 2006

Using XML Representations of a PHP parse Tree

The original PHP compiler doesn’t use AST representation of a source code so in the previous versions of phpAspect I had to fill the php grammar with my own AST constructions. It was a painful job and moreover I had to do it in each major version of PHP. For this new version, I'm using the yaxx project written by Dr. Yijun Yu. The yaxx tool is a yacc skeleton which build an xml ast representation of a source code according to his grammar.
For example, the following php source code:


We will obtain the following Tree (with the php lexer & grammar in input):


Using this compiler structure, the common visitors of a traditional compiler becomes xslt style sheet. A toEval visitor becomes a toEval xslt style sheet etc... I already wrote a very simple toWrite visitor which just take care of writing the text into tokens.

The hardest part is now to perform weaving using xslt and the main limitation is that xslt variables are constants.

I keep you in touch ;o)

Wednesday, June 7, 2006

Welcome to this blog

Hello !
This is going to be my journal for the Google Summer of code 2006. I'll publish my work advances here.
You can find my proposal here.
Sebastian Bergmann is my mentor and it's really a pleasure because he has both php and aop experience with projects like PHPUnit and aspectPHP. Moreover we get along very well.
The project is a new version of phpAspect written in C and using XSLT process to perform source code transformation:
Adopting this new approach will result in the following benefits. The lexical and syntax analysis will be independent of any PHP version. Existing XML tools like XSTL or XPath engine could be heavily reused to make the implementation significantly shorter and improve weaving performances.
Finally, it will introduce more flexibility in terms of the aspect language. For example, I could use the power of Xpath expression to introduce more logical operators in the aspect syntax. With this architecture, the compatibility with PHP 6 and features like namespaces will be very easy to implement.
If you have any question about the phpAspect project for the SoC, just let me know: wcandillon at gmail dot comor phpaspect at googlegroups dot com

Friday, June 2, 2006

Books of summer

I received yesterday the book of Sara Golemon, "Extending and Embedding PHP". It's an excellent resource if you want to build your own PHP extension in C/C++. I just finished to wrote mine tonight but I will tell you more about this in a further bill.

For the google summer of code I also use two very usefull books. "Learning XSLT" at O'reilly which is a very good reference about XSLT and "C Pocket Reference" which help me when I don't remember about C functions and stuff.
And of course, I always have my "AspectJ in action" with me...

There is also Google Books, it's a very great tool if you want to consult some cookbook about about a programming subject for example.


You can of course buy all these books on Amazon: