Exemplo n.º 1
0
 public function run()
 {
     $this->input = filter_input(INPUT_POST, 'english', FILTER_SANITIZE_FULL_SPECIAL_CHARS);
     if (isset($this->input)) {
         $lexer = new Lexer($this->input);
         $tokens = $lexer->run();
         $translator = new Translator($tokens);
         $result = $translator->run();
         if ($this->isAjax()) {
             $this->sendPayload($result);
         }
     }
 }
Exemplo n.º 2
0
            }
        }
        return $result;
    }
    protected static function _match($line, $number, $offset)
    {
        $string = substr($line, $offset);
        foreach (static::$_terminals as $pattern => $name) {
            if (preg_match($pattern, $string, $matches)) {
                return array('match' => $matches[1], 'token' => $name, 'line' => $number + 1);
            }
        }
        return false;
    }
    protected static function _exec($token)
    {
        switch ($token['token']) {
            case 'T_G':
                return 'g';
                break;
            case 'T_O':
                return 'o';
                break;
            case 'T_AL':
                return 'al';
                break;
        }
    }
}
echo Lexer::run(array("g()('al')"));