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 )
54 if ( fsm->cs == high_error )
56 if ( fsm->cs >= high_first_final )
65 unsigned int buf[BUFSIZE];
81 numbuf[numlen++] = fc;
85 /* Null terminate the buffer storing the number and reset. */
89 /* Store the number in the buf. If the buf is full then
90 * flush and reset the buffer. */
91 buf[buflen++] = strtoul( numbuf, 0, 16 );
92 if ( buflen == BUFSIZE ) {
93 high_execute( &high, buf, BUFSIZE );
100 high_execute( &high, buf, buflen );
101 if ( high_finish( &high ) > 0 )
107 num = ( digit | 'a'..'f' )+ $bufdigit %writeDigit;
108 main := ( num $1 %0 | space )* %/finish;
113 void tokenizer_init( struct tokenizer *fsm )
118 void tokenizer_execute( struct tokenizer *fsm, const char *_data, int _len )
120 const char *p = _data;
121 const char *pe = _data+_len;
122 const char *eof = pe;
127 int tokenizer_finish( struct tokenizer *fsm )
129 if ( fsm->cs == tokenizer_error )
131 if ( fsm->cs >= tokenizer_first_final )
136 struct tokenizer tok;
138 void test( char *cbuf )
140 int len = strlen( cbuf );
142 tokenizer_init( &tok );
143 tokenizer_execute( &tok, cbuf, len );
144 if ( tokenizer_finish( &tok ) <= 0 )
145 printf("Tokenizer FAIL\n");
149 "10 20 30 40 50 200 300 400 \n"
150 "d0000000 f0000000 fd000000 fe000000\n"
151 "ff000000 ffffffffffffffffffffffffff\n"
160 #ifdef _____OUTPUT_____