'begin'

	'comment'
		example for switch:
	;


	'begin'
		 'comment'
			first one :
		 ;

		'switch' s := label1, label2;

		outstring (1, "ONE ");
		'goto' s [1];
		outstring (1, "???");
	label1:
		outstring (1, "TWO ");
		'goto' s[2];
		outstring (1, "???");
	label2:
		outstring (1, "THREE\n\n");

	'end';

	'begin'
		 'comment'
			second one :
		 ;

		'integer' i;

		'procedure' foo (n, s);
		'begin'
			outstring (1, "foo:    ");
			'if' n > 0 'then'
				'goto' s [n];
			outstring (1, "ret\n");
		'end';

		'for' i := 1 'step' 1 'until' 2 'do' 'begin'

			'switch' sw1 := honk, fini;
			'begin'

				'switch' sw := lab1, lab2, 'if' i <= 1 'then'
						sw1 [1] 'else' sw1 [i];

					foo (1, sw);
				cont1:
					foo (2, sw);
				cont2:
					foo (3, sw);

				outstring (1, "not reached\n");

				lab1:
					outstring (1, "lab1.\n");
					'goto' cont1;
				lab2:
					outstring (1, "lab2.\n");
					'goto' cont2;
			'end';
		honk:
			outstring (1, "HONK\n");
			'goto' byebye;
		fini:
			outstring (1, "DONE.\n");
		byebye:
			;
		'end';

	'end';

	outstring (1, "\n");

	'begin'
		'comment'
			third one :
			switch parameter and designational
			expressions
		;

		'procedure' vprint (i);
			outinteger (1, i);

		'procedure' tgoto (flag, lab);
		'value' flag;
		'Boolean' flag;
		'label' lab;
			'if' flag 'then'
				'goto' lab
			'else' 'begin'
				'switch' this := lab;
				'goto' this [1]
			'end';

		'procedure' abort;
		'begin'
			vprint (9999);
			'goto' fini
		'end';

		'switch' sw := lab1, lab2, lab21;
	doit:
		vprint (1);
		tgoto ('true', sw [1]);
		abort;
	lab1:
		vprint (2);
		tgoto ('false', lab11);
		abort;
	lab11:
		vprint (3);
		tgoto ('false', sw [2]);
		abort;
	lab2:
		vprint (4);
		tgoto ('true', sw [3]);
		abort;
	lab21:
		'begin'
			'procedure' honk (p, flag, sw, idx);
				p (flag, sw [idx]);
			'integer' i;

			'for' i := 1 'step' 1 'until' 2 'do' 'begin'
				'switch' swl := lab3;
				'switch' s :=
				     'if' i = 1 'then' swl [1] 'else' lab4,
				     'if' i = 2 'then' lab4 'else' swl [1],
				     conti;
			doit:
				vprint (5+(i-1)*3);
				honk (tgoto, i = 1, s, i);
				abort;
			lab3:
				vprint (6);
				honk (tgoto, 'false', s, 3);
				abort;
			lab4:
				vprint (9);
				honk (tgoto, 'false', s, i+1);
				abort;
			conti:
				'if' i = 1 'then' vprint (7)
				'else' vprint (10)
			'end';
		'end';
		vprint (11);
	fini:
		outstring (1, "\n")
	'end';
'end'
