diff options
Diffstat (limited to 'test/rlhc.d/case/recdescent1.c-C-F0--goto-backend.in')
-rw-r--r-- | test/rlhc.d/case/recdescent1.c-C-F0--goto-backend.in | 212 |
1 files changed, 212 insertions, 0 deletions
diff --git a/test/rlhc.d/case/recdescent1.c-C-F0--goto-backend.in b/test/rlhc.d/case/recdescent1.c-C-F0--goto-backend.in new file mode 100644 index 00000000..25649079 --- /dev/null +++ b/test/rlhc.d/case/recdescent1.c-C-F0--goto-backend.in @@ -0,0 +1,212 @@ +host( "working/recdescent1.rl", 1 ) @{/* + * @@LANG: c + * @@PROHIBIT_FEATFLAGS: --var-backend + * + * Test growable stack. + */ + + #include <stdio.h> + #include <stdlib.h> + #include <string.h> + + + +}@ +array s8 _recdescent_actions( 0, 3 ) = { 0, 1, 0, 1, 1, 1, 2, 1, 3, 2, 1, 0, 2, 1, 2, 2, 1, 3, 0 }; + +array char _recdescent_trans_keys( 0, 5 ) = { 1, 0, 5, 5, 0, 5, 0, 5, 0, 5, 0 }; + +array s8 _recdescent_char_class( 0, 5 ) = { 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1, 1, 1, 1, 1, 1, 1, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 1, 1, 1, 1, 3, 1, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 4, 1, 5, 0 }; + +array s8 _recdescent_index_offsets( 0, 13 ) = { 0, 0, 1, 7, 13, 0 }; + +array s8 _recdescent_indicies( 0, 12 ) = { 0, 0, 1, 2, 3, 4, 5, 6, 1, 7, 8, 9, 10, 6, 1, 11, 12, 9, 10, 0 }; + +array s8 _recdescent_index_defaults( 0, 1 ) = { 0, 1, 1, 1, 1, 0 }; + +array s8 _recdescent_trans_cond_spaces( -1, 0 ) = { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 0 }; + +array s8 _recdescent_cond_targs( 0, 4 ) = { 2, 0, 3, 4, 1, 2, 2, 3, 4, 1, 2, 3, 4, 0 }; + +array s8 _recdescent_cond_actions( 0, 15 ) = { 0, 0, 1, 1, 5, 7, 3, 0, 9, 12, 15, 9, 0, 0 }; + +array s8 _recdescent_eof_actions( 0, 3 ) = { 0, 0, 0, 3, 3, 0 }; + +array s8 _recdescent_nfa_targs( 0, 0 ) = { 0, 0 }; + +array s8 _recdescent_nfa_offsets( 0, 0 ) = { 0, 0, 0, 0, 0, 0 }; + +array s8 _recdescent_nfa_push_actions( 0, 0 ) = { 0, 0 }; + +array s8 _recdescent_nfa_pop_trans( 0, 0 ) = { 0, 0 }; + +value int recdescent_start = 2; +value int recdescent_first_final = 2; +value int recdescent_error = 0; + +value int recdescent_en_main = 2; + +host( "working/recdescent1.rl", 73 ) @{ + + void test( char *buf ) + { + int cs; + int *stack; + int top, stack_size; + char *p, *pe, *eof, *item = 0; + + int len = strlen( buf ); + + }@ + { + cs = cast(int)recdescent_start; + top = 0; + } + host( "working/recdescent1.rl", 84 ) @{ + + stack_size = 1; + stack = (int*)malloc( sizeof(int) * stack_size ); + + p = buf; + pe = buf + len; + eof = pe; + + }@ + { + int _trans = 0; + index s8 _acts; + uint _nacts; + index char _keys; + index s8 _inds; + entry { + + if ( p == pe ) + goto _test_eof; + if ( cs == 0 ) + goto _out; + label _resume { + _keys = offset( _recdescent_trans_keys, (cs<<1) ); + _inds = offset( _recdescent_indicies, _recdescent_index_offsets[cs] ); + + if ( ( deref( data, p )) <= 125 && ( deref( data, p )) >= 9 ) + { + int _ic = cast(int)_recdescent_char_class[cast(int)( deref( data, p )) - 9]; + if ( _ic <= cast(int)deref( _recdescent_trans_keys, _keys+1 ) && _ic >= cast(int)deref( _recdescent_trans_keys, _keys ) ) + _trans = cast(int)deref( _recdescent_indicies, _inds + cast(int)( _ic - cast(int)deref( _recdescent_trans_keys, _keys ) ) ); + else + _trans = cast(int)_recdescent_index_defaults[cs]; + } + else { + _trans = cast(int)_recdescent_index_defaults[cs]; + } + + goto _match_cond; + } + label _match_cond { + cs = cast(int)_recdescent_cond_targs[_trans]; + + if ( _recdescent_cond_actions[_trans] == 0 ) + goto _again; + + _acts = offset( _recdescent_actions, _recdescent_cond_actions[_trans] ); + _nacts = cast(uint)deref( _recdescent_actions, _acts ); + _acts += 1; + while ( _nacts > 0 ) { + switch ( deref( _recdescent_actions, _acts ) ) + { + case 0 { + host( "working/recdescent1.rl", 31 ) ${ item = p; }$ + } + case 1 { + host( "working/recdescent1.rl", 34 ) ${ + printf( "item: " ); + fwrite( item, 1, p-item, stdout ); + printf( "\n" ); + }$ + } + case 2 { + host( "working/recdescent1.rl", 41 ) ${ + printf( "calling main\n" ); + ${host( "working/recdescent1.rl", 15 ) ${ + if ( top == stack_size ) { + printf( "growing stack\n" ); + stack_size = top * 2; + stack = (int*)realloc( stack, sizeof(int)*stack_size ); + } + }$stack[top] = cs; top += 1;cs = 2; goto _again;}$}$ + } + case 3 { + host( "working/recdescent1.rl", 47 ) ${ + if ( top == 0 ) { + printf( "STRAY CLOSE\n" ); + ${p += 1; goto _out; }$ + } + + printf( "returning from main\n" ); + ${p = p - 1; }$ + ${top -= 1;cs = stack[top];host( "working/recdescent1.rl", 23 ) ${ + if ( stack_size > (top * 4) ) { + stack_size = top * 2; + stack = (int*)realloc( stack, sizeof(int)*stack_size ); + printf( "shrinking stack\n" ); + } + }$goto _again;}$ + }$ + } + } + _nacts -= 1; + _acts += 1; + } + + + } + label _again { + if ( cs == 0 ) + goto _out; + p += 1; + if ( p != pe ) + goto _resume; + } + label _test_eof { {} + if ( p == eof ) + { + index s8 __acts; + uint __nacts; + __acts = offset( _recdescent_actions, _recdescent_eof_actions[cs] ); + __nacts = cast(uint)deref( _recdescent_actions, __acts ); __acts += 1; + while ( __nacts > 0 ) { + switch ( deref( _recdescent_actions, __acts ) ) { + case 1 { + host( "working/recdescent1.rl", 34 ) ${ + printf( "item: " ); + fwrite( item, 1, p-item, stdout ); + printf( "\n" ); + }$ + } + } + __nacts -= 1; + __acts += 1; + } + } + + } + label _out { {} + } + } + } + host( "working/recdescent1.rl", 93 ) @{ + + if ( cs == recdescent_error ) { + /* Machine failed before finding a token. */ + printf( "PARSE ERROR\n" ); + } + } + + int main() + { + test( "88 foo { 99 {{{{}}}}{ } }"); + test( "76 } sadf"); + return 0; +} + +}@
\ No newline at end of file |