summaryrefslogtreecommitdiffstats
path: root/lexer
diff options
context:
space:
mode:
Diffstat (limited to 'lexer')
-rw-r--r--lexer/theme-lexer.l29
-rw-r--r--lexer/theme-parser.y12
2 files changed, 35 insertions, 6 deletions
diff --git a/lexer/theme-lexer.l b/lexer/theme-lexer.l
index a576e266..e7430355 100644
--- a/lexer/theme-lexer.l
+++ b/lexer/theme-lexer.l
@@ -359,15 +359,16 @@ if ( queue == NULL ){
*/
- /**
- * Handle defaults: * { ... }
- */
<INITIAL>{CONFIGURATION} {
g_queue_push_head ( queue, GINT_TO_POINTER (YY_START) );
BEGIN(DEFAULTS);
return T_CONFIGURATION;
}
+
+ /**
+ * Handle defaults: * { ... }
+ */
<INITIAL>{ASTERIX} {
g_queue_push_head ( queue, GINT_TO_POINTER (YY_START) );
BEGIN(DEFAULTS);
@@ -385,8 +386,12 @@ if ( queue == NULL ){
return T_ERROR_DEFAULTS;
}
-<INITIAL>"#" { g_queue_push_head ( queue, GINT_TO_POINTER (YY_START) ); BEGIN(NAMESTR);return T_NAME_PREFIX;}
- /* Go into parsing an section*/
+<INITIAL>"#" {
+ g_queue_push_head ( queue, GINT_TO_POINTER (YY_START) );
+ BEGIN(NAMESTR);
+ return T_NAME_PREFIX;
+}
+ /* Go into parsing an section*/
<NAMESTR>"\{" {
g_queue_push_head ( queue, GINT_TO_POINTER (YY_START) );
BEGIN(SECTION);
@@ -470,6 +475,9 @@ if ( queue == NULL ){
yylval->colorval.blue = rofi_theme_parse_convert_hex(yytext[11],yytext[12]);
return T_COLOR;
}
+<PROPERTIES>argb:{HEX}{7} {
+ return T_ERROR_ARGB_SPEC;
+}
/* Color schemes */
<PROPERTIES>{RGBA} { return T_COL_RGBA; }
<PROPERTIES>{HSL} { return T_COL_HSL; }
@@ -557,6 +565,17 @@ if ( queue == NULL ){
yylloc->last_column = 1;
yylloc->last_line ++;
};
+
+ /**
+ * If we just encounter a word, we assume it is a Widget name.
+ * This makes include,theme, configuration a reserved keyword.
+ */
+<INITIAL>{WORD} {
+ g_queue_push_head ( queue, GINT_TO_POINTER (YY_START) );
+ BEGIN(NAMESTR);
+ yylval->sval = g_strdup(yytext);
+ return T_NAME_ELEMENT;
+}
<INITIAL>. {
return T_ERROR;
}
diff --git a/lexer/theme-parser.y b/lexer/theme-parser.y
index b97bae22..c9714ff3 100644
--- a/lexer/theme-parser.y
+++ b/lexer/theme-parser.y
@@ -155,6 +155,7 @@ static ThemeColor hwb_to_rgb ( double h, double w, double b)
%token <ival> T_ERROR_NAMESTRING 4 "invalid element name"
%token <ival> T_ERROR_DEFAULTS 5 "invalid defaults name"
%token <ival> T_ERROR_INCLUDE 6 "invalid import value"
+%token <ival> T_ERROR_ARGB_SPEC 7 "invalid argb color. Requires 8 (not 7) elements: argb:AARRGGBB."
%token <ival> T_INT "Integer number"
%token <fval> T_DOUBLE "Floating-point number"
%token <sval> T_STRING "UTF-8 encoded string"
@@ -248,6 +249,7 @@ static ThemeColor hwb_to_rgb ( double h, double w, double b)
%type <list> t_property_element_list
%type <list> t_property_element_list_optional
%type <ival> t_property_orientation
+%type <ival> t_name_prefix_optional
%start t_entry_list
%%
@@ -265,8 +267,16 @@ t_entry_list:
}
;
+/**
+ * Small dummy object to make the prefix optional.
+ */
+t_name_prefix_optional
+: T_NAME_PREFIX {}
+| %empty {}
+;
+
t_entry:
-T_NAME_PREFIX t_entry_name_path_selectors T_BOPEN t_property_list_optional T_BCLOSE
+t_name_prefix_optional t_entry_name_path_selectors T_BOPEN t_property_list_optional T_BCLOSE
{
for ( GList *liter = g_list_first ( $2); liter; liter = g_list_next ( liter ) ) {
ThemeWidget *widget = rofi_theme;