Exemplo n.º 1
0
 /**
  * Parses the source.
  * 
  * Most actual parsing is delegated to discovered handlers.
  */
 public function parse()
 {
     Handler::set_parser($this);
     $node_namespace = Library::namespace_from_class(get_called_class()) . '\\' . 'nodes';
     $root_class = $node_namespace . '\\Node';
     $this->root = new $root_class();
     $this->root->set_from_parser($this);
     $this->context = $this->root;
     $this->line_number = 0;
     $this->indent_level = 0;
     $this->force_handler = false;
     $this->context_locked = false;
     while (($this->content = $this->get_line()) !== false) {
         $this->line_number++;
         $this->update_context();
         if ($this->content = trim($this->content)) {
             $this->handle();
         }
     }
     foreach (static::$handlers as $handler) {
         $handler::reset();
     }
 }