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/lmgoto.cpp-C-F0--goto-backend.exp | |
parent | 2d8e9c3f5c0417d6237c945c50f92bf8d28b32d5 (diff) | |
download | colm-fff52cd5a567ec541cd487b9fee2d89bf9b6f6eb.tar.gz |
base (aapl, colm, ragel) test cases building
Diffstat (limited to 'test/rlhc.d/case/lmgoto.cpp-C-F0--goto-backend.exp')
-rw-r--r-- | test/rlhc.d/case/lmgoto.cpp-C-F0--goto-backend.exp | 930 |
1 files changed, 930 insertions, 0 deletions
diff --git a/test/rlhc.d/case/lmgoto.cpp-C-F0--goto-backend.exp b/test/rlhc.d/case/lmgoto.cpp-C-F0--goto-backend.exp new file mode 100644 index 00000000..42a9359f --- /dev/null +++ b/test/rlhc.d/case/lmgoto.cpp-C-F0--goto-backend.exp @@ -0,0 +1,930 @@ +#include <iostream> +#include <string.h> +using namespace std; + +#define TK_Dlit 192 +#define TK_Slit 193 +#define TK_Float 194 +#define TK_Id 195 +#define TK_NameSep 197 +#define TK_Arrow 211 +#define TK_PlusPlus 212 +#define TK_MinusMinus 213 +#define TK_ArrowStar 214 +#define TK_DotStar 215 +#define TK_ShiftLeft 216 +#define TK_ShiftRight 217 +#define TK_IntegerDecimal 218 +#define TK_IntegerOctal 219 +#define TK_IntegerHex 220 +#define TK_EqualsEquals 223 +#define TK_NotEquals 224 +#define TK_AndAnd 225 +#define TK_OrOr 226 +#define TK_MultAssign 227 +#define TK_DivAssign 228 +#define TK_PercentAssign 229 +#define TK_PlusAssign 230 +#define TK_MinusAssign 231 +#define TK_AmpAssign 232 +#define TK_CaretAssign 233 +#define TK_BarAssign 234 +#define TK_DotDotDot 240 +#define TK_Whitespace 241 +#define TK_Comment 242 + +struct Scanner +{ + int cs, act; + const char *ts, *te; + bool isCxx; + + void token( int tok ); + void run( const char *buf ); +}; + + + + +static const char _Scanner_actions [] = { 0, 1, 0, 1, 2, 1, 3, 1, 4, 1, 5, 1, 6, 1, 7, 1, 12, 1, 13, 1, 14, 1, 15, 1, 16, 1, 17, 1, 18, 1, 19, 1, 20, 1, 21, 1, 22, 1, 23, 1, 24, 1, 25, 1, 26, 1, 27, 1, 28, 1, 29, 1, 30, 1, 31, 1, 32, 1, 33, 1, 34, 1, 35, 1, 36, 1, 37, 1, 38, 1, 39, 1, 40, 1, 41, 1, 42, 1, 43, 1, 44, 1, 45, 1, 46, 1, 47, 1, 48, 1, 49, 2, 0, 1, 2, 3, 8, 2, 3, 9, 2, 3, 10, 2, 3, 11, 0 , }; +static const char _Scanner_trans_keys [] = { 1, 0, 0, 24, 1, 0, 0, 24, 1, 0, 11, 11, 9, 14, 13, 14, 13, 20, 2, 28, 2, 28, 16, 16, 16, 16, 6, 16, 16, 16, 9, 16, 10, 17, 8, 8, 8, 14, 13, 26, 13, 26, 8, 16, 11, 27, 11, 26, 22, 26, 22, 26, 22, 26, 13, 26, 22, 26, 11, 26, 15, 15, 16, 16, 13, 27, 3, 27, 16, 16, 16, 28, 0, 8, 12, 12, 0 , }; +static const char _Scanner_char_class [] = { 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 3, 4, 4, 5, 6, 7, 4, 4, 8, 9, 4, 10, 11, 12, 13, 14, 14, 14, 14, 14, 14, 14, 14, 14, 15, 4, 4, 16, 17, 4, 4, 18, 18, 18, 18, 19, 20, 21, 21, 21, 21, 21, 22, 21, 21, 21, 21, 21, 21, 21, 21, 23, 21, 21, 21, 21, 21, 4, 24, 4, 25, 21, 4, 18, 18, 18, 18, 19, 20, 21, 21, 21, 21, 21, 26, 21, 21, 21, 21, 21, 21, 21, 21, 23, 21, 21, 27, 21, 21, 4, 28, 4, 4, 0 , }; +static const short _Scanner_index_offsets [] = { 0, 0, 25, 25, 50, 50, 51, 57, 59, 67, 94, 121, 122, 123, 134, 135, 143, 151, 152, 159, 173, 187, 196, 213, 229, 234, 239, 244, 258, 263, 279, 280, 281, 296, 321, 322, 335, 344, 0 , }; +static const char _Scanner_indicies [] = { 0, 1, 1, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 3, 0, 4, 4, 4, 4, 4, 4, 5, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 6, 8, 9, 9, 0, 0, 10, 10, 10, 10, 12, 12, 11, 11, 11, 12, 12, 12, 14, 1, 15, 16, 17, 4, 18, 19, 20, 21, 22, 23, 24, 25, 26, 15, 27, 27, 27, 27, 28, 27, 15, 29, 27, 27, 30, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 33, 34, 35, 32, 32, 32, 32, 32, 32, 32, 32, 32, 36, 37, 38, 32, 32, 32, 32, 32, 32, 39, 40, 32, 32, 32, 32, 32, 41, 42, 44, 45, 32, 32, 46, 32, 47, 47, 47, 47, 48, 48, 48, 48, 49, 50, 48, 50, 48, 48, 48, 50, 10, 10, 48, 48, 48, 48, 48, 50, 48, 50, 48, 48, 48, 50, 51, 32, 32, 32, 52, 32, 32, 32, 53, 47, 54, 55, 55, 54, 54, 54, 54, 49, 54, 54, 56, 56, 54, 54, 56, 57, 47, 58, 55, 55, 58, 58, 58, 58, 49, 58, 58, 59, 59, 58, 58, 59, 60, 60, 58, 58, 60, 61, 61, 54, 54, 61, 62, 62, 54, 54, 62, 12, 12, 63, 63, 63, 12, 12, 12, 63, 64, 64, 63, 63, 64, 65, 65, 63, 63, 65, 47, 54, 24, 24, 54, 54, 54, 54, 49, 54, 54, 56, 56, 54, 54, 56, 66, 67, 27, 27, 68, 68, 68, 27, 27, 27, 27, 27, 27, 68, 68, 27, 27, 1, 68, 68, 68, 4, 68, 68, 68, 68, 68, 27, 27, 68, 68, 68, 27, 27, 27, 27, 27, 27, 68, 68, 27, 27, 69, 70, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 71, 73, 72, 72, 72, 72, 72, 72, 72, 74, 76, 0 , }; +static const char _Scanner_index_defaults [] = { 0, 1, 1, 4, 4, 7, 0, 0, 11, 13, 13, 32, 32, 32, 32, 32, 32, 43, 32, 48, 48, 32, 54, 58, 58, 54, 54, 63, 63, 54, 32, 32, 68, 68, 32, 32, 72, 75, 0 , }; +static const char _Scanner_trans_cond_spaces [] = { -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 , }; +static const char _Scanner_cond_targs [] = { 9, 1, 9, 2, 3, 9, 4, 9, 9, 7, 20, 9, 27, 10, 11, 9, 12, 13, 14, 15, 16, 18, 21, 22, 29, 30, 31, 32, 33, 34, 35, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 17, 9, 9, 9, 5, 19, 9, 6, 9, 9, 9, 9, 9, 23, 25, 8, 9, 24, 9, 26, 9, 9, 28, 9, 9, 9, 9, 9, 9, 9, 36, 36, 37, 36, 36, 0 , }; +static const char _Scanner_cond_actions [] = { 89, 0, 17, 0, 0, 15, 0, 87, 61, 0, 0, 85, 0, 0, 0, 63, 0, 0, 0, 0, 0, 5, 0, 100, 100, 0, 0, 0, 94, 0, 0, 83, 81, 31, 41, 33, 47, 37, 53, 43, 55, 45, 0, 79, 57, 59, 0, 97, 71, 0, 19, 65, 67, 39, 73, 103, 0, 0, 75, 0, 23, 0, 21, 77, 0, 25, 27, 29, 69, 49, 51, 35, 11, 9, 0, 13, 7, 0 , }; +static const char _Scanner_to_state_actions [] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 91, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0 , }; +static const char _Scanner_from_state_actions [] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 0, 0 , }; +static const char _Scanner_eof_trans [] = { 0, 1, 1, 1, 1, 8, 1, 1, 12, 0, 32, 33, 33, 33, 33, 33, 33, 44, 33, 49, 49, 33, 55, 59, 59, 55, 55, 64, 64, 55, 33, 33, 69, 69, 33, 33, 0, 76, 0 , }; +static const char _Scanner_nfa_targs [] = { 0, 0 , }; +static const char _Scanner_nfa_offsets [] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 , }; +static const char _Scanner_nfa_push_actions [] = { 0, 0 , }; +static const char _Scanner_nfa_pop_trans [] = { 0, 0 , }; +static const int Scanner_start = 9; +static const int Scanner_error = 0; +static const int Scanner_en_comment = 36; +static const int Scanner_en_main = 9; +void Scanner::token( int tok ) +{ + const char *data = ts; + int len = te - ts; + cout << "<" << tok << "> "; + if ( data != 0 ) { + for ( int i = 0; i < len; i++ ) + cout << data[i]; + } + cout << '\n'; +} + +void Scanner::run( const char *buf ) +{ + int len = strlen( buf ); + + { + cs = ( int ) Scanner_start; + ts = 0; + te = 0; + act = 0; + } + const char *p = buf; + const char *pe = buf + len; + const char *eof = pe; + + { + int _trans = 0; + const char *_acts; + unsigned int _nacts; + const char *_keys; + const char *_inds; + if ( p == pe ) + goto _test_eof; + + if ( cs == 0 ) + goto _out; + + _resume : + _acts = _Scanner_actions + _Scanner_from_state_actions[cs]; + _nacts = ( unsigned int ) (*( _acts )) + ; + _acts += 1; + while ( _nacts > 0 ) + { + switch ( (*( _acts )) + ) { + case 2 : + { + { + ts = p; + + } + + } + + break; + + } + _nacts -= 1; + _acts += 1; + } + + + _keys = _Scanner_trans_keys + (cs<<1); + _inds = _Scanner_indicies + _Scanner_index_offsets[cs]; + if ( ((*( p )) + )<= 126 && ((*( p )) + )>= 10 ) + { + int _ic = ( int ) _Scanner_char_class[( int ) ((*( p )) + )- 10]; + if ( _ic <= ( int ) (*( _keys+1 )) + && _ic >= ( int ) (*( _keys )) + ) + _trans = ( int ) (*( _inds + ( int ) (_ic - ( int ) (*( _keys )) + ) )) + ; + + else + _trans = ( int ) _Scanner_index_defaults[cs]; + + } + + else + { + _trans = ( int ) _Scanner_index_defaults[cs]; + } + + + goto _match_cond; + + _match_cond : + cs = ( int ) _Scanner_cond_targs[_trans]; + if ( _Scanner_cond_actions[_trans]== 0 ) + goto _again; + + + _acts = _Scanner_actions + _Scanner_cond_actions[_trans]; + _nacts = ( unsigned int ) (*( _acts )) + ; + _acts += 1; + while ( _nacts > 0 ) + { + switch ( (*( _acts )) + ) { + case 3 : + { + { + te = p+1; + + } + + } + + break; + case 4 : + { + { + te = p+1; + { + if ( ! isCxx ) + { + cs = 9; + goto _again; + } + else { + cout << "comm char: " << ts[0] << endl; + cout << "comm char: " << ts[1] << endl; + } + + } + + } + + } + + break; + case 5 : + { + { + te = p+1; + { + if ( isCxx ) + { + cs = 9; + goto _again; + } + else + cout << "comm char: " << ts[0] << endl; + + } + + } + + } + + break; + case 6 : + { + { + te = p+1; + { + cout << "comm char: " << ts[0] << endl; + + } + + } + + } + + break; + case 7 : + { + { + te = p; + p = p - 1; + { + cout << "comm char: " << ts[0] << endl; + + } + + } + + } + + break; + case 8 : + { + { + act = 6; + + } + + } + + break; + case 9 : + { + { + act = 7; + + } + + } + + break; + case 10 : + { + { + act = 8; + + } + + } + + break; + case 11 : + { + { + act = 9; + + } + + } + + break; + case 12 : + { + { + te = p+1; + { + token( TK_Slit ); + } + + } + + } + + break; + case 13 : + { + { + te = p+1; + { + token( TK_Dlit ); + } + + } + + } + + break; + case 14 : + { + { + te = p+1; + { + token( TK_Float ); + } + + } + + } + + break; + case 15 : + { + { + te = p+1; + { + token( TK_IntegerDecimal ); + } + + } + + } + + break; + case 16 : + { + { + te = p+1; + { + token( TK_IntegerOctal ); + } + + } + + } + + break; + case 17 : + { + { + te = p+1; + { + token( TK_IntegerHex ); + } + + } + + } + + break; + case 18 : + { + { + te = p+1; + { + token( TK_NameSep ); + } + + } + + } + + break; + case 19 : + { + { + te = p+1; + { + token( TK_EqualsEquals ); + } + + } + + } + + break; + case 20 : + { + { + te = p+1; + { + token( TK_NotEquals ); + } + + } + + } + + break; + case 21 : + { + { + te = p+1; + { + token( TK_AndAnd ); + } + + } + + } + + break; + case 22 : + { + { + te = p+1; + { + token( TK_OrOr ); + } + + } + + } + + break; + case 23 : + { + { + te = p+1; + { + token( TK_MultAssign ); + } + + } + + } + + break; + case 24 : + { + { + te = p+1; + { + token( TK_DivAssign ); + } + + } + + } + + break; + case 25 : + { + { + te = p+1; + { + token( TK_PercentAssign ); + } + + } + + } + + break; + case 26 : + { + { + te = p+1; + { + token( TK_PlusAssign ); + } + + } + + } + + break; + case 27 : + { + { + te = p+1; + { + token( TK_MinusAssign ); + } + + } + + } + + break; + case 28 : + { + { + te = p+1; + { + token( TK_AmpAssign ); + } + + } + + } + + break; + case 29 : + { + { + te = p+1; + { + token( TK_CaretAssign ); + } + + } + + } + + break; + case 30 : + { + { + te = p+1; + { + token( TK_BarAssign ); + } + + } + + } + + break; + case 31 : + { + { + te = p+1; + { + token( TK_PlusPlus ); + } + + } + + } + + break; + case 32 : + { + { + te = p+1; + { + token( TK_MinusMinus ); + } + + } + + } + + break; + case 33 : + { + { + te = p+1; + { + token( TK_ArrowStar ); + } + + } + + } + + break; + case 34 : + { + { + te = p+1; + { + token( TK_DotStar ); + } + + } + + } + + break; + case 35 : + { + { + te = p+1; + { + token( TK_DotDotDot ); + } + + } + + } + + break; + case 36 : + { + { + te = p+1; + { + token( ts[0] ); + } + + } + + } + + break; + case 37 : + { + { + te = p+1; + { + isCxx = false; { + cs = 36; + goto _again; + } + + } + + } + + } + + break; + case 38 : + { + { + te = p+1; + { + isCxx = true; { + cs = 36; + goto _again; + } + + } + + } + + } + + break; + case 39 : + { + { + te = p; + p = p - 1; + { + token( TK_Id ); + } + + } + + } + + break; + case 40 : + { + { + te = p; + p = p - 1; + { + token( TK_Float ); + } + + } + + } + + break; + case 41 : + { + { + te = p; + p = p - 1; + { + token( TK_IntegerDecimal ); + } + + } + + } + + break; + case 42 : + { + { + te = p; + p = p - 1; + { + token( TK_IntegerOctal ); + } + + } + + } + + break; + case 43 : + { + { + te = p; + p = p - 1; + { + token( TK_IntegerHex ); + } + + } + + } + + break; + case 44 : + { + { + te = p; + p = p - 1; + { + token( TK_Arrow ); + } + + } + + } + + break; + case 45 : + { + { + te = p; + p = p - 1; + { + token( ts[0] ); + } + + } + + } + + break; + case 46 : + { + { + te = p; + p = p - 1; + { + token( TK_Whitespace ); + } + + } + + } + + break; + case 47 : + { + { + p = ((te))-1; + { + token( TK_IntegerDecimal ); + } + + } + + } + + break; + case 48 : + { + { + p = ((te))-1; + { + token( ts[0] ); + } + + } + + } + + break; + case 49 : + { + { + switch ( act ) { + case 0 : + { + { + cs = 0; + goto _again; + } + + } + + break; + case 6 : + p = ((te))-1; + { + token( TK_Id ); + } + + break; + case 7 : + p = ((te))-1; + { + token( TK_Float ); + } + + break; + case 8 : + p = ((te))-1; + { + token( TK_IntegerDecimal ); + } + + break; + case 9 : + p = ((te))-1; + { + token( TK_IntegerOctal ); + } + + break; + + } + + } + + + } + + break; + + } + _nacts -= 1; + _acts += 1; + } + + + + + _again : + _acts = _Scanner_actions + _Scanner_to_state_actions[cs]; + _nacts = ( unsigned int ) (*( _acts )) + ; + _acts += 1; + while ( _nacts > 0 ) + { + switch ( (*( _acts )) + ) { + case 0 : + { + { + ts = 0; + + } + + } + + break; + case 1 : + { + { + act = 0; + + } + + } + + break; + + } + _nacts -= 1; + _acts += 1; + } + + + if ( cs == 0 ) + goto _out; + + p += 1; + if ( p != pe ) + goto _resume; + + + _test_eof : + {} + if ( p == eof ) + { + if ( _Scanner_eof_trans[cs]> 0 ) + { + _trans = ( int ) _Scanner_eof_trans[cs]- 1; + goto _match_cond; + } + + } + + + + _out : + {} + + } + if ( cs == Scanner_error ) { + /* Machine failed before finding a token. */ + cout << "PARSE ERROR" << endl; + } +} + +int main() +{ + Scanner scanner; + scanner.run( + "//hello*/\n" + "/*hi there*/ hello 0x88" + ); + return 0; +} + |