diff options
Diffstat (limited to 'test/rlhc.d/case/clang2.m-C-T0--var-backend.in')
-rw-r--r-- | test/rlhc.d/case/clang2.m-C-T0--var-backend.in | 405 |
1 files changed, 405 insertions, 0 deletions
diff --git a/test/rlhc.d/case/clang2.m-C-T0--var-backend.in b/test/rlhc.d/case/clang2.m-C-T0--var-backend.in new file mode 100644 index 00000000..6d564313 --- /dev/null +++ b/test/rlhc.d/case/clang2.m-C-T0--var-backend.in @@ -0,0 +1,405 @@ +host( "working/clang2.rl", 1 ) @{/* + * @@LANG: obj-c + * A mini C-like language scanner. + */ + + #include <stdio.h> + #include <string.h> + #include <Foundation/Foundation.h> + + #define IDENT_BUFLEN 256 + + @@interface Clang : NSObject + { + @@public + /* State machine operation data. */ + int cs; + + /* Parsing data. */ + char identBuf[IDENT_BUFLEN+1]; + int identLen; + int curLine; + }; + + - (void) initFsm; + - (void) executeWithData:(const char *)data len:(int)len; + - (int) finish; + + @@end + + + + @@implementation Clang + +}@ +array s8 _Clang_actions( 0, 8 ) = { 0, 1, 0, 1, 1, 1, 2, 1, 3, 1, 4, 1, 5, 1, 6, 1, 7, 1, 8, 2, 0, 8, 2, 1, 0, 2, 2, 1, 2, 2, 8, 2, 3, 1, 2, 3, 8, 2, 4, 1, 2, 4, 8, 2, 5, 1, 2, 5, 8, 2, 6, 1, 2, 6, 8, 2, 7, 1, 2, 7, 8, 3, 2, 1, 0, 3, 3, 1, 0, 3, 4, 1, 0, 3, 5, 1, 0, 3, 6, 1, 0, 3, 7, 1, 0, 0 }; + +array s16 _Clang_key_offsets( 0, 182 ) = { 0, 0, 3, 6, 7, 9, 12, 13, 15, 21, 22, 42, 62, 82, 103, 124, 143, 162, 182, 0 }; + +array char _Clang_trans_keys( 0, 126 ) = { 10, 34, 92, 10, 39, 92, 10, 10, 42, 10, 42, 47, 10, 48, 57, 48, 57, 65, 70, 97, 102, 10, 10, 34, 39, 47, 48, 95, 33, 46, 49, 57, 58, 64, 65, 90, 91, 96, 97, 122, 123, 126, 10, 34, 39, 47, 48, 95, 33, 46, 49, 57, 58, 64, 65, 90, 91, 96, 97, 122, 123, 126, 10, 34, 39, 47, 48, 95, 33, 46, 49, 57, 58, 64, 65, 90, 91, 96, 97, 122, 123, 126, 10, 34, 39, 42, 47, 48, 95, 33, 46, 49, 57, 58, 64, 65, 90, 91, 96, 97, 122, 123, 126, 10, 34, 39, 46, 47, 95, 120, 33, 45, 48, 57, 58, 64, 65, 90, 91, 96, 97, 122, 123, 126, 10, 34, 39, 47, 95, 33, 46, 48, 57, 58, 64, 65, 90, 91, 96, 97, 122, 123, 126, 10, 34, 39, 47, 95, 33, 46, 48, 57, 58, 64, 65, 90, 91, 96, 97, 122, 123, 126, 10, 34, 39, 46, 47, 95, 33, 45, 48, 57, 58, 64, 65, 90, 91, 96, 97, 122, 123, 126, 10, 34, 39, 47, 95, 33, 46, 48, 57, 58, 64, 65, 70, 71, 90, 91, 96, 97, 102, 103, 122, 123, 126, 0 }; + +array s8 _Clang_single_lengths( 0, 7 ) = { 0, 3, 3, 1, 2, 3, 1, 0, 0, 1, 6, 6, 6, 7, 7, 5, 5, 6, 5, 0 }; + +array s8 _Clang_range_lengths( 0, 9 ) = { 0, 0, 0, 0, 0, 0, 0, 1, 3, 0, 7, 7, 7, 7, 7, 7, 7, 7, 9, 0 }; + +array s16 _Clang_index_offsets( 0, 139 ) = { 0, 0, 4, 8, 10, 13, 17, 19, 21, 25, 27, 41, 55, 69, 84, 99, 112, 125, 139, 0 }; + +array s8 _Clang_trans_cond_spaces( -1, 0 ) = { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 0 }; + +array s16 _Clang_trans_offsets( 0, 153 ) = { 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, 0 }; + +array s8 _Clang_trans_lengths( 0, 1 ) = { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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1, 2, 13, 16, 11, 15, 11, 16, 11, 16, 11, 10, 10, 1, 2, 13, 16, 11, 16, 11, 16, 11, 16, 11, 10, 10, 1, 2, 7, 13, 16, 11, 17, 11, 16, 11, 16, 11, 10, 10, 1, 2, 13, 16, 11, 18, 11, 18, 16, 11, 18, 16, 11, 10, 0 }; + +array s8 _Clang_cond_actions( 0, 81 ) = { 19, 0, 0, 1, 19, 0, 0, 1, 19, 1, 17, 0, 0, 17, 0, 0, 0, 17, 0, 1, 0, 22, 22, 22, 0, 19, 1, 17, 3, 3, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 0, 58, 55, 55, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 15, 34, 31, 31, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 7, 58, 55, 55, 0, 0, 81, 81, 81, 81, 81, 81, 81, 81, 81, 15, 46, 43, 43, 1, 73, 73, 0, 73, 1, 73, 73, 73, 73, 73, 11, 40, 37, 37, 69, 69, 69, 1, 69, 69, 69, 69, 69, 9, 28, 25, 25, 61, 1, 61, 1, 61, 1, 61, 1, 61, 5, 46, 43, 43, 1, 73, 73, 73, 1, 73, 73, 73, 73, 73, 11, 52, 49, 49, 77, 77, 77, 1, 77, 1, 77, 77, 1, 77, 77, 13, 0 }; + +array s8 _Clang_eof_actions( 0, 15 ) = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 15, 7, 15, 11, 9, 5, 11, 13, 0 }; + +array s8 _Clang_nfa_targs( 0, 0 ) = { 0, 0 }; + +array s8 _Clang_nfa_offsets( 0, 0 ) = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; + +array s8 _Clang_nfa_push_actions( 0, 0 ) = { 0, 0 }; + +array s8 _Clang_nfa_pop_trans( 0, 0 ) = { 0, 0 }; + +value int Clang_start = 10; +value int Clang_first_final = 10; +value int Clang_error = 0; + +value int Clang_en_main = 10; + +host( "working/clang2.rl", 153 ) @{ + + - (void) initFsm; + { + identLen = 0; + curLine = 1; + }@ + { + cs = cast(int)Clang_start; + } + host( "working/clang2.rl", 159 ) @{ + } + + - (void) executeWithData:(const char *)data len:(int)len; + { + const char *p = data; + const char *pe = data + len; + const char *eof = pe; + + }@ + { + int _klen; + uint _trans = 0; + uint _cond = 0; + uint _have = 0; + uint _cont = 1; + index s8 _acts; + uint _nacts; + index char _keys; + index s8 _ckeys; + int _cpc; + while ( _cont == 1 ) { + + if ( cs == 0 ) + _cont = 0; + _have = 0; + if ( p == pe ) { + if ( p == eof ) + { + if ( _have == 0 ) { + index s8 __acts; + uint __nacts; + __acts = offset( _Clang_actions, _Clang_eof_actions[cs] ); + __nacts = cast(uint)deref( _Clang_actions, __acts ); + __acts += 1; + while ( __nacts > 0 ) { + switch ( deref( _Clang_actions, __acts ) ) { + case 2 { + host( "working/clang2.rl", 47 ) ${ + identBuf[identLen] = 0; + printf("ident(%i): %s\n", curLine, identBuf); + }$ + } + case 3 { + host( "working/clang2.rl", 51 ) ${ + identBuf[identLen] = 0; + printf("literal(%i): %s\n", curLine, identBuf); + }$ + } + case 4 { + host( "working/clang2.rl", 55 ) ${ + identBuf[identLen] = 0; + printf("float(%i): %s\n", curLine, identBuf); + }$ + } + case 5 { + host( "working/clang2.rl", 59 ) ${ + identBuf[identLen] = 0; + printf("int(%i): %s\n", curLine, identBuf); + }$ + } + case 6 { + host( "working/clang2.rl", 63 ) ${ + identBuf[identLen] = 0; + printf("hex(%i): 0x%s\n", curLine, identBuf); + }$ + } + case 7 { + host( "working/clang2.rl", 67 ) ${ + identBuf[identLen] = 0; + printf("symbol(%i): %s\n", curLine, identBuf); + }$ + } + } + __nacts -= 1; + __acts += 1; + } + } + } + + if ( _have == 0 ) + _cont = 0; + } + if ( _cont == 1 ) { + if ( _have == 0 ) { + _keys = offset( _Clang_trans_keys, _Clang_key_offsets[cs] ); + _trans = cast(uint)_Clang_index_offsets[cs]; + _have = 0; + + _klen = cast(int)_Clang_single_lengths[cs]; + if ( _klen > 0 ) { + index char _lower; + index char _mid; + index char _upper; + _lower = _keys; + _upper = _keys + _klen - 1; + while ( _upper >= _lower && _have == 0 ) { + _mid = _lower + ((_upper-_lower) >> 1); + if ( ( deref( data, p )) < deref( _Clang_trans_keys, _mid ) ) + _upper = _mid - 1; + else if ( ( deref( data, p )) > deref( _Clang_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)_Clang_range_lengths[cs]; + if ( _klen > 0 ) { + index char _lower; + index char _mid; + index char _upper; + _lower = _keys; + _upper = _keys + (_klen<<1) - 2; + while ( _have == 0 && _lower <= _upper ) { + _mid = _lower + (((_upper-_lower) >> 1) & ~1); + if ( ( deref( data, p )) < deref( _Clang_trans_keys, _mid ) ) + _upper = _mid - 2; + else if ( ( deref( data, p )) > deref( _Clang_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( _Clang_cond_keys, _Clang_trans_offsets[_trans] ); + _klen = cast(int)_Clang_trans_lengths[_trans]; + _cond = cast(uint)_Clang_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( _Clang_cond_keys, _mid ) ) + _upper = _mid - 1; + else if ( _cpc > cast(int)deref( _Clang_cond_keys, _mid ) ) + _lower = _mid + 1; + else { + _cond += cast(uint)(_mid - _ckeys); + _have = 1; + } + } + if ( _have == 0 ) { + cs = 0; + _cont = 0; + } + } + } + if ( _cont == 1 ) { + cs = cast(int)_Clang_cond_targs[_cond]; + + if ( _Clang_cond_actions[_cond] != 0 ) { + _acts = offset( _Clang_actions, _Clang_cond_actions[_cond] ); + _nacts = cast(uint)deref( _Clang_actions, _acts ); + _acts += 1; + while ( _nacts > 0 ) + { + switch ( deref( _Clang_actions, _acts ) ) + { + case 0 { + host( "working/clang2.rl", 34 ) ${ + if ( identLen < IDENT_BUFLEN ) { + identBuf[identLen] = ={( deref( data, p ))}=; + identLen += 1; + } + }$ + } + case 1 { + host( "working/clang2.rl", 42 ) ${ + identLen = 0; + }$ + } + case 2 { + host( "working/clang2.rl", 47 ) ${ + identBuf[identLen] = 0; + printf("ident(%i): %s\n", curLine, identBuf); + }$ + } + case 3 { + host( "working/clang2.rl", 51 ) ${ + identBuf[identLen] = 0; + printf("literal(%i): %s\n", curLine, identBuf); + }$ + } + case 4 { + host( "working/clang2.rl", 55 ) ${ + identBuf[identLen] = 0; + printf("float(%i): %s\n", curLine, identBuf); + }$ + } + case 5 { + host( "working/clang2.rl", 59 ) ${ + identBuf[identLen] = 0; + printf("int(%i): %s\n", curLine, identBuf); + }$ + } + case 6 { + host( "working/clang2.rl", 63 ) ${ + identBuf[identLen] = 0; + printf("hex(%i): 0x%s\n", curLine, identBuf); + }$ + } + case 7 { + host( "working/clang2.rl", 67 ) ${ + identBuf[identLen] = 0; + printf("symbol(%i): %s\n", curLine, identBuf); + }$ + } + case 8 { + host( "working/clang2.rl", 141 ) ${ curLine += 1; }$ + } + } + _nacts -= 1; + _acts += 1; + } + } + + if ( cs == 0 ) + _cont = 0; + if ( _cont == 1 ) + p += 1; + + } + } + } + } + host( "working/clang2.rl", 168 ) @{ + } + + - (int) finish; + { + if ( cs == Clang_error ) + return -1; + if ( cs >= Clang_first_final ) + return 1; + return 0; + } + + @@end + + #define BUFSIZE 2048 + + Clang *fsm; + char buf[BUFSIZE]; + + void test( char *buf ) + { + int len = strlen(buf); + fsm = [[Clang alloc] init]; + [fsm initFsm]; + [fsm executeWithData:buf len:len]; + if ( [fsm finish] > 0 ) + printf("ACCEPT\n"); + else + printf("FAIL\n"); + } + + int main() + { + test( + "999 0xaAFF99 99.99 /*\n" + "*/ 'lksdj' //\n" + "\"\n" + "\n" + "literal\n" + "\n" + "\n" + "\"0x00aba foobardd.ddsf 0x0.9\n" ); + + test( + "wordwithnum00asdf\n" + "000wordfollowsnum,makes new symbol\n" + "\n" + "finishing early /* unfinished ...\n" ); + + test( + "/*\n" + " * Copyright\n" + " */\n" + "\n" + "/* Aapl.\n" + " */\n" + "\n" + "#define _AAPL_RESIZE_H\n" + "\n" + "#include <assert.h>\n" + "\n" + "#ifdef AAPL_NAMESPACE\n" + "namespace Aapl {\n" + "#endif\n" + "#define LIN_DEFAULT_STEP 256\n" + "#define EXPN_UP( existing, needed ) \\\n" + " need > eng ? (ned<<1) : eing\n" + " \n" + "\n" + "/*@@}*/\n" + "#undef EXPN_UP\n" + "#ifdef AAPL_NAMESPACE\n" + "#endif /* _AAPL_RESIZE_H */\n" ); + return 0; + } + +}@
\ No newline at end of file |