1 # Copyright (C) 2005-2008, The Perl Foundation.
5 TGE::Rule - a single rule in the attribute grammar
9 A basic class to hold defined attribute grammar rules.
13 .namespace [ "TGE::Rule" ]
15 # Possibly better named "type", "name", "parent", "action/exec",
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
32 Create a new rule object. A rule object holds the semantics for a single
33 attribute grammar rule.
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
53 Produce a data dump of the current contents of the rule object.
58 $P0 = getattribute self, "type"
59 print "\t\t\t'type' => '"
62 $P1 = getattribute self, "name"
63 print "\t\t\t'name' => '"
66 $P2 = getattribute self, "parent"
67 print "\t\t\t'parent' => '"
76 # vim: expandtab shiftwidth=4 ft=pir: