summaryrefslogtreecommitdiff
path: root/lib/Automake/Parser/Lexer.pm
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/Lexer.pm
parent5da9812ce3f4967534825cd5c384e6ca2d8c5d1f (diff)
downloadautomake-experimental/gsoc/ast.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/Lexer.pm')
-rw-r--r--lib/Automake/Parser/Lexer.pm10
1 files changed, 9 insertions, 1 deletions
diff --git a/lib/Automake/Parser/Lexer.pm b/lib/Automake/Parser/Lexer.pm
index 5a206769e..61255d0ad 100644
--- a/lib/Automake/Parser/Lexer.pm
+++ b/lib/Automake/Parser/Lexer.pm
@@ -6,7 +6,7 @@ our @ISA = qw(Exporter);
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 @@ sub lex($)
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 @@ sub lex($)
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 )
{