summaryrefslogtreecommitdiffstats
Commit message (Collapse)AuthorAgeFilesLines
...
* Support quasiquoting over vectors also, and a bugfix for hashKaz Kylheku2012-03-146-10/+56
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | quasiquoting. We cannot use the same symbol for the literal form from the parser, and for the expanded form, because this creates a confusion when there are multiple nestings of quasiquote expansion. * eval.c (vector_lit_s, vector_list_s, hash_lit_s): New symbol variables. (hash_construct_s): Relocated here from hash.c. (expand_qquote): Part of bugfix: look for hash_lit_s instead of has_construct_s. Translate to a hash_construct_s form which is no longer recognizes as a hash literal. Implementing recognition of a quasiquote vector literal, handled similarly. (eval_init): Initialize vector_lit_s, vector_list_s, hash_list_s and hash_lit_s. Use vector_list_s when registering vector_list function. * eval.h (vector_lit_s, vector_list_s, hash_lit_s, hash_constuct_s): Declared. * hash.c (hash_construct_s): Variable removed and relocated into eval.c. (hash_init): Initialization of hash_construct_s removed. * hash.h (hash_construct_s): Declaration removed. * parser.y: (vector): Action updated to generate a (vec-lit ...) form if the object contains unquotes, otherwise generate a vector object. (hash): Generate hash-lit form, not a hash-construct form.
* Allow quasi-quoting over hash table literals,Kaz Kylheku2012-03-145-15/+50
| | | | | | | | | | | | | | | | | | | | to express dynamic hash table construction * eval.c (expand_qquote): Recognize hash-construct forms: expand the hash arguments and pairs separately, then rewrite to a new hash-construct form. (eval-init): hash-construct intrinsic function added. * hash.c (hash_construct_s): New symbol variable. (hash_construct): New function. (hash_init): Initialize hash_construct_s. * hash.h (hash_construct_s, hash_construct): Declared. * parser.y (hash): Rule rewritten to emit either a literal hash table object, or a hash-construct form, based on whether quasiquote unquotes occur within the syntax. (hash_from_notation): Function removed.
* Implementing #H((...) ...) read/print syntax for hash tables.Kaz Kylheku2012-03-145-5/+79
| | | | | | | | | | | | | | | | * hash.c (print_key_val, hash_print_op): New static functions. (hash_ops): hash_print_op wired in in place of cobj_print_op. * parser.l (HASH_H): New token recognized. * parser.y (HASH_H): New terminal symbol. (hash): New nonterminal symbol. (expr): Acquires hash as a constituent. (hash_from_notation): New static function. * txr.1: Hash syntax described. * txr.vim: Updated.
* Change: @(block) requires @(end) from now on.Kaz Kylheku2012-03-135-39/+156
| | | | | | | | | | | | | | | | | | | Blocks no longer extend to the end of the surrounding scope. * match.c (v_block): Rewrite for new syntax. * parser.l (BLOCK): New token type handled. * parser.y (BLOCK): New token. (block_clause): New nonterminal grammar symbol. (clause): Collateral fix: replaced a bunch of list(X, nao) forms with cons(X, nil). Introduced block_clause as a constituent of clause. * txr.1: Revamped documentation of block, and wrote about using blocks for reducing nested skips and reducing backtracking in general.
* * parser.l (ID_END): Bugfix: ID_END was defined incorrectlyKaz Kylheku2012-03-132-1/+8
| | | | | | for the current way in which an identifier token is recognized. As a result @(collect-ing) was being interpreted as @(collect -ing). It should be the complement of NSCHR.
* * regex.c (regsub): the replacement argumentKaz Kylheku2012-03-132-1/+11
| | | | | | can now be a function of one argument which maps the original piece of text matched by the regex to a replacement text.
* Remove accidentally added lines.Kaz Kylheku2012-03-131-3/+0
|
* * stream.c (stdio_put_string, stdio_put_char, stdio_put_byte): Do notKaz Kylheku2012-03-132-3/+10
| | | | | | consider data sent to std_error to be output for the purposes of the output_produced flag. Otherwise the program behavior changes in -v mode; it will not print bindings.
* Implementing URL filtering.Kaz Kylheku2012-03-136-2/+131
| | | | | | | | | | | | | | | | * eval.c (eval_init): New intrinsic functions: url-encode, url-decode. * filter.c (tourl_k, fromurl_k): New keyword variables. (is_url_reserved, digit_value): New static functions. (url_encode, url_decode): New functions. (filter_init): Intialize new keyword variables and register new :tourl and :fromurl filters. * filter.h (tourl_k, fromurl_k, url_encode, url_decode): Declared. * txr.1: Updated. * txr.vim: Likewise.
* * stream.c (string_out_byte_flush): Bugfix. Do not loop inside thisKaz Kylheku2012-03-134-4/+39
| | | | | | | | | | | | | | | | | | | | | | function. This must not flush out more than one character out of this small buffer, except when we are flushing out the last data. The correct operation is predicated on the assumption that a complete character can be pulled out. That's why we move the buffer to the front after consuming it, and do not automatically flush until there are four bytes. (string_out_put_string): We loop the call to string_out_byte_flush here because when a request comes in to write a Unicode character, we flush all the bytes, even if the tail of those bytes forms an incomplete sequence that turns into U+DCxx codes. (get_string_from_stream): Use the same loop termination test as in string_out_put_string, for consistency. In that function it is needed to prevent infinite looping in the case when the string_out_put_string is being called from string_out_byte_flush and is thus re-entering it. * tests/010/strstream.expected: New file. * tests/010/strstream.txr: New file.
* Implementing put_byte for string output stream.Kaz Kylheku2012-03-122-14/+99
| | | | | | | | | | | | | | | | | | | | | | | | | | | This does the Right Thing with a mixture of bytes and characters. Incomplete byte sequences. * stream.c (struct strm_ops): Changing byte argument of put_byte to int, since the put_byte API function can just pass down that value after validating it. (stdio_handle): Use available typedef. (stdio_put_byte): Follow interface change in strm_ops. Do not validate the range of a byte; the put_byte higher level function does that now. (struct string_output): New members: ud, byte_buf, head, tail. (string_out_byte_callback, string_out_byte_flush): New static functions. (string_out_put_string): Flush any UTF-8 bytes in the byte buffer before putting the string. (string_out_put_byte): New static function, implementation for put_byte on string output streams. (string_out_ops): string_out_put_byte wired in. (make_string_output_stream): Initialize new members of of struct string_output. (get_string_from_stream): Flush any UTF-8 bytes in the byte buffer before retrieving the string. (put_byte): Validate that the byte is in range. Pass byte as C int down to the put_byte virtual.
* Plugging memory leak.Kaz Kylheku2012-03-122-1/+20
| | | | | * stream.c (byte_in_stream_destroy): New function. (byte_in_ops): Use new function instead of noop stub.
* Fix brace/paren mismatch.Kaz Kylheku2012-03-051-1/+1
|
* * txr.vim: Update. Adding remq, remql, remqual, regsub, *stddebug*Kaz Kylheku2012-03-042-3/+8
|
* Bug #35718. Workaround good enough to get some code working.Kaz Kylheku2012-03-044-3/+30
| | | | | | | | | | | | * eval.c (cons_find): New function. (expand_op): Use cons_find rather than tree_find to look for rest_gensym. * regex.c (regsub): Rearranged arguments so that the string is last. This is better for partial evaluaton via the op operator. * regex.h (regsub): Updated declaration.
* * eval.c (eval_init): New intrinsic function, regsub.Kaz Kylheku2012-03-045-0/+42
| | | | | | | | * regex.c (regsub): New function. * regex.h (regsub): Declared. * txr.1: Doc stub added.
* * lib.c (split_str): Separator can be a regex now.Kaz Kylheku2012-03-042-23/+50
|
* * RELNOTES: Updated.Kaz Kylheku2012-03-041-0/+2
|
* * RELNOTES: Updated.Kaz Kylheku2012-03-042-14/+16
| | | | Extending release 60 to include the plus fix.
* * arith.c (plus): Showstopper bug: plus(bignum, fixnum)Kaz Kylheku2012-03-042-1/+6
| | | | broken for fixnum <= 0. Bad pointer passed to MPI.
* * mpi-patches/add-mp-hash (mp_hash): Fixed use of uninitializedKaz Kylheku2012-03-047-41/+73
| | | | | | | | | | | | | | | | | | variable on platforms where the MP digit is smaller than a long integer. (Not anything TXR is known to run on). Changed algorithm to take the first and last digit and add them together, rather than just taking the last digit. The last digit will be zeros for numbers that contain 2 as a factor with a large enough multiplicity. * mpi-patches/add-mpi-toradix-with-case: Refreshed. * mpi-patches/bit-search-optimizations: Likewise. * mpi-patches/faster-square-root: Likewise. * mpi-patches/fix-bad-shifts: Likewise. * mpi-patches/fix-mult-bug: Likewise.
* Version 60Kaz Kylheku2012-03-047-6/+75
| | | | | | | | | | | | | | | | | | | * txr.c (version): Bumped. * txr.1: Bumped version and set date. * configure (txr_ver): Bumped. * RELNOTES: Updated. * txr.vim: Handle : symbol properly. * eval.c (op_defun): Bugfix: documentation says that defun supports the same parameter list as lambda, and that is the intent. But this was broken, since op_defun was expecting the parameter list to be a proper list containing only bindable symbols, ruling out the use of the consing dot for rest parameter as well as the colon keyword symbol for optional parmeters.
* * eval.c (eval_init): Expose remq, remql and remqual.Kaz Kylheku2012-03-033-0/+27
| | | | * txr.1: Documented.
* * lib.c (sub_str): Removed second check for lazy string thatKaz Kylheku2012-03-033-13/+37
| | | | | | | | | | | | | | | | can't ever come out true. * match.c (search_form, h_var, h_coll, h_parallel, h_fun): Handle position t emanating from match_line, indicating match to end of line. (h_skip): When skipping to the end of line (empty spec), just return t as the position rather than the end of the line. This avoids calculating the length of the line, which forces a lazy string. (do_match_line): Near the beginning of the loop, if the position is t, then substitute the length of the line. (freeform_prepare): Return the freeform line limit value. (v_freeform): Check for t coming out of match line and do the conversion back to the trailing list in that case, but only if the freeform was limited by number of lines.
* * match.c (search_form): search_form works with relative positions now,Kaz Kylheku2012-03-012-2/+11
| | | | | | | but match_line returns absolute, and so needs to be offset by -c->base. (h_trailer, h_fun): Bugfix: return the absolute position, rather than relative c->pos. The return value of these functions becomes the return value of do_match_line, so the semantics has to agree.
* * match.c (sem_error, file_err): Bugfix: pull text formatted sourceKaz Kylheku2012-03-012-2/+7
| | | | location using source_loc_str rather than raw object using source_loc.
* * match.c (v_load): Check for errors during the parse and throw an exception.Kaz Kylheku2012-03-012-0/+5
|
* * match.c (v_load): Fixed broken functionality. Failing to evaluateKaz Kylheku2012-03-012-1/+29
| | | | directives following the load and consume input properly.
* Adding major section headings for the basic directives,Kaz Kylheku2012-03-011-0/+4
| | | | and for load.
* Pluralization fix in bind directive.Kaz Kylheku2012-03-011-23/+23
| | | | Load directive moved before Output section.
* Or operator computes logical or, not and.Kaz Kylheku2012-03-011-2/+2
| | | | Fixed typo.
* Confusing comment removed from examples of the op operator.Kaz Kylheku2012-03-011-2/+0
|
* Another instance of bad troff syntax.Kaz Kylheku2012-03-011-5/+5
|
* Fix bad troff syntax caused by apostrophe at the start of a line.Kaz Kylheku2012-03-011-2/+2
|
* Clarification about TXR Syntax.Kaz Kylheku2012-03-011-2/+3
|
* Capitalization.Kaz Kylheku2012-03-011-1/+1
|
* Minor fix.Kaz Kylheku2012-03-011-1/+1
|
* Fixing two instances of unintentional O(n*n) behavior and poor memory useKaz Kylheku2012-03-014-6/+56
| | | | | | | | | | | | | that occur in horizontal matching of basic text patterns. * lib.c (match_str, match_str_tree): New functions. * lib.h (match_str, match_str_tree): Declared. * match.c (do_match_line): Use match_str_tree and match_str when matching strings and string lists, respectively, rather than stupidly calling search functions and then asserting that the match was found at the starting position.
* * match.c (do_match_line): Function takes new argument, "completely".Kaz Kylheku2012-02-282-12/+36
| | | | | | | | | | | | | | | | The check for completely matching a line is now done within do_match_line. (match_line): Pass nil to do_match_line, specifying that a prefix match is okay. (match_line_completely): New interface to do_match_line, which requests a match to the end of the line. (v_freeform): Pass nil to do_match_line: freeform needs incomplete match semantics. (match_files): Use match_line_completely instead of match_line. By doing it this way, we do not need to compute the length of the original line and compare it to the absolute position. This saves time and memory since computing the length of a lazy string forces it.
* * match.c (consume_prefix): This memory optimization should onlyKaz Kylheku2012-02-282-6/+15
| | | | | | be done for lazy strings, otherwise it just causes unnecessary memory use by duplicating the line, and inefficiency via thanks to allocator churn.
* * lib.c (numberp): Fix bad type check: null pointer dereference whenKaz Kylheku2012-02-283-2/+15
| | | | | | | | | | object is nil. * match.c (do_match_line): Bugfix for incorrect treatment of long lines. Must return the absolute position from the start of the original line (plus(c->pos, c->base)), rather than just c->pos, which only measures from the start of a line that may have been chopped by consume_prefix.
* Bugfix: rlcp function was incorrect for new way of storingKaz Kylheku2012-02-283-1/+18
| | | | | | | | | line number info. * parser.h (rlset): Declared. (rlcp): Use rlset. * parser.y (rlset): New function.
* * debug.c (help, debug): New g command for tweaking log level.Kaz Kylheku2012-02-282-5/+20
|
* * debug.c: Missing d command implemented.Kaz Kylheku2012-02-284-3/+70
| | | | | | | | | | Condense the output to 8 times the screen width, for more context. Condense the output in vertical mode (when the entire input line is shown) not only character mode. * lib.c (remq, remql, remqual): New functions. * lib.h (remq, remql, remqual): Declared.
* Version 59txr-59Kaz Kylheku2012-02-285-4/+49
| | | | | | | | | | * txr.c (version): Bumped. * txr.1: Bumped version and set date. * configure (txr_ver): Bumped. * RELNOTES: Updated.
* * lib.c (sub_list, replace_list, lazy_sub_str, sub_str, replace_str,Kaz Kylheku2012-02-282-7/+13
| | | | | sub_vec, replace_vec): Regression: replace incorrect zerop(to) test with to == zero, because to is not necessarily a number.
* * txr.vim: Recognize backslash-newline break in regexes.Kaz Kylheku2012-02-272-3/+7
|
* * txr.vim: Substantially revised for better lexical accuracyKaz Kylheku2012-02-272-15/+31
| | | | and highlighting of errors.
* * match.c (extract): Check for negative value of opt_nobindings,Kaz Kylheku2012-02-274-9/+33
| | | | | | | | | | | which forces the printing. * txr.c (help): Under -b, mention that printing the word false is suppressed also. Added documentation for -B. (main): Implemented -B option. * txr.1: Documented -B option and added clarifying text under -b option explaining the conditions under which bindings are printed.
* Fix the issue properly, once and for all, of how to determineKaz Kylheku2012-02-276-22/+44
| | | | | | | | | | | | | | | | that output has taken place and suppress the printing of bindings. * debug.c (debug): std_output replaced with std_debug. * eval.c (eval_init): Registered new *stddebug* variable. * stream.c (std_debug): New variable. (stdio_put_string): Check that stream is other than std_debug, to determine that output has taken place. * stream.h (std_debug): Declared. * txr.1: Added *stddebug* to documentation stub heading.