summaryrefslogtreecommitdiff
path: root/test/erract9.rl
blob: ccd848a86e9af44fbefb99dcb0532d9112f522f8 (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
#
# @LANG: ruby
#
# Test the host language scanning for ruby.
#

%%{
	machine erract9;

	action on_char  { print("char: ", data[p..p], "\n"); }
	action on_err   { print("err: ", data[p..p], "\n"); }
	action to_state { print("to state: " , data[p..p], "\n"); }

	main := 'heXXX' $on_char $err(on_err) $to(to_state);
}%%

%% write data;

def run_machine( data )
	p = 0;
	pe = data.length
	cs = 0

	%% write init;
	%% write exec;

	print("rest: " , data[p..p+2], "\n")
end

inp = [
		"hello\n",
]

inp.each { |str| run_machine(str) }

=begin _____OUTPUT_____
char: h
to state: h
char: e
to state: e
err: l
rest: llo
=end _____OUTPUT_____