Example #1
0
 /**
  * @param FlageParser $parser
  * @param string $tag
  * @param string $tagRest
  */
 public function tagInit($parser, $tag, $tagRest)
 {
     $this->arguments = $parser->_tokenize_named_arguments($tagRest, '', false);
 }
Example #2
0
 protected function compile($source)
 {
     /** @noinspection PhpUnusedLocalVariableInspection */
     $__h = $this;
     $source_info = $this->getSourceInfo($source);
     $info = $this->{$source_info['info']}($source_info['source_data'], $source);
     if ($info['modified'] || $this->forceRecompile || $this->disableCache) {
         $this->setCurrentInfo($info);
         $_data = $this->{$source_info['get_data']}($info['filename']);
         require_once "FlageParser.parser.php";
         $parser = new FlageParser();
         $parser->setFlage($this);
         try {
             $__data = $parser->Parse($_data);
         } catch (FlageException $e) {
             if (!$e->isFileDefined()) {
                 $e->setFile($source);
             }
             throw $e;
         }
         $this->storeCompiled($info['compiled_filename'], $__data);
     }
 }
Example #3
0
 function _tokenize_named_arguments($statement, $type = '', $static_vars = true)
 {
     //$this->_generate_tokens_stack($statement);
     $_context_transitions = FlageParser::$_context_transitions;
     $_transitions = FlageParser::$_transitions;
     if ($static_vars) {
         FlageParser::$_context_transitions = FlageParser::$_context_transitions_arguments;
         FlageParser::$_transitions = FlageParser::$_transitions_arguments;
     }
     // Generate new state, which is counted as a function
     $state2 = new FlageState(null, $this->line, $this->col, false);
     // New function node
     $state2->node->next = new FlageNodeFunction(null, $this->line, $this->col, false);
     // Previous node of the function is the created state
     $state2->node->next->prev = $state2->node;
     // parent node is argument node, as we do not need function name
     $state2->parent_node = $state2->node = $state2->node->next->arguments->nextArgumentNode($this->line, $this->col);
     $state2->type = '';
     // Group type is a function
     $state2->group_type = 'block';
     // We need to tokenize only arguments
     $state = $this->_tokenize($statement, $state2);
     $nodes = $state->entry_node->next->arguments->nodes;
     $arguments = array();
     for ($i = 1; $i < count($nodes); $i++) {
         //$argument->
         if ($nodes[$i][0]) {
             $name = $nodes[$i][0]->generate($this);
             $value = $nodes[$i][1]->generate($this);
         } else {
             $name = $nodes[$i][1]->generate($this);
             $value = "'{$name}'";
         }
         //print "$name=$value\n";
         $arguments[$name] = $value;
     }
     //$retState = $state;
     //$retState = $this->_tokenize($statement,$type);
     if ($static_vars) {
         FlageParser::$_context_transitions = $_context_transitions;
         FlageParser::$_transitions = $_transitions;
     }
     return $arguments;
 }