summaryrefslogtreecommitdiff
path: root/test/trans.d/case/patact_go.rl
blob: 2ee97c3646cc08d560b48bece3a0626898efdbaf (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
95
96
97
98
99
100
101
102
103
104
/*
 * @LANG: go
 * @GENERATED: true
 */

package main
import "fmt"

var comm  byte ;
var top  int ;
var stack [32] int ;
var ts  int ;
var te  int ;
var act  int ;
var value  int ;

%%{
	machine patact;

	other := |* 
		[a-z]+ => {fmt.Print( "word\n" );};
		[0-9]+ => {fmt.Print( "num\n" );};
		[\n ] => {fmt.Print( "space\n" );};
	*|;

	exec_test := |* 
		[a-z]+ => {fmt.Print( "word (w/lbh)\n" );fexec te-1; 
fgoto other; 
};
		[a-z]+ ' foil' => {fmt.Print( "word (c/lbh)\n" );};
		[\n ] => {fmt.Print( "space\n" );};
		'22' => {fmt.Print( "num (w/switch)\n" );};
		[0-9]+ => {fmt.Print( "num (w/switch)\n" );fexec te-1; 
fgoto other;
};
		[0-9]+ ' foil' => {fmt.Print( "num (c/switch)\n" );};
		'!';# => { print_str "immdiate\n"; fgoto exec_test; };
	*|;

	semi := |* 
		';' => {fmt.Print( "in semi\n" );fgoto main; 
};
	*|;

	main := |* 
		[a-z]+ => {fmt.Print( "word (w/lbh)\n" );fhold; 
fgoto other; 
};
		[a-z]+ ' foil' => {fmt.Print( "word (c/lbh)\n" );};
		[\n ] => {fmt.Print( "space\n" );};
		'22' => {fmt.Print( "num (w/switch)\n" );};
		[0-9]+ => {fmt.Print( "num (w/switch)\n" );fhold; 
fgoto other;
};
		[0-9]+ ' foil' => {fmt.Print( "num (c/switch)\n" );};
		';' => {fmt.Print( "going to semi\n" );fhold; 
fgoto semi;
};
		'!' => {fmt.Print( "immdiate\n" );fgoto exec_test; 
};
	*|;
}%%


var cs int;
var blen int;
var buffer [1024] byte;

%% write data;

func prepare() {
	%% write init;
}

func exec(data string) {
	var p int = 0
	var pe int = len(data)
	var eof int = pe
	%% write exec;
}
func finish() {
	if cs >= patact_first_final {
		fmt.Println("ACCEPT")
	} else {
		fmt.Println("FAIL")
	}
}
var inp []string = []string {
"abcd foix\n",
"abcd\nanother\n",
"123 foix\n",
"!abcd foix\n",
"!abcd\nanother\n",
"!123 foix\n",
";",
};

func main() {
	for _, data := range inp {
		prepare()
		exec(data)
		finish()
	}
}