|
From: <da...@us...> - 2003-08-04 05:38:34
|
Update of /cvsroot/binaryphp/binaryphp
In directory sc8-pr-cvs1:/tmp/cvs-serv27272
Modified Files:
convert.php functions.php testfile.php tokenflow.php
Log Message:
Functional IRC bot example!
Index: convert.php
===================================================================
RCS file: /cvsroot/binaryphp/binaryphp/convert.php,v
retrieving revision 1.16
retrieving revision 1.17
diff -C2 -d -r1.16 -r1.17
*** convert.php 4 Aug 2003 00:48:37 -0000 1.16
--- convert.php 4 Aug 2003 05:38:31 -0000 1.17
***************
*** 16,20 ****
require_once 'functions.php';
$tokenizer = new Tokenizer();
! $tokenizer->Parse('testfile.php');
$tokenizer->Strip();
$gen = new Generator($tokenizer);
--- 16,20 ----
require_once 'functions.php';
$tokenizer = new Tokenizer();
! $tokenizer->Parse('testfile2.php');
$tokenizer->Strip();
$gen = new Generator($tokenizer);
Index: functions.php
===================================================================
RCS file: /cvsroot/binaryphp/binaryphp/functions.php,v
retrieving revision 1.34
retrieving revision 1.35
diff -C2 -d -r1.34 -r1.35
*** functions.php 4 Aug 2003 00:48:37 -0000 1.34
--- functions.php 4 Aug 2003 05:38:31 -0000 1.35
***************
*** 12,16 ****
'unlink' => array('stdio.h', 'io/unlink.cpp'),
'strtolower' => array('stdio.h', 'string/strtolower.cpp'),
! 'explode' => array(null, array('array.cpp', 'explode.cpp')),
'implode' => array(null, 'implode.cpp'),
'fopen' => array('cstdio', 'io/fopen.cpp'),
--- 12,16 ----
'unlink' => array('stdio.h', 'io/unlink.cpp'),
'strtolower' => array('stdio.h', 'string/strtolower.cpp'),
! 'explode' => array(null, array('arrays/array.cpp', 'explode.cpp')),
'implode' => array(null, 'implode.cpp'),
'fopen' => array('cstdio', 'io/fopen.cpp'),
***************
*** 18,22 ****
'is_resource' => array(null, 'is_resource.cpp'),
'file_get_contents' => array('stdio.h', 'io/file_get_contents.cpp'),
! 'file' => array('stdio.h', array('array.cpp', 'explode.cpp', 'count.cpp', 'file.cpp')),
'strstr' => array(null, 'string/strstr.cpp'),
'strpos' => array(null, 'string/strpos.cpp'),
--- 18,22 ----
'is_resource' => array(null, 'is_resource.cpp'),
'file_get_contents' => array('stdio.h', 'io/file_get_contents.cpp'),
! 'file' => array('stdio.h', array('arrays/array.cpp', 'explode.cpp', 'count.cpp', 'file.cpp')),
'strstr' => array(null, 'string/strstr.cpp'),
'strpos' => array(null, 'string/strpos.cpp'),
***************
*** 36,45 ****
'ksort' => array(null, 'ksort.cpp'),
'stristr' => array('stdio.h', array('string/strtolower.cpp', 'string/stristr.cpp')),
! 'ucwords' => array('stdio.h', array('array.cpp', 'explode.cpp', 'implode.cpp', 'ucwords.cpp')),
'ucfirst' => array('cstdio', 'ucfirst.cpp'),
'trim' => array(null, 'trim.cpp'),
'rtrim' => array(null, 'rtrim.cpp'),
'ltrim' => array(null, 'ltrim.cpp'),
! 'mysql_connect' => array('mysql/mysql.h', array('mysql.cpp', 'array.cpp', 'explode.cpp', 'mysql_connect.cpp'), 'mysqlclient'),
'mysql_select_db' => array('mysql/mysql.h', array('mysql.cpp', 'mysql_select_db.cpp'), 'mysqlclient'),
'mysql_query' => array('mysql/mysql.h', array('mysql.cpp', 'mysql_query.cpp'), 'mysqlclient'),
--- 36,45 ----
'ksort' => array(null, 'ksort.cpp'),
'stristr' => array('stdio.h', array('string/strtolower.cpp', 'string/stristr.cpp')),
! 'ucwords' => array('stdio.h', array('arrays/array.cpp', 'explode.cpp', 'implode.cpp', 'ucwords.cpp')),
'ucfirst' => array('cstdio', 'ucfirst.cpp'),
'trim' => array(null, 'trim.cpp'),
'rtrim' => array(null, 'rtrim.cpp'),
'ltrim' => array(null, 'ltrim.cpp'),
! 'mysql_connect' => array('mysql/mysql.h', array('mysql.cpp', 'arrays/array.cpp', 'explode.cpp', 'mysql_connect.cpp'), 'mysqlclient'),
'mysql_select_db' => array('mysql/mysql.h', array('mysql.cpp', 'mysql_select_db.cpp'), 'mysqlclient'),
'mysql_query' => array('mysql/mysql.h', array('mysql.cpp', 'mysql_query.cpp'), 'mysqlclient'),
***************
*** 47,54 ****
'mysql_fetch_array' => array('mysql/mysql.h', array('mysql.cpp', 'mysql_fetch_array.cpp'), 'mysqlclient'),
'mysql_error' => array('mysql/mysql.h', array('mysql.cpp', 'mysql_error.cpp'), 'mysqlclient'),
! 'socket_create' => array('sys/socket.h', 'socket_create.cpp'),
! 'socket_connect' => array(array('sys/socket.h', 'netinet/in.h', 'arpa/inet.h', 'netdb.h'), 'socket_connect.cpp'),
! 'socket_write' => array('unistd.h', 'socket_write.cpp'),
! 'socket_read' => array(null, 'socket_read.cpp'),
'opendir' => array(array('cstdio', 'dirent.h'), 'opendir.cpp'),
'readdir' => array(array('cstdio', 'dirent.h'), 'readdir.cpp'),
--- 47,54 ----
'mysql_fetch_array' => array('mysql/mysql.h', array('mysql.cpp', 'mysql_fetch_array.cpp'), 'mysqlclient'),
'mysql_error' => array('mysql/mysql.h', array('mysql.cpp', 'mysql_error.cpp'), 'mysqlclient'),
! 'socket_create' => array('sys/socket.h', 'sockets/socket_create.cpp'),
! 'socket_connect' => array(array('sys/socket.h', 'netinet/in.h', 'arpa/inet.h', 'netdb.h'), 'sockets/socket_connect.cpp'),
! 'socket_write' => array('unistd.h', 'sockets/socket_write.cpp'),
! 'socket_read' => array(null, 'sockets/socket_read.cpp'),
'opendir' => array(array('cstdio', 'dirent.h'), 'opendir.cpp'),
'readdir' => array(array('cstdio', 'dirent.h'), 'readdir.cpp'),
Index: testfile.php
===================================================================
RCS file: /cvsroot/binaryphp/binaryphp/testfile.php,v
retrieving revision 1.42
retrieving revision 1.43
diff -C2 -d -r1.42 -r1.43
*** testfile.php 4 Aug 2003 04:34:32 -0000 1.42
--- testfile.php 4 Aug 2003 05:38:31 -0000 1.43
***************
*** 8,11 ****
--- 8,12 ----
while ($data = socket_read($sock, 2046))
{
+ echo $data, "\n";
$temp = explode(':', $data);
$temp2 = explode('!', $temp[1]);
Index: tokenflow.php
===================================================================
RCS file: /cvsroot/binaryphp/binaryphp/tokenflow.php,v
retrieving revision 1.46
retrieving revision 1.47
diff -C2 -d -r1.46 -r1.47
*** tokenflow.php 4 Aug 2003 00:48:37 -0000 1.46
--- tokenflow.php 4 Aug 2003 05:38:31 -0000 1.47
***************
*** 416,428 ****
break;
case T_CONSTANT_ENCAPSED_STRING:
- if($tokenizer->tokens[$token_][0] == T_ARRAY && count($parameters) % 2 == 0 && (is_array($tokenizer->tokens[$i + 1]) && $tokenizer->tokens[$i + 1][1] != '=>'))
- $parameters[] = -1;
- if(strtolower($funcname) == 'define')
- $parameters[] = '"' . str_replace('"', '\\"', substr($data_, 1, -1) ) . '"';
- else
- $parameters[] = '(php_var)"' . str_replace('"', '\\"', substr($data, 1, -1) ) . '"';
- break;
- case ',':
- break;
case T_DEC:
case T_INC:
--- 416,419 ----
***************
*** 430,438 ****
case T_LNUMBER:
case T_VARIABLE:
- if($tokenizer->tokens[$token_][0] == T_ARRAY && count($parameters) % 2 == 0 && (is_array($tokenizer->tokens[$i + 1]) && $tokenizer->tokens[$i + 1][1] != '=>'))
- $parameters[] = -1;
list($parameters[], $i) = $this->parse_statement($tokenizer, $i);
! if($tokenizer->tokens[$token_][0] == T_ARRAY)
! $parameters[count($parameters) - 1] = $parameters[count($parameters) - 1];
break;
case ';':
--- 421,427 ----
case T_LNUMBER:
case T_VARIABLE:
list($parameters[], $i) = $this->parse_statement($tokenizer, $i);
! break;
! case ',':
break;
case ';':
***************
*** 532,535 ****
--- 521,525 ----
$params = array();
$inconcat = false;
+ $inbrace = false;
for($i = $token; $i < count($tokens); ++$i)
{
***************
*** 541,547 ****
--- 531,541 ----
$data_ = null;
}
+ if($tokenizer->tokens[$i + 1] == '.')
+ $inconcat = true;
switch($token_)
{
case T_VARIABLE:
+ if($inconcat == true && $inbrace == false)
+ $code .= '(string)(const char*)';
if(in_array(substr($data_, 1), $this->scope[$this->curfunction]) || $this->inclass == true)
$code .= '_' . substr($data_, 1);
***************
*** 556,561 ****
case T_ARRAY:
case T_STRING:
! if($inconcat == true)
! $code .= '(string)';
if(strtolower($data_) == 'true' || strtolower($data_) == 'false' || strtolower($data_) == 'null')
$code .= '(php_var) ' . strtolower($data_);
--- 550,555 ----
case T_ARRAY:
case T_STRING:
! if($inconcat == true && $inbrace == false)
! $code .= '(string)(const char*)';
if(strtolower($data_) == 'true' || strtolower($data_) == 'false' || strtolower($data_) == 'null')
$code .= '(php_var) ' . strtolower($data_);
***************
*** 588,599 ****
break;
case T_CONSTANT_ENCAPSED_STRING:
! if($inconcat == true)
! $code .= '(string)';
$code .= '"' . str_replace('"', '\\"', substr($data_, 1, -1) ). '"';
break;
case T_DNUMBER:
case T_LNUMBER:
! if($inconcat == true)
! $code .= '(string)';
$code .= '(php_var)' . $data_;
break;
--- 582,593 ----
break;
case T_CONSTANT_ENCAPSED_STRING:
! if($inconcat == true && $inbrace == false)
! $code .= '(string)(const char*)';
$code .= '"' . str_replace('"', '\\"', substr($data_, 1, -1) ). '"';
break;
case T_DNUMBER:
case T_LNUMBER:
! if($inconcat == true && $inbrace == false)
! $code .= '(string)(const char*)';
$code .= '(php_var)' . $data_;
break;
***************
*** 652,658 ****
--- 646,654 ----
case '[':
$code .= '[';
+ $inbrace = true;
break;
case ']':
$code .= ']';
+ $inbrace = false;
break;
case '-':
***************
*** 684,691 ****
return array(implode(' = ', $params), $i);
}
! function debug_token(&$tokenizer, $token)
{
for($i = $token; $i < count($tokenizer->tokens); ++$i)
{
if(is_array($tokenizer->tokens[$i]))
echo $i, ' - ', token_name($tokenizer->tokens[$i][0]), ': "', $tokenizer->tokens[$i][1], '"', "\n";
--- 680,689 ----
return array(implode(' = ', $params), $i);
}
! function debug_token(&$tokenizer, $token, $token_ = null)
{
for($i = $token; $i < count($tokenizer->tokens); ++$i)
{
+ if($token_ !== null && $tokenizer->tokens[$i] == $token_)
+ break;
if(is_array($tokenizer->tokens[$i]))
echo $i, ' - ', token_name($tokenizer->tokens[$i][0]), ': "', $tokenizer->tokens[$i][1], '"', "\n";
|