Пример #1
0
 function __construct($code)
 {
     $tmp_file = "/tmp/.snowcode";
     file_put_contents($tmp_file, $code);
     parent::__construct("");
     #var_dump(Snowscript_Lexer::$named_tokenmap,
     #         Snowscript_Lexer::$tokenMap); die;
     list($this->tokens, $this->debug) = $this->get_tokens($tmp_file);
     unlink($tmp_file);
 }
Пример #2
0
 public function __construct($code)
 {
     $this->inObjectAccess = false;
     // on PHP 5.4 don't do anything
     if (version_compare(PHP_VERSION, '5.4.0RC1', '>=')) {
         parent::__construct($code);
     } else {
         $code = $this->preprocessCode($code);
         parent::__construct($code);
         $this->postprocessTokens();
     }
 }
Пример #3
0
 public function __construct()
 {
     parent::__construct();
     $newKeywordsPerVersion = array('5.5.0-dev' => array('finally' => PHPParser_Parser::T_FINALLY, 'yield' => PHPParser_Parser::T_YIELD), '5.4.0-dev' => array('callable' => PHPParser_Parser::T_CALLABLE, 'insteadof' => PHPParser_Parser::T_INSTEADOF, 'trait' => PHPParser_Parser::T_TRAIT, '__trait__' => PHPParser_Parser::T_TRAIT_C), '5.3.0-dev' => array('__dir__' => PHPParser_Parser::T_DIR, 'goto' => PHPParser_Parser::T_GOTO, 'namespace' => PHPParser_Parser::T_NAMESPACE, '__namespace__' => PHPParser_Parser::T_NS_C));
     $this->newKeywords = array();
     foreach ($newKeywordsPerVersion as $version => $newKeywords) {
         if (version_compare(PHP_VERSION, $version, '>=')) {
             break;
         }
         $this->newKeywords += $newKeywords;
     }
 }
Пример #4
0
 public function __construct($code)
 {
     $this->tokens = array();
     $this->debug = array();
     $this->named_tokenmap = get_named_tokenmap();
     $this->transform_token_value = array('T_VARIABLE' => '$%s');
     $this->literal_tokens = array('T_PLUS' => 1, 'T_GREATER' => 1, 'T_LPAR' => 1, 'T_RPAR' => 1, 'T_MINUS' => 1, 'T_STAR' => 1, 'T_SLASH' => 1, 'T_EQUAL' => 1, 'T_AMPER' => 1, 'T_COMMA' => 1, 'T_LSQB' => 1, 'T_RSQB' => 1, 'T_QUESTION_MARK' => 1, 'T_COLON' => 1);
     $this->translated_tokens = array('T_NEWLINE' => ';', 'T_INDENT' => '{', 'T_DEDENT' => '}', 'T_BAND' => '&', 'T_BXOR' => '^', 'T_PERCENT' => '.', 'T_MOD' => '%', 'T_BNOT' => '~', 'T_BOR' => '|', 'T_LBRACE' => '{', 'T_RBRACE' => '}', 'T_LESS' => '<', 'T_NOT' => '!');
     $this->ignored_tokens = array('T_ENDMARKER' => 1, 'T_PASS' => 1);
     $this->token_types_map = array('T_NAME' => 'T_VARIABLE', 'T_PHP_STRING' => 'T_STRING', 'T_BLEFT' => 'T_SL', 'T_BRIGHT' => 'T_SR', 'T_FN' => 'T_FUNCTION', 'T_DOUBLE_DOT' => 'T_PAAMAYIM_NEKUDOTAYIM', 'T_CALLABLE' => 'T_STRING', 'T_TRUE' => 'T_STRING', 'T_FALSE' => 'T_STRING', 'T_ELIF' => 'T_ELSEIF', 'T_ISA' => 'T_INSTANCEOF', 'T_DIE' => 'T_EXIT', 'T_OR' => 'T_BOOLEAN_OR', 'T_XOR' => 'T_LOGICAL_XOR', 'T_AND' => 'T_BOOLEAN_AND', 'T__OR_' => 'T_LOGICAL_OR', 'T__AND_' => 'T_LOGICAL_AND', 'T_DOT' => 'T_OBJECT_OPERATOR', 'T_NULL' => 'T_STRING', 'T_CONSTANT_NAME' => 'T_STRING', 'T_CLASS_NAME' => 'T_STRING', 'T_FLOAT_CAST' => 'T_DOUBLE_CAST', 'T_STRINGTYPE_CAST' => 'T_STRING_CAST', 'T_NEXT' => 'T_CONTINUE', 'T_PARENT' => 'T_STRING', 'T_COLON' => 'T_DOUBLE_ARROW');
     $this->token_callback = array('T_STRING_WITH_CONCAT' => 1, 'T_NUMBER' => 1);
     $tmp_file = "/tmp/.snowcode";
     file_put_contents($tmp_file, $code);
     parent::__construct("");
     list($this->tokens, $this->debug) = $this->get_tokens($tmp_file);
     unlink($tmp_file);
 }