summaryrefslogtreecommitdiff
path: root/lib/Automake/Parser/parser.pl
diff options
context:
space:
mode:
authorVishal Gupta <vishalgupta7972@gmail.com>2018-08-04 17:56:37 +0530
committerVishal Gupta <vishalgupta7972@gmail.com>2018-08-04 17:56:37 +0530
commit5aebec2cc6dfdf969493a392053cfcf2ba4ddbbe (patch)
treec603103f2bd1901bd8c3c7ac659523c7792ee122 /lib/Automake/Parser/parser.pl
parent5da9812ce3f4967534825cd5c384e6ca2d8c5d1f (diff)
downloadautomake-5aebec2cc6dfdf969493a392053cfcf2ba4ddbbe.tar.gz
Updated include directive and added test cases.experimental/gsoc/ast
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.
Diffstat (limited to 'lib/Automake/Parser/parser.pl')
-rw-r--r--lib/Automake/Parser/parser.pl26
1 files changed, 22 insertions, 4 deletions
diff --git a/lib/Automake/Parser/parser.pl b/lib/Automake/Parser/parser.pl
index b2384fab9..d81de0493 100644
--- a/lib/Automake/Parser/parser.pl
+++ b/lib/Automake/Parser/parser.pl
@@ -12,10 +12,20 @@ use Lexer;
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 @@ while ( @stack )
{
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 )