<WANT_STRING>[^\n]+ { yy_pop_state(); yylval.string = sstrdup(yytext); return STR; }
<OUTPUT_COND>[a-zA-Z0-9_-]+ { yy_pop_state(); yylval.string = sstrdup(yytext); return OUTPUT; }
^[ \t]*#[^\n]* { return TOKCOMMENT; }
-<COLOR_COND>[0-9a-fA-F]+ { yy_pop_state(); yylval.string = sstrdup(yytext); return HEX; }
+<COLOR_COND>#[0-9a-fA-F]+ { yy_pop_state(); yylval.string = sstrdup(yytext+1); return HEXCOLOR; }
<ASSIGN_TARGET_COND>[ \t]*→[ \t]* { BEGIN(WANT_STRING); }
<ASSIGN_TARGET_COND>[ \t]+ { BEGIN(WANT_STRING); }
[0-9]+ { yylval.number = atoi(yytext); return NUMBER; }
%token <string> WORD "<word>"
%token <string> STR "<string>"
%token <string> STR_NG "<string (non-greedy)>"
-%token <string> HEX "<hex>"
%token <string> HEXCOLOR "#<hex>"
%token <string> OUTPUT "<RandR output>"
%token TOKBINDCODE
;
colorpixel:
- '#' HEX
+ HEXCOLOR
{
- char *hex;
- if (asprintf(&hex, "#%s", $2) == -1)
- die("asprintf()");
- free($2);
- $$ = get_colorpixel(hex);
- free(hex);
+ $$ = get_colorpixel($1);
+ free($1);
}
;