From e45e6fd274826991c2b7e01fde4d73110487e0e0 Mon Sep 17 00:00:00 2001 From: Jon Loeliger Date: Fri, 23 Mar 2007 15:18:41 -0500 Subject: 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 --- dtc-parser.y | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'dtc-parser.y') 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); } -- cgit v1.1