| Server IP : 182.53.201.61 / Your IP : 216.73.217.175 Web Server : Apache/2.2.15 (Fedora) System : Linux km10.dyndns.org 2.6.31.5-127.fc12.i686.PAE #1 SMP Sat Nov 7 21:25:57 EST 2009 i686 User : apache ( 48) PHP Version : 5.3.3 Disable Function : NONE MySQL : ON | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : ON | Pkexec : ON Directory : /usr/share/apps/dcopidlng/ |
Upload File : |
package Ast;
use strict;
use vars qw/ $this $pack @endCodes /;
#-----------------------------------------------------------------------------
# This package is used to create a simple Abstract Syntax tree. Each node
# in the AST is an associative array and supports two kinds of properties -
# scalars and lists of scalars.
# See SchemParser.pm for an example of usage.
# ... Sriram
#-----------------------------------------------------------------------------
# Constructor
# e.g AST::New ("personnel")
# Stores the argument in a property called astNodeName whose sole purpose
# is to support Print()
sub New {
my ($this) = {"astNodeName" => $_[0]};
bless ($this);
return $this;
}
# Add a property to this object
# $astNode->AddProp("className", "Employee");
sub AddProp {
my ($this) = $_[0];
$this->{$_[1]} = $_[2];
}
# Equivalent to AddProp, except the property name is associated
# with a list of values
# $classAstNode->AddProp("attrList", $attrAstNode);
sub AddPropList {
my ($this) = $_[0];
if (! exists $this->{$_[1]}) {
$this->{$_[1]} = [];
}
push (@{$this->{$_[1]}}, $_[2]);
}
# Returns a list of all the property names of this object
sub GetProps {
my ($this) = $_[0];
return keys %{$this};
}
1;