From 48680adea3552cec6713bb7af52f9286d1d44536 Mon Sep 17 00:00:00 2001 From: Kyle Maxwell Date: Thu, 19 Feb 2009 16:24:00 -0800 Subject: [PATCH] added css attribute extension --- Makefile.am | 1 + parser.y | 9 +++++++-- test/css_attr.dex | 3 +++ test/css_attr.html | 3 +++ test/css_attr.json | 1 + 5 files changed, 15 insertions(+), 2 deletions(-) create mode 100644 test/css_attr.dex create mode 100644 test/css_attr.html create mode 100644 test/css_attr.json diff --git a/Makefile.am b/Makefile.am index 8a8726e..4dc3f8f 100644 --- a/Makefile.am +++ b/Makefile.am @@ -33,6 +33,7 @@ check-am: @echo "function-magic..."; ./dexter test/function-magic.dex test/function-magic.html | diff test/function-magic.json - && echo " success." @echo "malformed-expr..."; ./dexter test/malformed-expr.dex test/malformed-expr.html | diff test/malformed-expr.json - && echo " success." @echo "malformed-json..."; ./dexter test/malformed-json.dex test/malformed-json.html | diff test/malformed-json.json - && echo " success." + @echo "css_attr..."; ./dexter -x test/css_attr.dex test/css_attr.html | diff test/css_attr.json - && echo " success." @echo "match..."; ./dexter -x test/match.dex test/match.xml | diff test/match.json - && echo " success." @echo "position..."; ./dexter test/position.dex test/position.html | diff test/position.json - && echo " success." @echo "remote..."; ./dexter test/remote.dex test/remote.html | diff test/remote.json - && echo " success." diff --git a/parser.y b/parser.y index ad08ceb..e1157df 100644 --- a/parser.y +++ b/parser.y @@ -409,10 +409,15 @@ NCName ; selectors_group - : selector COMMA OptS selectors_group { $$ = astrcat4(".//", $1, "|", $4); } - | selector { $$ = astrcat(".//", $1); } + : attribute_extended_selector COMMA OptS selectors_group { $$ = astrcat4(".//", $1, "|", $4); } + | attribute_extended_selector { $$ = astrcat(".//", $1); } ; +attribute_extended_selector + : selector + | selector S AT NAME { $$ = astrcat3($1, "/@", $4); } + ; + selector : simple_selector_sequence combinator selector { $$ = astrcat3($1, $2, $3); } | simple_selector_sequence diff --git a/test/css_attr.dex b/test/css_attr.dex new file mode 100644 index 0000000..8b150ec --- /dev/null +++ b/test/css_attr.dex @@ -0,0 +1,3 @@ +{ + "foo": "body @foo" +} \ No newline at end of file diff --git a/test/css_attr.html b/test/css_attr.html new file mode 100644 index 0000000..fdb0a8e --- /dev/null +++ b/test/css_attr.html @@ -0,0 +1,3 @@ + + + \ No newline at end of file diff --git a/test/css_attr.json b/test/css_attr.json new file mode 100644 index 0000000..8c850a5 --- /dev/null +++ b/test/css_attr.json @@ -0,0 +1 @@ +{ "foo": "bar" }