phpython Code
a python interpreter written in php
Status: Pre-Alpha
Brought to you by:
francescobianco
%class python %start stmt_start %left '+' '-' %left '*' '/' stmt_start = newlines stmt stmt_start | stmt . newlines = NEWLINE newlines | NEWLINE | . stmt = simple_stmt | compound_stmt . simple_stmt = small_stmt NEWLINE simple_stmt | small_stmt NEWLINE | small_stmt . small_stmt = expr_stmt | print_stmt . expr_stmt = testlist augassign yield_expr | testlist augassign testlist | testlist EQUAL yield_expr | testlist EQUAL testlist . augassign = PLUSEQUAL | MINUSEQUAL | STAREQUAL | SLASHEQUAL | MODEQUAL | AMPEQUAL | PIPEEQUAL | ACUEQUAL | LSHIFTEQUAL | RSHIFTEQUAL | DSTAREQUAL | DSLASHEQUAL . compound_stmt = while_stmt | for_stmt . while_stmt = WHILE test COLON suite | WHILE test COLON suite ELSE COLON suite . print_stmt = PRINT atom SEMICOLON { python_print($2); } | PRINT atom { python_print($2); } . for_stmt = FOR exprlist IN testlist COLON { python_for(); } suite { python_end_for(); } . suite = simple_stmt | NEWLINE INDENT stmt DEDENT . testlist = test . test = or_test IF or_test ELSE test | or_test | lambdef . or_test = and_test OR and_test | and_test . and_test = not_test AND not_test | not_test . not_test = NOT not_test | comparison . comparison = expr comp_op expr | expr . comp_op = LESS | GREAT | DEQUAL | GREATEQUAL | LESSEQUAL | DIFF | NOTEQUAL | IN | NOT IN | IS | IS NOT . expr = xor_expr PIPE xor_expr | xor_expr . xor_expr = and_expr ACUE and_expr | and_expr . and_expr = shift_expr AMPE shift_expr | shift_expr . shift_expr = arith_expr LSHIFT arith_expr | arith_expr RSHIFT arith_expr | arith_expr . arith_expr = term PLUS term | term MINUS term | term . term = factor STAR factor | factor SLASH factor | factor MOD factor | factor DSLASH factor | factor . factor = PLUS factor | MINUS factor | TILDE factor | power . power = atom trailer DSTAR factor | atom DSTAR factor | atom . trailer = RBO arglist RBC | SBO subscriptlist SBC | DOT NAME . argslist = NUMBER COMMA NUMBER . testlist_comp = testlist_comp_for | test test_tail { $$ = array("ciao"); echo "ad"; } | test | . test_tail = COMMA test test_tail | COMMA test {echo "as";} | . atom = RBO argslist RBC | SBO testlist_comp SBC { $$ = python_list($2); } | BO dictorsetmaker BC | NAME | NUMBER | DSTRING | TRIPLEDOT | NONE | TRUE | FALSE .