3 * @ALLOW_GENFLAGS: -T0 -T1 -G0 -G1 -G2
7 * Test a high character to make sure signedness
24 # We Want the header portion.
25 alphtype unsigned int;
28 0x20 .. 0xefffffff @1 @{printf("gothigh1\n");} |
29 0xf0000000 @1 @{printf("gothigh1\n");} |
30 0x200 .. 0xfe000000 @1 @{printf("gothigh2\n");} |
31 any @0 @{printf("else\n");}
37 void high_init( struct high *fsm )
42 void high_execute( struct high *fsm, const unsigned int *_data, int _len )
44 const unsigned int *p = _data;
45 const unsigned int *pe = _data+_len;
50 int high_finish( struct high *fsm )
52 if ( fsm->cs == high_error )
54 if ( fsm->cs >= high_first_final )
63 unsigned int buf[BUFSIZE];
79 numbuf[numlen++] = fc;
83 /* Null terminate the buffer storing the number and reset. */
87 /* Store the number in the buf. If the buf is full then
88 * flush and reset the buffer. */
89 buf[buflen++] = strtoul( numbuf, 0, 16 );
90 if ( buflen == BUFSIZE ) {
91 high_execute( &high, buf, BUFSIZE );
98 high_execute( &high, buf, buflen );
99 if ( high_finish( &high ) > 0 )
105 num = ( digit | 'a'..'f' )+ $bufdigit %writeDigit;
106 main := ( num $1 %0 | space )* %/finish;
111 void tokenizer_init( struct tokenizer *fsm )
116 void tokenizer_execute( struct tokenizer *fsm, const char *_data, int _len )
118 const char *p = _data;
119 const char *pe = _data+_len;
120 const char *eof = pe;
125 int tokenizer_finish( struct tokenizer *fsm )
127 if ( fsm->cs == tokenizer_error )
129 if ( fsm->cs >= tokenizer_first_final )
134 struct tokenizer tok;
136 void test( char *cbuf )
138 int len = strlen( cbuf );
140 tokenizer_init( &tok );
141 tokenizer_execute( &tok, cbuf, len );
142 if ( tokenizer_finish( &tok ) <= 0 )
143 printf("Tokenizer FAIL\n");
147 "10 20 30 40 50 200 300 400 \n"
148 "d0000000 f0000000 fd000000 fe000000\n"
149 "ff000000 ffffffffffffffffffffffffff\n"
158 #ifdef _____OUTPUT_____