summaryrefslogtreecommitdiff
path: root/test/cases/trans.d/case/gotocallret1_julia.rl
blob: 3b7c980afa5abda650350e1a66e0659cda85c619 (plain)
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
//
// @LANG: julia
// @GENERATED: true
//


%%{
	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 {print( "error: garbling line\n" );
}
	action goto_main {fgoto main;}
	action recovery_failed {print( "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;fret;}

	# 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 >= 'a' )
	fcall alp_comm;
else
	fcall dig_comm;
end
}

	# Specifies command string. Note that the arg is left out.
	command = (
		[a-z0-9] @{comm = fc;
} ' ' @comm_arg '\n'
	) @{print( "correct command\n" );
};

	# Any number of commands. If there is an 
	# error anywhere, garble the line.
	main := command* $!{fhold;fgoto garble_line;}; 
}%%



%% write data;

function m( data::AbstractString )
	p = 0
	pe = length(data)
	eof = length(data)
	cs = 0
	buffer = ""
comm = 0;
top = 0;
stack = Int [ 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 ];

	%% write init;
	%% write exec;

	if ( cs >= GotoCallRet_first_final )
		println( "ACCEPT" );
	else
		println( "FAIL" );
	end
end

	m( "lkajsdf\n" );
	m( "2134\n" );
	m( "(\n" );
	m( "\n" );
	m( "*234234()0909 092 -234aslkf09`1 11\n" );
	m( "1\n" );
	m( "909\n" );
	m( "1 a\n" );
	m( "11 1\n" );
	m( "a 1\n" );
	m( "aa a\n" );
	m( "1 1\n" );
	m( "1 123456\n" );
	m( "a a\n" );
	m( "a abcdef\n" );
	m( "h" );
	m( "a aa1" );