7 #include <objc/Object.h>
12 @interface CallTest : Object
15 /* State machine operation data. */
16 int cs, top, stack[32];
19 // Initialize the machine. Invokes any init statement blocks. Returns 0
20 // if the machine begins in a non-accepting state and 1 if the machine
21 // begins in an accepting state.
24 // Execute the machine on a block of data. Returns -1 if after processing
25 // the data, the machine is in the error state and can never accept, 0 if
26 // the machine is in a non-accepting state and 1 if the machine is in an
28 - (void) executeWithData:(const char *)data len:(int)len;
30 // Indicate that there is no more data. Returns -1 if the machine finishes
31 // in the error state and does not accept, 0 if the machine finishes
32 // in any other non-accepting state and 1 if the machine finishes in an
38 @implementation CallTest
50 # Test call and return functionality.
51 even := 'even' any @{fhold; fret;};
52 odd := 'odd' any @{fhold; fret;};
53 num = [0-9]+ ${ num = num * 10 + (fc - '0'); };
54 even_odd = num ' ' @check_num "\n";
56 # Test calls in out actions.
58 out_acts = 'OA ok\n' |
62 main := even_odd | out_acts;
73 - (void) executeWithData:(const char *)data len:(int)len;
76 const char *pe = data + len;
82 if ( cs == CallTest_error )
84 return ( cs >= CallTest_first_final ) ? 1 : 0;
91 void test( char *buf )
93 CallTest *test = [[CallTest alloc] init];
95 [test executeWithData:buf len:strlen(buf)];
96 if ( [test finish] > 0 )
109 test( "OA error1\n" );
110 test( "OA error2\n" );
114 #ifdef _____OUTPUT_____