6 #include <objc/Object.h>
8 #define IDENT_BUFLEN 256
10 @interface ErrAct : Object
16 // Initialize the machine. Invokes any init statement blocks. Returns 0
17 // if the machine begins in a non-accepting state and 1 if the machine
18 // begins in an accepting state.
21 // Execute the machine on a block of data. Returns -1 if after processing
22 // the data, the machine is in the error state and can never accept, 0 if
23 // the machine is in a non-accepting state and 1 if the machine is in an
25 - (void) executeWithData:(const char *)data len:(int)len;
27 // Indicate that there is no more data. Returns -1 if the machine finishes
28 // in the error state and does not accept, 0 if the machine finishes
29 // in any other non-accepting state and 1 if the machine finishes in an
35 @implementation ErrAct
40 # The data that is to go into the fsm structure.
41 action hello_fails { printf("hello fails\n");}
43 newline = ( any | '\n' @{printf("newline\n");} )*;
44 hello = 'hello\n'* $^hello_fails @/hello_fails;
45 main := newline | hello;
56 - (void) executeWithData:(const char *)_data len:(int)_len;
58 const char *p = _data;
59 const char *pe = _data + _len;
66 if ( cs == ErrAct_error )
68 else if ( cs >= ErrAct_first_final )
82 void test( char *buf )
84 int len = strlen(buf);
85 fsm = [[ErrAct alloc] init];
88 [fsm executeWithData:buf len:len];
89 if ( [fsm finish] > 0 )
120 #ifdef _____OUTPUT_____