[DOCS]
[parrot.git] / examples / pir / local_label.pir
blob477453495302bbc4d1d4f5495a73d62a3713e7e6
1 # Copyright (C) 2001-2008, The Perl Foundation.
2 # $Id$
4 =head1 NAME
6 examples/pir/local_label.pir - Local labels
8 =head1 SYNOPSIS
10     % ./parrot examples/pir/local_label.pir
12 =head1 DESCRIPTION
14 Show the use of a C<.label> label.
16 =cut
18 .macro TEST1 ()
19     print     "Branching to '$ok' in macro 'TEST1'\n"
20     branch    .$ok
21     end
22 .label $ok:
23     print    "Branched to '$ok' in macro 'TEST1'\n"
24 .endm
26 .macro TEST2 ()
27 test2:        # not local
28     print     "Branching to '$ok' in macro 'TEST2'\n"
29     branch    .$ok
30     end
31 .label $ok:
32     print    "Branched to '$ok' in macro 'TEST2'\n"
33     branch   not_local
34 .endm
36 .sub "example" :main
37     .TEST1 ()
38     print "After .TEST1 ()\n"
39     .TEST2 ()
40     print "After .TEST2 ()\n"
41     end
42 not_local:
43     print    "Branched to 'non_local' in sub 'example'\n"
44 .end
47 # Local Variables:
48 #   mode: pir
49 #   fill-column: 100
50 # End:
51 # vim: expandtab shiftwidth=4 ft=pir: