diff options
author | Dave Davenport <qball@gmpclient.org> | 2017-03-13 16:42:17 +0100 |
---|---|---|
committer | Dave Davenport <qball@gmpclient.org> | 2017-03-13 16:42:17 +0100 |
commit | 9cfb075bc469faa11941cc7b2a9a1be5e0443038 (patch) | |
tree | 8d6779d87fd60e8d688e764768c695715a38a376 /lexer | |
parent | d67a562d884bbb8152bf75a21e97f7539a75bd25 (diff) |
Add filename to location in error message.
Diffstat (limited to 'lexer')
-rw-r--r-- | lexer/theme-lexer.l | 2 | ||||
-rw-r--r-- | lexer/theme-parser.y | 29 |
2 files changed, 31 insertions, 0 deletions
diff --git a/lexer/theme-lexer.l b/lexer/theme-lexer.l index 110b23f7..fb005919 100644 --- a/lexer/theme-lexer.l +++ b/lexer/theme-lexer.l @@ -142,6 +142,7 @@ YY_LLOC_START %{ if ( queue == NULL ){ queue = g_queue_new ( ); + yylloc->filename = current->filename; } %} @@ -219,6 +220,7 @@ if ( queue == NULL ){ yypush_buffer_state (yy_create_buffer ( 0, YY_BUF_SIZE )); yylloc->first_line = yylloc->last_line = 1; yylloc->first_column = yylloc->last_column = 1; + yylloc->filename = current->filename; } else { char *str = g_markup_printf_escaped ( "Failed to open theme: <i>%s</i>\nError: <b>%s</b>", filename, strerror ( errno ) ); diff --git a/lexer/theme-parser.y b/lexer/theme-parser.y index 78269fe7..e304ff29 100644 --- a/lexer/theme-parser.y +++ b/lexer/theme-parser.y @@ -7,6 +7,35 @@ %parse-param {const char *what} %code requires { #include "theme.h" + +typedef struct YYLTYPE { + int first_line; + int first_column; + int last_line; + int last_column; + char *filename; +} YYLTYPE; +# define YYLTYPE_IS_DECLARED 1 /* alert the parser that we have our own definition */ + +# define YYLLOC_DEFAULT(Current, Rhs, N) \ + do \ + if (N) \ + { \ + (Current).first_line = YYRHSLOC (Rhs, 1).first_line; \ + (Current).first_column = YYRHSLOC (Rhs, 1).first_column; \ + (Current).last_line = YYRHSLOC (Rhs, N).last_line; \ + (Current).last_column = YYRHSLOC (Rhs, N).last_column; \ + (Current).filename = YYRHSLOC (Rhs, 1).filename; \ + } \ + else \ + { /* empty RHS */ \ + (Current).first_line = (Current).last_line = \ + YYRHSLOC (Rhs, 0).last_line; \ + (Current).first_column = (Current).last_column = \ + YYRHSLOC (Rhs, 0).last_column; \ + (Current).filename = NULL; /* new */ \ + } \ + while (0) } %{ #include <stdio.h> |