summaryrefslogtreecommitdiffstats
Commit message (Collapse)AuthorAgeFilesLines
...
| * * arith.c (expo): New function.Kaz Kylheku2012-03-226-2/+21
| | | | | | | | | | | | | | | | | | | | * eval.c (eval_init): expo registered as intrinsic exp. * lib.h (expo): Declared. * txr.1: Added to stub heading. * txr.vim: Highlighting for exp.
| * * eval.c (transform_op): use integerp instead of numberp.Kaz Kylheku2012-03-222-1/+7
| | | | | | | | | | Not all numbers are integers now, and that situation requires an integer.
| * * parser.l: Bugfix: was not allowing e-notation floatsKaz Kylheku2012-03-223-21/+41
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | with no decimal point like 1E1. * stream.c: (vformat): Keep track of whether or not precision was given in precision_p local variable. When printing #<bad-float> pass a precision of 0 to vformat_str, not precision, since precision does not apply. In ~f and ~e, if the precision was not given, default it to 3. Restructured float printing in ~a and ~s. It now just uses sprintf's %g with a precision. If user does not specify precision, it defaults to DBL_DIG to print the number with reasonable accuracy. A .0 is added if it sprintf produces an integer, and the conversion is ~s rather than ~a.
| * Fix sqrt confusion. There must be a separate isqrtKaz Kylheku2012-03-226-16/+38
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | for the integer square root. * arith.c (sqroot_fixnum): Renamed back to isqrt_fixnum. (sqroot): Rewritten to handle only floating-point square root. (isqrt): New function, based on previous sqroot, handles only integers. * eval.c (eval_init): New intrinsic, isqrt. * lib.h (isqrt): New declaration. * txr.1: Doc stubs. * txr.vim: Highlighting for isqrt.
| * * arith.c (floorf, ceili, sine, cosi, atang, loga): New functions.Kaz Kylheku2012-03-226-2/+60
| | | | | | | | | | | | | | | | | | | | | | * eval.c (eval_init): New intrinsic functions registered: floor, ceil, sin, cons, atan, log. * lib.h (floorf, ceili, sine, cosi, atang, loga): Declared. * txr.1: Doc stub section for new functions. * txr.vim: Highighting added.
| * * arith.c (int_flo): If sprintf produces somethingKaz Kylheku2012-03-223-0/+29
| | | | | | | | | | | | | | | | that doesn't begin with a digit, it's most likely NaN or Inf. We can turn that into an exception. * stream.c (vformat): If sprintf produces a non-number, turn it into the printed representation #<bad-float>.
| * * arith.c (to_float): New static function.Kaz Kylheku2012-03-224-137/+197
| | | | | | | | | | | | | | | | | | | | | | | | | | (divi): Uses to_float. (zerop, gt, lt, ge, le, expt): Floating support. (isqrt_fixnum): Static function renamed to sqroot_fixnum. (isqrt): Renamed to sqroot. Floating support. (evenp, oddp, exptmod, gcd): Work with integers, not floats. * eval.c (eval_init): intrinsic registration of sqrt follows rename of isqrt to sqroot. * lib.h (isqrt): Declaration replaced.
| * * arith.c (divi): New function.Kaz Kylheku2012-03-216-2/+54
| | | | | | | | | | | | | | | | | | | | * eval.c (eval_init): divi registered as / intrinsic. * lib.h (divi): Declared. * txr.1: divi added to stub heading. * txr.vim: / operator highlighted.
| * * arith.c (mod): Floating support.Kaz Kylheku2012-03-212-82/+107
| |
| * * arith.c (trunc): Floating support.Kaz Kylheku2012-03-212-34/+77
| |
| * * arith.c (plus, minus, mul): Removing unnecessary type checks,Kaz Kylheku2012-03-212-7/+5
| | | | | | | | which are already implied by the switch case.
| * * txr.1: Doc stubs for new functions floatp, integerp,Kaz Kylheku2012-03-213-3/+14
| | | | | | | | | | | | float-str, int-flo and flo-int. * txr.vim: Highlighting for new functions.
| * * Makefile: link in -lm, which is needed now on some systems.Kaz Kylheku2012-03-213-57/+97
| | | | | | | | | | * arith.c (plus, minus): Eliminated some unnecessary (double) casts. (abso, mul): Floating support.
| * * arith.c (neg): Floating-point support.Kaz Kylheku2012-03-214-31/+71
| | | | | | | | | | | | | | | | | | | | | | | | | | * parser.l: FLO and FLODOT cases had to be reordered because the lex trailing context counts as part of the match length, causing 3.0 to be matched as three characters with 0 as the trailing context. The cases are split up to eliminate a flex warning. * stream.c (vformat): Support bignum in floating point conversion. Bugfixes: floating point conversion was accessing obj->fl.n instead of using n. Changed some if/else ladders to switches.
| * * arith.c (plus): Minor code simplification.Kaz Kylheku2012-03-213-61/+87
| | | | | | | | | | | | | | | | (minus): Floating point support. * mpi-patches/mpi-to-double (mp_to_double): Re-apply lost bugfix: index incremented instead of decremented. Didn't refresh patch last time, then did a make distclean.
| * Regression fix: 1..3 scans incorrectly into 1. .3 tokens.Kaz Kylheku2012-03-202-3/+21
| | | | | | | | | | | | | | | | | | | | | | * parser.l (SGN, EXP, DIG): New regex definitions. (FLO): Do not recognize numbers of the form 123. Decimal point must be followed either by exponent, or digits (which may then be followed by an exponent). (FLODOT): New token type, recognizes 123. (grammar): Recognize FLODOT as a floating point number, only if it not trailed by another dot, and recognize FLO unconditionally.
| * * arith.c (plus): Completed implementation of bignum-floatKaz Kylheku2012-03-202-6/+11
| | | | | | | | and float-bignum cases.
| * * stream.c (vformat): Use larger num_buf buffer so we don'tKaz Kylheku2012-03-202-1/+6
| | | | | | | | overrun. IEEE double floats can go to e+-308.
| * * arith.c (flo_int): New function.Kaz Kylheku2012-03-206-0/+89
| | | | | | | | | | | | | | | | | | | | | | * eval.c (eval_init): flo-int registered as intrinsic. * lib.h (flo_int): Declared. * mpi-patches/series: Added mpi-to-double to patch stack. (mp_to_double): New MPI function. * mpi-patches/mpi-to-double: New file.
| * * arith.c (plus): Optimization: use num_fast whenKaz Kylheku2012-03-205-46/+164
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | result is in the fixnum range. Implemented FLNUM cases, except for adding a FLNUM to BGNUM. (minus, mul): Use num_fast when the cnum value is in the fixnum range. (int_flo): New function. * eval.c (eval_init): Register int-flo intrinsic. * lib.c (c_flo): New function. * lib.h (TYPE_SHIFT, TYPE_PAIR): New macros, carried over from the lazy strings branch. (c_flo, int_flo): Declared.
| * * parser.l (FLO): Adjusted syntax of floating point numbersKaz Kylheku2012-03-202-1/+6
| | | | | | | | to allow leading or trailing decimal.
| * * stream.c (vformat): num_buf increased to 256 because weKaz Kylheku2012-03-192-1/+65
| | | | | | | | | | | | | | | | | | | | are now printing floating point numbers into it, letting the C library handle precision which can generate many digits. We cap the precision at at 128. New format specifiers ~e and ~f implemented, which loosely correspond to those of printf. The ~s and ~a directives handle floats similarly to ~g in printf, except that they ensure that a decimal point is printed for the non-exponential notation.
| * * configure (uintptr): New variable. Indicates whether unsignedKaz Kylheku2012-03-199-17/+162
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | version of intptr_t is available and should be generated in config.h as uintptr_t. * eval.c (eval_init): New intrinsic functions floatp, integerp, flo-str. * gc.c (finalize): Handle FLNUM case. Rearranged cases so that all trivially returning cases are together. (mark): Handle FLNUM case. * hash.c (hash_double): New function. (equal_hash): Handle FLNUM via hash_double. (eql_hash): Likewise. * lib.c: <math.h> is included. (float_s): New symbol variable. (code2type, equal): Handle FLNUM case in switch. (integerp): New function; does the same thing as integerp before. (numberp): Returns t for floats. (flo, floatp, flo_str): New functions. (obj_init): Initialize new float_s variable. (obj_print, obj_pprint): Handle FLNUM case in switch. Printing does not work yet; needs work in stream.c. * lib.h (enum type): New enumeration FLNUM. (struct flonum): New struct type. (union obj): New member, fl. (float_s, flo, floatp, integerp, flo_str): Declared. * parser.l (FLO): New token pattern definition. Scans to a NUMBER token. Corrected uses of yylval.num to yylval.val. * parser.y (%union): Removed num member from yystype.
* | * debug.c (debug): Breakpointing now takes into accountKaz Kylheku2012-03-202-10/+27
|/ | | | | | | the module file name, not only the line number. Breakpoints work on source locations rather than line numbers. Boy, this was easy. Keep the breakpoint list free of duplicates. Issue a message if a nonexistent breakpoint is asked to be deleted.
* * eval.c (eval_init): url_decode has two parameters now,Kaz Kylheku2012-03-185-15/+54
| | | | | | | | | | | | | | | | | | so we make the second one optional. * filter.c (topercent_k, frompercent_k): New keyword variables. (url_encode, url_decode): Take a second parameter, space_plus. This determines whether or not to apply the rule that a space encodes as a + character. (filter_init): Initialize new keyword variables, and register :topercent and :frompercent filters. Fix the previous registrations of :tourl and :fromurl using currying. * filter.h (urlencode, urldecode): Declarations updated. (topercent_k, frompercent_k): Declared. * txr.1: Documented.
* Changing type function to not blow up on nil, which makes a lot of codeKaz Kylheku2012-03-178-102/+103
| | | | | | | | | | | | | | | | | | | | | | | | | | | simpler. A pseudo type code is introduced called NIL with value 0. * lib.h (enum type): New enumeration value, NIL. (type): Function accepts object nil and maps it to code NIL. * eval.c (dwim_loc, op_dwim): test for nil obj and goto hack is gone, just handle NIL in the switch. * gc.c (make_obj, mark): Handle new NIL type code in switch. * hash.c (equal_hash): Handle NIL in the switch instead of nil test. * lib.c (code2type): Map new NIL type code to null. (typeof, typecheck): Code simplified. (class_check, car): Move nil test into switch. (eql, equal, consp, bignump, stringp, lazy_stringp, symbolp, functionp, vectorp, cobjp): Simplified. (length, sub, ref, refset, replace, obj_print, obj_pprint): Handle NIL in switch instead of nil test. goto hack removed from refset. * match.c (do_match_line, do_output_line): switch condition simplified. * regex.c (regexp): Simplified. (regex_nfa): Assert condition simplified.
* * filter.c (digit_value): static function moved.Kaz Kylheku2012-03-172-14/+18
| | | | | (html_hex_continue): Use digit_value instead of hex digits string literal.
* * lib.c (do_chain): More useful behavior. The firstKaz Kylheku2012-03-162-3/+17
| | | | | | function, if any, is treated as variadic. Subsequent functions are monadic. (chain, chainv): Turn do_chain into variadic.
* * eval.c (eval_init): New intrinsic functionsKaz Kylheku2012-03-166-7/+72
| | | | | | | | | | | | | | | | | | chain, andf, orf, iff. * lib.c (chainv): New function. (do_and, do_or): Generalized to handle functions of any arguments via apply. (andf, orf): Turn do_and and do_or into variadic function instead of a monadic function. (do_iff): New static function. (andv, orv, iff): New functions. * lib.h (chainv, andv, orv, iff): New functions declared. * txr.1: Doc stubs created. * txr.vim: Updated.
* Formatting fix.Kaz Kylheku2012-03-161-3/+1
|
* * lib.c (quicksort): Bugfix: incorrect loop from 0 rather than fromKaz Kylheku2012-03-162-1/+6
| | | | leading to unbounded recursion.
* Version 61txr-61Kaz Kylheku2012-03-159-12/+38
| | | | | | | | | | | | | | | | | | | | | * txr.c (version): Bumped. * txr.1: Bumped version and set date. * configure (txr_ver): Bumped. * eval.c (op_modplace): Fix warning about uninitialized variable. No bug. * filter.c: gcc compilation regresion: missing <stdio.h> breaks inclusion of "stream.h" header. Strangely, didn't show up when configured for compiling with g++ on Ubuntu. * match.c (match_filter): Fixed ununsed variable warning. * txr.vim: Bunch of missing keywords added. * dep.mk: Regenerated.
* * tests/010/block.expected: New file.Kaz Kylheku2012-03-155-0/+24
| | | | | | | | * tests/010/block.txr: New file. * tests/010/reghash.expected: New file. * tests/010/reghash.txr: New file.
* * RELNOTES: Updated for upcoming 61.Kaz Kylheku2012-03-142-0/+43
|
* * txr.1: Documented hash and vector quasiliterals.Kaz Kylheku2012-03-142-2/+49
|
* 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.