tagged release 0.7.1
[parrot.git] / compilers / tge / TGE / Rule.pir
blobfc7e09c192882ed4a78f904a3fdbc06b23ff4114
1 # Copyright (C) 2005-2008, The Perl Foundation.
3 =head1 NAME
5 TGE::Rule - a single rule in the attribute grammar
7 =head1 DESCRIPTION
9 A basic class to hold defined attribute grammar rules.
11 =cut
13 .namespace [ "TGE::Rule" ]
15 # Possibly better named "type", "name", "parent", "action/exec",
16 # "copy/value"
18 .sub "__onload" :load
19     .local pmc base
20     newclass base, "TGE::Rule"
21     addattribute base, "type"   # node type that this rule applies to
22     addattribute base, "name"   # name of attribute being defined
23     addattribute base, "parent" # where the attribute is applied
24                                 # (current node or child node)
25     addattribute base, "action" # a compiled subroutine
26     addattribute base, "line"   # line number in the grammar source file
27     .return ()
28 .end
30 =head2 new
32 Create a new rule object. A rule object holds the semantics for a single
33 attribute grammar rule.
35 =cut
37 .sub __init :method
38     $P0 = new 'Undef'
39     $P1 = new 'Undef'
40     $P2 = new 'Undef'
41     $P3 = new 'Undef'
42     $P4 = new 'Undef'
43     $P5 = new 'Sub'
44     setattribute self, "type", $P0
45     setattribute self, "name", $P1
46     setattribute self, "parent", $P2
47     setattribute self, "line", $P4
48     setattribute self, "action", $P5
49 .end
51 =head2 dump
53 Produce a data dump of the current contents of the rule object.
55 =cut
57 .sub "dump" :method
58     $P0 = getattribute self, "type"
59     print "\t\t\t'type' => '"
60     print $P0
61     print "',\n"
62     $P1 = getattribute self, "name"
63     print "\t\t\t'name' => '"
64     print $P1
65     print "',\n"
66     $P2 = getattribute self, "parent"
67     print "\t\t\t'parent' => '"
68     print $P2
69     print "',\n"
70 .end
72 # Local Variables:
73 #   mode: pir
74 #   fill-column: 100
75 # End:
76 # vim: expandtab shiftwidth=4 ft=pir: