parse calling template or block :
<gc:call template="name()">
<gc:call block="name()">
@access protected
@return void
@since 3.0
@package Gcs\Framework\Core\Template
498687
protected function _parseCall() {
        $this->_content = preg_replace_callback('`' . $this->_openTag . $this->_name . preg_quote($this->markup['call'][0]) . $this->_spaceR . preg_quote($this->markup['call'][1]) . $this->_space . '=' . $this->_space . '"' . $this->_space . '(\w+)\(\)' . $this->_space . '"' . $this->_space . '/' . $this->_closeTag . '`isU', ['Gcs\Framework\Core\Template\Parser', '_parseCallBlockCallback'], $this->_content);
        $this->_content = preg_replace_callback('`' . $this->_openTag . $this->_name . preg_quote($this->markup['call'][0]) . $this->_spaceR . preg_quote($this->markup['call'][2]) . $this->_space . '=' . $this->_space . '"' . $this->_space . '(\w+)\((.*)\)' . $this->_space . '"' . $this->_space . '/' . $this->_closeTag . '`isU', ['Gcs\Framework\Core\Template\Parser', '_parseCallTemplateCallback'], $this->_content);
    }
1038831
protected function _parseArgs()
    {
        $inString = false;
        $cpt = 0;
        $last = $char = $value = $name = '';
        $args = [];
        $body = '';
        while ($token = $this->_stream->current(true)) {
            $body .= $token[1];
            switch ($token[0]) {
                case '(':
                    if ($cpt) {
                        $value .= $token[1];
                    }
                    $cpt++;
                break;
                case '=':
                    $name = $value;
                    $value = '';
                break;
                case ')':
                    $cpt--;
                    if ($cpt) {
                        $value .= $token[1];
                        break;
                    }
                case ',':
                    $value = trim($value);
                    if ($value !== '') {
                        $name ? $args[trim($name)] = $value : $args[] = $value;
                    }
                    $name = $value = '';
                break;
                default:
                    $value .= $token[1];
                break;
            }
            if ($token[1] === ')' && $cpt === 0) {
                break;
            }
            $this->_stream->next();
        }
        return compact('args', 'body');
    }
575195
protected function parse()
    {
        $this->checkFormat();
        $this->parsePalmDb();
        $this->parsePalmDoc();
        $this->parseMobiHeader();
        $this->parseExth();
    }
358026
private function compileAndSetName() { 
      $name = \Nuki\Handlers\Core\Assist::classNameShort($this);
      
      $this->name = strtolower($name);
    }
337900
function compile( $compiled_template_filename = '' )
		{
			if (empty($this->template))
			{
				return;
			}
			/* Quick hack to allow subtemplates */
			if(eregi("<!-- INCLUDE", $this->template))
			{
				while ($this->count_subtemplates() > 0)
				{
					preg_match_all('/<!-- INCLUDE ([a-zA-Z0-9_.]+) -->/', $this->template, $tvar);
					foreach($tvar[1] as $subfile)
					{
						if(file_exists($this->template_dir . "/$subfile"))
						{
							$subst = implode('',file($this->template_dir . "/$subfile"));
						}
						else
						{
							$subst = 'SmartTemplate Parser Error: Subtemplate not found: \''.$subfile.'\'';
						}
						$this->template = str_replace("<!-- INCLUDE $subfile -->", $subst, $this->template);
					}
				}
			}
			//	END, ELSE Blocks
			$page  =  preg_replace("/<!-- ENDIF.+?-->/",  "<?php\n}\n?>",  $this->template);
			$page  =  preg_replace("/<!-- END[ a-zA-Z0-9_.]* -->/",  "<?php\n}\n\$_obj=\$_stack[--\$_stack_cnt];}\n?>",  $page);
			$page  =  str_replace("<!-- ELSE -->",  "<?php\n} else {\n?>",  $page);

			//	'BEGIN - END' Blocks
			if (preg_match_all('/<!-- BEGIN ([a-zA-Z0-9_.]+) -->/', $page, $var))
			{
				foreach ($var[1] as $tag)
				{
					list($parent, $block)  =  $this->var_name($tag);
					$code  =  "<?php\n"
							. "if (!empty(\$$parent"."['$block'])){\n"
							. "if (!is_array(\$$parent"."['$block']))\n"
							. "\$$parent"."['$block']=array(array('$block'=>\$$parent"."['$block']));\n"
							. "\$_tmp_arr_keys=array_keys(\$$parent"."['$block']);\n"
							. "if (\$_tmp_arr_keys[0]!='0')\n"
							. "\$$parent"."['$block']=array(0=>\$$parent"."['$block']);\n"
							. "\$_stack[\$_stack_cnt++]=\$_obj;\n"
							. "foreach (\$$parent"."['$block'] as \$rowcnt=>\$$block) {\n"
							. "\$$block"."['ROWCNT']=\$rowcnt;\n"
							. "\$$block"."['ALTROW']=\$rowcnt%2;\n"
							. "\$$block"."['ROWBIT']=\$rowcnt%2;\n"
							. "\$_obj=&\$$block;\n?>";
					$page  =  str_replace("<!-- BEGIN $tag -->",  $code,  $page);
				}
			}

			//	'IF nnn=mmm' Blocks
			if (preg_match_all('/<!-- (ELSE)?IF ([a-zA-Z0-9_.]+)[ ]*([!=<>]+)[ ]*(["]?[^"]*["]?) -->/', $page, $var))
			{
				foreach ($var[2] as $cnt => $tag)
				{
					list($parent, $block)  =  $this->var_name($tag);
					$cmp   =  $var[3][$cnt];
					$val   =  $var[4][$cnt];
					$else  =  ($var[1][$cnt] == 'ELSE') ? '} else' : '';
					if ($cmp == '=')
					{
						$cmp  =  '==';
					}
					
					if (preg_match('/"([^"]*)"/',$val,$matches))
					{
						$code  =  "<?php\n$else"."if (\$$parent"."['$block'] $cmp \"".$matches[1]."\"){\n?>";
					}
					elseif (preg_match('/([^"]*)/',$val,$matches))
					{
						list($parent_right, $block_right)  =  $this->var_name($matches[1]);
						$code  =  "<?php\n$else"."if (\$$parent"."['$block'] $cmp \$$parent_right"."['$block_right']){\n?>";
					}
					
					$page  =  str_replace($var[0][$cnt],  $code,  $page);
				}
			}

			//	'IF nnn' Blocks
			if (preg_match_all('/<!-- (ELSE)?IF ([a-zA-Z0-9_.]+) -->/', $page, $var))
			{
				foreach ($var[2] as $cnt => $tag)
				{
					$else  =  ($var[1][$cnt] == 'ELSE') ? '} else' : '';
					list($parent, $block)  =  $this->var_name($tag);
					$code  =  "<?php\n$else"."if (!empty(\$$parent"."['$block'])){\n?>";
					$page  =  str_replace($var[0][$cnt],  $code,  $page);
				}
			}

			//	Replace Scalars
			if (preg_match_all('/{([a-zA-Z0-9_. >]+)}/', $page, $var))
			{
				foreach ($var[1] as $fulltag)
				{
					//	Determin Command (echo / $obj[n]=)
					list($cmd, $tag)  =  $this->cmd_name($fulltag);

					list($block, $skalar)  =  $this->var_name($tag);
					$code  =  "<?php\n$cmd \$$block"."['$skalar'];\n?>\n";
					$page  =  str_replace('{'.$fulltag.'}',  $code,  $page);
				}
			}


			//	ROSI Special: Replace Translations
			if (preg_match_all('/<"([a-zA-Z0-9_.]+)">/', $page, $var))
			{
				foreach ($var[1] as $tag)
				{
					list($block, $skalar)  =  $this->var_name($tag);
					$code  =  "<?php\necho gettext('$skalar');\n?>\n";
					$page  =  str_replace('<"'.$tag.'">',  $code,  $page);
				}
			}


			//	Include Extensions
			$header = '';
			if (preg_match_all('/{([a-zA-Z0-9_]+):([^}]*)}/', $page, $var))
			{
				foreach ($var[2] as $cnt => $tag)
				{
					//	Determin Command (echo / $obj[n]=)
					list($cmd, $tag)  =  $this->cmd_name($tag);

					$extension  =  $var[1][$cnt];
					if (!isset($this->extension_tagged[$extension]))
					{
						$header  .=  "include_once \"smarttemplate_extensions/smarttemplate_extension_$extension.php\";\n";
						$this->extension_tagged[$extension]  =  true;
					}
					if (!strlen($tag))
					{
						$code  =  "<?php\n$cmd smarttemplate_extension_$extension();\n?>\n";
					}
					elseif (substr($tag, 0, 1) == '"')
					{
						$code  =  "<?php\n$cmd smarttemplate_extension_$extension($tag);\n?>\n";
					}
					elseif (strpos($tag, ','))
					{
						list($tag, $addparam)  =  explode(',', $tag, 2);
						list($block, $skalar)  =  $this->var_name($tag);
						if (preg_match('/^([a-zA-Z_]+)/', $addparam, $match))
						{
							$nexttag   =  $match[1];
							list($nextblock, $nextskalar)  =  $this->var_name($nexttag);
							$addparam  =  substr($addparam, strlen($nexttag));
							$code  =  "<?php\n$cmd smarttemplate_extension_$extension(\$$block"."['$skalar'],\$$nextblock"."['$nextskalar']"."$addparam);\n?>\n";
						}
						else
						{
							$code  =  "<?php\n$cmd smarttemplate_extension_$extension(\$$block"."['$skalar'],$addparam);\n?>\n";
						}
					}
					else
					{
						list($block, $skalar)  =  $this->var_name($tag);
						$code  =  "<?php\n$cmd smarttemplate_extension_$extension(\$$block"."['$skalar']);\n?>\n";
					}
					$page  =  str_replace($var[0][$cnt],  $code,  $page);
				}
			}

			//	Add Include Header
			if (isset($header) && !empty($header))
			{
				$page  =  "<?php\n$header\n?>$page";
			}

			//	Store Code to Temp Dir
			if (strlen($compiled_template_filename))
			{
		        if ($hd  =  fopen($compiled_template_filename,  "w"))
		        {
			        fwrite($hd,  $page);
			        fclose($hd);
			        return true;
			    }
			    else
			    {
			    	$this->error  =  "Could not write compiled file.";
			        return false;
			    }
			}
			else
			{
				return $page;
			}
		}
548952
public function parseNextBlock()
    {
        // Init block variables.
        $found_var = false;
        $found_equal = false;
        $found_semicolon = false;
        $found_open_tag = false;
        $found_close_tag = false;
        $end_block = false;
        $var_name = '';
        $var_value = '';
        $line = 0;

        // Loop through tokens until end of block or file.
        while (!$end_block && $this->tokens->valid()) {
            // Init loop variables
            $add_name = false;

            // Get normed token array
            $token = static::normalizeToken($this->tokens->current());
            $line = max($token[self::T_LINE], $line);
            $this->logger->debug('Found token ' . static::getTokenName($token) . " at line $line.");

            // Closing block allow only one whitespace.
            if ($found_semicolon  || $found_open_tag || $found_close_tag) {
                if ($token[self::T_KEY] == T_WHITESPACE) {
                    $end_block = true;
                    if (!$this->test_mode && $token[self::T_VALUE] != "\n") {
                        // Set only one line return after a semicolon or close tag.
                        $this->logger->notice("Removing spaces at line $line.");
                        $token[self::T_VALUE] = "\n";
                    }
                } else {
                    // Stop processing now.
                    break;
                }
            } else {
                switch ($token[self::T_KEY]) {
                    // Comments and whitespace are allowed anywhere.
                    case T_COMMENT:
                    case T_DOC_COMMENT:
                    case T_WHITESPACE:
                        break;
                    case T_OPEN_TAG:
                        $found_open_tag = true;
                        break;
                    // New variable
                    case T_VARIABLE:
                        if (!$found_var) {
                            // Set that we found a var definition and record the name
                            $found_var = true;
                            $add_name = true;
                        } else {
                            // We shouldn't see a variable definition.
                            throw new \Exception('Unexpected T_VARIABLE ' . $token[self::T_VALUE] . " at line $line.");
                        }
                        break;
                    // Variable name..
                    case '[':
                    case ']':
                    case T_CONSTANT_ENCAPSED_STRING:
                        if ($found_var) {
                            if (!$found_equal) {
                                // If inside variable definition, add name for sorting.
                                $add_name = true;
                            }
                        } else {
                            // Not in variable definition or value.
                            $name = static::getTokenName($token);
                            throw new \Exception('Unexpected ' . $name . " at line $line.");
                        }
                        break;
                    case '=':
                        // Equal allowed only after var definition
                        if ($found_var && !$found_equal) {
                            $found_equal = true;
                        } else {
                            throw new \Exception("Unexpected = at line $line.");
                        }
                        break;
                    case ';':
                        if ($found_var && !$found_equal) {
                            throw new \Exception("Unexpected ; at line $line.");
                        }
                        $found_semicolon = true;
                        break;
                    case T_CLOSE_TAG:
                        if ($found_var) {
                            throw new \Exception("Unexpected T_CLOSE_TAG at line $line.");
                        }
                        $found_close_tag = true;
                        break;
                    default:
                        if (!$found_var || !$found_equal) {
                            $name = static::getTokenName($token);
                            throw new \Exception('Unexpected ' . $name . " at line $line.");
                        }
                        break;
                }
            }
            if ($add_name) {
                $var_name .= $token[self::T_VALUE];
            }
            $var_value .= $token[self::T_VALUE];
            $this->logger->debug('Advance to next token.');
            $this->tokens->next();
        }
        if ($found_var && !$found_semicolon) {
            throw new \Exception('Missing ; before end of file.');
        }
        if (!$this->test_mode && "\n" != substr($var_value, -1)) {
            $this->logger->info('Add return line to end of block.');
            $var_value .= "\n";
        }
        if ($found_close_tag) {
            $this->end_blocks[] = $var_value;
        } elseif (!empty($var_name)) {
            if ($this->test_mode) {
                // Try to recreate the file as is.
                $this->var_blocks[] = $var_value;
            } else {
                // Strip $GLOBALS from variables names for sorting.
                // This will merge local and global version of the same var name.
                $var_name = $this->normalizeVariableName($var_name);
                // Warnings if key already exists.
                $this->checkVarName($var_name);
                $this->var_blocks[$var_name] = $var_value;
            }
        } else {
            $this->empty_blocks[] = $var_value;
        }
    }
598998
protected function parseCall()
    {

        if ($this->call instanceof Closure) {
            $this->callClass = Closure::class;
            $this->callMethod = '';
            $this->isStaticMethod = false;
            $this->isFunction = false;
            $this->isClosure = true;
            return;
        }

        list($class, $method) = $this->toClassAndMethod($this->call);

        if ($class === '') {
            $this->callClass = '';
            $this->callMethod = $method;
            $this->isStaticMethod = false;
            $this->isFunction = true;
            $this->isClosure = false;
            return;
        }

        $this->callClass = $class;
        $this->callMethod = $method;
        $this->isFunction = false;
        $this->isClosure = false;

        $reflection = new ReflectionMethod($class, $method);
        $this->isStaticMethod = $reflection->isStatic();

        if (!$reflection->isPublic()) {
            throw new LogicException("Method '$method' of $class is not public and therefore not callable.");
        }

        return;

    }
915523
public function parseMain()
    {
        $out = '';

        while ($token = $this->stream->next()) {
            if ($token->test(T_COMMENT, '/* OUTPUT */')) {
                $out .= $this->parseOutput();
            } elseif ($token->test(T_COMMENT, '/* DIRECTIVE */')) {
                $out .= $this->parseDirective();
            } else {
                $out .= $token->getValue();
            }
        }

        if ($this->variables) {
            $info = sprintf('<?php /* %s */ extract(%s, EXTR_SKIP) ?>', $this->filename, str_replace("\n", '', var_export($this->variables, true)));
        } else {
            $info = sprintf('<?php /* %s */ ?>', $this->filename);
        }

        return $info.$out;
    }
1125356
public function parse($name)
    {
        $rawData = $this->getRawData($name);

        $result = new PageTemplate();
        $result->setName($rawData['name']);
        $rows = [];
        foreach ($rawData['rows'] as $rawRow) {
            $regions = [];
            foreach ($rawRow['regions'] as $rawRegion) {
                $region = $this->buildRegion($rawRegion);
                $regions[] = $region;
            }
            $rows[] = new Row($regions);
        }

        $result->setRows($rows);
        $result->setTemplate($rawData['template']);

        return $result;
    }
1285047
public function get_static_view_template_name() {
		// @codingStandardsIgnoreStart
		// @todo サニタイズしているのに Detected usage of a non-validated input variable: $_SERVER がでる。バグ？
		$request_uri = sanitize_text_field( wp_unslash( $_SERVER['REQUEST_URI'] ) );
		// @codingStandardsIgnoreEnd
		$request_uri = $this->_get_relative_path( $request_uri );
		$path        = $this->_remove_http_query( $request_uri );
		$path        = $this->_remove_paged_slug( $path );
		$path        = trim( $path, '/' );

		if ( ! $path ) {
			return Helper\locate_template( (array) Helper\config( 'static' ), 'index' );
		}

		$template_name = Helper\locate_template( (array) Helper\config( 'static' ), $path );
		if ( empty( $template_name ) ) {
			$template_name = Helper\locate_template( (array) Helper\config( 'static' ), $path . '/index' );
		}

		return $template_name;
	}
161192
private function guessTemplateName()
	{
		if ($this->package === null) {
			throw new \RuntimeException(sprintf(
				'Block package is unknown, thus it is impossible to guess template name for block [%s].',
				$this->getTitle()
			));
		}

		$name = (new \ReflectionClass($this))->getShortName();

		if (($pos = strpos($name, 'Config')) !== false
			&& $pos === (strlen($name) - 6)) {

			$name = substr($name, 0, -6);
		}

		return $this->package->getName() . ':blocks' . DIRECTORY_SEPARATOR . Inflector::tableize($name) . '.html.twig';
	}
1348486
protected function _parseInclude() {
        $this->_content = preg_replace_callback('`' . $this->_openTag . $this->_name . preg_quote($this->markup['include'][0]) . $this->_spaceR . preg_quote($this->markup['include'][1]) . $this->_space . '=' . $this->_space . '"([A-Za-z0-9_\-\$/]+)"' . $this->_space . '((' . preg_quote($this->markup['include'][2]) . $this->_space . '=' . $this->_space . '"([0-9]*)"' . $this->_space . ')*)' . $this->_space . '/' . $this->_closeTag . '`isU', ['Gcs\Framework\Core\Template\Parser', '_parseIncludeCallback'], $this->_content);
        $this->_content = preg_replace_callback('`' . $this->_openTag . $this->_name . preg_quote($this->markup['include'][0]) . $this->_spaceR . preg_quote($this->markup['include'][1]) . $this->_space . '=' . $this->_space . '"([A-Za-z0-9_\-\$/]+)"' . $this->_space . preg_quote($this->markup['include'][3]) . $this->_space . '=' . $this->_space . '"' . preg_quote($this->markup['include'][4]) . '"' . $this->_space . '((' . preg_quote($this->markup['include'][2]) . $this->_space . '=' . $this->_space . '"([0-9]*)"' . $this->_space . ')*)' . $this->_space . '/' . $this->_closeTag . '`isU', ['Gcs\Framework\Core\Template\Parser', '_parseIncludeCompileCallback'], $this->_content);
    }
932261
function ClosedBlock_Handle_With(&$res)
    {
        if ($res['ArgumentCount'] != 1) {
            throw new SSTemplateParseException('Either no or too many arguments in with block. Must be one ' .
                'argument only.', $this);
        }

        $arg = $res['Arguments'][0];
        if ($arg['ArgumentMode'] == 'string') {
            throw new SSTemplateParseException('Control block cant take string as argument.', $this);
        }

        $on = str_replace('$$FINAL', 'obj', ($arg['ArgumentMode'] == 'default') ? $arg['lookup_php'] : $arg['php']);
        return
            $on . '; $scope->pushScope();' . PHP_EOL .
                $res['Template']['php'] . PHP_EOL .
            '; $scope->popScope(); ';
    }
86952
public function parse() {
        $name_without_parens = preg_replace('/[{}]/', '', $this->full_name);

        $parts = explode('|', $name_without_parens);
        $name_without_pipes = trim($parts[0]);

        $parts = explode('::', $name_without_pipes);
        $name_without_case_keys = trim($parts[0]);
        array_shift($parts);
        $this->case_keys = array_map('trim', $parts);

        $parts = explode(':', $name_without_case_keys);
        $this->short_name = trim($parts[0]);
        array_shift($parts);
        $this->context_keys = array_map('trim', $parts);

        $this->separator = (strpos($this->full_name,'||') !== false) ? '||' : '|';

        $this->parameters = array();
        $parts = explode($this->separator, $name_without_parens);
        if (count($parts) > 1) {
            $parts = explode(',', $parts[1]);
            foreach($parts as $part) {
                array_push($this->parameters, trim($part));
            }
        }
    }
659564
public function compileBlocks()
    {
        do {
            $blockProceeded = 0;
            foreach ($this->getBlocks() as $name => $blocks) {
                foreach ($blocks as $block) {
                    $this->assert(
                        $block instanceof BlockElement,
                        'Unexpected block for the name '.$name,
                        $block instanceof AbstractElement ? $block->getOriginNode() : null
                    );
                    /** @var BlockElement $block */
                    if ($block->hasParent()) {
                        $this->replaceBlock($block);
                        $blockProceeded++;
                    }
                }
            }
        } while ($blockProceeded);

        return $this;
    }
1230591
public function parse( $template_file )
    {
        if ( file_exists( $template_file ) ) {
            $content = file_get_contents($template_file);

            foreach ( $this->vars as $key => $value ) {
                if ( is_array( $value ) ) {
                    $content = $this->parsePair($key, $value, $content);
                } else {
                    $content = $this->parseSingle($key, (string) $value, $content);
                }
            }

            return $content;
        } else {
            exit( '<h1>Template error</h1>' );
        }
    }
63894
protected function parseCodeBlock()
    {
        $stream = $this->parser->getStream();

        while (!$stream->getCurrent()->test(\Twig_Token::BLOCK_END_TYPE)) {
            $this->parseEncounteredToken($stream->getCurrent(), $stream);
        }

        $stream->expect(\Twig_Token::BLOCK_END_TYPE);
        $this->body = $this->parser->subparse(array($this, 'decideBlockEnd'), true);
        $stream->expect(\Twig_Token::BLOCK_END_TYPE);
    }