Beispiel #1
0
 static function compile($codestr)
 {
     #-- ideally, we want to avoid generating our parser table at every compilation.
     #-- 2 layers of caching: using an external file, and using static vars.
     global $def_fun_track;
     static $lex = NULL;
     static $parser = NULL;
     if ($lex == NULL) {
         $t0 = microtime(1);
         $path = dirname(__FILE__) . "/js.ly.php";
         if (file_exists($path)) {
             include $path;
         } else {
             $path = JS_CACHE_DIR . "/js.ly.php";
             if (file_exists($path)) {
                 include $path;
             } else {
                 require_once dirname(__FILE__) . "/parse/generator.so.php";
                 $lexp = generate_scanner_from_file(dirname(__FILE__) . "/js.l", 0)->pattern;
                 $dpa = generate_parser_from_file(dirname(__FILE__) . "/js.y");
                 file_put_contents($path, "<?php\n" . "// This file is dynamically generated from js.l and js.y by metaphp's CFG parser\n" . "// Do not waste your time editing it or reading it. Move along. Thank you.\n" . "\n" . $GLOBALS['func_def'] . "\$lexp = " . var_export($lexp, 1) . ";\n\$dpa = " . var_export($dpa, 1) . ";\n?>");
             }
         }
         $t1 = microtime(1);
         $lex = new preg_scanner(0, $lexp);
         $parser = new easy_parser($dpa);
         $t2 = microtime(1);
         #echo "Table loading: ".($t1-$t0)." seconds<br>";
         #echo "Pre generation: ".($t2-$t1)." seconds<br>";
     }
     $t3 = microtime(1);
     $lex->start($codestr);
     $program = $parser->parse("Program", $lex);
     $t4 = microtime(1);
     #echo "Parse time: ".($t4-$t3)." seconds<br>";
     # convert into usable php code
     try {
         $php = $program->emit();
     } catch (Exception $e) {
         #-- Compilation error. should be pretty rare. usually the parser will barf long before this.
         echo "Compilation Error: " . $e->value->msg . "<hr>";
     }
     return $php;
 }
Beispiel #2
0
function dadosWS()
{
    global $param, $cp, $servico, $funcaows;
    //ini_set("memory_limit","28M");
    include_once dirname(__FILE__) . '/../pacotes/SOAP/nusoap.php';
    include_once dirname(__FILE__) . "/../pacotes/SOAP/easy_parser.inc";
    $soapclient = new Xsoapclient($servico . "?wsdl", "wsdl");
    $retorna = "erro";
    $parametros = "";
    if (isset($param)) {
        $parametros = array();
        $linhas = explode("|", $param);
        if (count($linhas) == 0) {
            $linhas[] = $param;
        }
        foreach ($linhas as $linha) {
            $p = explode("*", $linha);
            if ($p[1] == "null" || $p[1] == "") {
                $p[1] = null;
            }
            $parametros = array_merge(array($p[0] => $p[1]), $parametros);
        }
    }
    $resultado = $soapclient->call($funcaows, $parametros);
    $xml = new easy_parser();
    $result = $xml->parser($resultado, false);
    // if source of document is not a file then use $result = $xml->parser($var_source,false)
    if (@($r = $xml->view_source())) {
        $retorna = "<b>Resultado da chamada XML:</b><br><br>" . $r;
    } else {
        if (@($p = $soapclient->getproxy())) {
            $vv = $p->{$funcaows}($parametros);
            $retorna = "<br><b>Resultado da chamada com getproxy</b><br>";
            $retorna .= "<pre>";
            $retorna .= print_r($vv, true);
            $retorna .= "</pre>";
            $retorna .= "<b>Resultado da chamada normal</b><br>";
            $retorna .= "<pre><font color=red>";
            $retorna .= print_r($resultado, true);
        }
    }
    if (function_exists("mb_convert_encoding")) {
        $cp->set_data(mb_convert_encoding($retorna, "UTF-8", "ISO-88591"));
    } else {
        $cp->set_data($retorna);
    }
}