Updated include directive and added test cases.

After parsing the file given in the include directive, the tree generated
is printed to standard input using Data::Dumper and this is evaled in the
program having include directive. As a result the tree gets appended to
the parent AST.
diff --git a/lib/Automake/Parser/Lexer.pm b/lib/Automake/Parser/Lexer.pm
index 5a20676..61255d0 100644
--- a/lib/Automake/Parser/Lexer.pm
+++ b/lib/Automake/Parser/Lexer.pm
@@ -6,7 +6,7 @@
 our @EXPORT = qw(lex);
 
 # Store end token.
-my @end_tok = ["end"];
+my @end_tok = [ "end" ];
 
 # lex(string,multiline)
 # Takes as input a string of line and multiline variable deciding whether 
@@ -84,6 +84,13 @@
 			push @tokens, [ "newline" ] unless $multiline;
 			$_ = undef;
 		}
+		elsif( $include )
+		{
+			push @tokens, [ "value" , $1] if m/^\s+(.+)/;
+			push @tokens, [ "newline" ];
+			$include = 0;
+			last;
+		}
 		elsif( s/^##.*\n$//o )
 		{
 		}
@@ -104,6 +111,7 @@
 		elsif( s/^(PROGRAMS|LIBRARIES|LTLIBRARIES|LISP|PYTHON|JAVA|SCRIPTS|DATA|HEADERS|MASN|TEXINFOS|if|else|endif|include)//o)
 		{
 			push @tokens, [$1];
+			$include = 1 if ( $1 eq 'include' );			
 		}
 		elsif( s/^([a-zA-Z0-9_]+)//o )
 		{
diff --git a/lib/Automake/Parser/Tree.pm b/lib/Automake/Parser/Tree.pm
index e6e9c98..69153ff 100644
--- a/lib/Automake/Parser/Tree.pm
+++ b/lib/Automake/Parser/Tree.pm
@@ -3,19 +3,24 @@
 use Exporter;
 
 our @ISA = qw(Exporter);
-our @EXPORT = qw(input stmts stmt automakerule makerule conditional ifblock 
-optionalelse optionalcond optionalrhs optionalcomments lhs rhs commentlist primaries 
+our @EXPORT = qw(basedir input stmts stmt automakerule makerule conditional ifblock 
+optionalelse optionalcond optionalrhs optionalcomments includerule lhs rhs commentlist primaries 
 optionlist traverse printgraph recursesubdirs);
 
+# Stores whether subdir directive is used or not. If used array
+# consist of subdirectories.
 my $isSubdir = 0 , @subdirnodes = ();
 
+# Stores the value recieved by Parser.pl
+our $basedir;
+
 # Grammar Rule : (1) input => stmts
 # Create a node having child as stmts.
 sub input($)
 {
 	my ( $val ) = @_;
 	my %node = ( name => input, childs => [ $val ] );
-	push @{$node{childs}}, subdirNode() if $#subdirnodes > -1;
+	push @{ $node{ childs } }, subdirNode() if $#subdirnodes > -1;
 	return \%node;
 }
 
@@ -44,7 +49,7 @@
 	}
 	else
 	{
-		push @{$val1 -> { childs }}, $val2;
+		push @{ $val1 -> { childs } }, $val2;
 		return $val1;
 	}
 }
@@ -70,7 +75,7 @@
 {
 	my ( $val1, $val2, $val3, $val4, $val5 ) = @_;
 	my %node = (name => automakerule, childs => [ $val1 ]);
-	if($val2->[0] eq '=')
+	if($val2 -> [0] eq '=')
 	{
 		push @{ $node{ childs }}, $val3;
 		push @{ $node{ childs }}, $val4 if $val4;
@@ -89,7 +94,7 @@
 sub makerule($$$)
 {
 	my ( $val1, $val2, $val3 ) = @_;
-	my %node = (name => makerule, childs => [ $val1,$val3 ]);
+	my %node = ( name => makerule, childs => [ $val1,$val3 ]);
 	return \%node;
 }
 
@@ -296,11 +301,19 @@
 	}
 }
 
+# Grammar Rule : (1) includerule : include value
+# Create a node having the tree after parsing the included value.
+# String recieved as standard input is evaled to generate corresponding
+# tree.
 sub includerule($$)
 {
 	my ( $val1, $val2 ) = @_;
-	print STDERR $val2;
-	my %node = (name => includerule, value => $val2);
+	my $VAL1;
+	my $file = $val2 -> [1];
+	my $data = `parser.pl -include $basedir/$file`;
+	my %node = %{ eval( $data ) };
+	$node{ name } = includerule;
+	$node{ file } = $val2;
 	return \%node;
 }
 
@@ -312,7 +325,7 @@
 	print "graph graphname {\n";
 	my ( $ref ) = @_;
 	print "0 [label=\"Root\"];";
-	traverse( $ref, 0);
+	traverse( $ref, 0 );
 	print "}\n";
 }
 
@@ -324,9 +337,9 @@
 # to Standard Output. Call all its child with Parent Id equal to current Node Id.
 sub traverse($$)
 {
-	my ( $ref,$parent ) = @_;
+	my ( $ref , $parent ) = @_;
 	my %node = %$ref;
-	return if $node{empty};
+	return if $node{ empty };
 	$id++;
 	my $curr_id = $id;
 	print "$parent--$id;\n";
@@ -355,12 +368,12 @@
 	}
 }
 
-# recursesubdirs(Basedir, Reference)
+# recursesubdirs( Tree Reference)
 # Recurse into sub directories to generate AST 
-sub recursesubdirs($$)
+sub recursesubdirs($)
 {
-	my ( $basedir , $ref) = @_;
-	my %node= %$ref;
+	my ( $ref ) = @_;
+	my %node = %$ref;
 	if( scalar @{ $node{childs} } == 2)
 	{
 		my $subdirRef = $node{childs} -> [1];
diff --git a/lib/Automake/Parser/input.txt b/lib/Automake/Parser/input.txt
deleted file mode 100644
index 618da52..0000000
--- a/lib/Automake/Parser/input.txt
+++ /dev/null
@@ -1,3 +0,0 @@
-bin_PROGRAMS = server client
-server_SOURCES = server.c
-client_SOURCES = client.c
diff --git a/lib/Automake/Parser/parser.pl b/lib/Automake/Parser/parser.pl
index b2384fa..d81de04 100644
--- a/lib/Automake/Parser/parser.pl
+++ b/lib/Automake/Parser/parser.pl
@@ -12,10 +12,20 @@
 use Tree;
 use ParserTable;
 use File::Basename;
+use Data::Dumper;
+
+# Checks if the parser is called on a file included using include
+# directive in parent file.
+my $isinclude = 0;
+if( $ARGV[0] eq '-include' )
+{	
+	$isinclude = 1;
+	shift @ARGV;
+}
 
 # Stores the relative path of the Makefile.am file with respect to 
 # current working directory
-my $basedir = File::Basename::dirname($ARGV[0]);
+$Tree::basedir = File::Basename::dirname($ARGV[0]);
 
 # To enable debug mode, use 1 . Prints the parser stack at each 
 # iteration
@@ -34,9 +44,17 @@
 {
 	if($stack[-1] == $ParserTable::accept)
 	{
-		print STDERR "Complete\n";
-		printgraph( $stack[-4] );
-		recursesubdirs( $basedir, $stack[-4] );
+		if($isinclude)
+		{
+			# Dump the tree to standard output.
+			print Dumper( $stack[-4] );
+		}
+		else
+		{
+			print STDERR "Complete\n";
+			printgraph( $stack[-4] );
+			recursesubdirs( $stack[-4] );
+		}
 		last;
 	}
 	while( !@tokens )
diff --git a/lib/Automake/Parser/t/app/Makefile.am b/lib/Automake/Parser/t/app/Makefile.am
index 7946892..c6d6bd0 100644
--- a/lib/Automake/Parser/t/app/Makefile.am
+++ b/lib/Automake/Parser/t/app/Makefile.am
@@ -1,2 +1,2 @@
 bin_PROGRAMS=apple
-SUBDIRS = app3
+SUBDIRS = app
diff --git a/lib/Automake/Parser/t/app/app3/Makefile.am b/lib/Automake/Parser/t/app/app/Makefile.am
similarity index 100%
rename from lib/Automake/Parser/t/app/app3/Makefile.am
rename to lib/Automake/Parser/t/app/app/Makefile.am
diff --git a/lib/Automake/Parser/t/app1/Makefile.am b/lib/Automake/Parser/t/app1/Makefile.am
index 1566cc4..3d1c248 100644
--- a/lib/Automake/Parser/t/app1/Makefile.am
+++ b/lib/Automake/Parser/t/app1/Makefile.am
@@ -1 +1,2 @@
-bin_PROGRAMS=apple
\ No newline at end of file
+bin_PROGRAMS=apple
+apple_SOURCES=apple.c
diff --git a/lib/Automake/Parser/t/app2/Makefile.am b/lib/Automake/Parser/t/app2/Makefile.am
index 1566cc4..3d1c248 100644
--- a/lib/Automake/Parser/t/app2/Makefile.am
+++ b/lib/Automake/Parser/t/app2/Makefile.am
@@ -1 +1,2 @@
-bin_PROGRAMS=apple
\ No newline at end of file
+bin_PROGRAMS=apple
+apple_SOURCES=apple.c
diff --git a/lib/Automake/Parser/t/app3/Makefile.am b/lib/Automake/Parser/t/app3/Makefile.am
new file mode 100644
index 0000000..694ae2b
--- /dev/null
+++ b/lib/Automake/Parser/t/app3/Makefile.am
@@ -0,0 +1 @@
+include app/Makefile.am
diff --git a/lib/Automake/Parser/t/app3/app/Makefile.am b/lib/Automake/Parser/t/app3/app/Makefile.am
new file mode 100644
index 0000000..faa681b
--- /dev/null
+++ b/lib/Automake/Parser/t/app3/app/Makefile.am
@@ -0,0 +1,2 @@
+bin_PROGRAMS = apple
+apple_SOURCES = apple.c
diff --git a/lib/Automake/Parser/t/fragment.txt b/lib/Automake/Parser/t/fragment.txt
new file mode 100644
index 0000000..43285fa
--- /dev/null
+++ b/lib/Automake/Parser/t/fragment.txt
@@ -0,0 +1,3 @@
+include app1/Makefile.am
+include app2/Makefile.am
+include app3/Makefile.am