Exemple #1
0
 private function compile(array $expansion, Map $context) : TokenStream
 {
     $cg = (object) ['ts' => TokenStream::fromSlice($expansion), 'context' => $context];
     $cg->ts->trim();
     traverse(either(token(T_VARIABLE), chain(identifier(), token(':')), chain(token(T_GOTO), identifier()))->onCommit(function () {
         $this->unsafe = true;
     }))->parse($cg->ts);
     $cg->ts->reset();
     traverse(consume(chain(token(T_NS_SEPARATOR), token(T_NS_SEPARATOR), parentheses()->as('cloaked')))->onCommit(function (Ast $result) use($cg) {
         $cg->ts->inject(TokenStream::fromSequence(new Token(Token::CLOAKED, implode('', $result->cloaked))));
         $this->cloaked = true;
     }), token(Token::CLOAKED), chain(rtoken('/^··\\w+$/')->as('expander'), either(parentheses(), braces())->as('args'))->onCommit(function () {
         $this->constant = false;
     }), chain(rtoken('/^·\\w+|···\\w+$/')->as('label'), operator('···'), optional(parentheses()->as('delimiters')), braces()->as('expansion'))->onCommit(function (Ast $result) use($cg) {
         $this->lookupContext($result->label, $cg->context, self::E_UNDEFINED_EXPANSION);
         $this->constant = false;
     }), rtoken('/^(T_\\w+·\\w+|·\\w+|···\\w+)$/')->onCommit(function (Ast $result) use($cg) {
         $this->lookupContext($result->token(), $cg->context, self::E_UNDEFINED_EXPANSION);
         $this->constant = false;
     }), rtoken('/·/')->onCommit(function (Ast $result) use($cg) {
         $this->lookupContext($result->token(), $cg->context, self::E_BAD_EXPANSION);
     }))->parse($cg->ts);
     $cg->ts->reset();
     return $cg->ts;
 }
Exemple #2
0
 public function getId()
 {
     if (is_null($this->id)) {
         $set = $this->setId();
         $set->send((yield identifier()));
     }
     (yield $this->id);
 }
Exemple #3
0
function hygienize(TokenStream $ts, string $scope) : TokenStream
{
    $ts->reset();
    traverse(either(chain(token(T_STRING, '·unsafe'), parentheses()), either(token(T_VARIABLE)->as('target'), chain(identifier()->as('target'), token(':')), chain(token(T_GOTO), identifier()->as('target')))->onCommit(function (Ast $result) use($scope) {
        (function () use($scope) {
            if ((string) $this !== '$this') {
                $this->value = (string) $this . '·' . $scope;
            }
        })->call($result->target);
    }), any()))->parse($ts);
    $ts->reset();
    return $ts;
}
Exemple #4
0
function hygienize(TokenStream $ts, array $context) : TokenStream
{
    $ts->reset();
    $cg = (object) ['node' => null, 'context' => $context, 'ts' => $ts];
    $saveNode = function (Parser $parser) use($cg) {
        return midrule(function ($ts) use($cg, $parser) {
            $cg->node = $ts->index();
            return $parser->parse($ts);
        });
    };
    traverse(chain(token(T_STRING, '··unsafe'), either(parentheses(), braces())), either($saveNode(token(T_VARIABLE)), chain($saveNode(identifier()), token(':')), chain(token(T_GOTO), $saveNode(identifier())))->onCommit(function (Ast $result) use($cg) {
        if (($t = $cg->node->token) && ($value = (string) $t) !== '$this') {
            $cg->node->token = new Token($t->type(), "{$value}·{$cg->context['scope']}", $t->line());
        }
    }))->parse($ts);
    $ts->reset();
    return $ts;
}
Exemple #5
0
        $count2 = mysql_fetch_assoc(Mysql_query("SELECT COUNT(*) FROM {$CONF['sqlPrefix']}statRobots WHERE LOWER(user_agent) LIKE '%{$value}%' AND time<" . time() . " AND time>" . (time() - 60 * 60 * 24 * 30) . " "));
        // Zobrazení
        $bgcolor = $i % 2 ? "#EFEFEF" : "#DFDFDF";
        echo "<tr>\n                    <td bgcolor={$bgcolor}>{$key}</td>\n                    <td bgcolor={$bgcolor}>" . ($radek["time"] ? date("j.n.Y G:i", $radek["time"]) : "&nbsp;- bez návštěvy - ") . "</td>\n                    <td bgcolor={$bgcolor}>" . $count["COUNT(*)"] . "</td>                \n                    <td bgcolor={$bgcolor}>" . $count2["COUNT(*)"] . "x / měsíc</td>\n                    <td bgcolor={$bgcolor}>" . ($radek2["time"] ? timeToStr($radek["time"] - $radek2["time"]) : '') . "</td>\n                  </tr>";
        $i++;
    }
    echo "</table>";
    //////////////////////
    // Poslední návštěvy
    //////////////////////
    echo "<h3>Posledních 30 návštěv</h3>\n          <table border=0 width=100%>\n            <tr>\n              <td bgcolor=#CFCFCF width=40><strong>id</strong></td> \n              <td bgcolor=#CFCFCF><strong>Název vyhledávače</strong></td>\n              <td bgcolor=#CFCFCF width=160><strong>Datum</strong></td>     \n            </tr>\n          </table>\n          <div style=\"\"> <!--height: 200px; overflow: auto;-->\n          <table border=0 width=100%>\n          ";
    $dotaz = Mysql_query("SELECT * FROM {$CONF['sqlPrefix']}statRobots ORDER BY time DESC LIMIT 30");
    $i = 1;
    while ($radek = mysql_fetch_assoc($dotaz)) {
        $bgcolor = $i % 2 ? "#EFEFEF" : "#DFDFDF";
        echo "<tr>\n                  <td bgcolor={$bgcolor} width=40>{$radek['id']}</td>\n                  <td bgcolor={$bgcolor}>" . identifier($radek["user_agent"]) . "</td>\n                  <td bgcolor={$bgcolor} width=144>" . date("j.n.Y G:i", $radek["time"]) . "</td>\n                 </tr>";
        $i++;
    }
    echo "</table>\n          </div>";
}
/***************/
/* VYHLEDÁVAČE */
/***************/
if ($_GET["n"] == 'zbozi') {
    $dotaz = Mysql_query("SELECT * FROM {$CONF['sqlPrefix']}statProdukty join {$CONF['sqlPrefix']}zbozi on idProduktu=id ORDER BY pocet DESC LIMIT 30 ");
    echo '<table border="0">
            <tr>
              <td bgcolor="#CFCFCF"><b>Zboží</b></td>
              <td bgcolor="#CFCFCF"><b>Počet prohlídnutí</b></td>
            </tr>';
    $i = 1;
Exemple #6
0
 private function compileExpansion(int $line, array $expansion) : TokenStream
 {
     $ts = TokenStream::fromSlice($expansion);
     $ts->trim();
     traverse(either(consume(chain(token(T_NS_SEPARATOR), token(T_NS_SEPARATOR), parentheses()->as('cloaked')))->onCommit(function (Ast $result) use($ts) {
         $ts->inject(TokenStream::fromSequence(new Token(Token::CLOAKED, implode('', $result->cloaked))));
         $this->cloaked = true;
     }), token(Token::CLOAKED), either(token(T_VARIABLE), chain(identifier(), token(':')), chain(token(T_GOTO), identifier()))->onCommit(function () {
         $this->unsafe = true;
     }), chain(rtoken('/^·\\w+$/')->as('expander'), parentheses()->as('args'))->onCommit(function ($r) {
         $this->constant = false;
     }), chain(rtoken('/^·\\w+|···\\w+$/')->as('label'), operator('···'), braces()->as('expansion'))->onCommit(function (Ast $result) {
         if (!isset($this->lookup[$id = (string) $result->label])) {
             $this->fail(self::E_EXPANSION, $id, $result->label->line(), json_encode(array_keys($this->lookup), self::PRETTY_PRINT));
         }
         $this->constant = false;
     }), rtoken('/^(T_\\w+·\\w+|·\\w+|···\\w+)$/')->onCommit(function (Ast $result) {
         $token = $result->token();
         if (!isset($this->lookup[$id = (string) $token])) {
             $this->fail(self::E_EXPANSION, $id, $token->line(), json_encode(array_keys($this->lookup), self::PRETTY_PRINT));
         }
         $this->constant = false;
     }), rtoken('/·/')->onCommit(function (Ast $result) {
         $token = $result->token();
         $this->fail(self::E_BAD_EXPANSION, $token, $token->line());
     }), any()))->parse($ts);
     $ts->reset();
     return $ts;
 }