diff options
Diffstat (limited to 'test/trans.d/case/gotocallret3_cs.rl')
-rw-r--r-- | test/trans.d/case/gotocallret3_cs.rl | 123 |
1 files changed, 123 insertions, 0 deletions
diff --git a/test/trans.d/case/gotocallret3_cs.rl b/test/trans.d/case/gotocallret3_cs.rl new file mode 100644 index 00000000..4b5d34f1 --- /dev/null +++ b/test/trans.d/case/gotocallret3_cs.rl @@ -0,0 +1,123 @@ +/* + * @LANG: csharp + * @GENERATED: true + */ + +using System; +// Disables lots of warnings that appear in the test suite +#pragma warning disable 0168, 0169, 0219, 0162, 0414 +namespace Test { +class Test +{ +char comm; +int top; +int [] stack = new int [32]; + +%%{ + machine gotocallret; + + # A reference to a state in an unused action caused a segfault in 5.8. */ + action unusedAction {fentry(garble_line); +} + + action err_garbling_line {Console.Write( "error: garbling line\n" );} + action goto_main {fnext main;} + action recovery_failed {Console.Write( "error: failed to recover\n" );} + + # Error machine, consumes to end of + # line, then starts the main line over. + garble_line := ( (any-'\n')*'\n') + >err_garbling_line + @goto_main + $/recovery_failed; + + action hold_and_return {fhold;fnret;} + + # Look for a string of alphas or of digits, + # on anything else, hold the character and return. + alp_comm := alpha+ $!hold_and_return; + dig_comm := digit+ $!hold_and_return; + + # Choose which to machine to call into based on the command. + action comm_arg {if ( comm >= 97 ) +{ + fncall alp_comm; +} +else { + fncall dig_comm; +} +} + + # Specifies command string. Note that the arg is left out. + command = ( + [a-z0-9] @{comm = fc; +} ' ' @comm_arg @{Console.Write( "prints\n" );} '\n' + ) @{Console.Write( "correct command\n" );}; + + # Any number of commands. If there is an + # error anywhere, garble the line. + main := command* $!{fhold;fnext garble_line;}; +}%% + + +%% write data; +int cs; + +void init() +{ + %% write init; +} + +void exec( char[] data, int len ) +{ + int p = 0; + int pe = len; + int eof = len; + string _s; + char [] buffer = new char [1024]; + int blen = 0; + %% write exec; +} + +void finish( ) +{ + if ( cs >= gotocallret_first_final ) + Console.WriteLine( "ACCEPT" ); + else + Console.WriteLine( "FAIL" ); +} + +static readonly string[] inp = { +"lkajsdf\n", +"2134\n", +"(\n", +"\n", +"*234234()0909 092 -234aslkf09`1 11\n", +"1\n", +"909\n", +"1 a\n", +"11 1\n", +"a 1\n", +"aa a\n", +"1 1\n", +"1 123456\n", +"a a\n", +"a abcdef\n", +"h", +"a aa1", +}; + + +static readonly int inplen = 17; + +public static void Main (string[] args) +{ + Test machine = new Test(); + for ( int i = 0; i < inplen; i++ ) { + machine.init(); + machine.exec( inp[i].ToCharArray(), inp[i].Length ); + machine.finish(); + } +} +} +} |