6 #include <objc/Object.h>
14 @interface Fsm : 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 - (int) executeWithData:( struct LangEl *)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
53 ${printf("%s\n", fpc->name);}
54 %/{printf("accept\n");};
65 - (int) executeWithData:( struct LangEl *)_data len:(int)_len;
67 struct LangEl *p = _data;
68 struct LangEl *pe = _data + _len;
69 struct LangEl *eof = pe;
72 if ( self->cs == Fsm_error )
74 return ( self->cs >= Fsm_first_final ) ? 1 : 0;
79 if ( self->cs == Fsm_error )
81 return ( self->cs >= Fsm_first_final ) ? 1 : 0;
90 static struct LangEl lel[] = {
98 fsm = [[Fsm alloc] init];
100 [fsm executeWithData:lel len:5];
106 @interface Fsm2 : Object
108 // The current state may be read and written to from outside of the
109 // machine. From within action code, curs is -1 and writing to it has no
118 // Execute the machine on a block of data. Returns -1 if after processing
119 // the data, the machine is in the error state and can never accept, 0 if
120 // the machine is in a non-accepting state and 1 if the machine is in an
123 executeWithElements:(int) elements
124 length:(unsigned)length;
130 executeWithElements:(int)elements
131 length:(unsigned)length;
137 #ifdef _____OUTPUT_____