[Templates-cvs] cvs commit: Template2/parser Parser.yp
cvs@template-toolkit.org
cvs@template-toolkit.org
Tue, 02 Dec 2003 13:15:03 +0000
cvs 03/12/02 13:15:02
Modified: parser Parser.yp
Log:
* added file/line reporting
Revision Changes Path
2.18 +12 -8 Template2/parser/Parser.yp
Index: Parser.yp
===================================================================
RCS file: /template-toolkit/Template2/parser/Parser.yp,v
retrieving revision 2.17
retrieving revision 2.18
diff -u -r2.17 -r2.18
--- Parser.yp 2003/12/01 16:06:35 2.17
+++ Parser.yp 2003/12/02 13:15:02 2.18
@@ -37,7 +37,7 @@
#
#------------------------------------------------------------------------
#
-# $Id: Parser.yp,v 2.17 2003/12/01 16:06:35 abw Exp $
+# $Id: Parser.yp,v 2.18 2003/12/02 13:15:02 abw Exp $
#
#========================================================================
@@ -70,17 +70,21 @@
chunks: chunks chunk { push(@{$_[1]}, $_[2])
if defined $_[2]; $_[1] }
- | chunk { defined $_[1] ? [ $_[1] ] : [ ] }
+ | chunk { defined $_[1] ? [ $_[1] ] : [ ] }
;
-chunk: TEXT { $factory->textblock($_[1]) }
- | statement ';' { my $line = ${$_[0]->{LINE}};
- $line =~ s/\-.*$//;
- "#line $line \"$_[0]->{FILEINFO}->[-1]->{path}\"\n$_[1]" }
+chunk: TEXT { $factory->textblock($_[1]) }
+ | statement ';' { return '' unless $_[1];
+ my $line = ${$_[0]->{LINE}};
+ my $info = $_[0]->{FILEINFO}->[-1];
+ my $file = $info->{ path } || $info->{ name }
+ || '(unknown template)';
+ $line =~ s/\-.*$//; # might be 'n-n'
+ "#line $line \"$file\"\n$_[1]" }
;
-statement: directive
- | defblock
+statement: directive
+ | defblock
| anonblock
| capture
| macro