A_stm prog3(void) { return A_CompoundStm( A_PrintStm(A_PairExpList( A_EseqExp( A_CompoundStm( A_PrintStm(A_PairExpList( A_EseqExp( A_AssignStm( "a", A_NumExp(1) ), A_IdExp("a") ), A_LastExpList(A_NumExp(3)) )), A_AssignStm( "b", A_NumExp(2) ) ), A_IdExp("a") ), A_LastExpList(A_IdExp("a")) )), A_PrintStm(A_LastExpList(A_IdExp("b"))) ); }
A_stm prog(void) { return A_CompoundStm(A_AssignStm("a", A_OpExp(A_NumExp(5), A_plus, A_NumExp(3))), A_CompoundStm(A_AssignStm("b", A_EseqExp(A_PrintStm(A_PairExpList(A_IdExp("a"), A_LastExpList(A_OpExp(A_IdExp("a"), A_minus, A_NumExp(1))))), A_OpExp(A_NumExp(10), A_times, A_IdExp("a")))), A_PrintStm(A_LastExpList(A_IdExp("b"))))); }
A_stm right_prog(void) { // a = 5 + 3; b = (print(a, a-1), 10*a); print b; // a = 5 + b; b = (print(a, a, a-1), 10*a); print b; // a = (a = a+b, a); A_stm stm1 = prog_prog(); return A_CompoundStm( stm1, A_AssignStm("a", A_EseqExp(A_AssignStm("a", A_OpExp(A_IdExp("a"), A_plus, A_IdExp("b"))), A_IdExp("a")))); }
A_stm prog(void) { // a = 5 + 3; b = (print(a, a-1), 10*a); print b; return A_CompoundStm(A_AssignStm("a", A_OpExp(A_NumExp(5), A_plus, A_NumExp(3))), A_CompoundStm(A_AssignStm("b", A_EseqExp(A_PrintStm(A_PairExpList(A_IdExp("a"), A_LastExpList(A_OpExp(A_IdExp("a"), A_minus, A_NumExp(1))))), A_OpExp(A_NumExp(10), A_times, A_IdExp("a")))), A_PrintStm(A_LastExpList(A_IdExp("b"))))); }
A_stm error_prog(void) { // a = 5 + 3; b = (print(a, a-1), 10*a); print b; // a = 5 + b; b = (print(a, a, a-1), 10*a); print b; // a = c; A_stm stm1 = prog_prog(); return A_CompoundStm( stm1, A_AssignStm("a", A_IdExp("c"))); }
static void test_maxargs_complex(void** state) { // maxargs(stm) works with an arbitrary complex statement A_stm stm = A_CompoundStm( A_AssignStm( "a", A_OpExp(A_NumExp(5), A_plus, A_NumExp(3)) ), A_CompoundStm( A_AssignStm("b", A_EseqExp( A_PrintStm(A_PairExpList( A_IdExp("a"), A_LastExpList( A_OpExp(A_IdExp("a"), A_minus, A_NumExp(1)) ) )), A_OpExp(A_NumExp(10), A_times, A_IdExp("a")) )), A_PrintStm(A_LastExpList(A_IdExp("b"))) ) ); assert_int_equal(2, maxargs(stm)); }