1 # Copyright (C) 2005-2008, Parrot Foundation.
6 TGE::Rule - a single rule in the attribute grammar
10 A basic class to hold defined attribute grammar rules.
14 .namespace [ 'TGE'; 'Rule' ]
16 # Possibly better named "type", "name", "parent", "action/exec",
21 newclass base, ['TGE';'Rule']
22 addattribute base, "type" # node type that this rule applies to
23 addattribute base, "name" # name of attribute being defined
24 addattribute base, "parent" # where the attribute is applied
25 # (current node or child node)
26 addattribute base, "action" # a compiled subroutine
27 addattribute base, "line" # line number in the grammar source file
33 Create a new rule object. A rule object holds the semantics for a single
34 attribute grammar rule.
45 setattribute self, "type", $P0
46 setattribute self, "name", $P1
47 setattribute self, "parent", $P2
48 setattribute self, "line", $P4
49 setattribute self, "action", $P5
54 Produce a data dump of the current contents of the rule object.
59 $P0 = getattribute self, "type"
60 print "\t\t\t'type' => '"
63 $P1 = getattribute self, "name"
64 print "\t\t\t'name' => '"
67 $P2 = getattribute self, "parent"
68 print "\t\t\t'parent' => '"
77 # vim: expandtab shiftwidth=4 ft=pir: