
'begin'
	'comment'
		some routines about procedure passing.
	;

	'begin' 'comment' part 1 ;

		'procedure' bar (p, s);
			p (s);

		'procedure' foo (s);
			bar (vprint, s);

		bar (foo, "nase");
		bar (vprint, 99);
		bar (vprint, "aga");
		bar (foo, 100);
		foo ("onk 1.")
	'end';

	'begin' 'comment' part 2 ;

		'integer' nase;

		'integer' 'procedure' bar (p, x);
			bar := nase := p (x);

		'integer' 'procedure' foo (x);
			foo := x;

		'procedure' bbar (bp, bx);
			bp (bx);

		'procedure' ffoo (fx);
			vprint (fx);

		bar (foo, 100);
		vprint (nase);
		vprint (bar (foo, 101));

		bbar (ffoo, 102);
		bbar (ffoo, 103);

		vprint ("onk 2.")
	'end';

	'begin'
		'integer' 'procedure' don (f, n);
			'if' n > 0 'then' don := n * f (f, n - 1)
			'else' don := 1;
		'integer' 'procedure' dov (f, n);
			'value' n;  'integer' n;
			'integer' 'procedure' f;
			'if' n > 0 'then' dov := n * f (f, n - 1)
			'else' dov := 1;
		vprint (don (don, 2));
		vprint (dov (dov, 3));
		vprint (dov (don, 4));
		vprint (don (dov, 5));
		vprint ("onk 3.");
	'end';

	'comment'
		from rdt@qucis.queensu.ca (Robert Tennent)
	;
	'BEGIN'
	
	  'PROCEDURE' p(b, q);
	    'BOOLEAN' b; 'PROCEDURE' q;
	    'BEGIN' 
	      'PROCEDURE' outputb; vprint(b);
	      'IF' b 
	        'THEN' p('NOT' b, outputb) 
	        'ELSE' 'BEGIN' q; outputb 'END'
	    'END' p;
	
	  'PROCEDURE' skip; ;
	
	  p('true', skip) 
	
	'END'


	'comment'
		another procedure passing check
	;

	'begin'

		'integer' i;
	
		'procedure' p (x);  'procedure' x;
		'begin'
			'integer' k;
			'procedure' q;  vprint(k);
	
			i := i + 1;
			k := i;
	
			'if' i = 1 
		        'then' p(q) 
		        'else' 'begin' q; x 'end'
		'end' p;
	
		'procedure' nase; vprint("Nase");
	
	
		i := 0;
	
		p(nase)
	
	'end'


'end'
