#4 analyzer cannot analyze BEGIN and END macro

closed
Kuwata Makoto
kwartz-php (4)
5
2005-01-10
2005-01-10
Kuwata Makoto
No

KwartzAnalyzer doesn't analyze BEGIN and END macro.

hoge.html
----------------------------------------
<ul kd="mark:ul">
<li kd="value:item">hoge</li>
</ul>
----------------------------------------

hoge.plogic
----------------------------------------
:element(ul)
@stag
:foreach(item=list)
@cont
:end
@etag
:end

:macro(BEGIN)
:set(list = args['list'])
:end
----------------------------------------

analyze

$ kwartz-php -v
kwartz-php: 55 (2005-01-09 22:32:44), Kwartz.php: 55
(2005-01-09 22:32:44)
$ kwartz-php -a analyze -p hoge.plogic hoge.html
global variable(s): list
local variable(s): item
========================================

Discussion

  • Kuwata Makoto
    Kuwata Makoto
    2005-01-10

    Logged In: YES
    user_id=221589

    KwartzAnalyzer#analyze() analyzes only normal macros except
    BEGIN and END macro.

    ----------------------------------------
    --- Kwartz/KwartzAnalyzer.php (revision 55)
    +++ Kwartz/KwartzAnalyzer.php (working copy)
    @@ -34,7 +34,27 @@
    }

    function analyze() {
    + $begin_block = NULL;
    + $end_block = NULL;
    + if ($this->node->token() == '<<block>>') {
    + $block = $this->node;
    + foreach ($block->statements() as $stmt) {
    + if ($stmt->token() == ':macro') {
    + if ($stmt->macro_name() == 'BEGIN') {
    + $begin_block = $stmt->body_block();
    + } elseif ($stmt->macro_name() == 'END') {
    + $end_block = $stmt->body_block();
    + }
    + }
    + }
    + }
    + if ($begin_block) {
    + $begin_block->accept($this->analyze_visitor);
    + }
    $this->node->accept($this->analyze_visitor);
    + if ($end_block) {
    + $end_block->accept($this->analyze_visitor);
    + }
    }
    ----------------------------------------

    fixed at: rev.56
    test case: KwartzAnalyzerTest#test_analyze_macro3()

     
  • Kuwata Makoto
    Kuwata Makoto
    2005-01-10

    • status: open --> closed