phpython Code
a python interpreter written in php
Status: Pre-Alpha
Brought to you by:
francescobianco
%class python %start stmt %left '+' '-' %left '*' '/' stmt = simple_stmt | compound_stmt . simple_stmt = small_stmt NEWLINE simple_stmt | small_stmt NEWLINE | small_stmt . small_stmt = print_stmt | assign_stmt | cmd_stmt . compound_stmt = for_stmt . cmd_stmt = LNAME DSTRING { python_command($1,$2); } . print_stmt = PRINT atom SEMICOLON { python_print($2); } | PRINT atom { python_print($2); } . assign_stmt = varlist EQUAL exprlist { python_assign($1,$3); } . varlist = LNAME . exprlist = atom . for_stmt = FOR exprlist IN testlist COLON { python_for(); } suite { python_end_for(); } . suite = simple_stmt | NEWLINE INDENT stmt DEDENT . testlist = test . test = expr . expr = LNAME RBO argslist RBC | atom . 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 | LNAME | NUMBER | DSTRING | TRIPLEDOT | NONE | TRUE | FALSE .