Thus, if I were to write a centered paragraph of HTML text, I could either do:

echo "<p align=\"center\">Hello World!</p>";


<p {
    & align "center";
    ? "Hello World!";

I am giving examples in HTML so that I don't need to explain the meaning or usage of the tags. When I wrote this into my editor, the highlighting didn't come out right on some parts of it and the 'code insight' feature (the one that suggests what's next) was somewhat confused, but the code beautifier indented everything nicely and the brace matching worked perfectly as well.

More complex examples worked just as well:

<table for ( $i=1; $i < 10; $i++) {
    <div {
        &style = ($i & 1?"odd":"even");
        <tr {
            <td ?  'data for column one, row: ' , $i;
            <td {               
                 &align 'right';
                 ?  "data for column two, row: " , $i;

Notice that in this example I am using both the <, & and ? symbols in their two meanings, as their regular PHP use of 'less than', 'bitwise and' and 'conditional operator' and as their extended meanings. I am also mixing XML blocks with control flow blocks and I am enclosing some blocks with braces, others not. PHP also accepts single and double quotes to enclose strings, and I used both, the pre-compiler will always use double quotes for attribute values and even escape un-escaped quotes within them.

Since a statement can be empty, a line break (<br />) could be simply be written as:

< br;

or an extra wide horizontal line as:

<hr &size = 10;

There can be spaces in between the < and & symbols and the names and the = sign for the attribute argument is optional.

A most simple heading could be:

<h1 ? 'AT & T';

in which the ? instruction will escape the & sign and output 'AT &amp; T'.

On the other hand, the following is invalid

<p {
    ? "Hello World!";
    & align "center"; // error

The ? instruction would force the <p> tag to be closed so the attribute will produce an error. The precompiler tries to leave start tags open (ie. <p ) as long as possible but any output instruction makes it assume there are no further attributes within the opening tag.

A further working sample can be found at po.pht, a sample program to build a purchase order. The pre-compiled result can be seen in po.php, and a sample run of it at po.xml. The purchase order was modeled from the XML schema po.xsd though it had some additions to test some features of the pre-compiler.

< Previous: Introduction


Next: Formal Definition >