summaryrefslogtreecommitdiffstats
path: root/txr.1
Commit message (Collapse)AuthorAgeFilesLines
...
* json: tojson function.Kaz Kylheku2021-05-281-0/+66
| | | | | | | | | | | | * eval.c (eval_init): tojson intrinsic registered. * lib.c (tojson): New function. * lib.h (tojson): Declared. * txr.1: Documented. * share/txr/stdlib/doc-syms.tl: Updated.
* json: printing support.Kaz Kylheku2021-05-281-0/+12
| | | | | | | | | | First cut, without line breaks or indentation. * lib.c (out_json_str, out_json_rec, out_json): New static functions. (obj_print_impl): Hook in json printing via out_json. * txr.1: Add notes about output to JSON extensions.
* json: support forgotten null object.Kaz Kylheku2021-05-281-2/+12
| | | | | | | | | | | | | The JSON null will map to the Lisp null symbol. I thought about using : but that could cause surprises; like when it's passed to functions as an optional argument, it will trigger the default value. * parser.l (JSON): Add rules for producing null keyword. * txr.1: Documented. * lex.yy.c.shipped: Updated.
* json: handling for bad UTF-8 bytes, NUL and \u0000.Kaz Kylheku2021-05-281-1/+15
| | | | | | | | | | | * parser.l <JLIT>: Convert \u+0000 sequence to U+DC00 code point, the pseudo-null. Also include JLIT in in the rule for catching bad bytes that are not matched by {UANYN}. * txr.1: Document this treatment as extensions to JSON. * lex.yy.c.shipped: Updated.
* json: hash issues with quasiquoting.Kaz Kylheku2021-05-281-0/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | There are two problems. One is that in #J{~foo:"bar"} the foo expression is parsed while the scanner is in Lisp mode and the : token is grabbed by the parser as a lookahead token in the same mode. Thus it comes back as a SYMTOK (the colon symbol). We fix this by recognizing the colon symbol as synonym of the colon character. But only if it is spelled ":" in the syntax: we look at the lexeme. The second problem is that even if we fix the above, ~foo produces a sys:unquote form which is rejected because it is not a string. We fix this in the most straightforward way: by deleting the code which restricts keys to strings, an extension I already thought about making anyway. * parser.y (json_col): New non-terminal. This recognizes either a SYMTOK or a ':' token, with the semantic restriction that the SYMTOK's lexeme must be ":". (json_vals): Use yybadtok instead of generic error. (json_pairs): Do not require keys to be strings. Use json_col instead of ':', and also yybadtok instead of generic error. * y.tab.c.shipped: Updated.
* doc: document json syntax support.Kaz Kylheku2021-05-271-0/+155
| | | | | | * txr.1: Documented #J, #J^ and json macro. * share/txr/stdlib/doc-syms.tl: Updated.
* Version 260txr-260Kaz Kylheku2021-05-261-2/+2
| | | | | | | | | | * RELNOTES: Updated. * configure, txr.1: Bumped version and date. * share/txr/stdlib/ver.tl: Bumped. * txr.vim, tl.vim: Regenerated.
* tests: fix vtest being hindrance to error finding.Kaz Kylheku2021-05-251-2/+2
| | | | | | | | | | | | | * tests/common.tl (vtest): Only if the expected expression is :error or (quote :error) do we wrap the expansion and evaluation of the test expression with exception handling, because only then do we expect an error. When the test expression is anything else, we don't intercept any errors, and so problems in test cases are easier to debug now. * tests/012/struct.tl: In one case we must initialize the *gensym-counter* to 4 to compensate for the change in vtest to get the same gensym numbers in the output.
* window-map: add tests, improve doc, add examples.Kaz Kylheku2021-05-251-23/+64
| | | | | | | * tests/012/seq.tl: New tests. * txr.1: Improve documentation of window-map's :wrap and :reflect. Add examples.
* doc: issue in identity function heading.Kaz Kylheku2021-05-251-1/+1
| | | | | | | * txr.1: Fix heading repeating identity instead of listing idenitty and identity*. * share/txr/stdlib/doc-syms.tl: Regenerated.
* doc: functions apply to arguments not vice versa.Kaz Kylheku2021-05-251-27/+32
| | | | | | * txr.1: Fix numerous instances of text which uses the wording that arguments are applied to a function. A few of the changes repair wording that was entirely botched.
* doc: maintenance in description of toint, tofloat.Kaz Kylheku2021-05-251-4/+6
| | | | * txr.1: Improve wording, eliminate superfluous comma.
* matcher: allow hash pattern to omit values.Kaz Kylheku2021-05-241-1/+23
| | | | | | | | | | | | The @(hash ...) operator now allows key-only patterns like (42) or (@x), where x could be bound or unbound. This has separate semantics from when a value is present. * share/txr/stdlib/match.tl (compile-hash-match): Implement. * tests/011/patmatch.tl: Test. * txr.1: Document.
* doc: improvements ARGUMENTS AND OPTIONS.Kaz Kylheku2021-05-211-14/+80
| | | | | | * txr.1: Round out the documentation with various missing details, or details that benefit repeating in more than one place int the document.
* txr/doc: refer to arguments not data-files.Kaz Kylheku2021-05-211-1/+1
| | | | | | | * txr.1: The arguments after the script-file are not necessary data files; they can have any meaning. * txr.c (help): Also adjust the help text.
* doc: macrolet doesn't contain top-level forms.Kaz Kylheku2021-05-171-0/+28
| | | | | | * txr.1: For eval and for compilation, document that symacrolet and macrolet do not enclose multiple top-level forms.
* doc: deindent top-level form rules.Kaz Kylheku2021-05-171-1/+0
| | | | | * txr.1: Because we are not in indented paragraphs, we don't need the opening .RS.
* doc: a round of documentation fixes.Paul A. Patience2021-05-171-98/+190
| | | | | * txr.1: Hyphenation, punctuation, spelling and formatting throughout document.
* doc: incorrect precedence of repeat special clauses.Kaz Kylheku2021-05-171-16/+28
| | | | | | | | | * txr.1: The precedence among the repeat clauses is documented incorrectly: the @(mod) clause has a lower precedence than modlast and last. Redocumenting this area for better clarity, and mentioning why @(empty) isn't in the precedence list. This issue was reported by Paul A. Patience with a patch, which I reworked.
* doc: deffi, defplace: syntax heading.Paul A. Patience2021-05-171-4/+4
| | | | | | * txr.1: Use let-like small indentation for the clauses of defplace. Formatting adjusted slightly by K. K. Remove spurious defmacro element in deffi syntax.
* doc: rewrite flawed doc for sme operator.Kaz Kylheku2021-05-161-15/+42
| | | | | | | * txr.1: The documentation of the semantics of sme contradicts itself by neglecting to specify that the middle part of the input is searched for match for the middle pattern mpat. Let's fix this by giving detailed semantics in bulleted form.
* compiler: better code for global var definitions.Kaz Kylheku2021-05-141-0/+3
| | | | | | | | | | | | | | | | | | | | | | | | * eval.c (rt_defvarl): More accurate self string. (rt_defv): New static function: like rt_defvarl but ensures that the new variable has a binding cell, and returns that cell instead of the hash cell. (op_defvarl): Take advantage of rt_defv to not have to cons up the binding cell. (eval_init): Register sys:rt-defv intrinsic. * parser.c (read_file_common): Compiled files are now version 7, so we must recognize them. We still load version 6 files because rt:defvarl still exists for them. * share/txr/stdlib/compiler.tl (expand-defvarl): Improve the generated code in two ways. Firstly, use the new sys:rt-defv, which returns the binding cell, so that the value can be stored into it with rplacd without having to cons up anything. Secondly, if there is no value expression, don't emit the code to do the assignment. (%tlo-ver%): Bump compiled file version to (7 0). * txr.1: Add note about TXR 260 loading version 7 and 6.
* Version 259txr-259Kaz Kylheku2021-05-131-3/+3
| | | | | | | | | | * RELNOTES: Updated. * configure, txr.1: Bumped version and date. * share/txr/stdlib/ver.tl: Bumped. * txr.vim, tl.vim: Regenerated.
* doc: show .tlo files in deployment example.Kaz Kylheku2021-05-121-0/+2
| | | | | * txr.1: The example deployment structure shows only .tl files. Add a .tlo in there.
* tree: let tree-iter be iterable via generic iteration.Kaz Kylheku2021-05-121-0/+21
| | | | | | | | | | * lib.c (seq_iter_init_with_info): Recognize tree_iter object, and treat using tree iterator function. * tests/010/tree.tl: test case for tree subrange iteration with collect-each. * txr.1: Updated.
* doc: nonexistent tree-value-atKaz Kylheku2021-05-111-2/+2
| | | | * txr.1: Fix typos: tree-value-at should be trie-value-at.
* tree: streamline iteration; provide high limit.Kaz Kylheku2021-05-111-73/+44
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Getting rid of tree-begin-at and tree-reset-at. Now tree-begin takes two optional parameters, for specifying high and low range. * tree.c (struct tree_diter): New members, tree and highkey. We need tree due to requiring access to the less function. If the iterator has no highkey, the iterator itself is stored in that member to indicate this. (tree_iter_mark): Mark the tree and highkey. (tree_begin): Take optional lowkey and highkey arguments, initializing iterator acordingly. (tree_begin_at): Function removed. (copy_tree_iter, replace_tree_iter): Copy tree and highkey members. The latter require special handling due to the funny convention for indicating highkey absence. (tree_reset): Take optional lowkey and highkey arguments, configuring these in the iterator being reset. (tree_reset_at): Function removed. (tree_next, tree_peek): Implement highkey semantics. (sub_tree): Simplified: from and to arguments are just passed through to tree_begin, and there is no need for a separate loop which enforces the upper limit, that now being handled by the iterator itself. (tree_begin): Update registrations of tree-begin and tree-reset; remove tree-begin-at and tree-reset-at intrinsics. * tree.h (tree_begin_at, tree_reset_at): Declarations removed. (tree_begin, tree_reset): Declarations updated. * lib.c (seq_iter_rewind, seq_iter_init_with_info, where, populate_obj_hash): Default new optional arguments in tree_begin and tree_reset calls. * parser.c (circ_backpatch): Likewise. * tests/010/tree.tl: Affected cases updated. * txr.1: Documentation updated. * share/txr/stdlib/doc-syms.tl: Regenerated.
* tree: support indexing and range extraction.Kaz Kylheku2021-05-111-0/+75
| | | | | | | | | | | | | | | | | | | * lib.c (do_generic_funcall): Support tree object invocation with one or two arguments via sub and ref. (sub): Implement for trees via sub_tree. (ref): Implement for trees via tree_lookup. * tree.c (sub_tree): New function. (tree_init): Register sub-tree intrinsic. * tree.h (sub_tree): Declared. * tests/010/tree.tl: New tests. * txr.1: Documented: DWIM bracket syntax on trees, sub and ref support for trees, sub-tree function, * share/txr/stdlib/doc-syms.tl: Regenerated.
* tree: replace-tree-iter function.Kaz Kylheku2021-05-111-0/+31
| | | | | | | | | | | | | * tree.c (replace_tree_iter): New function. (tree_init): Register replace-tree-iter intrinsic. * tree.h (tree_init): Declared. * share/txr/stdlib/doc-syms.tl: Updated. * txr.1: Documented. * tests/010/tree.tl: New test case.
* tree: copy-tree-iter function.Kaz Kylheku2021-05-101-0/+25
| | | | | | | | | | | | | | | * lib.c (copy): Handle tree_iter_s via copy_tree_iter. * tree.c (copy_tree_iter): New function. (tree_init): copy-tree-iter intrinsic registered. * tree.h (copy_tree_iter): Declared. * tests/010/tree.tl: New test case. * txr.1: Documented. * share/txr/stdlib/doc-syms.tl: Updated.
* doc: fix out of order compat notes.Kaz Kylheku2021-05-101-23/+23
| | | | | * txr.1: Move compatibility notes 258, 257 and 231 to the correct position, so the numbers are descending.
* tree: new tree-peek function.Kaz Kylheku2021-05-091-10/+29
| | | | | | | | | | | | | | * tree.c (tn_peek_next): New static function. (tree_peek): New function. (tree_init): Register tree-peek intrinsic. * tree.h (tree_peek): Declared. * txr.1: Documented. * tests/010/tree.c: Work tree-peek into existing test case. * share/txr/stdlib/doc-syms.tl: Updated.
* tree: new make_similar_tree unction.Kaz Kylheku2021-05-091-0/+17
| | | | | | | | | | | * tree.c (make_similar_tree): New function. (tree_init): Register make-similar-tree intrinsic * tree.h (make_similar_tree): Declared. * tests/010/tree.tl: New tests. * txr.1: Documented.
* matcher: new "each-match family" of macros.Kaz Kylheku2021-05-041-0/+232
| | | | | | | | | | | | | | | | | | * lisplib.c (match_set_entries): New autoload symbols: each-match, append-matches, keep-matches, each-match-product, append-match-products, keep-match-products. * share/txr/stdlib/doc-syms.tl: Updated. * share/txr/stdlib/match.tl (each-match-expander): New function. (each-match, append-matches, keep-matches, each-match-product, append-match-products, keep-match-products): New macros. * tests/011/patmatch.tl: New tests covering each macro, far from exhaustively. * txr.1: Documented.
* format: ~x/~X specifiers support buffers.Kaz Kylheku2021-05-041-5/+4
| | | | | | | | | | | | | * buf.c (buf_hex): New function. * buf.h (buf_hex): Declared. * stream.c (formatv): Support printing of buffers in hex via temporary buffer containing hex characters, similarly to how bignums are handled. * tests/018/format.tl: New file, providing some coverage over new and affected code.
* rel-path: bugfixes.Kaz Kylheku2021-05-031-11/+116
| | | | | | | | | | | | | | | * share/txr/stdlib/copy-file.tl: When removing .. components, a dotdot must only cancel preceding non-dotdot. We must check not only that the out stack is not empty but that the top element isn't dotdot. Also, eliminate empty components, like the documentation says. Lastly, we must check for the impossible cases, when the from path uses .. components that are impossible to navigate backwards to form a relative path. * tests/018/rel-path.tl: Test cases added. * txr.1: Updated with additional descriptions, fixes and examples.
* New function: rel-path.Kaz Kylheku2021-05-031-0/+99
| | | | | | | | | | | | | * lisplib.c (copy_file_set_entries): Add rel-path as autoload trigger for copy-file module. * share/txr/stdlib/copy-file.tl (rel-path): New function. * tests/018/rel-path.tl: New file. * txr.1: Documented. * share/txr/stdlib/doc-syms.tl: Updated.
* New function: portable-abs-path-p.Kaz Kylheku2021-05-021-5/+31
| | | | | | | | | | | | | | | * share/txr/stdlib/doc-syms.tl: Updated. * stream.c (portable_abs_path_p): New function, exact copy of old abs_path_p. (abs_path_p): Rewritten to be specific to host platform. No Windows-drive-like prefixes are checked on POSIX. (stream_init): Register new function. Register abs-path-p conditionally based on 258 compatibility. * stream.h (portable_abs_path_p): Declared. * txr.1: Documented, with compat notes.
* doc: "suficient" typo in new paragraph.Kaz Kylheku2021-05-021-1/+1
| | | | | * txr.1: Fix typo in recently introduced paragraph about file compiler's treatment of symbols.
* Version 258txr-258Kaz Kylheku2021-05-011-3/+3
| | | | | | | | | | * RELNOTES: Updated. * configure, txr.1: Bumped version and date. * share/txr/stdlib/ver.tl: Bumped. * txr.vim, tl.vim: Regenerated.
* doc: note a diff between compiled and source files.Kaz Kylheku2021-04-301-0/+42
| | | | | | * txr.1: A new paragraph about how symbols are treated: source files can refer to unqualified symbols, but compiled files do not.
* tree: new functions for reseting iterator.Kaz Kylheku2021-04-301-0/+51
| | | | | | | | | | | | | | * tree.c (tree_reset, tree_reset_at): New functions. (tree_init): tree-reset and tree-reset-at intrinsics registered. * tree.h (tree_reset, tree_reset_at): Declared. * tests/010/tree.tl: New tests. * txr.1: Documented. * share/txr/stdlib/doc-syms.tl: Updated.
* tree: new tree-begin-at function.Kaz Kylheku2021-04-291-3/+12
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * tree.c (enum tree_iter_state): New iterator state tr_find_low_prepared dedicated to the tree-begin-at traversal. This state indicates that tree-next should visit the starting node that it is given, and then after that, treat anything to the left of it as having been visited. In the other states, tree-next does not visit the node it is given but uses it as the starting point to find the next node. (tn_find_next): Bugfix here: when navigating the right link, the function neglected to add the node to the path. But the logic for backtracking up the path expects this: it checks whether the node from the path is the parent of a right child. Somehow this didn't cause a problem for full traversals with tree-begin; at least the existing test cases don't expose an issue. It caused a problem for tree-begin-at, though. (tn_find_low): New static function. This finds the low-key node in the tree, priming the iterator object with the correct state and path content to continue the traversal from that node on . We need the tr_find_low_prepared state in the iterator in order to visit the low node itself that was found. (tree_begin_at): New function. (tree_init): Register tree-begin-at intrinsic. * tree.h (tree_begin_at): Declared. * tests/010/tree.tl: New test cases for tree-begin-at. * txr.1: Documented. * share/txr/stdlib/doc-syms.tl: Updated.
* doc: wrong heading for tree-insertKaz Kylheku2021-04-291-1/+1
| | | | * txr.1: Fix tree-insert being under tree-insert-node heading.
* macros: lexical-var-p: don't report t for specials.Kaz Kylheku2021-04-281-4/+52
| | | | | | | | | | | | | | | | | | | | The lexical-var-p function wrongly reports true for locally rebound special variables, which are not lexical. * eval.c (special_var_p): Static function moved to avoid forward declaration. (lexical_var_p): Bail if sym satisfies special_var_p. (old_lexical_var_p): New function, copy of old lexical_var_p before this bugfix. (eval_init): Conditionally register lexical-var-p as either lexical_var_p or old_lexical_var_p depending on the compat value. * txr.1: Update documentation for lexical-var-p to clarify that it doesn't report true for specials. Also make note that it doesn't report true for global lexicals, and likewise that lexical-fun-p doesn't report global functions. Added compat note.
* doc: document seq-iter type and redocument iter-beginKaz Kylheku2021-04-281-10/+30
| | | | | | * txr.1: mention seq-iter in the type hierarchy diagram. The documentation for iter-begin is revised, and now mentions that the returned value is of this type in some cases.
* doc: document --free-allKaz Kylheku2021-04-261-0/+9
| | | | | * txr.1: the --free-all command line option appeared in TXR 144 in 2016, but was never documented.
* match-str: return useful position instead of t.Kaz Kylheku2021-04-261-6/+20
| | | | | | | * lib.c (match_str): The match_str function is hereby altered to return an integer instead of the symbol t in the matching case. * txr.1: Updated.
* doc: document quasiliteral matchingKaz Kylheku2021-04-261-6/+202
| | | | | | * txr.1: New operator <2> for meta-syntax, used when two italicized terms are sandwiched in three non-italicized terms. Documented quasiliteral matching.
* Version 257txr-257Kaz Kylheku2021-04-231-3/+3
| | | | | | | | | | | | | | | | | Log message correction superseding original commit 65213f5f7f6a204886a02c32f259ae2617d1dfb6. * RELNOTES: Updated. * configure, txr.1: Bumped version and date. * share/txr/stdlib/ver.tl: Bumped. * txr.vim, tl.vim: Regenerated. * protsymc.: Likewise * share/txr/stdlib/doc-syms.tl: Likewise.