diff options
author | Adrian Thurston <thurston@colm.net> | 2019-09-09 10:19:58 -0600 |
---|---|---|
committer | Adrian Thurston <thurston@colm.net> | 2019-09-09 10:19:58 -0600 |
commit | fff52cd5a567ec541cd487b9fee2d89bf9b6f6eb (patch) | |
tree | 046a3f0f457343f7c99bf096863daf023a085051 /test/rlhc.d/case/element2.c-C-T0--var-backend.in | |
parent | 2d8e9c3f5c0417d6237c945c50f92bf8d28b32d5 (diff) | |
download | colm-fff52cd5a567ec541cd487b9fee2d89bf9b6f6eb.tar.gz |
base (aapl, colm, ragel) test cases building
Diffstat (limited to 'test/rlhc.d/case/element2.c-C-T0--var-backend.in')
-rw-r--r-- | test/rlhc.d/case/element2.c-C-T0--var-backend.in | 261 |
1 files changed, 261 insertions, 0 deletions
diff --git a/test/rlhc.d/case/element2.c-C-T0--var-backend.in b/test/rlhc.d/case/element2.c-C-T0--var-backend.in new file mode 100644 index 00000000..748e9c3a --- /dev/null +++ b/test/rlhc.d/case/element2.c-C-T0--var-backend.in @@ -0,0 +1,261 @@ +host( "working/element2.rl", 1 ) @{/* + * @@LANG: c + */ + + #include <stdio.h> + + struct LangEl + { + int key; + char *name; + }; + + struct fsm + { + int cs; + }; + + + +}@ +array s8 _fsm_actions( 0, 1 ) = { 0, 1, 0, 1, 1, 0 }; + +array s8 _fsm_key_offsets( 0, 3 ) = { 0, 0, 1, 3, 0 }; + +array int _fsm_trans_keys( 0, 3 ) = { 1, 2, 3, 0 }; + +array s8 _fsm_single_lengths( 0, 2 ) = { 0, 1, 2, 0, 0 }; + +array s8 _fsm_range_lengths( 0, 0 ) = { 0, 0, 0, 0, 0 }; + +array s8 _fsm_index_offsets( 0, 5 ) = { 0, 0, 2, 5, 0 }; + +array s8 _fsm_trans_cond_spaces( -1, 0 ) = { -1, -1, -1, -1, -1, -1, 0 }; + +array s8 _fsm_trans_offsets( 0, 5 ) = { 0, 1, 2, 3, 4, 5, 0 }; + +array s8 _fsm_trans_lengths( 0, 1 ) = { 1, 1, 1, 1, 1, 1, 0 }; + +array s8 _fsm_cond_keys( 0, 0 ) = { 0, 0, 0, 0, 0, 0, 0 }; + +array s8 _fsm_cond_targs( 0, 3 ) = { 2, 0, 2, 3, 0, 0, 0 }; + +array s8 _fsm_cond_actions( 0, 1 ) = { 1, 0, 1, 1, 0, 0, 0 }; + +array s8 _fsm_eof_actions( 0, 3 ) = { 0, 0, 0, 3, 0 }; + +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 }; + +value int fsm_start = 1; +value int fsm_first_final = 3; +value int fsm_error = 0; + +value int fsm_en_main = 1; + +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; + + }@ + { + int _klen; + uint _trans = 0; + uint _cond = 0; + uint _have = 0; + uint _cont = 1; + index s8 _acts; + uint _nacts; + index int _keys; + index s8 _ckeys; + int _cpc; + while ( _cont == 1 ) { + + if ( host( "-", 1 ) ={ fsm->cs}= == 0 ) + _cont = 0; + _have = 0; + if ( p == pe ) { + if ( p == eof ) + { + if ( _have == 0 ) { + index s8 __acts; + uint __nacts; + __acts = offset( _fsm_actions, _fsm_eof_actions[host( "-", 1 ) ={ fsm->cs}=] ); + __nacts = cast(uint)deref( _fsm_actions, __acts ); + __acts += 1; + while ( __nacts > 0 ) { + switch ( deref( _fsm_actions, __acts ) ) { + case 1 { + host( "working/element2.rl", 30 ) ${printf("accept\n");}$ + } + } + __nacts -= 1; + __acts += 1; + } + } + } + + if ( _have == 0 ) + _cont = 0; + } + if ( _cont == 1 ) { + if ( _have == 0 ) { + _keys = offset( _fsm_trans_keys, _fsm_key_offsets[host( "-", 1 ) ={ fsm->cs}=] ); + _trans = cast(uint)_fsm_index_offsets[host( "-", 1 ) ={ fsm->cs}=]; + _have = 0; + + _klen = cast(int)_fsm_single_lengths[host( "-", 1 ) ={ fsm->cs}=]; + if ( _klen > 0 ) { + index int _lower; + index int _mid; + index int _upper; + _lower = _keys; + _upper = _keys + _klen - 1; + while ( _upper >= _lower && _have == 0 ) { + _mid = _lower + ((_upper-_lower) >> 1); + if ( host( "-", 1 ) ={p->key}= < deref( _fsm_trans_keys, _mid ) ) + _upper = _mid - 1; + else if ( host( "-", 1 ) ={p->key}= > deref( _fsm_trans_keys, _mid ) ) + _lower = _mid + 1; + else { + _trans += cast(uint)(_mid - _keys); + _have = 1; + } + } + if ( _have == 0 ) { + _keys += _klen; + _trans += cast(uint)_klen; + } + } + + if ( _have == 0 ) { + _klen = cast(int)_fsm_range_lengths[host( "-", 1 ) ={ fsm->cs}=]; + if ( _klen > 0 ) { + index int _lower; + index int _mid; + index int _upper; + _lower = _keys; + _upper = _keys + (_klen<<1) - 2; + while ( _have == 0 && _lower <= _upper ) { + _mid = _lower + (((_upper-_lower) >> 1) & ~1); + if ( host( "-", 1 ) ={p->key}= < deref( _fsm_trans_keys, _mid ) ) + _upper = _mid - 2; + else if ( host( "-", 1 ) ={p->key}= > deref( _fsm_trans_keys, _mid + 1 ) ) + _lower = _mid + 2; + else { + _trans += cast(uint)((_mid - _keys)>>1); + _have = 1; + } + } + if ( _have == 0 ) + _trans += cast(uint)_klen; + } + } + + _ckeys = offset( _fsm_cond_keys, _fsm_trans_offsets[_trans] ); + _klen = cast(int)_fsm_trans_lengths[_trans]; + _cond = cast(uint)_fsm_trans_offsets[_trans]; + _have = 0; + + _cpc = 0; + { + index s8 _lower; + index s8 _mid; + index s8 _upper; + _lower = _ckeys; + _upper = _ckeys + _klen - 1; + while ( _have == 0 && _lower <= _upper ) { + _mid = _lower + ((_upper-_lower) >> 1); + if ( _cpc < cast(int)deref( _fsm_cond_keys, _mid ) ) + _upper = _mid - 1; + else if ( _cpc > cast(int)deref( _fsm_cond_keys, _mid ) ) + _lower = _mid + 1; + else { + _cond += cast(uint)(_mid - _ckeys); + _have = 1; + } + } + if ( _have == 0 ) { + host( "-", 1 ) ={ fsm->cs}= = 0; + _cont = 0; + } + } + } + if ( _cont == 1 ) { + host( "-", 1 ) ={ fsm->cs}= = cast(int)_fsm_cond_targs[_cond]; + + if ( _fsm_cond_actions[_cond] != 0 ) { + _acts = offset( _fsm_actions, _fsm_cond_actions[_cond] ); + _nacts = cast(uint)deref( _fsm_actions, _acts ); + _acts += 1; + while ( _nacts > 0 ) + { + switch ( deref( _fsm_actions, _acts ) ) + { + case 0 { + host( "working/element2.rl", 29 ) ${printf("%s\n", p->name);}$ + } + } + _nacts -= 1; + _acts += 1; + } + } + + if ( host( "-", 1 ) ={ fsm->cs}= == 0 ) + _cont = 0; + if ( _cont == 1 ) + p += 1; + + } + } + } + } + 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 |