Permalink
Browse files

:content() pseudo-selector

  • Loading branch information...
1 parent a9308ab commit 00282c5c10c7d05ed5a554c0c05178323509b72a @fizx committed Jun 10, 2009
Showing with 1,353 additions and 1,339 deletions.
  1. +1 −0 Makefile.am
  2. +1 −0 Makefile.in
  3. +953 −948 parser.c
  4. +33 −32 parser.h
  5. +2 −0 parser.y
  6. +359 −354 scanner.c
  7. +2 −0 scanner.l
  8. +1 −1 test/content.json
  9. +1 −4 test/content.let
View
@@ -29,6 +29,7 @@ bench:
@echo "craigs..."; ./parsley test/craigs.let test/craigs.html > /dev/null
check-am:
+ @echo "content..."; ./parsley test/content.let test/content.html 2>&1 | diff test/content.json - && echo " success."
@echo "whitespace..."; ./parsley test/whitespace.let test/whitespace.html 2>&1 | diff test/whitespace.json - && echo " success."
@echo "backslash..."; ./parsley test/backslash.let test/backslash.html 2>&1 | diff test/backslash.json - && echo " success."
@echo "question_regressions..."; ./parsley test/question_regressions.let test/question_regressions.html 2>&1 | diff test/question_regressions.json - && echo " success."
View
@@ -729,6 +729,7 @@ bench:
@echo "craigs..."; ./parsley test/craigs.let test/craigs.html > /dev/null
check-am:
+ @echo "content..."; ./parsley test/content.let test/content.html 2>&1 | diff test/content.json - && echo " success."
@echo "whitespace..."; ./parsley test/whitespace.let test/whitespace.html 2>&1 | diff test/whitespace.json - && echo " success."
@echo "backslash..."; ./parsley test/backslash.let test/backslash.html 2>&1 | diff test/backslash.json - && echo " success."
@echo "question_regressions..."; ./parsley test/question_regressions.let test/question_regressions.html 2>&1 | diff test/question_regressions.json - && echo " success."
View
1,901 parser.c

Large diffs are not rendered by default.

Oops, something went wrong.
View
@@ -104,37 +104,38 @@
CXEQ = 321,
CXGT = 322,
CXLT = 323,
- CXHEADER = 324,
- CXCONTAINS = 325,
- CXEMPTY = 326,
- CXHAS = 327,
- CXPARENT = 328,
- CXNTHCH = 329,
- CXNTHLASTCH = 330,
- CXNTHTYPE = 331,
- CXNTHLASTTYPE = 332,
- CXFIRSTCH = 333,
- CXLASTCH = 334,
- CXFIRSTTYPE = 335,
- CXLASTTYPE = 336,
- CXONLYCH = 337,
- CXONLYTYPE = 338,
- CXINPUT = 339,
- CXTEXT = 340,
- CXPASSWORD = 341,
- CXRADIO = 342,
- CXCHECKBOX = 343,
- CXSUBMIT = 344,
- CXIMAGE = 345,
- CXRESET = 346,
- CXBUTTON = 347,
- CXFILE = 348,
- CXENABLED = 349,
- CXDISABLED = 350,
- CXCHECKED = 351,
- CXSELECTED = 352,
- NAME = 353,
- STRING = 354
+ CXCONTENT = 324,
+ CXHEADER = 325,
+ CXCONTAINS = 326,
+ CXEMPTY = 327,
+ CXHAS = 328,
+ CXPARENT = 329,
+ CXNTHCH = 330,
+ CXNTHLASTCH = 331,
+ CXNTHTYPE = 332,
+ CXNTHLASTTYPE = 333,
+ CXFIRSTCH = 334,
+ CXLASTCH = 335,
+ CXFIRSTTYPE = 336,
+ CXLASTTYPE = 337,
+ CXONLYCH = 338,
+ CXONLYTYPE = 339,
+ CXINPUT = 340,
+ CXTEXT = 341,
+ CXPASSWORD = 342,
+ CXRADIO = 343,
+ CXCHECKBOX = 344,
+ CXSUBMIT = 345,
+ CXIMAGE = 346,
+ CXRESET = 347,
+ CXBUTTON = 348,
+ CXFILE = 349,
+ CXENABLED = 350,
+ CXDISABLED = 351,
+ CXCHECKED = 352,
+ CXSELECTED = 353,
+ NAME = 354,
+ STRING = 355
};
#endif
@@ -198,7 +199,7 @@ typedef union YYSTYPE
pxpathPtr node;
}
/* Line 2616 of glr.c. */
-#line 202 "parser.h"
+#line 203 "parser.h"
YYSTYPE;
# define YYSTYPE_IS_DECLARED 1
# define YYSTYPE_IS_TRIVIAL 1
View
@@ -122,6 +122,7 @@ void answer(pxpathPtr);
%token <string> CXEQ
%token <string> CXGT
%token <string> CXLT
+%token <string> CXCONTENT
%token <string> CXHEADER
%token <string> CXCONTAINS
%token <string> CXEMPTY
@@ -493,6 +494,7 @@ simple_selector_sequence
| possibly_empty_sequence CXLAST { $$ = APPEND($1, "[last()]"); }
| possibly_empty_sequence CXEVEN { $$ = APPEND($1, "[position() % 2 = 0]"); }
| possibly_empty_sequence CXODD { $$ = APPEND($1, "[position() % 2 = 1]"); }
+ | possibly_empty_sequence CXCONTENT LPAREN StringLike RPAREN { $$ = P4E($1, "[normalize-space(.)=", $4, "]"); }
| possibly_empty_sequence CXHEADER { $$ = APPEND($1, "[contains('h1 h2 h3 h4 h5 h6', lower-case(local-name()))]"); }
| possibly_empty_sequence CXEMPTY { $$ = APPEND($1, "[not(node())]"); }
| possibly_empty_sequence CXPARENT { $$ = APPEND($1, "[node()]"); }
View
713 scanner.c

Large diffs are not rendered by default.

Oops, something went wrong.
View
@@ -87,6 +87,7 @@ CXODD ":odd"
CXEQ ":eq"
CXGT ":gt"
CXLT ":lt"
+CXCONTENT ":content"
CXHEADER ":header"
CXCONTAINS ":contains"
CXEMPTY ":empty"
@@ -185,6 +186,7 @@ NAME [a-zA-Z_][a-zA-Z0-9\-_]*
{CXEQ} yylval.string = strdup(yytext); return CXEQ;
{CXGT} yylval.string = strdup(yytext); return CXGT;
{CXLT} yylval.string = strdup(yytext); return CXLT;
+{CXCONTENT} yylval.string = strdup(yytext); return CXCONTENT;
{CXHEADER} yylval.string = strdup(yytext); return CXHEADER;
{CXCONTAINS} yylval.string = strdup(yytext); return CXCONTAINS;
{CXEMPTY} yylval.string = strdup(yytext); return CXEMPTY;
View
@@ -1 +1 @@
-{ "paras": [{ "id": "1", "is_a": "a" }, { "id": "3", "is_a": "a " }, { "id": "1", "is_a": " a" }] }
+{ "foo": [ "a", "a ", " a" ] }
View
@@ -1,6 +1,3 @@
{
- "paras(p)": [{
- "id": "@id",
- "is_a": ":content('a')"
- }]
+ "foo": [":content('a')"]
}

0 comments on commit 00282c5

Please sign in to comment.