From cf8796ccd3cf04b4ab1029f3da32c7784443e1d1 Mon Sep 17 00:00:00 2001 From: Dave Davenport Date: Tue, 9 May 2017 13:53:45 +0200 Subject: Move position parsing to bison file. --- lexer/theme-lexer.l | 41 +++++------------------------------------ lexer/theme-parser.y | 37 +++++++++++++++++++++++++++++++++++-- 2 files changed, 40 insertions(+), 38 deletions(-) (limited to 'lexer') diff --git a/lexer/theme-lexer.l b/lexer/theme-lexer.l index cf0cfdf4..0829ef33 100644 --- a/lexer/theme-lexer.l +++ b/lexer/theme-lexer.l @@ -539,42 +539,11 @@ if ( queue == NULL ){ return T_COLOR; } -{CENTER} { - yylval->ival = WL_CENTER; - return T_POSITION; -} -{EAST} { - yylval->ival = WL_EAST; - return T_POSITION; -} -{WEST} { - yylval->ival = WL_WEST; - return T_POSITION; -} -{SOUTH}{EAST} { - yylval->ival = WL_SOUTH_EAST; - return T_POSITION; -} -{SOUTH}{WEST} { - yylval->ival = WL_SOUTH_WEST; - return T_POSITION; -} -{SOUTH} { - yylval->ival = WL_SOUTH; - return T_POSITION; -} -{NORTH}{EAST} { - yylval->ival = WL_NORTH_EAST; - return T_POSITION; -} -{NORTH}{WEST} { - yylval->ival = WL_NORTH_WEST; - return T_POSITION; -} -{NORTH} { - yylval->ival = WL_NORTH; - return T_POSITION; -} +{CENTER} { return T_POS_CENTER; } +{EAST} { return T_POS_EAST; } +{WEST} { return T_POS_WEST; } +{SOUTH} { return T_POS_SOUTH; } +{NORTH} { return T_POS_NORTH; } {NONE} { yylval->ival = HL_NONE; return T_HIGHLIGHT_STYLE; diff --git a/lexer/theme-parser.y b/lexer/theme-parser.y index 99f47ccc..6a414f70 100644 --- a/lexer/theme-parser.y +++ b/lexer/theme-parser.y @@ -81,6 +81,7 @@ int yylex (YYSTYPE *, YYLTYPE *); double fval; char *sval; int bval; + WindowLocation wloc; ThemeColor colorval; ThemeWidget *theme; GList *name_path; @@ -100,7 +101,6 @@ int yylex (YYSTYPE *, YYLTYPE *); %token T_DOUBLE %token T_STRING %token N_STRING "property name" -%token T_POSITION; %token T_HIGHLIGHT_STYLE %token NAME_ELEMENT "Element name" %token T_BOOLEAN @@ -108,6 +108,12 @@ int yylex (YYSTYPE *, YYLTYPE *); %token T_PIXEL %token T_LINK %token FIRST_NAME +%token T_POS_CENTER "Center" +%token T_POS_EAST "East" +%token T_POS_WEST "West" +%token T_POS_NORTH "North" +%token T_POS_SOUTH "South" + %token BOPEN "bracket open ('{')" %token BCLOSE "bracket close ('}')" @@ -120,6 +126,9 @@ int yylex (YYSTYPE *, YYLTYPE *); %token CONFIGURATION "Configuration block" %type highlight_styles +%type t_position +%type t_position_ew +%type t_position_sn %type entry %type pvalue %type entries @@ -242,7 +251,7 @@ property $$->name = $1; $$->value.padding = (Padding){ $3, $4, $5, $6 }; } -| pvalue PSEP T_POSITION PCLOSE{ +| pvalue PSEP t_position PCLOSE{ $$ = rofi_theme_property_create ( P_POSITION ); $$->name = $1; $$->value.i = $3; @@ -260,6 +269,30 @@ property } ; +/** + * Position can be either center, + * East or West, North Or South + * Or combi of East or West and North or South + */ +t_position +: T_POS_CENTER { $$ =WL_CENTER;} +| t_position_ew +| t_position_sn +| t_position_ew t_position_sn { $$ = $1|$2;} +| t_position_sn t_position_ew { $$ = $1|$2;} +; +t_position_ew +: T_POS_EAST { $$ = WL_EAST;} +| T_POS_WEST { $$ = WL_WEST;} +; +t_position_sn +: T_POS_NORTH { $$ = WL_NORTH;} +| T_POS_SOUTH { $$ = WL_SOUTH;} +; + +/** + * Highlight style, allow mulitple styles to be combined. + */ highlight_styles: T_HIGHLIGHT_STYLE { $$ = $1; } | highlight_styles T_HIGHLIGHT_STYLE { -- cgit v1.2.3