src/Leevel/View/Parser.php
protected function codeParse(string &$compiled): void
    {
        foreach ($this->compilers['code'] as $compilers => $tag) {
            // 处理一些正则表达式中有特殊意义的符号
            $names[] = $this->escapeRegexCharacter($compilers);
        }

        // 正则分析
        $tag = $this->getTag('code');
        $names = implode('|', $names);
        $regex = '/'.$tag['left']."\\s*({$names})(|.+?)".$tag['right'].'/s';

        if (preg_match_all($regex, $compiled, $res)) {
            $startPos = 0;

            foreach ($res[0] as $index => &$source) {
                $type = trim($res[1][$index]);
                !$type && $type = '/';

                $content = trim($res[2][$index]);

                $theme = [
                    'source'   => $source,
                    'content'  => $content,
                    'compiler' => $this->compilers['code'][$type].'Code', // 编译器
                    'children' => [],
                ];

                $theme['position'] = $this->getPosition($compiled, $source, $startPos);
                $startPos = $theme['position']['end'] + 1;
                $theme = $this->normalizeThemeStruct($theme);

                // 将模板数据加入到树结构中
                $this->addTheme($theme);
            }
        }
    }
protected function codeParse(string &$compiled): void
    {
        foreach ($this->compilers['code'] as $compilers => $tag) {
            // 处理一些正则表达式中有特殊意义的符号
            $names[] = $this->escapeRegexCharacter($compilers);
        }

        // 正则分析
        $tag = $this->getTag('code');
        $names = implode('|', $names);
        $regex = '/'.$tag['left']."\\s*({$names})(|.+?)".$tag['right'].'/s';

        if (preg_match_all($regex, $compiled, $res)) {
            $startPos = 0;

            foreach ($res[0] as $index => &$source) {
                $type = trim($res[1][$index]);
                !$type && $type = '/';

                $content = trim($res[2][$index]);

                $theme = [
                    'source'   => $source,
                    'content'  => $content,
                    'compiler' => $this->compilers['code'][$type].'Code', // 编译器
                    'children' => [],
                ];

                $theme['position'] = $this->getPosition($compiled, $source, $startPos);
                $startPos = $theme['position']['end'] + 1;
                $theme = $this->normalizeThemeStruct($theme);

                // 将模板数据加入到树结构中
                $this->addTheme($theme);
            }
        }
    }
code 方式分析器.

@param string $compiled