1
0
Fork 0
mirror of https://github.com/davatorium/rofi.git synced 2024-11-18 13:54:36 -05:00

Update highlight style parsing

This commit is contained in:
Dave Davenport 2017-05-09 14:12:03 +02:00
parent cf8796ccd3
commit 00e297c5ca
2 changed files with 29 additions and 30 deletions

View file

@ -377,11 +377,11 @@ if ( queue == NULL ){
<SECTION>":" { g_queue_push_head ( queue, GINT_TO_POINTER (YY_START) ); BEGIN(PROPERTIES); return PSEP; }
<PROPERTIES>";" { BEGIN(GPOINTER_TO_INT ( g_queue_pop_head ( queue ))); return PCLOSE;}
<PROPERTIES>(true|false) { yylval->bval= g_strcmp0(yytext, "true") == 0; return T_BOOLEAN;}
<PROPERTIES>(true|false) { yylval->bval= g_strcmp0(yytext, "true") == 0; return T_BOOLEAN;}
<PROPERTIES>{PNNUMBER} { yylval->ival = (int)g_ascii_strtoll(yytext, NULL, 10); return T_INT;}
<PROPERTIES>{PNNUMBER}\.{NUMBER}+ { yylval->fval = g_ascii_strtod(yytext, NULL); return T_DOUBLE;}
<PROPERTIES>\"{STRING}\" { yytext[yyleng-1] = '\0'; yylval->sval = g_strdup(&yytext[1]); return T_STRING;}
<PROPERTIES>@{WORD} {
<PROPERTIES>\"{STRING}\" { yytext[yyleng-1] = '\0'; yylval->sval = g_strdup(&yytext[1]); return T_STRING;}
<PROPERTIES>@{WORD} {
yylval->sval = g_strdup(yytext);
return T_LINK;
}
@ -539,27 +539,15 @@ if ( queue == NULL ){
return T_COLOR;
}
<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;
}
<PROPERTIES>{BOLD} {
yylval->ival = HL_BOLD;
return T_HIGHLIGHT_STYLE;
}
<PROPERTIES>{ITALIC} {
yylval->ival = HL_ITALIC;
return T_HIGHLIGHT_STYLE;
}
<PROPERTIES>{UNDERLINE} {
yylval->ival = HL_UNDERLINE;
return T_HIGHLIGHT_STYLE;
}
<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} { return T_NONE; }
<PROPERTIES>{BOLD} { return T_BOLD; }
<PROPERTIES>{ITALIC} { return T_ITALIC; }
<PROPERTIES>{UNDERLINE} { return T_UNDERLINE; }
<INITIAL><<EOF>> {
ParseObject *po = g_queue_pop_head ( file_queue );
if ( po ) {

View file

@ -101,7 +101,6 @@ int yylex (YYSTYPE *, YYLTYPE *);
%token <fval> T_DOUBLE
%token <sval> T_STRING
%token <sval> N_STRING "property name"
%token <ival> T_HIGHLIGHT_STYLE
%token <sval> NAME_ELEMENT "Element name"
%token <bval> T_BOOLEAN
%token <colorval> T_COLOR
@ -114,6 +113,11 @@ int yylex (YYSTYPE *, YYLTYPE *);
%token T_POS_NORTH "North"
%token T_POS_SOUTH "South"
%token T_NONE "None"
%token T_BOLD "Bold"
%token T_ITALIC "Italic"
%token T_UNDERLINE "Underline"
%token BOPEN "bracket open ('{')"
%token BCLOSE "bracket close ('}')"
@ -126,6 +130,7 @@ int yylex (YYSTYPE *, YYLTYPE *);
%token CONFIGURATION "Configuration block"
%type <ival> highlight_styles
%type <ival> highlight_style
%type <wloc> t_position
%type <wloc> t_position_ew
%type <wloc> t_position_sn
@ -292,12 +297,18 @@ t_position_sn
/**
* Highlight style, allow mulitple styles to be combined.
* Empty not allowed
*/
highlight_styles:
T_HIGHLIGHT_STYLE { $$ = $1; }
| highlight_styles T_HIGHLIGHT_STYLE {
$$ = $1 | $2;
}
highlight_styles
: highlight_style { $$ = $1;}
| highlight_styles highlight_style { $$ = $1|$2;}
;
/** Single style. */
highlight_style
: T_NONE { $$ = HL_NONE; }
| T_BOLD { $$ = HL_BOLD; }
| T_UNDERLINE { $$ = HL_UNDERLINE; }
| T_ITALIC { $$ = HL_ITALIC; }
;
pvalue: N_STRING { $$ = $1; }