summaryrefslogtreecommitdiffstats
path: root/lexer
diff options
context:
space:
mode:
Diffstat (limited to 'lexer')
-rw-r--r--lexer/theme-lexer.l31
-rw-r--r--lexer/theme-parser.y11
2 files changed, 39 insertions, 3 deletions
diff --git a/lexer/theme-lexer.l b/lexer/theme-lexer.l
index b2c2914a..5c62e2b5 100644
--- a/lexer/theme-lexer.l
+++ b/lexer/theme-lexer.l
@@ -1,4 +1,6 @@
-%option noyywrap nounput never-interactive
+%option noyywrap
+%option nounput
+%option never-interactive
%option bison-locations
%{
@@ -35,7 +37,7 @@ typedef struct _ParseObject {
char *filename;
/** Length of string */
- size_t str_len;
+ yy_size_t str_len;
/** String */
const char *input_str;
/** Position in file */
@@ -100,9 +102,21 @@ static char * rofi_theme_parse_prepare_file ( const char *file, const char *pare
yylloc->first_column = yylloc->last_column;\
}
%}
+
+ASC [\x00-\x7f]
+ASCN [\x00-\t\v-\x7f]
+U [\x80-\xbf]
+U2 [\xc2-\xdf]
+U3 [\xe0-\xef]
+U4 [\xf0-\xf4]
+
+ // UANY {ASC}|{U2}{U}|{U3}{U}{U}|{U4}{U}{U}{U}
+UANYN {ASCN}|{U2}{U}|{U3}{U}{U}|{U4}{U}{U}{U}
+ // UONLY {U2}{U}|{U3}{U}{U}|{U4}{U}{U}{U}
+
WHITESPACE [[:blank:]]
WORD [[:alnum:]-]+
-STRING [[:print:]]+
+STRING {UANYN}+
HEX [[:xdigit:]]
NUMBER [[:digit:]]
PNNUMBER [-+]?[[:digit:]]+
@@ -129,6 +143,8 @@ LS_SOLID "solid"
INCLUDE "@import"
+CONFIGURATION "Configuration"
+
%x INCLUDE
%x PROPERTIES
%x NAMESTR
@@ -143,6 +159,9 @@ YY_LLOC_START
if ( queue == NULL ){
queue = g_queue_new ( );
yylloc->filename = current->filename;
+ // unsure why todo this.
+ yylloc->first_line = yylloc->last_line = 1;
+ yylloc->first_column = yylloc->last_column = 1;
}
%}
@@ -245,6 +264,12 @@ if ( queue == NULL ){
/**
* Handle defaults: * { ... }
*/
+<INITIAL>{CONFIGURATION} {
+ g_queue_push_head ( queue, GINT_TO_POINTER (YY_START) );
+ BEGIN(DEFAULTS);
+ return CONFIGURATION;
+
+}
<INITIAL>{ASTERIX} {
g_queue_push_head ( queue, GINT_TO_POINTER (YY_START) );
BEGIN(DEFAULTS);
diff --git a/lexer/theme-parser.y b/lexer/theme-parser.y
index e304ff29..4a5368b8 100644
--- a/lexer/theme-parser.y
+++ b/lexer/theme-parser.y
@@ -7,6 +7,7 @@
%parse-param {const char *what}
%code requires {
#include "theme.h"
+#include "xrmoptions.h"
typedef struct YYLTYPE {
int first_line;
@@ -89,6 +90,7 @@ int yylex (YYSTYPE *, YYLTYPE *);
%token NAME_PREFIX "Element section ('# {name} { ... }')"
%token WHITESPACE "White space"
%token PDEFAULTS "Default settings section ( '* { ... }')"
+%token CONFIGURATION "Configuration block"
%type <ival> highlight_styles
%type <sval> entry
@@ -131,6 +133,15 @@ NAME_PREFIX name_path BOPEN optional_properties BCLOSE
PDEFAULTS BOPEN optional_properties BCLOSE {
rofi_theme_widget_add_properties ( rofi_theme, $3);
}
+| CONFIGURATION BOPEN optional_properties BCLOSE {
+ GHashTableIter iter;
+ g_hash_table_iter_init ( &iter, $3 );
+ gpointer key,value;
+ while ( g_hash_table_iter_next ( &iter, &key, &value ) ) {
+ Property *p = (Property *) value;
+ config_parse_set_property ( p );
+ }
+}
;
/**