summaryrefslogtreecommitdiff
path: root/dtc-parser.y
diff options
context:
space:
mode:
authorJon Loeliger <jdl@freescale.com>2007-03-23 15:18:41 -0500
committerJon Loeliger <jdl@freescale.com>2007-03-26 08:36:07 -0500
commite45e6fd274826991c2b7e01fde4d73110487e0e0 (patch)
tree5770119a61cc0c2767757a507e074ddd4e80e34e /dtc-parser.y
parentb29597d9a343761f768a9d78a63f1c09e71b43d2 (diff)
downloaddtc-e45e6fd274826991c2b7e01fde4d73110487e0e0.tar.gz
DTC: Add support for a C-like #include "file" mechanism.
Keeps track of open files in a stack, and assigns a filenum to source positions for each lexical token. Modified error reporting to show source file as well. No policy on file directory basis has been decided. Still handles stdin. Tested on all arch/powerpc/boot/dts DTS files Signed-off-by: Jon Loeliger <jdl@freescale.com>
Diffstat (limited to 'dtc-parser.y')
-rw-r--r--dtc-parser.y9
1 files changed, 8 insertions, 1 deletions
diff --git a/dtc-parser.y b/dtc-parser.y
index a8902fc..39d9dac 100644
--- a/dtc-parser.y
+++ b/dtc-parser.y
@@ -23,6 +23,7 @@
%{
#include "dtc.h"
+#include "srcpos.h"
int yylex(void);
void yyerror(char const *);
@@ -178,7 +179,13 @@ label: DT_LABEL { $$ = $1; }
void yyerror (char const *s)
{
- fprintf (stderr, "%s at line %d\n", s, yylloc.first_line);
+ const char *fname = srcpos_filename_for_num(yylloc.filenum);
+
+ if (strcmp(fname, "-") == 0)
+ fname = "stdin";
+
+ fprintf(stderr, "%s:%d %s\n",
+ fname, yylloc.first_line, s);
}