private function tree() { try { $lexer = new Tokenizer($this->source); $parser = new TokenReader($lexer); $parser->arithmetic(); $parser->printExpressionTree(); } catch (Exception $e) { echo $e->getMessage(); } }
/** * This method is called to load the sources from the reader * into the buffer of the source. */ function load() { // Create new Reader if ($this->classname === null) { throw new BuildException("No Classname given to TokenSource."); } $classname = Phing::import($this->classname); $this->reader = new $classname($this->project); // Configure Reader $this->configureTokenReader($this->reader); // Load Tokens try { while ($token = $this->reader->readToken()) { $this->tokens[] = $token; } } catch (BuildException $e) { $this->log("Error reading TokenSource: " . $e->getMessage(), PROJECT_MSG_WARN); } catch (IOException $e) { $this->log("Error reading TokenSource: " . $e->getMessage(), PROJECT_MSG_WARN); } }
<?php /** * @author Elynton Fellipe Bazzo * @author Andrei Siqueira */ require_once 'Lexer.php'; require_once 'Parser.php'; require_once 'Tokenizer.php'; require_once 'TokenReader.php'; require_once 'Token.php'; require_once 'LexerError.php'; require_once 'ParserError.php'; $source = <<<END -(3) / -10; END; try { // Instanciamos o lexer e o parser, fazemos a análise aritmética e // imprimimos a árvore gerada $lexer = new Tokenizer($source); $parser = new TokenReader($lexer); $parser->arithmetic(); $parser->printExpressionTree(); } catch (Exception $e) { echo $e->getMessage(); }
$httpCode = 400; } else { $execurl = "{$target}?" . http_build_query($get); $url = "http://" . $_SERVER["SERVER_NAME"] . "/{$execurl}"; if (($script_result = @get_contents($url, $_SERVER["REQUEST_METHOD"], $post)) === false) { $errors[] = "HTTP request for file on server failed."; } elseif (preg_match("/<b>Parse error<\\/b>: syntax error, (.*) in .* on line <b>(\\d+)<\\/b>/", $script_result["content"], $matches)) { $errors[] = array("syntaxError" => array("reason" => $matches[1], "lineNumber" => $matches[2])); $httpCode = 200; // still made successful request } elseif ($script_result["status"]["code"] == 200) { if (($target_contents = @file_get_contents($targetfile)) === false) { $errors[] = "Cannot open specified PHP file on server {$targetfile}."; $httpCode = 404; } else { $tok = new TokenReader($target_contents); $execurl = "{$target}?" . http_build_query($get); $url = "http://" . $_SERVER["SERVER_NAME"] . "/{$execurl}"; $pdovar = null; $queries = array(); $username = null; $host = null; $dbname = null; while (!$tok->atEnd()) { $result = $tok->findInputVars($_SERVER["REQUEST_METHOD"]); if ($result !== null) { $vars->addVar($result[0][0], $result[0][1], $result[0][2], $result[0][3]); $tok->forward($result[1]); } else { $result = $tok->findPdoInfo(); if ($result !== null) {