/**
  * Constructor. Processes the block and generates the inner/outer contents. Computes
  * the name and the type of block
  * @param ReflectionTemplate $reflector   
  * @param integer            $start       The start position of this block in the parent template
  * @param [type]             $end         The end position of this block in the parent template
  * @param integer            $parentIndex The start position of the parent block
  */
 public function __construct(ReflectionTemplate $reflector, $start = 0, $end = null, $parentIndex = 0)
 {
     parent::__construct();
     $this->reflector = $reflector;
     $this->id = $start;
     if (!$end) {
         $end = strlen($this->reflector->getCode());
     }
     $this->allContents = $reflector->getCode();
     $this->blockOuterContents = substr($this->allContents, $this->id, $end - $this->id + 14);
     // strlen of <% end_loop|with %>
     $this->parentIndex = $parentIndex;
     preg_match("/<% (loop|with) [\$]?([A-Za-z0-9_]+)(.*?) %>/", $this->blockOuterContents, $match);
     if ($match) {
         $this->openingDelimiter = $match[0];
         $this->name = trim($match[2]);
         $this->type = $match[1];
         $this->blockInnerContents = substr($this->allContents, $this->id + strlen($this->openingDelimiter), $end - $this->id);
     } else {
         if ($start == 0 && $parentIndex == 0) {
             $this->name = "Root";
             $this->type = "root";
             $this->blockInnerContents = substr($this->allContents, $this->id, $end - $this->id);
         } else {
             throw new Exception("ReflectionTemplate_Block given a code block that is not properly formed: {$this->blockOuterContents}");
         }
     }
 }