lib/ParserGenerator/PHP/ParserGenerator/Data.php
function emit_destructor_code($out, PHP_ParserGenerator_Symbol $sp, &$lineno)
//    FILE *out;
//    struct symbol *sp;
//    struct lemon *lemp;
//    int *lineno;
    {
        $cp = 0;
        
        $linecnt = 0;
        if ($sp->type == PHP_ParserGenerator_Symbol::TERMINAL) {
            $cp = $this->tokendest;
            if ($cp === 0) {
                return;
            }
            $this->tplt_linedir($out, $this->tokendestln, $this->filename);
            fwrite($out, "{");
        } elseif ($sp->destructor) {
            $cp = $sp->destructor;
            $this->tplt_linedir($out, $sp->destructorln, $this->filename);
            fwrite($out, "{");
        } elseif ($this->vardest) {
            $cp = $this->vardest;
            if ($cp === 0) {
                return;
            }
            $this->tplt_linedir($out, $this->vardestln, $this->filename);
            fwrite($out, "{");
        } else {
            throw new Exception('emit_destructor'); /* Cannot happen */
        }
        for ($i = 0; $i < strlen($cp); $i++) {
            if ($cp[$i]=='$' && $cp[$i + 1]=='$' ) {
                fprintf($out, "(yypminor->yy%d)", $sp->dtnum);
                $i++;
                continue;
            }
            if ($cp[$i] == "\n") {
                $linecnt++;
            }
            fwrite($out, $cp[$i]);
        }
        $lineno += 3 + $linecnt;
        fwrite($out, "}\n");
        $this->tplt_linedir($out, $lineno, $this->outname);
    }
function emit_destructor_code($out, PHP_ParserGenerator_Symbol $sp, &$lineno)
//    FILE *out;
//    struct symbol *sp;
//    struct lemon *lemp;
//    int *lineno;
    {
        $cp = 0;
        
        $linecnt = 0;
        if ($sp->type == PHP_ParserGenerator_Symbol::TERMINAL) {
            $cp = $this->tokendest;
            if ($cp === 0) {
                return;
            }
            $this->tplt_linedir($out, $this->tokendestln, $this->filename);
            fwrite($out, "{");
        } elseif ($sp->destructor) {
            $cp = $sp->destructor;
            $this->tplt_linedir($out, $sp->destructorln, $this->filename);
            fwrite($out, "{");
        } elseif ($this->vardest) {
            $cp = $this->vardest;
            if ($cp === 0) {
                return;
            }
            $this->tplt_linedir($out, $this->vardestln, $this->filename);
            fwrite($out, "{");
        } else {
            throw new Exception('emit_destructor'); /* Cannot happen */
        }
        for ($i = 0; $i < strlen($cp); $i++) {
            if ($cp[$i]=='$' && $cp[$i + 1]=='$' ) {
                fprintf($out, "(yypminor->yy%d)", $sp->dtnum);
                $i++;
                continue;
            }
            if ($cp[$i] == "\n") {
                $linecnt++;
            }
            fwrite($out, $cp[$i]);
        }
        $lineno += 3 + $linecnt;
        fwrite($out, "}\n");
        $this->tplt_linedir($out, $lineno, $this->outname);
    }
function emit_destructor_code ( $ out , PHP_ParserGenerator_Symbol $ sp , & $ lineno ) //    FILE *out; //    struct symbol *sp; //    struct lemon *lemp; //    int *lineno; { $ cp = 0 ; $ linecnt = 0 ; if ( $ sp -> type == PHP_ParserGenerator_Symbol :: TERMINAL ) { $ cp = $ this -> tokendest ; if ( $ cp === 0 ) { return ; } $ this -> tplt_linedir ( $ out , $ this -> tokendestln , $ this -> filename ) ; fwrite ( $ out , "{" ) ; } elseif ( $ sp -> destructor ) { $ cp = $ sp -> destructor ; $ this -> tplt_linedir ( $ out , $ sp -> destructorln , $ this -> filename ) ; fwrite ( $ out , "{" ) ; } elseif ( $ this -> vardest ) { $ cp = $ this -> vardest ; if ( $ cp === 0 ) { return ; } $ this -> tplt_linedir ( $ out , $ this -> vardestln , $ this -> filename ) ; fwrite ( $ out , "{" ) ; } else { throw new Exception ( 'emit_destructor' ) ; /* Cannot happen */ } for ( $ i = 0 ; $ i < strlen ( $ cp ) ; $ i ++ ) { if ( $ cp [ $ i ] == '$' && $ cp [ $ i + 1 ] == '$' ) { fprintf ( $ out , "(yypminor->yy%d)" , $ sp -> dtnum ) ; $ i ++ ; continue ; } if ( $ cp [ $ i ] == "\n" ) { $ linecnt ++ ; } fwrite ( $ out , $ cp [ $ i ] ) ; } $ lineno += 3 + $ linecnt ; fwrite ( $ out , "}\n" ) ; $ this -> tplt_linedir ( $ out , $ lineno , $ this -> outname ) ; }
The following routine emits code for the destructor for the
symbol sp
The following routine emits code for the destructor for the symbol sp