diff options
author | Dave Davenport <qball@gmpclient.org> | 2017-01-09 08:55:51 +0100 |
---|---|---|
committer | Dave Davenport <qball@gmpclient.org> | 2017-01-09 08:55:51 +0100 |
commit | a199fa3275c2bf2dfe6320de1410266ac626c6db (patch) | |
tree | 2139ecc65d188e9d2824c237d758cd8bfece06d9 | |
parent | 5188e36147010c22c3fc5041e7a82f3f1a7c9e3f (diff) |
Improve error message theme a little bit
-rw-r--r-- | lexer/theme-lexer.l | 12 | ||||
-rw-r--r-- | lexer/theme-parser.y | 5 | ||||
-rw-r--r-- | source/rofi.c | 5 | ||||
-rw-r--r-- | source/theme.c | 8 |
4 files changed, 14 insertions, 16 deletions
diff --git a/lexer/theme-lexer.l b/lexer/theme-lexer.l index 843eeccb..c9a8c152 100644 --- a/lexer/theme-lexer.l +++ b/lexer/theme-lexer.l @@ -307,10 +307,6 @@ if ( queue == NULL ){ yylval->ival = WL_NORTH; return T_POSITION; } -<PROPERTIES>{NORTH} { - yylval->ival = WL_NORTH; - return T_POSITION; -} <PROPERTIES>{NONE} { yylval->ival = HL_NONE; return T_HIGHLIGHT_STYLE; @@ -343,15 +339,11 @@ if ( queue == NULL ){ yylloc->last_line ++; }; <INITIAL>. { - const char *error_msg = "Expected 'root' element or a 'named' element.\n"\ - "Place all global properties in a root element:\n"\ - " * {\n"\ - " }\n"; - YY_FATAL_ERROR( error_msg ); + return T_ERROR; } <*>. { fprintf(stderr, "Invalid character: '%c'\n", *yytext); - yyterminate(); + return T_ERROR; } %% diff --git a/lexer/theme-parser.y b/lexer/theme-parser.y index 055add3b..074a90c8 100644 --- a/lexer/theme-parser.y +++ b/lexer/theme-parser.y @@ -33,6 +33,7 @@ int yylex (YYSTYPE *, YYLTYPE *); Distance distance; } +%token <ival> T_ERROR "error from file parser" %token <ival> T_INT %token <fval> T_DOUBLE %token <sval> T_STRING @@ -51,9 +52,9 @@ int yylex (YYSTYPE *, YYLTYPE *); %token PSEP "property separator"; %token PCLOSE "property close"; %token NSEP "Name separator"; -%token NAME_PREFIX "Name prefix"; +%token NAME_PREFIX "Name element prefix ('#')"; %token WHITESPACE "White space"; -%token PDEFAULTS "Default settings"; +%token PDEFAULTS "Default settings section ( '* { ... }')"; %type <ival> highlight_styles %type <sval> entry diff --git a/source/rofi.c b/source/rofi.c index f39bed53..10f2b69d 100644 --- a/source/rofi.c +++ b/source/rofi.c @@ -949,7 +949,10 @@ int main ( int argc, char *argv[] ) if ( config.theme ) { TICK_N ( "Parse theme" ); - rofi_theme_parse_file ( config.theme ); + if ( ! rofi_theme_parse_file ( config.theme ) ) { + // TODO: instantiate fallback theme.? + + } TICK_N ( "Parsed theme" ); } else { diff --git a/source/theme.c b/source/theme.c index 03f86fde..ecb475a9 100644 --- a/source/theme.c +++ b/source/theme.c @@ -861,12 +861,14 @@ gboolean rofi_theme_parse_file ( const char *file ) extern const char*input_str; str_len = 0; input_str = NULL; - while ( yyparse () ) { - ; - } + int parser_retv = yyparse(); yylex_destroy (); g_free ( filename ); yyin = NULL; + if ( parser_retv != 0 ){ + fprintf ( stderr, "Failed to parse theme: %s.\n", file ); + return TRUE; + } return FALSE; } gboolean rofi_theme_parse_string ( const char *string ) |