/**
  * Parses the given tokens
  *
  * @param array $tokens
  *
  * @throws \Liquid\LiquidException
  * @return void
  */
 public function parse(array &$tokens)
 {
     $startRegexp = new Regexp('/^' . Liquid::get('TAG_START') . '/');
     $tagRegexp = new Regexp('/^' . Liquid::get('TAG_START') . '\\s*(\\w+)\\s*(.*)?' . Liquid::get('TAG_END') . '$/');
     $variableStartRegexp = new Regexp('/^' . Liquid::get('VARIABLE_START') . '/');
     $this->nodelist = array();
     if (!is_array($tokens)) {
         return;
     }
     $tags = Template::getTags();
     while (count($tokens)) {
         $token = array_shift($tokens);
         if ($startRegexp->match($token)) {
             if ($tagRegexp->match($token)) {
                 // If we found the proper block delimitor just end parsing here and let the outer block proceed
                 if ($tagRegexp->matches[1] == $this->blockDelimiter()) {
                     $this->endTag();
                     return;
                 }
                 $tagName = null;
                 if (array_key_exists($tagRegexp->matches[1], $tags)) {
                     $tagName = $tags[$tagRegexp->matches[1]];
                 } else {
                     $tagName = '\\Liquid\\Tag\\Tag' . ucwords($tagRegexp->matches[1]);
                     $tagName = class_exists($tagName) === true ? $tagName : null;
                 }
                 if ($tagName !== null) {
                     $this->nodelist[] = new $tagName($tagRegexp->matches[2], $tokens, $this->fileSystem);
                     if ($tagRegexp->matches[1] == 'extends') {
                         return;
                     }
                 } else {
                     $this->unknownTag($tagRegexp->matches[1], $tagRegexp->matches[2], $tokens);
                 }
             } else {
                 throw new LiquidException("Tag {$token} was not properly terminated");
                 // harry
             }
         } elseif ($variableStartRegexp->match($token)) {
             $this->nodelist[] = $this->createVariable($token);
         } elseif ($token != '') {
             $this->nodelist[] = $token;
         }
     }
     $this->assertMissingDelimitation();
 }