11 #include <objc/Object.h>
14 @interface ErrAct : Object
20 // Initialize the machine. Invokes any init statement blocks. Returns 0
21 // if the machine begins in a non-accepting state and 1 if the machine
22 // begins in an accepting state.
25 // Execute the machine on a block of data. Returns -1 if after processing
26 // the data, the machine is in the error state and can never accept, 0 if
27 // the machine is in a non-accepting state and 1 if the machine is in an
29 - (void) executeWithData:(const char *)data len:(int)len;
31 // Indicate that there is no more data. Returns -1 if the machine finishes
32 // in the error state and does not accept, 0 if the machine finishes
33 // in any other non-accepting state and 1 if the machine finishes in an
39 @implementation ErrAct
44 action expect_digit_plus_minus { printf(" DIGIT PLUS MINUS\n"); }
45 action expect_digit { printf(" DIGIT\n"); }
46 action expect_digit_decimal { printf(" DIGIT DECIMAL\n"); }
50 [\-+] >!expect_digit_plus_minus %!expect_digit |
53 ( [0-9] [0-9]* $!expect_digit_decimal )
54 ( '.' [0-9]+ $!expect_digit )?
68 - (void) executeWithData:(const char *)_data len:(int)_len;
70 const char *p = _data;
71 const char *pe = _data + _len;
78 if ( cs == ErrAct_error )
80 else if ( cs >= ErrAct_first_final )
90 void test( char *buf )
92 ErrAct *errAct = [[ErrAct alloc] init];
94 [errAct executeWithData:buf len:strlen(buf)];
95 if ( [errAct finish] > 0 )
121 #ifdef _____OUTPUT_____