diff options
author | thurston <thurston@052ea7fc-9027-0410-9066-f65837a77df0> | 2007-01-21 22:58:22 +0000 |
---|---|---|
committer | thurston <thurston@052ea7fc-9027-0410-9066-f65837a77df0> | 2007-01-21 22:58:22 +0000 |
commit | 12056158053532946b53b6249cb0e6cfd4580051 (patch) | |
tree | 9b5449ef42e829f98bf7a6c6e0554b88d4ab9132 /test/builtin.rl | |
download | ragel-12056158053532946b53b6249cb0e6cfd4580051.tar.gz ragel-12056158053532946b53b6249cb0e6cfd4580051.tar.bz2 ragel-12056158053532946b53b6249cb0e6cfd4580051.zip |
Import from my private repository. Snapshot after version 5.16, immediately
following the rewrite of the parsers. Repository revision number 3961.
git-svn-id: http://svn.complang.org/ragel/trunk@2 052ea7fc-9027-0410-9066-f65837a77df0
Diffstat (limited to 'test/builtin.rl')
-rw-r--r-- | test/builtin.rl | 1209 |
1 files changed, 1209 insertions, 0 deletions
diff --git a/test/builtin.rl b/test/builtin.rl new file mode 100644 index 0000000..626927b --- /dev/null +++ b/test/builtin.rl @@ -0,0 +1,1209 @@ +/* + * @LANG: c + */ + +#include <stdio.h> + +void alph(const char *type) +{ + printf("%s\n", type); +} + +struct builtin +{ + int cs; +}; + +%%{ + machine builtin; + alphtype unsigned int; + variable curstate fsm->cs; + + main := ( + any @{alph("any");} | + ascii @{alph("ascii");} | + extend @{alph("extend");} | + alpha @{alph("alpha");} | + digit @{alph("digit");} | + alnum @{alph("alnum");} | + lower @{alph("lower");} | + upper @{alph("upper");} | + cntrl @{alph("cntrl");} | + graph @{alph("graph");} | + print @{alph("print");} | + punct @{alph("punct");} | + space @{alph("space");} | + xdigit @{alph("xdigit");} + )*; +}%% + +%% write data; + +void builtin_init( struct builtin *fsm ) +{ + %% write init; +} + +void builtin_execute( struct builtin *fsm, const unsigned int *data, int len ) +{ + const unsigned int *p = data; + const unsigned int *pe = data+len; + %% write exec; +} + +int builtin_finish( struct builtin *fsm ) +{ + if ( fsm->cs == builtin_error ) + return -1; + else if ( fsm->cs >= builtin_first_final ) + return 1; + return 0; +} + +#include <stdio.h> +#define BUFSIZE 2048 + +struct builtin fsm; +char buf[BUFSIZE]; +unsigned int i; + +int test( const unsigned int *data, int len ) +{ + builtin_init( &fsm ); + builtin_execute( &fsm, data, len ); + if ( builtin_finish( &fsm ) > 0 ) + printf("ACCEPT\n"); + else + printf("FAIL\n"); + return 0; +} + +#define DLEN 258 +unsigned int data[DLEN] = { + -1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, + 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, + 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, + 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, + 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, + 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, + 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, + 127, 128, 129, 130, 131, 132, 133, 134, 135, 136, 137, 138, 139, 140, 141, + 142, 143, 144, 145, 146, 147, 148, 149, 150, 151, 152, 153, 154, 155, 156, + 157, 158, 159, 160, 161, 162, 163, 164, 165, 166, 167, 168, 169, 170, 171, + 172, 173, 174, 175, 176, 177, 178, 179, 180, 181, 182, 183, 184, 185, 186, + 187, 188, 189, 190, 191, 192, 193, 194, 195, 196, 197, 198, 199, 200, 201, + 202, 203, 204, 205, 206, 207, 208, 209, 210, 211, 212, 213, 214, 215, 216, + 217, 218, 219, 220, 221, 222, 223, 224, 225, 226, 227, 228, 229, 230, 231, + 232, 233, 234, 235, 236, 237, 238, 239, 240, 241, 242, 243, 244, 245, 246, + 247, 248, 249, 250, 251, 252, 253, 254, 255, 256 +}; + +int main() +{ + test( data, DLEN ); + return 0; +} + +#ifdef _____OUTPUT_____ +any +any +ascii +extend +cntrl +any +ascii +extend +cntrl +any +ascii +extend +cntrl +any +ascii +extend +cntrl +any +ascii +extend +cntrl +any +ascii +extend +cntrl +any +ascii +extend +cntrl +any +ascii +extend +cntrl +any +ascii +extend +cntrl +any +ascii +extend +cntrl +space +any +ascii +extend +cntrl +space +any +ascii +extend +cntrl +space +any +ascii +extend +cntrl +space +any +ascii +extend +cntrl +space +any +ascii +extend +cntrl +any +ascii +extend +cntrl +any +ascii +extend +cntrl +any +ascii +extend +cntrl +any +ascii +extend +cntrl +any +ascii +extend +cntrl +any +ascii +extend +cntrl +any +ascii +extend +cntrl +any +ascii +extend +cntrl +any +ascii +extend +cntrl +any +ascii +extend +cntrl +any +ascii +extend +cntrl +any +ascii +extend +cntrl +any +ascii +extend +cntrl +any +ascii +extend +cntrl +any +ascii +extend +cntrl +any +ascii +extend +cntrl +any +ascii +extend +cntrl +any +ascii +extend +print +space +any +ascii +extend +graph +print +punct +any +ascii +extend +graph +print +punct +any +ascii +extend +graph +print +punct +any +ascii +extend +graph +print +punct +any +ascii +extend +graph +print +punct +any +ascii +extend +graph +print +punct +any +ascii +extend +graph +print +punct +any +ascii +extend +graph +print +punct +any +ascii +extend +graph +print +punct +any +ascii +extend +graph +print +punct +any +ascii +extend +graph +print +punct +any +ascii +extend +graph +print +punct +any +ascii +extend +graph +print +punct +any +ascii +extend +graph +print +punct +any +ascii +extend +graph +print +punct +any +ascii +extend +digit +alnum +graph +print +xdigit +any +ascii +extend +digit +alnum +graph +print +xdigit +any +ascii +extend +digit +alnum +graph +print +xdigit +any +ascii +extend +digit +alnum +graph +print +xdigit +any +ascii +extend +digit +alnum +graph +print +xdigit +any +ascii +extend +digit +alnum +graph +print +xdigit +any +ascii +extend +digit +alnum +graph +print +xdigit +any +ascii +extend +digit +alnum +graph +print +xdigit +any +ascii +extend +digit +alnum +graph +print +xdigit +any +ascii +extend +digit +alnum +graph +print +xdigit +any +ascii +extend +graph +print +punct +any +ascii +extend +graph +print +punct +any +ascii +extend +graph +print +punct +any +ascii +extend +graph +print +punct +any +ascii +extend +graph +print +punct +any +ascii +extend +graph +print +punct +any +ascii +extend +graph +print +punct +any +ascii +extend +alpha +alnum +upper +graph +print +xdigit +any +ascii +extend +alpha +alnum +upper +graph +print +xdigit +any +ascii +extend +alpha +alnum +upper +graph +print +xdigit +any +ascii +extend +alpha +alnum +upper +graph +print +xdigit +any +ascii +extend +alpha +alnum +upper +graph +print +xdigit +any +ascii +extend +alpha +alnum +upper +graph +print +xdigit +any +ascii +extend +alpha +alnum +upper +graph +print +any +ascii +extend +alpha +alnum +upper +graph +print +any +ascii +extend +alpha +alnum +upper +graph +print +any +ascii +extend +alpha +alnum +upper +graph +print +any +ascii +extend +alpha +alnum +upper +graph +print +any +ascii +extend +alpha +alnum +upper +graph +print +any +ascii +extend +alpha +alnum +upper +graph +print +any +ascii +extend +alpha +alnum +upper +graph +print +any +ascii +extend +alpha +alnum +upper +graph +print +any +ascii +extend +alpha +alnum +upper +graph +print +any +ascii +extend +alpha +alnum +upper +graph +print +any +ascii +extend +alpha +alnum +upper +graph +print +any +ascii +extend +alpha +alnum +upper +graph +print +any +ascii +extend +alpha +alnum +upper +graph +print +any +ascii +extend +alpha +alnum +upper +graph +print +any +ascii +extend +alpha +alnum +upper +graph +print +any +ascii +extend +alpha +alnum +upper +graph +print +any +ascii +extend +alpha +alnum +upper +graph +print +any +ascii +extend +alpha +alnum +upper +graph +print +any +ascii +extend +alpha +alnum +upper +graph +print +any +ascii +extend +graph +print +punct +any +ascii +extend +graph +print +punct +any +ascii +extend +graph +print +punct +any +ascii +extend +graph +print +punct +any +ascii +extend +graph +print +punct +any +ascii +extend +graph +print +punct +any +ascii +extend +alpha +alnum +lower +graph +print +xdigit +any +ascii +extend +alpha +alnum +lower +graph +print +xdigit +any +ascii +extend +alpha +alnum +lower +graph +print +xdigit +any +ascii +extend +alpha +alnum +lower +graph +print +xdigit +any +ascii +extend +alpha +alnum +lower +graph +print +xdigit +any +ascii +extend +alpha +alnum +lower +graph +print +xdigit +any +ascii +extend +alpha +alnum +lower +graph +print +any +ascii +extend +alpha +alnum +lower +graph +print +any +ascii +extend +alpha +alnum +lower +graph +print +any +ascii +extend +alpha +alnum +lower +graph +print +any +ascii +extend +alpha +alnum +lower +graph +print +any +ascii +extend +alpha +alnum +lower +graph +print +any +ascii +extend +alpha +alnum +lower +graph +print +any +ascii +extend +alpha +alnum +lower +graph +print +any +ascii +extend +alpha +alnum +lower +graph +print +any +ascii +extend +alpha +alnum +lower +graph +print +any +ascii +extend +alpha +alnum +lower +graph +print +any +ascii +extend +alpha +alnum +lower +graph +print +any +ascii +extend +alpha +alnum +lower +graph +print +any +ascii +extend +alpha +alnum +lower +graph +print +any +ascii +extend +alpha +alnum +lower +graph +print +any +ascii +extend +alpha +alnum +lower +graph +print +any +ascii +extend +alpha +alnum +lower +graph +print +any +ascii +extend +alpha +alnum +lower +graph +print +any +ascii +extend +alpha +alnum +lower +graph +print +any +ascii +extend +alpha +alnum +lower +graph +print +any +ascii +extend +graph +print +punct +any +ascii +extend +graph +print +punct +any +ascii +extend +graph +print +punct +any +ascii +extend +graph +print +punct +any +ascii +extend +cntrl +any +extend +any +extend +any +extend +any +extend +any +extend +any +extend +any +extend +any +extend +any +extend +any +extend +any +extend +any +extend +any +extend +any +extend +any +extend +any +extend +any +extend +any +extend +any +extend +any +extend +any +extend +any +extend +any +extend +any +extend +any +extend +any +extend +any +extend +any +extend +any +extend +any +extend +any +extend +any +extend +any +extend +any +extend +any +extend +any +extend +any +extend +any +extend +any +extend +any +extend +any +extend +any +extend +any +extend +any +extend +any +extend +any +extend +any +extend +any +extend +any +extend +any +extend +any +extend +any +extend +any +extend +any +extend +any +extend +any +extend +any +extend +any +extend +any +extend +any +extend +any +extend +any +extend +any +extend +any +extend +any +extend +any +extend +any +extend +any +extend +any +extend +any +extend +any +extend +any +extend +any +extend +any +extend +any +extend +any +extend +any +extend +any +extend +any +extend +any +extend +any +extend +any +extend +any +extend +any +extend +any +extend +any +extend +any +extend +any +extend +any +extend +any +extend +any +extend +any +extend +any +extend +any +extend +any +extend +any +extend +any +extend +any +extend +any +extend +any +extend +any +extend +any +extend +any +extend +any +extend +any +extend +any +extend +any +extend +any +extend +any +extend +any +extend +any +extend +any +extend +any +extend +any +extend +any +extend +any +extend +any +extend +any +extend +any +extend +any +extend +any +extend +any +extend +any +extend +any +extend +any +extend +any +extend +any +extend +any +extend +any +ACCEPT +#endif |