quirk is a programming language which is implemented in and compiles to PHP. It is meant as an advanced templating system for one of my website systems (a system which this site is based on). quirk is meant to provide easy access to slinki, the database system used by the website. quirk is always spelled with a lower-case q, even if it is the first word in a sentence. Its name comes from some quirks in it (or at least, quirks which used to be in it, as several have been ironed out), and when referring to its quirkiness, quirki should be spelled with an i at the end.
The compilation of quirk is in itself a bit quirki. It uses a tokenizer, but one which I created by hand, and which is probably a bit different than other tokenizers. The token stream is completely flat - it is not a tree. The compilation process is two-pass: tokenization, and then compilation.
Some example code (and its compiled PHP code) is below. It is actually the code for the "blog in images" and "recent gallery additions" which are on the left hand side of the site (in what I call the "dashboard"). I picked this code because of its cleanliness: since no editing occurs in these areas, there are no editing controls, which sometimes gunk up the code a bit.
quirki: (Code written in quirk)
<li class = "dashboard-module dashboard-images-module">
<h2>{:$ $title}</h2>
<ul class = "dashboard-image-grid">
<!-- {:
@ $gallery {"children" as "$child" count 9 order by "create-date" desc} [
$path = "";
$img = "/templates/jiskander/images/err.jpg";
($child isfile) then [
$child {"day-node"} store $daynode;
$child {"create-date"} store $date;
$path = ("/" . $ $area . "/" . $date format "Y/m/d/" . $daynode getpath $child);
$img = ($path . "/:thumb:256");
}-->
<li><a href = "{:$path}" ><img src = "{:$img}" class = "{: $child filetype; }" alt = "{: $child value}" /></a></li>
<!-- {:
];
];
} -->
</ul>
<div class = "dashboard-module-footer"></div>
</li>
PHP:
<?php ?><li class = "dashboard-module dashboard-images-module">
<h2><?php echo $objects['$title'];?></h2>
<ul class = "dashboard-image-grid">
<?php if (isset($objects['iterator_0_iterator_stack'])) array_push($objects['_iterator_0_iterator_stack'],$objects['_iterator_0_iterator']);else $objects['_iterator_0_iterator_stack'] = array('');$objects['_iterator_0_iterator'] = $objects['$gallery']->getItems(true, 'children',array("field"=>'create-date',"direction"=>"DESC"),false,9);foreach ($objects['_iterator_0_iterator'] as $objects['$child']){$objects['_iterator_0_ids']=$objects['$child']->id;$objects['$path'] = '';$objects['$img'] = '/templates/jiskander/images/err.jpg';$last_condition = ( (base::confirm("file","exists",array("item"=>$objects['$child']))));if (( (base::confirm("file","exists",array("item"=>$objects['$child']))))) {if (isset($objects['iterator_1_iterator_stack'])) array_push($objects['_iterator_1_iterator_stack'],$objects['_iterator_1_iterator']);else $objects['_iterator_1_iterator_stack'] = array('');$objects['_iterator_1_iterator'] = $objects['$child']->getItems(true, 'day-node',false,false,false);foreach ($objects['_iterator_1_iterator'] as $objects['_iterator_1_vals']){$objects['_iterator_1_ids']=$objects['_iterator_1_vals']->id;$objects['$daynode']=$objects['_iterator_1_vals'];}$objects['_iterator_1_iterator'] = array_pop($objects['_iterator_1_iterator_stack']);if (isset($objects['iterator_2_iterator_stack'])) array_push($objects['_iterator_2_iterator_stack'],$objects['_iterator_2_iterator']);else $objects['_iterator_2_iterator_stack'] = array('');$objects['_iterator_2_iterator'] = $objects['$child']->getItems(true, 'create-date',false,false,false);foreach ($objects['_iterator_2_iterator'] as $objects['_iterator_2_vals']){$objects['_iterator_2_ids']=$objects['_iterator_2_vals']->id;$objects['$date']=$objects['_iterator_2_vals'];}$objects['_iterator_2_iterator'] = array_pop($objects['_iterator_2_iterator_stack']);$objects['$path'] = ( '/' . $objects['$area'] . '/' . date('Y/m/d/',intval($objects['$date']->getValue())) . base::run_first("path","get-path", array("parent"=> $objects['$daynode'], "child" => $objects['$child'])));$objects['$img'] = ( $objects['$path'] . '/:thumb:256');?>
<li><a href = "<?php echo $objects['$path'];?>" ><img src = "<?php echo $objects['$img'];?>" class = "<?php echo (base::run_first("file","type",array("item"=>$objects['$child'])));?>" alt = "<?php echo $objects['$child']->getValue();?>" /></a></li>
<?php }}$objects['_iterator_0_iterator'] = array_pop($objects['_iterator_0_iterator_stack']);?>
</ul>
<div class = "dashboard-module-footer"></div>
</li><?php ?>