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 int execute( const char *data, 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
40 action expect_digit_plus_minus { printf(" DIGIT PLUS MINUS\n"); }
41 action expect_digit { printf(" DIGIT\n"); }
42 action expect_digit_decimal { printf(" DIGIT DECIMAL\n"); }
46 [\-+] >err expect_digit_plus_minus %err expect_digit |
49 ( [0-9] [0-9]* $err expect_digit_decimal )
50 ( '.' [0-9]+ $err expect_digit )?
64 int ErrAct::execute( const char *_data, int _len )
66 const char *p = _data;
67 const char *pe = _data+_len;
71 if ( cs == ErrAct_error )
73 if ( cs >= ErrAct_first_final )
80 if ( cs == ErrAct_error )
82 if ( cs >= ErrAct_first_final )
89 void test( const char *buf )
93 errAct.execute( buf, strlen(buf) );
94 if ( errAct.finish() > 0 )
95 cout << "ACCEPT" << endl;
97 cout << "FAIL" << endl;
120 #ifdef _____OUTPUT_____