summaryrefslogtreecommitdiffstats
path: root/lexer
diff options
context:
space:
mode:
authorDave Davenport <qball@gmpclient.org>2017-05-09 13:53:45 +0200
committerDave Davenport <qball@gmpclient.org>2017-05-09 13:53:45 +0200
commitcf8796ccd3cf04b4ab1029f3da32c7784443e1d1 (patch)
tree581c3fcba5eb2e6bc72749db5caf43fe8a1cd5b1 /lexer
parent2a381856aa554965d6d1b18bbded6c60c0b41ed4 (diff)
Move position parsing to bison file.
Diffstat (limited to 'lexer')
-rw-r--r--lexer/theme-lexer.l41
-rw-r--r--lexer/theme-parser.y37
2 files changed, 40 insertions, 38 deletions
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;
}
-<PROPERTIES>{CENTER} {
- yylval->ival = WL_CENTER;
- return T_POSITION;
-}
-<PROPERTIES>{EAST} {
- yylval->ival = WL_EAST;
- return T_POSITION;
-}
-<PROPERTIES>{WEST} {
- yylval->ival = WL_WEST;
- return T_POSITION;
-}
-<PROPERTIES>{SOUTH}{EAST} {
- yylval->ival = WL_SOUTH_EAST;
- return T_POSITION;
-}
-<PROPERTIES>{SOUTH}{WEST} {
- yylval->ival = WL_SOUTH_WEST;
- return T_POSITION;
-}
-<PROPERTIES>{SOUTH} {
- yylval->ival = WL_SOUTH;
- return T_POSITION;
-}
-<PROPERTIES>{NORTH}{EAST} {
- yylval->ival = WL_NORTH_EAST;
- return T_POSITION;
-}
-<PROPERTIES>{NORTH}{WEST} {
- yylval->ival = WL_NORTH_WEST;
- return T_POSITION;
-}
-<PROPERTIES>{NORTH} {
- yylval->ival = WL_NORTH;
- return T_POSITION;
-}
+<PROPERTIES>{CENTER} { return T_POS_CENTER; }
+<PROPERTIES>{EAST} { return T_POS_EAST; }
+<PROPERTIES>{WEST} { return T_POS_WEST; }
+<PROPERTIES>{SOUTH} { return T_POS_SOUTH; }
+<PROPERTIES>{NORTH} { return T_POS_NORTH; }
<PROPERTIES>{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 <fval> T_DOUBLE
%token <sval> T_STRING
%token <sval> N_STRING "property name"
-%token <ival> T_POSITION;
%token <ival> T_HIGHLIGHT_STYLE
%token <sval> NAME_ELEMENT "Element name"
%token <bval> T_BOOLEAN
@@ -108,6 +108,12 @@ int yylex (YYSTYPE *, YYLTYPE *);
%token <distance> T_PIXEL
%token <sval> T_LINK
%token <sval> 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 <ival> highlight_styles
+%type <wloc> t_position
+%type <wloc> t_position_ew
+%type <wloc> t_position_sn
%type <sval> entry
%type <sval> pvalue
%type <theme> 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 {