summaryrefslogtreecommitdiffstats
path: root/lexer
diff options
context:
space:
mode:
authorDave Davenport <qball@gmpclient.org>2017-05-09 14:12:03 +0200
committerDave Davenport <qball@gmpclient.org>2017-05-09 14:12:03 +0200
commit00e297c5caefa21daf896a22ab1092131d60999a (patch)
treee9cd47a2bacd0e62d5bed15e2999fbf44f942ffc /lexer
parentcf8796ccd3cf04b4ab1029f3da32c7784443e1d1 (diff)
Update highlight style parsing
Diffstat (limited to 'lexer')
-rw-r--r--lexer/theme-lexer.l36
-rw-r--r--lexer/theme-parser.y23
2 files changed, 29 insertions, 30 deletions
diff --git a/lexer/theme-lexer.l b/lexer/theme-lexer.l
index 0829ef33..e80d57a0 100644
--- a/lexer/theme-lexer.l
+++ b/lexer/theme-lexer.l
@@ -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 ) {
diff --git a/lexer/theme-parser.y b/lexer/theme-parser.y
index 6a414f70..d82dc4a5 100644
--- a/lexer/theme-parser.y
+++ b/lexer/theme-parser.y
@@ -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; }