summaryrefslogtreecommitdiffstats
Commit message (Collapse)AuthorAgeFilesLines
...
* * arith.c (to_float): Fix unterminated argument list in throwf.Kaz Kylheku2012-03-263-2/+8
| | | | * lib.c (funcall): Likewise.
* * lib.c (rebind_s): New symbol variable.Kaz Kylheku2012-03-245-5/+69
| | | | | | | | | | * lib.h (rebind_s): Declared. * match.c (v_rebind): New static function. (dir_tables_init): Registered rebind_s to v_rebind, and also to hv_trampoline in the horizontal directive table. * txr.1: Documented it.
* Bug #35989Kaz Kylheku2012-03-242-1/+8
| | | | | * match.c (syms_init): text_s must be in the system package because it's not a user-visible operator.
* Performance improvement in the GC: keep at least one heap's worthKaz Kylheku2012-03-242-4/+23
| | | | | | | | | | | | | of free space, so programs close to exhausting a heap do not waste cycles frequently calling the collector. * gc.c (more): Do not assert that free_list is null; this will not be the case any more. (make_obj): Comment added regarding why we the free_tail variable is fixed up. (sweep): Now returns a count of the objects that are free. (gc): If sweep reports that less than 75% of the objects are free then let us add another heap.
* * eval.c (eval_init): Register match-str and match-str-treeKaz Kylheku2012-03-245-0/+24
| | | | | | | | | | intrinsics. * lib.c (match_str, match_str_tree): Default position to zero. * txr.1: Doc stubs created. * txr.vim: Highlighting for match-str and match-str-tree.
* Bugfix: code like @(skip)@{var /partial/} whereKaz Kylheku2012-03-242-11/+34
| | | | | | | | | | | | | | | | the regular expression does not match all the way to the end of the line was getting by the check for a complete match. * match.c (do_match_line): Loses the second parameter named completely. The check whether the line was matched completely is done higher up, in match_line_completely. This is needed because do_match_line has some early successful return cases which bypass the check. (match_line): Remove second paramter in call to do_match_line. (match_line_completely): Do the check here that the line was matched completely. Nothing can get by this. (v_freeform): Do notpass second nil argument to do_match_line.
* * lib.c (search_str): If start_num is nil, default it to zero.Kaz Kylheku2012-03-242-0/+9
| | | | This is needed for this to work right as an optional argument.
* Version 62txr-62Kaz Kylheku2012-03-234-4/+14
| | | | | | | | * txr.c (version): Bumped. * txr.1: Bumped version and set date. * configure (txr_ver): Bumped.
* * RELNOTES: Updated.Kaz Kylheku2012-03-233-2/+90
| | | | * txr.1: Describe floating-point constants.
* * Makefile (TXR_ARGS): Pass new file to tests/009/json.txr test.Kaz Kylheku2012-03-235-18/+130
| | | | | | | | | | * tests/009/json.expected: Updated. * tests/009/json.txr: Updated source. Translates to a more native representation with vectors and hash tables. Numbers go to floating point instead of remaining as strings. * tests/009/pass1.json: New file: a test case from json.org.
* Merge branch 'float-support'Kaz Kylheku2012-03-2216-424/+1322
|\ | | | | | | | | Conflicts: ChangeLog
| * * 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.