cdata.in 872 Bytes
Newer Older
dcw's avatar
dcw committed
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
EXPORT {

/* hello there - welcome to my test file */

/* isn't it fun? */

@@

#ifdef HASPROTOS
extern int length( intlist );
#else
extern int length();
#endif

/* bye now */

}


GLOBAL {

/* not a lot to say here... */
@@

int length( l ) intlist l;
{
	int len = 0;
	int hd;

	while( l != intlist_nil() ) 
	{
		get_intlist_cons( l, &hd, &l );
		len++;
	}
	return len;

} /* length */


}


dcw's avatar
dcw committed
43 44
TYPE {

45 46 47 48 49 50
first	= a | b | c | d | e;
second	= a( int aa );
third	= a | b;
fourth	= a | b | c(int cc) | d | e;
fifth	= a | b | c(int cc) | d( string dd) | e;
sixth	= a(int aa) | b | c | d | e;
51

dcw's avatar
dcw committed
52 53 54 55 56 57 58 59 60 61 62
intlist = nil						"nil"
	| cons( int first, intlist next )		1 " , " 2
	;

illist  = nil						"nil"
	| cons( intlist first, illist next )		"[ " 1 " ] , " 2
	;

idtree  = leaf( string id, intlist l )			"leaf( '" 1 "', " 2 ")"
	| node( idtree left, idtree right )		"( " 1 " , " 2 " )"
	;
dcw's avatar
dcw committed
63
}