diff options
Diffstat (limited to 'test/rlhc.d/case/element2.c-C-G2--goto-backend.in')
-rw-r--r-- | test/rlhc.d/case/element2.c-C-G2--goto-backend.in | 157 |
1 files changed, 157 insertions, 0 deletions
diff --git a/test/rlhc.d/case/element2.c-C-G2--goto-backend.in b/test/rlhc.d/case/element2.c-C-G2--goto-backend.in new file mode 100644 index 00000000..ad14bca2 --- /dev/null +++ b/test/rlhc.d/case/element2.c-C-G2--goto-backend.in @@ -0,0 +1,157 @@ +host( "working/element2.rl", 1 ) @{/* + * @@LANG: c + */ + + #include <stdio.h> + + struct LangEl + { + int key; + char *name; + }; + + struct fsm + { + int cs; + }; + + + +}@ +value int fsm_start = 1; +value int fsm_first_final = 3; +value int fsm_error = 0; + +value int fsm_en_main = 1; + +array s8 _fsm_nfa_targs( 0, 0 ) = { 0, 0 }; + +array s8 _fsm_nfa_offsets( 0, 0 ) = { 0, 0, 0, 0, 0 }; + +array s8 _fsm_nfa_push_actions( 0, 0 ) = { 0, 0 }; + +array s8 _fsm_nfa_pop_trans( 0, 0 ) = { 0, 0 }; + +host( "working/element2.rl", 34 ) @{ + + void fsm_init( struct fsm *fsm ) + { + }@ + { + host( "-", 1 ) ={ fsm->cs}= = cast(int)fsm_start; + } + host( "working/element2.rl", 38 ) @{ + } + + void fsm_execute( struct fsm *fsm, struct LangEl *_data, int _len ) + { + struct LangEl *p = _data; + struct LangEl *pe = _data+_len; + struct LangEl *eof = pe; + + }@ + { + if ( p == pe ) + goto _test_eof; + switch ( host( "-", 1 ) ={ fsm->cs}= ) + { + case 1: + goto st_case_1; + case 0: + goto st_case_0; + case 2: + goto st_case_2; + case 3: + goto st_case_3; + } + goto st_out; + st_case_1: + if ( host( "-", 1 ) ={p->key}= == 1 ) { + goto ctr0; + } + { + goto st0; + } + st_case_0: + st0: + host( "-", 1 ) ={ fsm->cs}= = 0; + goto _out; + ctr0: + host( "working/element2.rl", 29 ) ${printf("%s\n", p->name);}$ + + goto st2; + st2: + p+= 1; + if ( p == pe ) + goto _test_eof2; + st_case_2: + switch( host( "-", 1 ) ={p->key}= ) { + case 2: { + goto ctr0; + } + case 3: { + goto ctr2; + } + } + { + goto st0; + } + ctr2: + host( "working/element2.rl", 29 ) ${printf("%s\n", p->name);}$ + + goto st3; + st3: + p+= 1; + if ( p == pe ) + goto _test_eof3; + st_case_3: + { + goto st0; + } + st_out: + _test_eof2: host( "-", 1 ) ={ fsm->cs}= = 2; goto _test_eof; + _test_eof3: host( "-", 1 ) ={ fsm->cs}= = 3; goto _test_eof; + + _test_eof: {} + if ( p == eof ) + { + switch ( host( "-", 1 ) ={ fsm->cs}= ) { + case 3: + host( "working/element2.rl", 30 ) ${printf("accept\n");}$ + break; + } + } + + _out: {} + } + host( "working/element2.rl", 47 ) @{ + } + + int fsm_finish( struct fsm *fsm ) + { + if ( fsm->cs == fsm_error ) + return -1; + if ( fsm->cs >= fsm_first_final ) + return 1; + return 0; + } + + int main() + { + static struct fsm fsm; + static struct LangEl lel[] = { + {1, "one"}, + {2, "two-a"}, + {2, "two-b"}, + {2, "two-c"}, + {3, "three"} + }; + + fsm_init( &fsm ); + fsm_execute( &fsm, lel, 5 ); + fsm_finish( &fsm ); + + return 0; + } + +}@
\ No newline at end of file |