}
%token LE GE NE CC
+%token SINGLE_PROP
%token <s> NUMBER IDENT QUOTED RGB
%type <s> ident_or_quoted
%%
input:
+ input_css
+ | prop_single
+ ;
+
+input_css:
/* empty */
- | input rule { clist_add_tail(&css_this->rules, &$2->n); }
+ | input_css rule { clist_add_tail(&css_this->rules, &$2->n); }
;
rule_start:
}
;
+prop_single:
+ SINGLE_PROP prop_value
+ {
+ struct style_prop *p = css_alloc(sizeof(*p));
+ css_this->parsed_prop = p;
+ *p = $2;
+ }
+ ;
+
ident_or_quoted: IDENT | QUOTED ;
%%
css_this = NULL;
return ss;
}
+
+struct style_prop *css_parse_prop(struct mempool *mp, char *objname, const char *key_str, const char *value_str)
+{
+ struct css_sheet ss = {
+ .pool = mp,
+ .filename = objname,
+ .pushed_token = SINGLE_PROP,
+ };
+ clist_init(&ss.rules);
+
+ css_this = &ss;
+ css_lex_string(value_str);
+ css_parse();
+
+ struct style_prop *p = ss.parsed_prop;
+ p->key = style_prop_encode(key_str);
+
+ css_this = NULL;
+ return p;
+}