our $accept=17;
our @table=(
- {input => 4, optionlist => 13, ifblock => 10, value => 1, lhs => 11, if => 3, makerule => 8, automakerule => 7, stmts => 5, stmt => 6, comment => 2, conditional => 9, commentlist => 12},
+ {stmts => 5, makerule => 8, comment => 2, lhs => 11, input => 4, ifblock => 10, stmt => 6, optionlist => 13, automakerule => 7, conditional => 9, if => 3, commentlist => 12, value => 1},
{reduce => [1, \&lhs], ':' => 14, '_' => 15},
{reduce => [1, \&commentlist]},
{value => 16},
{end => 17},
- {stmt => 18, comment => 2, commentlist => 12, conditional => 9, reduce => [1, \&input], lhs => 11, value => 1, optionlist => 13, ifblock => 10, if => 3, makerule => 8, automakerule => 7},
+ {makerule => 8, comment => 2, lhs => 11, ifblock => 10, stmt => 18, optionlist => 13, automakerule => 7, conditional => 9, if => 3, reduce => [1, \&input], commentlist => 12, value => 1},
{newline => 19},
{reduce => [1, \&stmt]},
{reduce => [1, \&stmt]},
{reduce => [1, \&stmt]},
- {else => 20, reduce => [0, \&optionalelse], optionalelse => 21},
- {'=' => 22, '+' => 23},
+ {optionalelse => 21, reduce => [0, \&optionalelse], else => 20},
+ {'+' => 23, '=' => 22},
{comment => 24, reduce => [1, \&stmt]},
- {LISP => 29, primaries => 37, HEADERS => 34, LIBRARIES => 27, JAVA => 31, PROGRAMS => 26, TEXINFOS => 36, DATA => 33, MASN => 35, LTLIBRARIES => 28, PYTHON => 30, SCRIPTS => 32, value => 25},
+ {PYTHON => 30, SCRIPTS => 32, JAVA => 31, LTLIBRARIES => 28, DATA => 33, value => 25, HEADERS => 34, TEXINFOS => 36, primaries => 37, LIBRARIES => 27, PROGRAMS => 26, LISP => 29, MASN => 35},
{rhs => 39, rhsval => 38},
{reduce => [2, \&optionlist]},
{newline => 40},
{reduce => [2, \&stmts]},
{newline => 42},
{endif => 43},
- {reduce => [0, \&optionalrhs], rhs => 45, optionalrhs => 44, rhsval => 38},
+ {optionalrhs => 44, rhs => 45, rhsval => 38, reduce => [0, \&optionalrhs]},
{'=' => 46},
{reduce => [2, \&commentlist]},
{reduce => [1, \&primaries], '_' => 47},
{reduce => [2, \&lhs]},
{reduce => [1, \&rhs]},
{reduce => [3, \&makerule], rhsval => 48},
- {if => 3, makerule => 8, automakerule => 7, stmts => 49, value => 1, lhs => 11, ifblock => 10, optionlist => 13, commentlist => 12, conditional => 9, stmt => 6, comment => 2},
+ {lhs => 11, ifblock => 10, stmts => 49, makerule => 8, comment => 2, conditional => 9, if => 3, commentlist => 12, value => 1, stmt => 6, optionlist => 13, automakerule => 7},
{reduce => [3, \&stmts]},
- {ifblock => 10, optionlist => 13, value => 1, lhs => 11, stmts => 50, makerule => 8, automakerule => 7, if => 3, stmt => 6, comment => 2, conditional => 9, commentlist => 12},
- {optionalcond => 52, reduce => [0, \&optionalcond], value => 51},
- {commentlist => 54, reduce => [0, \&optionalcomments], comment => 2, optionalcomments => 53},
+ {comment => 2, stmts => 50, makerule => 8, ifblock => 10, lhs => 11, automakerule => 7, optionlist => 13, stmt => 6, value => 1, commentlist => 12, if => 3, conditional => 9},
+ {reduce => [0, \&optionalcond], value => 51, optionalcond => 52},
+ {optionalcomments => 53, comment => 2, commentlist => 54, reduce => [0, \&optionalcomments]},
{reduce => [1, \&optionalrhs], rhsval => 48},
- {rhsval => 38, optionalrhs => 55, reduce => [0, \&optionalrhs], rhs => 45},
+ {rhs => 45, optionalrhs => 55, reduce => [0, \&optionalrhs], rhsval => 38},
{reduce => [3, \&optionlist]},
{reduce => [2, \&rhs]},
- {makerule => 8, automakerule => 7, if => 3, value => 1, lhs => 11, ifblock => 10, optionlist => 13, commentlist => 12, reduce => [4, \&ifblock], conditional => 9, stmt => 18, comment => 2},
- {commentlist => 12, conditional => 9, reduce => [3, \&optionalelse], stmt => 18, comment => 2, makerule => 8, automakerule => 7, if => 3, value => 1, lhs => 11, ifblock => 10, optionlist => 13},
+ {reduce => [4, \&ifblock], value => 1, commentlist => 12, if => 3, conditional => 9, automakerule => 7, optionlist => 13, stmt => 18, ifblock => 10, lhs => 11, comment => 2, makerule => 8},
+ {comment => 2, makerule => 8, ifblock => 10, lhs => 11, automakerule => 7, optionlist => 13, stmt => 18, reduce => [3, \&optionalelse], value => 1, commentlist => 12, if => 3, conditional => 9},
{reduce => [1, \&optionalcond]},
{reduce => [4, \&conditional]},
{reduce => [4, \&automakerule]},
- {comment => 24, reduce => [1, \&optionalcomments]},
- {comment => 2, optionalcomments => 56, commentlist => 54, reduce => [0, \&optionalcomments]},
+ {reduce => [1, \&optionalcomments], comment => 24},
+ {reduce => [0, \&optionalcomments], commentlist => 54, comment => 2, optionalcomments => 56},
{reduce => [5, \&automakerule]}
);
\ No newline at end of file
optionalelse optionalcond optionalrhs optionalcomments lhs rhs commentlist primaries
optionlist traverse printgraph);
+my $isSubdir = 0 , @subdirnodes = ();
+
# Grammar Rule : (1) input => stmts
# Create a node having child as stmts.
sub input($)
{
my ( $val ) = @_;
- my %node = (name => input, childs => [ $val ]);
+ my %node = ( name => input, childs => [ $val ] );
+ push @{$node -> {childs}}, subdirNode() if $#subdirnodes > -1;
+ return \%node;
+}
+
+# Creates a Node having all the sub directories which are to be recursed.
+sub subdirNode()
+{
+ my %node = ( name => subdir, empty => 1 );
+ my @subdir = ();
+ push @subdir, @{ $_ -> { value }} foreach @subdirnodes;
+ $node{ subdirs } = \@subdir;
return \%node;
}
my ( $val1, $val2, $val3) = @_;
if($val3 == undef)
{
- my %node=(name => stmts, childs => [ $val1 ]);
+ my %node = ( name => stmts, childs => [ $val1 ]);
return \%node;
}
else
{
my ( $val1, $val2, $val3, $val4, $val5 ) = @_;
my %node = (name => automakerule, childs => [ $val1 ]);
- if($val2 == '=')
+ if($val2->[0] eq '=')
{
push @{ $node{ childs }}, $val3;
push @{ $node{ childs }}, $val4 if $val4;
else
{
$node{ childs } = [ $val ];
+ push @subdirnodes, $val if $isSubdir;
}
+ $isSubdir = 0;
return \%node;
}
if( $val2 == undef )
{
$node{ value } = $val1 -> [1];
+ $isSubdir = 1 if $node{value} eq 'SUBDIRS';
}
else
{
}
else
{
- push @{ $val1 -> {value}} , $val2 -> [1];
+ push @{ $val1 -> { value }} , $val2 -> [1];
return $val1;
}
}
my %node = ( name => primaries );
if( $val -> [0] eq 'value')
{
- $node{value}= $val -> [1];
+ $node{ value } = $val -> [1];
}
else
{
- $node{value}= $val;
+ $node{ value } = $val;
}
return \%node;
}
}
#Stores the next id to be alloted to new node.
-my $id=0;
+my $id = 0;
# traverse(Hash, Parent Id)
# Traverses the tree recursively. Prints the information about the current node to Standard Output. Call all its child with Parent Id equal to current Node Id.
my $val1 = $node{childs};
foreach $child (@$val1)
{
- traverse($child,$curr_id);
+ traverse( $child, $curr_id );
}
}
}