[phc-general] pretty php request
Edsko de Vries
edsko at phpcompiler.org
Wed Oct 10 21:44:10 CEST 2007
Hi Arkadiy,
> I have 2 requests, if that is possible:
> 1. Add an option to remove the leading tab (the first one at the
> beginning of the line).
This was an easy one, so I have added this option. It is called
--no-leading-tab.
> 2. I have a problem with all brackets "{" and "}" starting at a new
> line, so {snip}
In fact, the unparser already does this, but you must not use the latest
official release but download the latest ("cutting edge" :-) revision
from the repository (instructions at http://code.google.com/p/phc/source).
By default, the unparser now outputs brackets on the same line:
$ src/phc --pretty-print test.php
<?php
if ($x) {
echo "hi";
} else {
echo "foo";
}
?>
It is possible to change that for people such as myself who prefer them on the
next line :)
$ src/phc --pretty-print --next-line-curlies test.php
<?php
if ($x)
{
echo "hi";
}
else
{
echo "foo";
}
?>
And now with the new --no-leading-tab option:
$ src/phc --pretty-print --no-leading-tab test.php
<?php
if ($x) {
echo "hi";
} else {
echo "foo";
}
?>
As per your request :)
As Paul mentioned, though, the unparser in the latest revision will *not*
reorder your script. Functions will be declared exactly where you declare them.
If you don't like that, you must write a plugin (this is not difficult to do if
you know C++; plugin writing is described in detail at www.phpcompiler.org/doc
-- unfortunately, that documentation is slightly out of date with the latest
revision in the repository (it's been a long time since we released because we
are working on code generation). However, if you read those tutorials and then
have a look at the example plugins in the repository (in plugins/tutorials),
you should be able to work it out easily enough -- of course, you can always
ask questions here.
Hope this helps,
Edsko
More information about the phc-general
mailing list