From: bjourne@gmail.com Date: Wed, 24 Apr 2013 19:57:56 +0000 (+0200) Subject: Docs moved to own file and ? instead of if. X-Git-Tag: 0.97~1416 X-Git-Url: https://gitweb.factorcode.org/gitweb.cgi?p=factor.git;a=commitdiff_plain;h=dd320646915c527ccef114bc5a7f2be20c089bb1 Docs moved to own file and ? instead of if. --- diff --git a/extra/html/parser/analyzer/analyzer-docs.factor b/extra/html/parser/analyzer/analyzer-docs.factor new file mode 100644 index 0000000000..797126b1f2 --- /dev/null +++ b/extra/html/parser/analyzer/analyzer-docs.factor @@ -0,0 +1,11 @@ +USING: help.syntax help.markup html.parser.analyzer sequences strings ; +IN: html.parser.analyzer-docs + +HELP: stack-find +{ $values { "seq" sequence } { "quot" { $quotation "( elt -- 1/0/-1 )" } } } +{ $description "Takes a sequence and a quotation expected to return -1 if the element decrements the stack, 0 if it doesnt affect it and 1 if it increments it. Then finds the first element where the stack is empty." } ; + +HELP: tag-classifier +{ $values { "string" string } } +{ $description "Builds a function that classifies tag tuples. Returns 1 if the tag is an opening tag with the given name, -1 if it is a closing tag and 0 otherwise." } ; + diff --git a/extra/html/parser/analyzer/analyzer.factor b/extra/html/parser/analyzer/analyzer.factor index eeb15950a7..952b344216 100644 --- a/extra/html/parser/analyzer/analyzer.factor +++ b/extra/html/parser/analyzer/analyzer.factor @@ -51,19 +51,12 @@ ERROR: undefined-find-nth m n seq quot ; : find-first-name ( vector string -- i/f tag/f ) >lower '[ name>> _ = ] find ; inline -! Takes a sequence and a quotation expected to return -1 if the -! element decrements the stack, 0 if it doesnt affect it and 1 if it -! increments it. Then finds the matching element where the stack is -! empty. -: stack-find ( seq quot -- i/f ) +: stack-find ( seq quot: ( elt -- 1/0/-1 ) -- i/f ) map cum-sum [ 0 = ] find drop ; inline -! Produces a function which returns 1 if the input item is an opening -! tag element with the specified name, -1 if it is a closing tag of -! the same name and 0 otherwise. : tag-classifier ( string -- quot ) >lower - '[ dup name>> _ = [ closing?>> [ -1 ] [ 1 ] if ] [ drop 0 ] if ] ; inline + '[ dup name>> _ = [ closing?>> -1 1 ? ] [ drop 0 ] if ] ; inline : find-between* ( vector i/f tag/f -- vector ) over integer? [