1
0
Fork 0
mirror of https://github.com/davatorium/rofi.git synced 2024-11-25 13:55:34 -05:00

Improve error message theme a little bit

This commit is contained in:
Dave Davenport 2017-01-09 08:55:51 +01:00
parent 5188e36147
commit a199fa3275
4 changed files with 14 additions and 16 deletions

View file

@ -307,10 +307,6 @@ if ( queue == NULL ){
yylval->ival = WL_NORTH; yylval->ival = WL_NORTH;
return T_POSITION; return T_POSITION;
} }
<PROPERTIES>{NORTH} {
yylval->ival = WL_NORTH;
return T_POSITION;
}
<PROPERTIES>{NONE} { <PROPERTIES>{NONE} {
yylval->ival = HL_NONE; yylval->ival = HL_NONE;
return T_HIGHLIGHT_STYLE; return T_HIGHLIGHT_STYLE;
@ -343,15 +339,11 @@ if ( queue == NULL ){
yylloc->last_line ++; yylloc->last_line ++;
}; };
<INITIAL>. { <INITIAL>. {
const char *error_msg = "Expected 'root' element or a 'named' element.\n"\ return T_ERROR;
"Place all global properties in a root element:\n"\
" * {\n"\
" }\n";
YY_FATAL_ERROR( error_msg );
} }
<*>. { <*>. {
fprintf(stderr, "Invalid character: '%c'\n", *yytext); fprintf(stderr, "Invalid character: '%c'\n", *yytext);
yyterminate(); return T_ERROR;
} }
%% %%

View file

@ -33,6 +33,7 @@ int yylex (YYSTYPE *, YYLTYPE *);
Distance distance; Distance distance;
} }
%token <ival> T_ERROR "error from file parser"
%token <ival> T_INT %token <ival> T_INT
%token <fval> T_DOUBLE %token <fval> T_DOUBLE
%token <sval> T_STRING %token <sval> T_STRING
@ -51,9 +52,9 @@ int yylex (YYSTYPE *, YYLTYPE *);
%token PSEP "property separator"; %token PSEP "property separator";
%token PCLOSE "property close"; %token PCLOSE "property close";
%token NSEP "Name separator"; %token NSEP "Name separator";
%token NAME_PREFIX "Name prefix"; %token NAME_PREFIX "Name element prefix ('#')";
%token WHITESPACE "White space"; %token WHITESPACE "White space";
%token PDEFAULTS "Default settings"; %token PDEFAULTS "Default settings section ( '* { ... }')";
%type <ival> highlight_styles %type <ival> highlight_styles
%type <sval> entry %type <sval> entry

View file

@ -949,7 +949,10 @@ int main ( int argc, char *argv[] )
if ( config.theme ) { if ( config.theme ) {
TICK_N ( "Parse 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" ); TICK_N ( "Parsed theme" );
} }
else { else {

View file

@ -861,12 +861,14 @@ gboolean rofi_theme_parse_file ( const char *file )
extern const char*input_str; extern const char*input_str;
str_len = 0; str_len = 0;
input_str = NULL; input_str = NULL;
while ( yyparse () ) { int parser_retv = yyparse();
;
}
yylex_destroy (); yylex_destroy ();
g_free ( filename ); g_free ( filename );
yyin = NULL; yyin = NULL;
if ( parser_retv != 0 ){
fprintf ( stderr, "Failed to parse theme: %s.\n", file );
return TRUE;
}
return FALSE; return FALSE;
} }
gboolean rofi_theme_parse_string ( const char *string ) gboolean rofi_theme_parse_string ( const char *string )