summaryrefslogtreecommitdiff
path: root/test/cases/rlhc.d/case/erract6.c-C-G1--goto-backend.in
blob: d1a4a4de830b5eb2699a069e037e3ce25ded0173 (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
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
host( "working/erract6.rl", 1 ) @{/*
	* @@LANG: c
	*/
	
	/*
	* Test of a transition going to the error state.
	*/
	
	#include <stdio.h>
	#define BUFSIZE 2048
	
	struct errintrans
	{
		int cs;
	};
	
	
	
}@
array s8 _errintrans_nfa_targs( 0, 0 ) = { 0, 0 };

array s8 _errintrans_nfa_offsets( 0, 0 ) = { 0, 0, 0, 0 };

array s8 _errintrans_nfa_push_actions( 0, 0 ) = { 0, 0 };

array s8 _errintrans_nfa_pop_trans( 0, 0 ) = { 0, 0 };

value int errintrans_start = 1;
value int errintrans_first_final = 2;
value int errintrans_error = 0;

value int errintrans_en_main = 1;

host( "working/erract6.rl", 27 ) @{
	
	void errintrans_init( struct errintrans *fsm )
	{
	}@
	{
		host( "-", 1 ) ={ fsm->cs}= = cast(int)errintrans_start;
	}
	host( "working/erract6.rl", 31 ) @{
	}
	
	void errintrans_execute( struct errintrans *fsm, const char *_data, int _len )
	{
		const char *p = _data;
		const char *pe = _data+_len;
		
	}@
	{
		if ( p == pe )
		goto _test_eof;
		if ( host( "-", 1 ) ={ fsm->cs}= == 0 )
		goto _out;
		_resume:
		switch ( host( "-", 1 ) ={ fsm->cs}= ) {
			case 1:
			if ( ( deref( data, p )) == 10 ) {
				goto ctr1;
			}
			if ( 48 <= ( deref( data, p )) && ( deref( data, p )) <= 57 ) {
				goto ctr2;
			}
			{
				goto ctr0;
			}
			case 2:
			if ( ( deref( data, p )) == 10 ) {
				goto ctr1;
			}
			if ( 48 <= ( deref( data, p )) && ( deref( data, p )) <= 57 ) {
				goto ctr2;
			}
			{
				goto ctr0;
			}
			case 0:
			goto _out;
		}
		
		ctr2: host( "-", 1 ) ={ fsm->cs}= = 0; goto _again;
		ctr0: host( "-", 1 ) ={ fsm->cs}= = 1; goto _again;
		ctr1: host( "-", 1 ) ={ fsm->cs}= = 2; goto _again;
		
		_again:
		if ( host( "-", 1 ) ={ fsm->cs}= == 0 )
		goto _out;
		p+= 1;
		if ( p != pe )
		goto _resume;
		_test_eof: {}
		_out: {}
	}
	host( "working/erract6.rl", 39 ) @{
	}
	
	int errintrans_finish( struct errintrans *fsm )
	{
		if ( fsm->cs == errintrans_error )
		return -1;
		if ( fsm->cs >= errintrans_first_final )
		return 1;
		return 0;
	}
	
	
	struct errintrans fsm;
	#include <string.h>
	
	void test( char *buf )
	{
		int len = strlen( buf );
		errintrans_init( &fsm );
		errintrans_execute( &fsm, buf, len );
		if ( errintrans_finish( &fsm ) > 0 )
		printf("ACCEPT\n");
		else
		printf("FAIL\n");
	}
	
	
	int main()
	{
		test(
		"good, does not have numbers\n"
		);
		
		test(
		"bad, has numbers 666\n"
		);
		
		return 0;
	}
	
}@