phpython Code
a python interpreter written in php
Status: Pre-Alpha
Brought to you by:
francescobianco
--- a/trunk/python/python.class +++ b/trunk/python/python.class @@ -25,7 +25,13 @@ array ( 'simple_stmt' => 's 1', 'compound_stmt' => 's 2', - 'stmt' => 's 3', + 'small_stmt' => 's 3', + 'cmd_stmt' => 's 6', + 'for_stmt' => 's 9', + 'NAME' => 's 7', + 'FOR' => 's 10', + '\'for_stmt\'7' => 's 17', + 'stmt' => 's 19', '\'start\'' => 'a \'start\'', ), 1 => @@ -38,7 +44,77 @@ ), 3 => array ( + 'NEWLINE' => 's 4', + ), + 4 => + array ( + 'small_stmt' => 's 3', + 'simple_stmt' => 's 5', + 'cmd_stmt' => 's 6', + 'NAME' => 's 7', + '#' => 'r 3', + ), + 5 => + array ( '#' => 'r 2', + ), + 6 => + array ( + 'NEWLINE' => 'r 4', + ), + 7 => + array ( + 'DSTRING' => 's 8', + ), + 8 => + array ( + 'NEWLINE' => 'r 6', + ), + 9 => + array ( + '#' => 'r 5', + ), + 10 => + array ( + 'exprlist' => 's 11', + 'NAME' => 's 16', + ), + 11 => + array ( + 'IN' => 's 12', + ), + 12 => + array ( + 'testlist' => 's 13', + 'NAME' => 's 15', + ), + 13 => + array ( + 'COLON' => 's 14', + ), + 14 => + array ( + 'suite' => 'r 7', + ), + 15 => + array ( + 'COLON' => 'r 10', + ), + 16 => + array ( + 'IN' => 'r 9', + ), + 17 => + array ( + 'suite' => 's 18', + ), + 18 => + array ( + '#' => 'r 8', + ), + 19 => + array ( + '#' => 'r 11', ), ); function reduce_0_stmt_1($tokens, &$result) { @@ -57,9 +133,81 @@ } -function reduce_2_start_1($tokens, &$result) { -# -# (2) 'start' := stmt +function reduce_2_simple_stmt_1($tokens, &$result) { +# +# (2) simple_stmt := small_stmt NEWLINE simple_stmt +# +$result = reset($tokens); + +} + +function reduce_3_simple_stmt_2($tokens, &$result) { +# +# (3) simple_stmt := small_stmt NEWLINE +# +$result = reset($tokens); + +} + +function reduce_4_small_stmt_1($tokens, &$result) { +# +# (4) small_stmt := cmd_stmt +# +$result = reset($tokens); + +} + +function reduce_5_compound_stmt_1($tokens, &$result) { +# +# (5) compound_stmt := for_stmt +# +$result = reset($tokens); + +} + +function reduce_6_cmd_stmt_1($tokens, &$result) { +# +# (6) cmd_stmt := NAME DSTRING +# +$result = reset($tokens); +python_command($tokens[0],$tokens[1]); +} + +function reduce_7_for_stmt7_1($tokens, &$result) { +# +# (7) 'for_stmt'7 := FOR exprlist IN testlist COLON +# +$result = reset($tokens); + foreach(array("a") as $c): +} + +function reduce_8_for_stmt_1($tokens, &$result) { +# +# (8) for_stmt := 'for_stmt'7 suite +# +$result = reset($tokens); + endforeach; +} + +function reduce_9_exprlist_1($tokens, &$result) { +# +# (9) exprlist := NAME +# +$result = reset($tokens); + +} + +function reduce_10_testlist_1($tokens, &$result) { +# +# (10) testlist := NAME +# +$result = reset($tokens); + +} + +function reduce_11_start_1($tokens, &$result) { +# +# (11) 'start' := stmt # $result = reset($tokens); @@ -68,7 +216,16 @@ var $method = array ( 0 => 'reduce_0_stmt_1', 1 => 'reduce_1_stmt_2', - 2 => 'reduce_2_start_1', + 2 => 'reduce_2_simple_stmt_1', + 3 => 'reduce_3_simple_stmt_2', + 4 => 'reduce_4_small_stmt_1', + 5 => 'reduce_5_compound_stmt_1', + 6 => 'reduce_6_cmd_stmt_1', + 7 => 'reduce_7_for_stmt7_1', + 8 => 'reduce_8_for_stmt_1', + 9 => 'reduce_9_exprlist_1', + 10 => 'reduce_10_testlist_1', + 11 => 'reduce_11_start_1', ); var $a = array ( 0 => @@ -85,6 +242,60 @@ ), 2 => array ( + 'symbol' => 'simple_stmt', + 'len' => 3, + 'replace' => true, + ), + 3 => + array ( + 'symbol' => 'simple_stmt', + 'len' => 2, + 'replace' => true, + ), + 4 => + array ( + 'symbol' => 'small_stmt', + 'len' => 1, + 'replace' => true, + ), + 5 => + array ( + 'symbol' => 'compound_stmt', + 'len' => 1, + 'replace' => true, + ), + 6 => + array ( + 'symbol' => 'cmd_stmt', + 'len' => 2, + 'replace' => true, + ), + 7 => + array ( + 'symbol' => '\'for_stmt\'7', + 'len' => 5, + 'replace' => false, + ), + 8 => + array ( + 'symbol' => 'for_stmt', + 'len' => 7, + 'replace' => true, + ), + 9 => + array ( + 'symbol' => 'exprlist', + 'len' => 1, + 'replace' => true, + ), + 10 => + array ( + 'symbol' => 'testlist', + 'len' => 1, + 'replace' => true, + ), + 11 => + array ( 'symbol' => '\'start\'', 'len' => 1, 'replace' => true,