From 1fb002a4fd466e2384d12b80176a1bf526d0ce5f Mon Sep 17 00:00:00 2001 From: Kaz Kylheku Date: Tue, 11 Mar 2014 20:10:40 -0700 Subject: * eval.c (eval_init): Registration of url_encode and url_decode moved to filter.c. * filter.c (trie_compress_intrinsic, html_encode, html_decode): New static functions. (filter_init): Register make_trie, trie_add, trie_compress_intrinsic, filter_string_tree, filter_equal, html_encode and html_decode as intrinsics. Move registration of url_encode and url_decode here. * genvim.txr: Look for registrations in filter.c too. * txr.1: Documented. * txr.vim: Updated. --- txr.1 | 155 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 155 insertions(+) (limited to 'txr.1') diff --git a/txr.1 b/txr.1 index 87e0b624..b34ba7cf 100644 --- a/txr.1 +++ b/txr.1 @@ -13179,6 +13179,161 @@ argument is omitted or specified as nil, then + (plus) characters in the encoded data are retained as + characters in the decoded strings. Otherwise, plus characters are converted to spaces. +.SS Functions html-encode and html-decode + +.TP +Syntax: + + (html-encode ) + (html-decode ) + +.TP +Description: + +The html-encode and decode functions convert between an HTML and raw +representation of of text. + +The hml-encode function returns a string which is based on the content of +, but in which all characters which have special meaning in HTML +have been replaced by special HTML codes for representing those characters. +The returned string is the HTML-encoded verbatim representation of +. + +The html-decode function converts , which may contain HTML +character encodings, into a string which contains the characters represented +by those encodings. + +The function composition (html-decode (html-encode text)) returns a string +which is equal to text. + +The reverse composition (html-encode (html-decode html)) does not necessarily +return a string equal to text. + +For instance if html is the string "

Hello, world!

", +then html-decode produces "

Hello, world!

". Then, html-encode +produces "<p>Hello, world!</p>". + +.SH FILTER MODULE + +The filter module provides a trie (pronunced "try") data structure, +which is suitable for representing dictionaries for efficient filtering. +Dictionaires are unordered collections of keys, which are strings, which +have associated values, which are also strings. A trie can be used to filter +text, such that keys appearing in the text are replaced by the corresponding +values. A trie supports this filtering operation by providing an efficient +prefix-based lookup method which only looks at each input character ones, and +which does not require knowledge of the length of the key in advance. + +.SS Function make-trie + +.TP +Syntax: + + (make-trie) + +.TP +Description: + +This function creates an empty trie. There is no special data type for +a trie; a trie is some existing type such as a hash table. + +.SS Function trie-add + +.TP +Syntax: + + (trie-add ) + +.TP +Description: + +The trie-add function adds the string to the trie, associating +it with . If already exists in , then the value +is updated with . + +The must be a trie that has not been compressed with trie-compress. + +A trie can contain keys which are prefixes of other keys. For instance +it can contain "dog" and "dogma". When a trie is used for matching +and substitution, the longest match is used. If the input presents +the text "doggy", then the match is "dog". If the input is "dogmatic", +then "dogma" matches. + + +.SS Function trie-compress + +.TP +Syntax: + + (trie-compress ) + +.TP +Description: + +The trie-compress function changes the representation of to +a representation which occupies less space and supports faster lookups. +The new representation is returned. + +The compressed representation of a trie does not support the trie-add function. + +This function destructively manipulates , and may return an object +that is the same object as , or it may return a different object, +while at the same time still modifying the internals of . +Consequently, the program should not retain the input object , +but use the returned object in its place. + + +.SS Function filter-string-tree + +.TP +Syntax: + + (filter-string-tree ) + +.TP +The filter-string-tree a tree structure similar to , in which all of the +string atoms have been filtered through . + +The argument is a string tree structure: either the symbol nil, denoting +an empty structure; a string; or a list of tree structures. If is +nil, then filter-string-tree returns nil. + +The argument is a filter: it is either a trie, a function, or nil. +If is nil, then filter-string-trie just returns . + +If is a function, it must be a function that can be called +with one argument. The strings of the string tree are filtered by passing +each one into the function and substituting the return value into the +corresponding place in the returned structure. + +Otherwise if is a trie, then this trie is used for filtering, +the string elements similarly to a function. For each string, a new +string is returned in which occurrences of the keys in the trie are +replaced by the values in the trie. + +.SS Function filter-equal + +.TP +Syntax: + + (filter-equal ) + +.TP +Description: + +The filter-equal function tests whether two string trees are equal +under the given filters. + +The precise semantics can be given by this expression: + + (equal (filter-string-tree ) + (filter-string-tree )) + +The string tree is filtered through , as if +by the filter-string-tree function, and similarly, is +filtered through . The resulting structures are compared +using equal, and the result of that is returned. + .SH ACCESS TO TXR PATTERN LANGUAGE FROM LISP .SS Function match-fun -- cgit v1.2.3