summaryrefslogtreecommitdiff
path: root/test/rlhc.d/case/forder1.c-C-T1--goto-backend.in
diff options
context:
space:
mode:
Diffstat (limited to 'test/rlhc.d/case/forder1.c-C-T1--goto-backend.in')
-rw-r--r--test/rlhc.d/case/forder1.c-C-T1--goto-backend.in237
1 files changed, 237 insertions, 0 deletions
diff --git a/test/rlhc.d/case/forder1.c-C-T1--goto-backend.in b/test/rlhc.d/case/forder1.c-C-T1--goto-backend.in
new file mode 100644
index 00000000..87e37936
--- /dev/null
+++ b/test/rlhc.d/case/forder1.c-C-T1--goto-backend.in
@@ -0,0 +1,237 @@
+host( "working/forder1.rl", 1 ) @{/*
+ * @@LANG: c
+ */
+
+ #include <stdio.h>
+ #include <string.h>
+
+ struct forder
+ {
+ int cs;
+ };
+
+
+
+}@
+array s8 _forder_key_offsets( 0, 3 ) = { 0, 0, 1, 2, 3, 0 };
+
+array char _forder_trans_keys( 0, 98 ) = { 97, 98, 10, 0 };
+
+array s8 _forder_single_lengths( 0, 1 ) = { 0, 1, 1, 1, 0, 0 };
+
+array s8 _forder_range_lengths( 0, 0 ) = { 0, 0, 0, 0, 0, 0 };
+
+array s8 _forder_index_offsets( 0, 6 ) = { 0, 0, 2, 4, 6, 0 };
+
+array s8 _forder_trans_cond_spaces( -1, 0 ) = { -1, -1, -1, -1, -1, -1, -1, 0 };
+
+array s8 _forder_trans_offsets( 0, 6 ) = { 0, 1, 2, 3, 4, 5, 6, 0 };
+
+array s8 _forder_trans_lengths( 0, 1 ) = { 1, 1, 1, 1, 1, 1, 1, 0 };
+
+array s8 _forder_cond_keys( 0, 0 ) = { 0, 0, 0, 0, 0, 0, 0, 0 };
+
+array s8 _forder_cond_targs( 0, 4 ) = { 2, 0, 3, 0, 4, 0, 0, 0 };
+
+array s8 _forder_cond_actions( 0, 2 ) = { 1, 0, 2, 0, 0, 0, 0, 0 };
+
+array s8 _forder_nfa_targs( 0, 0 ) = { 0, 0 };
+
+array s8 _forder_nfa_offsets( 0, 0 ) = { 0, 0, 0, 0, 0, 0 };
+
+array s8 _forder_nfa_push_actions( 0, 0 ) = { 0, 0 };
+
+array s8 _forder_nfa_pop_trans( 0, 0 ) = { 0, 0 };
+
+value int forder_start = 1;
+value int forder_first_final = 4;
+value int forder_error = 0;
+
+value int forder_en_main = 1;
+
+host( "working/forder1.rl", 31 ) @{
+
+ void forder_init( struct forder *fsm )
+ {
+ }@
+ {
+ host( "-", 1 ) ={ fsm->cs}= = cast(int)forder_start;
+ }
+ host( "working/forder1.rl", 35 ) @{
+ }
+
+ void forder_execute( struct forder *fsm, const char *_data, int _len )
+ {
+ const char *p = _data;
+ const char *pe = _data+_len;
+
+ }@
+ {
+ int _klen;
+ index char _keys;
+ index s8 _ckeys;
+ int _cpc;
+ uint _trans = 0;
+ uint _cond = 0;
+ entry {
+
+ if ( p == pe )
+ goto _test_eof;
+ if ( host( "-", 1 ) ={ fsm->cs}= == 0 )
+ goto _out;
+ label _resume {
+ _keys = offset( _forder_trans_keys, _forder_key_offsets[host( "-", 1 ) ={ fsm->cs}=] );
+ _trans = cast(uint)_forder_index_offsets[host( "-", 1 ) ={ fsm->cs}=];
+
+ _klen = cast(int)_forder_single_lengths[host( "-", 1 ) ={ fsm->cs}=];
+ if ( _klen > 0 ) {
+ index char _lower;
+ index char _mid;
+ index char _upper;
+ _lower = _keys;
+ _upper = _keys + _klen - 1;
+ while ( TRUE ) {
+ if ( _upper < _lower )
+ break;
+
+ _mid = _lower + ((_upper-_lower) >> 1);
+ if ( ( deref( data, p )) < deref( _forder_trans_keys, _mid ) )
+ _upper = _mid - 1;
+ else if ( ( deref( data, p )) > deref( _forder_trans_keys, _mid ) )
+ _lower = _mid + 1;
+ else {
+ _trans += cast(uint)(_mid - _keys);
+ goto _match;
+ }
+ }
+ _keys += _klen;
+ _trans += cast(uint)_klen;
+ }
+
+ _klen = cast(int)_forder_range_lengths[host( "-", 1 ) ={ fsm->cs}=];
+ if ( _klen > 0 ) {
+ index char _lower;
+ index char _mid;
+ index char _upper;
+ _lower = _keys;
+ _upper = _keys + (_klen<<1) - 2;
+ while ( TRUE ) {
+ if ( _upper < _lower )
+ break;
+
+ _mid = _lower + (((_upper-_lower) >> 1) & ~1);
+ if ( ( deref( data, p )) < deref( _forder_trans_keys, _mid ) )
+ _upper = _mid - 2;
+ else if ( ( deref( data, p )) > deref( _forder_trans_keys, _mid + 1 ) )
+ _lower = _mid + 2;
+ else {
+ _trans += cast(uint)((_mid - _keys)>>1);
+ goto _match;
+ }
+ }
+ _trans += cast(uint)_klen;
+ }
+
+ }
+ label _match {
+ _ckeys = offset( _forder_cond_keys, _forder_trans_offsets[_trans] );
+ _klen = cast(int)_forder_trans_lengths[_trans];
+ _cond = cast(uint)_forder_trans_offsets[_trans];
+
+ _cpc = 0;
+ {
+ index s8 _lower;
+ index s8 _mid;
+ index s8 _upper;
+ _lower = _ckeys;
+ _upper = _ckeys + _klen - 1;
+ while ( TRUE ) {
+ if ( _upper < _lower )
+ break;
+
+ _mid = _lower + ((_upper-_lower) >> 1);
+ if ( _cpc < cast(int)deref( _forder_cond_keys, _mid ) )
+ _upper = _mid - 1;
+ else if ( _cpc > cast(int)deref( _forder_cond_keys, _mid ) )
+ _lower = _mid + 1;
+ else {
+ _cond += cast(uint)(_mid - _ckeys);
+ goto _match_cond;
+ }
+ }
+ host( "-", 1 ) ={ fsm->cs}= = 0;
+ goto _again;
+ }
+ }
+ label _match_cond {
+ host( "-", 1 ) ={ fsm->cs}= = cast(int)_forder_cond_targs[_cond];
+
+ if ( _forder_cond_actions[_cond] == 0 )
+ goto _again;
+
+ switch ( _forder_cond_actions[_cond] ) {
+ case 1 {
+ host( "working/forder1.rl", 24 ) ${printf("finish a\n");}$
+ }
+ case 2 {
+ host( "working/forder1.rl", 23 ) ${printf("leave a\n");}$
+ host( "working/forder1.rl", 18 ) ${printf("enter b1\n");}$
+ host( "working/forder1.rl", 19 ) ${printf("enter b2\n");}$
+ }
+ }
+
+
+ }
+ label _again {
+ if ( host( "-", 1 ) ={ fsm->cs}= == 0 )
+ goto _out;
+ p += 1;
+ if ( p != pe )
+ goto _resume;
+ }
+ label _test_eof { {}
+ }
+ label _out { {}
+ }
+ }
+ }
+ host( "working/forder1.rl", 43 ) @{
+ }
+
+ int forder_finish( struct forder *fsm )
+ {
+ if ( fsm->cs == forder_error )
+ return -1;
+ if ( fsm->cs >= forder_first_final )
+ return 1;
+ return 0;
+ }
+
+ struct forder fsm;
+
+ void test( char *buf )
+ {
+ int len = strlen(buf);
+ forder_init( &fsm );
+ forder_execute( &fsm, buf, len );
+ if ( forder_finish( &fsm ) > 0 )
+ printf("ACCEPT\n");
+ else
+ printf("FAIL\n");
+ }
+
+ int main()
+ {
+ test( "ab\n");
+ test( "abx\n");
+ test( "" );
+
+ test(
+ "ab\n"
+ "fail after newline\n"
+ );
+
+ return 0;
+ }
+
+}@ \ No newline at end of file