pure-lang-svn Mailing List for Pure (Page 24)
Status: Beta
Brought to you by:
agraef
You can subscribe to this list here.
2008 |
Jan
|
Feb
|
Mar
|
Apr
(5) |
May
(141) |
Jun
(184) |
Jul
(97) |
Aug
(232) |
Sep
(196) |
Oct
|
Nov
|
Dec
|
---|
From: <ag...@us...> - 2008-06-23 23:38:42
|
Revision: 291 http://pure-lang.svn.sourceforge.net/pure-lang/?rev=291&view=rev Author: agraef Date: 2008-06-23 16:38:50 -0700 (Mon, 23 Jun 2008) Log Message: ----------- Start refactoring the runtime library in order to provide a sensible public API to external modules which need access to Pure expression data. Modified Paths: -------------- pure/trunk/runtime.cc pure/trunk/runtime.h Modified: pure/trunk/runtime.cc =================================================================== --- pure/trunk/runtime.cc 2008-06-23 13:07:26 UTC (rev 290) +++ pure/trunk/runtime.cc 2008-06-23 23:38:50 UTC (rev 291) @@ -298,51 +298,17 @@ return pure_const(interpreter::g_interp->symtab.segfault_sym().f); } -extern "C" -pure_expr *pure_clos(bool local, bool thunked, int32_t tag, uint32_t n, - void *f, void *e, uint32_t m, /* m x pure_expr* */ ...) -{ - // Parameterless closures are always thunked, otherwise they would already - // have been executed. - if (n==0) thunked = true; - pure_expr *x = new_expr(); - x->tag = tag; - x->data.clos = new pure_closure; - x->data.clos->local = local; - x->data.clos->thunked = thunked; - x->data.clos->n = n; - x->data.clos->m = m; - x->data.clos->fp = f; - x->data.clos->ep = e; - if (e) ((Env*)e)->refc++; - if (m == 0) - x->data.clos->env = 0; - else { - x->data.clos->env = new pure_expr*[m]; - va_list ap; - va_start(ap, m); - for (size_t i = 0; i < m; i++) { - x->data.clos->env[i] = va_arg(ap, pure_expr*); - assert(x->data.clos->env[i]->refc > 0); - } - va_end(ap); - } - MEMDEBUG_NEW(x) - return x; -} +/* PUBLIC API. **************************************************************/ -extern "C" -pure_expr *pure_const(int32_t tag) -{ - // XXXFIXME: We should cache these on a per interpreter basis, so that only - // a single expression node exists for each symbol. - pure_expr *x = new_expr(); - x->tag = tag; - x->data.clos = 0; - MEMDEBUG_NEW(x) - return x; -} +// XXXTODO +int32_t pure_sym(const char *s); +int32_t pure_getsym(const char *s); +const char *pure_sym_pname(int32_t sym); +int8_t pure_sym_nprec(int32_t sym); + +pure_expr *pure_symbol(int32_t sym); + extern "C" pure_expr *pure_int(int32_t i) { @@ -369,7 +335,7 @@ } } -static void make_bigint(mpz_t z, int32_t size, limb_t *limbs) +static void make_bigint(mpz_t z, int32_t size, const limb_t *limbs) { // FIXME: For efficiency, we poke directly into the mpz struct here, this // might need to be reviewed for future GMP revisions. @@ -385,7 +351,7 @@ } extern "C" -pure_expr *pure_bigint(int32_t size, limb_t *limbs) +pure_expr *pure_bigint(int32_t size, const limb_t *limbs) { pure_expr *x = new_expr(); x->tag = EXPR::BIGINT; @@ -395,7 +361,7 @@ } extern "C" -pure_expr *pure_mpz(mpz_t z) +pure_expr *pure_mpz(const mpz_t z) { pure_expr *x = new_expr(); x->tag = EXPR::BIGINT; @@ -466,9 +432,113 @@ return x; } +// XXXTODO + +pure_expr *pure_app(pure_expr *fun, pure_expr *arg); + +pure_expr *pure_listl(size_t size, ...); +pure_expr *pure_listv(size_t size, pure_expr **elems); +pure_expr *pure_tuplel(size_t size, ...); +pure_expr *pure_tuplev(size_t size, pure_expr **elems); + +bool pure_is_symbol(const pure_expr *x, int32_t *sym); +bool pure_is_int(const pure_expr *x, int32_t *i); +bool pure_is_long(const pure_expr *x, int64_t *l); +bool pure_is_bigint(const pure_expr *x, int32_t *size, limb_t **limbs); +bool pure_is_mpz(const pure_expr *x, mpz_t *z); +bool pure_is_double(const pure_expr *x, double *d); +bool pure_is_pointer(const pure_expr *x, void **p); + +bool pure_is_string(const pure_expr *x, const char **sym); +bool pure_is_string_dup(const pure_expr *x, char **sym); +bool pure_is_cstring_dup(const pure_expr *x, char **sym); + +bool pure_is_app(const pure_expr *x, pure_expr **fun, pure_expr **arg); + +bool pure_is_listv(const pure_expr *x, size_t *size, pure_expr ***elems); +bool pure_is_tuplev(const pure_expr *x, size_t *size, pure_expr ***elems); + extern "C" -int32_t pure_cmp_bigint(pure_expr *x, int32_t size, limb_t *limbs) +pure_expr *pure_new(pure_expr *x) { + return pure_new_internal(x); +} + +extern "C" +void pure_free(pure_expr *x) +{ + pure_free_internal(x); +} + +extern "C" +void pure_freenew(pure_expr *x) +{ + if (x->refc == 0) + pure_free_internal(pure_new_internal(x)); +} + +extern "C" +void pure_ref(pure_expr *x) +{ + x->refc++; +} + +extern "C" +void pure_unref(pure_expr *x) +{ + pure_unref_internal(x); +} + +/* END OF PUBLIC API. *******************************************************/ + +extern "C" +pure_expr *pure_const(int32_t tag) +{ + // XXXFIXME: We should cache these on a per interpreter basis, so that only + // a single expression node exists for each symbol. + pure_expr *x = new_expr(); + x->tag = tag; + x->data.clos = 0; + MEMDEBUG_NEW(x) + return x; +} + +extern "C" +pure_expr *pure_clos(bool local, bool thunked, int32_t tag, uint32_t n, + void *f, void *e, uint32_t m, /* m x pure_expr* */ ...) +{ + // Parameterless closures are always thunked, otherwise they would already + // have been executed. + if (n==0) thunked = true; + pure_expr *x = new_expr(); + x->tag = tag; + x->data.clos = new pure_closure; + x->data.clos->local = local; + x->data.clos->thunked = thunked; + x->data.clos->n = n; + x->data.clos->m = m; + x->data.clos->fp = f; + x->data.clos->ep = e; + if (e) ((Env*)e)->refc++; + if (m == 0) + x->data.clos->env = 0; + else { + x->data.clos->env = new pure_expr*[m]; + va_list ap; + va_start(ap, m); + for (size_t i = 0; i < m; i++) { + x->data.clos->env[i] = va_arg(ap, pure_expr*); + assert(x->data.clos->env[i]->refc > 0); + } + va_end(ap); + } + MEMDEBUG_NEW(x) + return x; +} + +extern "C" +int32_t pure_cmp_bigint(pure_expr *x, int32_t size, const limb_t *limbs) +{ assert(x && x->tag == EXPR::BIGINT); mpz_t z; make_bigint(z, size, limbs); @@ -812,37 +882,6 @@ } extern "C" -pure_expr *pure_new(pure_expr *x) -{ - return pure_new_internal(x); -} - -extern "C" -void pure_free(pure_expr *x) -{ - pure_free_internal(x); -} - -extern "C" -void pure_freenew(pure_expr *x) -{ - if (x->refc == 0) - pure_free_internal(pure_new_internal(x)); -} - -extern "C" -void pure_ref(pure_expr *x) -{ - x->refc++; -} - -extern "C" -void pure_unref(pure_expr *x) -{ - pure_unref_internal(x); -} - -extern "C" void pure_new_args(uint32_t n, ...) { va_list ap; @@ -1067,6 +1106,8 @@ if (bail_out) exit(0); } +/* LIBRARY API. *************************************************************/ + extern "C" pure_expr *pure_byte_string(const char *s) { Modified: pure/trunk/runtime.h =================================================================== --- pure/trunk/runtime.h 2008-06-23 13:07:26 UTC (rev 290) +++ pure/trunk/runtime.h 2008-06-23 23:38:50 UTC (rev 291) @@ -15,6 +15,9 @@ /* Our "limb" type. Used to pass bigint constants to the runtime. */ typedef mp_limb_t limb_t; +/* The following data structures should be considered opaque by + applications. */ + /* Closure data. This is a bit on the heavy side, so expressions which need it (i.e., functions) refer to this extra data via an allocated pointer. */ @@ -57,35 +60,178 @@ pure_expr x[MEMSIZE]; // expression data } pure_mem; -/* Expression constructors. */ +/* PUBLIC API. **************************************************************/ -pure_expr *pure_clos(bool local, bool thunked, int32_t tag, uint32_t n, - void *f, void *e, uint32_t m, /* m x pure_expr* */ ...); -pure_expr *pure_const(int32_t tag); +/* The following routines are meant to be used by external C modules and other + applications which need direct access to Pure expression data. */ + +/* Symbol table access. pure_sym returns the integer code of a (function or + variable) symbol given by its print name; if the symbol doesn't exist yet, + it is created (as an ordinary function or variable symbol). pure_getsym is + like pure_sym, but returns 0 if the symbol doesn't exist. + + Given the (positive) symbol number, pure_sym_pname returns its print name + and pure_sym_nprec its "normalized" precedence. The latter is a small + integer value defined as nprec = 10*prec+fix, where prec is the precedence + level of the symbol and fix its fixity. For operators, the combined value + ranges from 0 (weakest infix operator on level 0) to 94 (strongest postfix + operator on level 9). Applications have nprec=95, ordinary function and + variable symbols nprec=100. */ + +int32_t pure_sym(const char *s); +int32_t pure_getsym(const char *s); +const char *pure_sym_pname(int32_t sym); +int8_t pure_sym_nprec(int32_t sym); + +/* Expression constructors. Atomic objects are constructed with the following + routines: + + - pure_symbol: Takes the integer code of a symbol and returns that symbol + as a Pure value. If the symbol is a global variable or parameterless + function then it is evaluated, giving the value of the variable or the + return value of the function as the result. + + - pure_int: Constructs a Pure machine int from a 32 bit integer value. + + - pure_long: Constructs a Pure bigint from a 64 bit integer value. + + - pure_bigint: Constructs a Pure bigint from a vector of limbs. The size + argument may be negative to denote a negative number, its absolute value + is the number of elements in the limbs vector (the vector is owned by the + caller and won't be be freed). + + - pure_mpz: Constructs a Pure bigint from a (copy of a) GMP mpz_t. + + - pure_double: Constructs a Pure floating point number from a double value. + + - pure_pointer: Constructs a Pure pointer from a C pointer (void*). */ + +pure_expr *pure_symbol(int32_t sym); pure_expr *pure_int(int32_t i); pure_expr *pure_long(int64_t l); -pure_expr *pure_bigint(int32_t size, limb_t *limbs); -pure_expr *pure_mpz(mpz_t z); +pure_expr *pure_bigint(int32_t size, const limb_t *limbs); +pure_expr *pure_mpz(const mpz_t z); pure_expr *pure_double(double d); pure_expr *pure_pointer(void *p); /* String constructors. There are four variations of these, depending on whether the original string is already in utf-8 (_string routines) or in the system encoding (_cstring), and whether the string should be copied - (_dup suffix) or whether Pure takes ownership of the string (no _dup - suffix). All these routines also handle the case that the given string is a - null pointer and will then return the appropriate Pure pointer expression - instead. */ + (_dup suffix) or whether Pure takes ownership of the string. All four + routines handle the case that the given string is a null pointer and will + then return the appropriate Pure pointer expression instead. */ pure_expr *pure_string_dup(const char *s); pure_expr *pure_cstring_dup(const char *s); pure_expr *pure_string(char *s); pure_expr *pure_cstring(char *s); +/* Function applications. pure_app applies the given function to the given + argument. The result is evaluated if possible (i.e., if it is a saturated + function call). Otherwise, the result is a literal application and + references on function and argument are counted automatically. */ + +pure_expr *pure_app(pure_expr *fun, pure_expr *arg); + +/* Convenience functions to construct Pure list and tuple values from a vector + or a varargs list of element expressions. (Internally these are actually + represented as function applications.) The vectors are owned by the caller + and won't be freed. References on the element expressions are counted + automatically. */ + +pure_expr *pure_listl(size_t size, ...); +pure_expr *pure_listv(size_t size, pure_expr **elems); +pure_expr *pure_tuplel(size_t size, ...); +pure_expr *pure_tuplev(size_t size, pure_expr **elems); + +/* Expression deconstructors for all the expression types above. These all + return a bool value indicating whether the given expression is of the + corresponding type and, if so, set the remaining parameter pointers to the + corresponding values. Parameter pointers may be NULL in which case they are + not set and only the result of the type check is returned. + + NOTES: pure_is_symbol will return true not only for constant and unbound + variable symbols, but also for arbitrary closures including local and + anonymous functions. In the case of an anonymous closure, the returned + symbol will be 0. You can check whether an expression actually represents a + named or anonymous closure using the funp and lambdap predicates from the + library API (see below). + + pure_is_long checks whether the result actually fits into a 64 bit integer. + pure_is_bigint mallocs the returned limb vector (if limbs!=NULL); the + caller is responsible for freeing it. */ + +bool pure_is_symbol(const pure_expr *x, int32_t *sym); +bool pure_is_int(const pure_expr *x, int32_t *i); +bool pure_is_long(const pure_expr *x, int64_t *l); +bool pure_is_bigint(const pure_expr *x, int32_t *size, limb_t **limbs); +bool pure_is_mpz(const pure_expr *x, mpz_t *z); +bool pure_is_double(const pure_expr *x, double *d); +bool pure_is_pointer(const pure_expr *x, void **p); + +/* String results are copied with the _dup routines (it is then the caller's + responsibility to free them when appropriate). pure_is_cstring_dup also + converts the string to the system encoding. The string value returned by + pure_is_string points directly to the string data in the Pure expression + and must not be changed by the caller. */ + +bool pure_is_string(const pure_expr *x, const char **sym); +bool pure_is_string_dup(const pure_expr *x, char **sym); +bool pure_is_cstring_dup(const pure_expr *x, char **sym); + +/* Deconstruct literal applications. */ + +bool pure_is_app(const pure_expr *x, pure_expr **fun, pure_expr **arg); + +/* Convenience functions to deconstruct lists and tuples. Returned element + vectors are malloc'd and must be freed by the caller. Note that + pure_is_tuplev will always return true, since a singleton expression, which + is not either a pair or (), is considered a tuple of size 1. */ + +bool pure_is_listv(const pure_expr *x, size_t *size, pure_expr ***elems); +bool pure_is_tuplev(const pure_expr *x, size_t *size, pure_expr ***elems); + +/* Memory management. */ + +/* Count a new reference to an expression. This should be called whenever you + want to store an expression somewhere, in order to prevent it from being + garbage-collected. */ + +pure_expr *pure_new(pure_expr *x); + +/* Drop a reference to an expression. This will cause the expression to be + garbage-collected when it is no longer needed. */ + +void pure_free(pure_expr *x); + +/* Count a reference and then immediately drop it. This is useful to collect + temporaries which are not referenced yet. */ + +void pure_freenew(pure_expr *x); + +/* Increment and decrement the reference counter of an expression. This can be + used to temporarily protect an expression from being garbage-collected. It + doesn't actually change the status of the expression and does not collect + it. */ + +void pure_ref(pure_expr *x); +void pure_unref(pure_expr *x); + +/* END OF PUBLIC API. *******************************************************/ + +/* Stuff below this line is for internal use by the Pure interpreter. Don't + call these directly, unless you know what you are doing. */ + +/* Construct constant symbols and closures. */ + +pure_expr *pure_const(int32_t tag); +pure_expr *pure_clos(bool local, bool thunked, int32_t tag, uint32_t n, + void *f, void *e, uint32_t m, /* m x pure_expr* */ ...); + /* Compare a bigint or string expression against a constant value. This is used by the pattern matching code. */ -int32_t pure_cmp_bigint(pure_expr *x, int32_t size, limb_t *limbs); +int32_t pure_cmp_bigint(pure_expr *x, int32_t size, const limb_t *limbs); int32_t pure_cmp_string(pure_expr *x, const char *s); /* Get the string value of a string expression in the system encoding. Each @@ -127,33 +273,10 @@ /* Run a Pure function and catch exceptions. If everything goes normal, pure_invoke returns the return value of the executed function. Otherwise it returns 0 and sets e to the exception value, as given by pure_throw(). - XXXFIXME: This only supports parameterless functions right now. */ + FIXME: This only supports parameterless functions right now. */ pure_expr *pure_invoke(void *f, pure_expr** e); -/* Count a new reference to an expression. This should be called whenever you - want to store an expression somewhere, in order to prevent it from being - garbage-collected. */ - -pure_expr *pure_new(pure_expr *x); - -/* Drop a reference to an expression. This will cause the expression to be - garbage-collected when it is no longer needed. */ - -void pure_free(pure_expr *x); - -/* Count a reference and then immediately drop it. This is useful to collect - temporaries which are not referenced yet. */ - -void pure_freenew(pure_expr *x); - -/* Increment and decrement the reference counter. This can be used to - temporarily protect an expression from being garbage-collected. It doesn't - actually change the status of the expression and does not collect it. */ - -void pure_ref(pure_expr *x); -void pure_unref(pure_expr *x); - /* Manage arguments of a function call. pure_new_args counts references on a given collection of arguments in preparation for a function call, while pure_free_args collects the arguments of a function call. In both cases the @@ -199,8 +322,12 @@ void pure_debug(int32_t tag, const char *format, ...); -/* Supplementary routines. These are used in the standard library. */ +/* LIBRARY API. *************************************************************/ +/* Add any stuff that is needed in the standard library here. Applications and + external C modules may call these, but be warned that these APIs are + subject to change without further notice. */ + /* Conversions between numeric and pointer types. The input argument must be an expression denoting an int, double, bigint or pointer value. The numeric value of a pointer is its address, cast to a suitably large integer type, @@ -272,7 +399,8 @@ /* Convert a Pure expression to a string and vice versa. Note that eval() will actually parse and execute any Pure source, so it can be used, e.g., to add - new rules to the executing program at runtime. */ + new rules to the executing program at runtime. The result of eval() is the + last computed expression (NULL if none). */ pure_expr *str(const pure_expr *x); pure_expr *eval(const char *s); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ag...@us...> - 2008-06-23 13:07:17
|
Revision: 290 http://pure-lang.svn.sourceforge.net/pure-lang/?rev=290&view=rev Author: agraef Date: 2008-06-23 06:07:26 -0700 (Mon, 23 Jun 2008) Log Message: ----------- Make pure_invoke() callable from C. Modified Paths: -------------- pure/trunk/ChangeLog pure/trunk/interpreter.cc pure/trunk/runtime.cc pure/trunk/runtime.h Modified: pure/trunk/ChangeLog =================================================================== --- pure/trunk/ChangeLog 2008-06-23 11:10:39 UTC (rev 289) +++ pure/trunk/ChangeLog 2008-06-23 13:07:26 UTC (rev 290) @@ -1,3 +1,7 @@ +2008-06-23 Albert Graef <Dr....@t-...> + + * runtime.h, runtime.cc: Make pure_invoke() callable from C. + 2008-06-22 Albert Graef <Dr....@t-...> * expr.cc, interpreter.cc, parser.yy, lexer.ll, printer.cc: Modified: pure/trunk/interpreter.cc =================================================================== --- pure/trunk/interpreter.cc 2008-06-23 11:10:39 UTC (rev 289) +++ pure/trunk/interpreter.cc 2008-06-23 13:07:26 UTC (rev 290) @@ -2743,7 +2743,7 @@ assert(f.fp); e = 0; clock_t t0 = clock(); - pure_expr *res = pure_invoke(f.fp, e); + pure_expr *res = pure_invoke(f.fp, &e); if (interactive && stats) clocks = clock()-t0; // Get rid of our anonymous function. JIT->freeMachineCodeForFunction(f.f); @@ -2829,7 +2829,7 @@ assert(f.fp); e = 0; clock_t t0 = clock(); - pure_expr *res = pure_invoke(f.fp, e); + pure_expr *res = pure_invoke(f.fp, &e); if (interactive && stats) clocks = clock()-t0; // Get rid of our anonymous function. JIT->freeMachineCodeForFunction(f.f); Modified: pure/trunk/runtime.cc =================================================================== --- pure/trunk/runtime.cc 2008-06-23 11:10:39 UTC (rev 289) +++ pure/trunk/runtime.cc 2008-06-23 13:07:26 UTC (rev 290) @@ -755,8 +755,10 @@ } extern "C" -pure_expr *pure_invoke(void *f, pure_expr*& e) +pure_expr *pure_invoke(void *f, pure_expr** _e) { + assert(_e); + pure_expr*& e = *_e; interpreter& interp = *interpreter::g_interp; // Cast the function pointer to the right type (takes no arguments, returns // a pure_expr*), so we can call it as a native function. Modified: pure/trunk/runtime.h =================================================================== --- pure/trunk/runtime.h 2008-06-23 11:10:39 UTC (rev 289) +++ pure/trunk/runtime.h 2008-06-23 13:07:26 UTC (rev 290) @@ -127,12 +127,9 @@ /* Run a Pure function and catch exceptions. If everything goes normal, pure_invoke returns the return value of the executed function. Otherwise it returns 0 and sets e to the exception value, as given by pure_throw(). - XXXFIXME: This only works with C++ and only supports parameterless - functions right now. */ + XXXFIXME: This only supports parameterless functions right now. */ -#ifdef __cplusplus -pure_expr *pure_invoke(void *f, pure_expr*& e); -#endif +pure_expr *pure_invoke(void *f, pure_expr** e); /* Count a new reference to an expression. This should be called whenever you want to store an expression somewhere, in order to prevent it from being This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ag...@us...> - 2008-06-23 11:10:32
|
Revision: 289 http://pure-lang.svn.sourceforge.net/pure-lang/?rev=289&view=rev Author: agraef Date: 2008-06-23 04:10:39 -0700 (Mon, 23 Jun 2008) Log Message: ----------- Add some remarks about implementation restrictions of 'as' patterns. Modified Paths: -------------- pure/trunk/pure.1.in Modified: pure/trunk/pure.1.in =================================================================== --- pure/trunk/pure.1.in 2008-06-23 10:26:04 UTC (rev 288) +++ pure/trunk/pure.1.in 2008-06-23 11:10:39 UTC (rev 289) @@ -1185,6 +1185,28 @@ them around as function values or partial applications, but in this case they lose all their special call-by-name argument processing. .PP +.B ``As'' patterns. +In the current implementation, ``as'' patterns cannot be placed on the +``spine'' of a function definition. Thus rules like the following, which have +the pattern somewhere in the head of the left-hand side, will all provoke an +error message from the compiler: +.sp +.nf +a@foo x y = a,x,y; +a@(foo x) y = a,x,y; +a@(foo x y) = a,x,y; +.fi +.PP +This is because the spine of a function application is not available when the +function is called at runtime. ``As'' patterns in pattern bindings are not +affected by this restriction since the entire value to be matched is available +at runtime. For instance: +.sp +.nf +> \fBcase\fP bar 99 \fBof\fP y@(bar x) = y,x+1; \fBend\fP; +bar 99,100 +.fi +.PP .B Manipulating function applications. The ``head = function'' rule means that the head symbol f of an application f x1 ... xn occurring on (or inside) the left-hand side of an equation, pattern This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ag...@us...> - 2008-06-23 10:25:57
|
Revision: 288 http://pure-lang.svn.sourceforge.net/pure-lang/?rev=288&view=rev Author: agraef Date: 2008-06-23 03:26:04 -0700 (Mon, 23 Jun 2008) Log Message: ----------- Elaborate on declaration syntax. Modified Paths: -------------- pure/trunk/pure.1.in Modified: pure/trunk/pure.1.in =================================================================== --- pure/trunk/pure.1.in 2008-06-23 01:41:19 UTC (rev 287) +++ pure/trunk/pure.1.in 2008-06-23 10:26:04 UTC (rev 288) @@ -679,9 +679,11 @@ \fBinfixl\fP 7 * / div mod ; .fi .sp -Moreover, constant symbols are introduced using a declaration of -the form: +Note that to declare multiple symbols in a single declaration, you just list +them all with whitespace in between. .sp +Similarly, constant symbols are introduced using a declaration of the form: +.sp .nf \fBnullary \fIsymbol\fR ...; .fi This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ag...@us...> - 2008-06-23 01:41:12
|
Revision: 287 http://pure-lang.svn.sourceforge.net/pure-lang/?rev=287&view=rev Author: agraef Date: 2008-06-22 18:41:19 -0700 (Sun, 22 Jun 2008) Log Message: ----------- Add special '@' symbol. Modified Paths: -------------- pure/trunk/etc/pure.lang Modified: pure/trunk/etc/pure.lang =================================================================== --- pure/trunk/etc/pure.lang 2008-06-23 01:33:45 UTC (rev 286) +++ pure/trunk/etc/pure.lang 2008-06-23 01:41:19 UTC (rev 287) @@ -17,7 +17,7 @@ $DIGIT=regex(0[xX][0-9a-fA-F]+L?|\d+(?:\.\d+)?(?:[eE][\-\+]\d+)?L?) # Other special symbols (lambda, parens, list brackets, type tags). -$SYMBOLS= \ ( ) [ ] :: +$SYMBOLS= \ ( ) [ ] :: @ # Double-quoted strings and escapes. $STRINGDELIMITERS=" This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ag...@us...> - 2008-06-23 01:33:36
|
Revision: 286 http://pure-lang.svn.sourceforge.net/pure-lang/?rev=286&view=rev Author: agraef Date: 2008-06-22 18:33:45 -0700 (Sun, 22 Jun 2008) Log Message: ----------- Update documentation. Modified Paths: -------------- pure/trunk/pure.1.in Modified: pure/trunk/pure.1.in =================================================================== --- pure/trunk/pure.1.in 2008-06-23 00:39:49 UTC (rev 285) +++ pure/trunk/pure.1.in 2008-06-23 01:33:45 UTC (rev 286) @@ -178,8 +178,8 @@ .sp .nf > // my first Pure example -> fact 1 = 1; -> fact n::int = n*fact (n-1) \fBif\fP n>1; +> fact 0 = 1; +> fact n::int = n*fact (n-1) \fBif\fP n>0; > \fBlet\fP x = fact 10; x; 3628800 .fi @@ -215,22 +215,31 @@ (a+b)*(a+b) .fi .PP -The Pure language provides built-in support for machine integers (32 bit), -bigints (implemented using GMP), floating point values (double precision -IEEE), character strings (UTF-8 encoded) and generic C pointers (these don't -have a syntactic representation in Pure, though, so they need to be created -with external C functions). Truth values are encoded as machine integers (as -you might expect, zero denotes ``false'' and any non-zero value ``true''). +In fact, all the Pure interpreter does is evaluating expressions in a symbolic +fashion, rewriting expressions using the equations supplied by the programmer, +until no more equations are applicable. The result of this process is called a +.I "normal form" +which represents the ``value'' of the original expression. Keeping with the +tradition of term rewriting, there's no distinction between ``defined'' and +``constructor'' function symbols in Pure; any function symbol (or operator) +also acts as a constructor if it happens to occur in a normal form term. .PP Expressions are generally evaluated from left to right, innermost expressions first, i.e., using -.I call by value +.I "call by value" semantics. Pure also has a few built-in special forms (most notably, conditional expressions and the short-circuit logical connectives && and ||) which take some of their arguments using -.I call by name +.I "call by name" semantics. .PP +The Pure language provides built-in support for machine integers (32 bit), +bigints (implemented using GMP), floating point values (double precision +IEEE), character strings (UTF-8 encoded) and generic C pointers (these don't +have a syntactic representation in Pure, though, so they need to be created +with external C functions). Truth values are encoded as machine integers (as +you might expect, zero denotes ``false'' and any non-zero value ``true''). +.PP Expressions consist of the following elements: .TP .B Constants: \fR4711, 4711L, 1.2e-3, \(dqHello,\ world!\en\(dq @@ -266,18 +275,18 @@ .TP .B Function and variable symbols: \fRfoo, foo_bar, BAR, bar2 These consist of the usual sequence of ASCII letters (including the -underscore) and digits, starting with a letter. Case is significant, but it -doesn't carry any meaning (that's in contrast to languages like Prolog and Q, -where variables must be capitalized). Pure simply distinguishes function and -variable symbols on the left-hand side of an equation by the ``head = -function'' rule: Any symbol which occurs as the head symbol of a function +underscore) and digits, starting with a letter. The `_' symbol, when occurring +on the left-hand side of an equation, is special; it denotes the +.IR "anonymous variable" . +The case of identifiers is significant, but it doesn't carry any meaning +(that's in contrast to languages like Prolog and Q, where variables must be +capitalized). Instead, Pure distinguishes function and variable symbols on the +left-hand side of an equation by the ``head = function'' rule: Any symbol +(except the anonymous variable) which occurs as the head symbol of a function application is a function symbol, all other symbols are variables -- except symbols explicitly declared as ``constant'' a.k.a. .B nullary -symbols, see below. Another important thing to know is that in Pure, keeping -with the tradition of term rewriting, there's no distinction between -``defined'' and ``constructor'' function symbols; any function symbol can also -act as a constructor if it happens to occur in a normal form term. +symbols, see below. .TP .B Operator and constant symbols: \fRx+y, x==y, \fBnot\fP\ x As indicated, these take the form of an identifier or a sequence of ASCII @@ -417,9 +426,8 @@ binding.) .PP In any case, the left-hand side pattern must not contain repeated variables -(i.e., rules must be ``left-linear''), except for the ``anonymous'' variable -`_' which matches an arbitrary value without binding a variable -symbol. +(i.e., rules must be ``left-linear''), except for the anonymous variable `_' +which matches an arbitrary value without binding a variable symbol. .PP A left-hand side variable may be followed by one of the special type tags \fB::int\fP, \fB::bigint\fP, \fB::double\fP, \fB::string\fP, to indicate that @@ -1180,23 +1188,20 @@ x1 ... xn occurring on (or inside) the left-hand side of an equation, pattern binding, or pattern-matching lambda expression, is always interpreted as a literal function symbol (not a variable). This implies that you cannot match -the ``function'' component of an application against a variable, and thus you -cannot directly define a generic function which operates on arbitrary function -applications. As a remedy, the prelude provides three operations to handle -such objects: -.BR applp , -a predicate which checks whether a given expression is a function application, -and -.B fun -and -.BR arg , -which determine the function and argument parts of such an expression, -respectively. (This may seem a little awkward, but as a matter of fact the -``head = function'' rule is quite convenient since it covers the common cases -without forcing the programmer to declare ``constructor'' symbols (except -nullary symbols). Also note that in standard term rewriting you do not have -rules parameterizing over the head symbol of a function application either.) +the ``function'' component of an application against a variable, at least not +directly. However, an anonymous ``as'' pattern like f@_ will do the trick, +since the anonymous variable is always recognized, even if it occurs as the +head symbol of a function application. .PP +This may seem a little awkward, but as a matter of fact the ``head = +function'' rule is quite useful since it covers the common cases without +forcing the programmer to declare ``constructor'' symbols (except nullary +symbols). On the other hand, generic rules operating on arbitrary function +applications are not all that common, so having to ``escape'' a variable using +the anonymous ``as'' pattern trick is a small price to pay for that +convenience. Moreover, the prelude also provides operations to recognize and +decompose function applications. +.PP .B Numeric types. If possible, you should always decorate numeric variables on the left-hand sides of function definitions with the appropriate type tags, like @@ -1204,7 +1209,17 @@ or .BR ::double . This often helps the compiler to generate better code and makes your programs -run faster. +run faster. The `|' syntax makes it easy to add the necessary specializations +of existing rules to your program. E.g., taking the polymorphic implementation +of the factorial as an example, you only have to add a left-hand side with the +appropriate type tag to make that definition go as fast as possible for the +special case of machine integers: +.sp +.nf +fact n::int | +fact n = n*fact(n-1) \fBif\fP n>0; + = 1 \fBotherwise\fP; +.fi .PP Talking about the built-in types, please note that .B int This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ag...@us...> - 2008-06-23 00:39:41
|
Revision: 285 http://pure-lang.svn.sourceforge.net/pure-lang/?rev=285&view=rev Author: agraef Date: 2008-06-22 17:39:49 -0700 (Sun, 22 Jun 2008) Log Message: ----------- Updated ChangeLog. Modified Paths: -------------- pure/trunk/ChangeLog Modified: pure/trunk/ChangeLog =================================================================== --- pure/trunk/ChangeLog 2008-06-23 00:07:02 UTC (rev 284) +++ pure/trunk/ChangeLog 2008-06-23 00:39:49 UTC (rev 285) @@ -1,7 +1,9 @@ 2008-06-22 Albert Graef <Dr....@t-...> * expr.cc, interpreter.cc, parser.yy, lexer.ll, printer.cc: - Implement Haskell-like "as" patterns. + Implement Haskell-style "as" patterns. Also make sure that '_' on + the lhs is always treated as the anonymous variable, even if it + occurs as the head symbol in a function application. 2008-06-21 Albert Graef <Dr....@t-...> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ag...@us...> - 2008-06-23 00:06:57
|
Revision: 284 http://pure-lang.svn.sourceforge.net/pure-lang/?rev=284&view=rev Author: agraef Date: 2008-06-22 17:07:02 -0700 (Sun, 22 Jun 2008) Log Message: ----------- '_' on the lhs should always be the anonymous variable, even if it occurs as the head symbol of a function application. Modified Paths: -------------- pure/trunk/interpreter.cc Modified: pure/trunk/interpreter.cc =================================================================== --- pure/trunk/interpreter.cc 2008-06-22 23:55:56 UTC (rev 283) +++ pure/trunk/interpreter.cc 2008-06-23 00:07:02 UTC (rev 284) @@ -1052,8 +1052,9 @@ default: assert(x.tag() > 0); const symbol& sym = symtab.sym(x.tag()); - if (sym.prec < 10 || sym.fix == nullary || p.len() == 0 && !b || - p.len() > 0 && p.last() == 0) { + if (sym.s != "_" && + (sym.prec < 10 || sym.fix == nullary || p.len() == 0 && !b || + p.len() > 0 && p.last() == 0)) { // constant or constructor if (x.ttag() != 0) throw err("error in pattern (misplaced type tag)"); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ag...@us...> - 2008-06-22 23:55:47
|
Revision: 283 http://pure-lang.svn.sourceforge.net/pure-lang/?rev=283&view=rev Author: agraef Date: 2008-06-22 16:55:56 -0700 (Sun, 22 Jun 2008) Log Message: ----------- Correction: Placing an "as" pattern at the spine of a function application causes trouble; forbid this. Modified Paths: -------------- pure/trunk/interpreter.cc Modified: pure/trunk/interpreter.cc =================================================================== --- pure/trunk/interpreter.cc 2008-06-22 23:08:38 UTC (rev 282) +++ pure/trunk/interpreter.cc 2008-06-22 23:55:56 UTC (rev 283) @@ -1028,7 +1028,7 @@ case EXPR::APP: { if (p.len() >= MAXDEPTH) throw err("error in pattern (nesting too deep)"); - expr u = bind(vars, x.xval1(), 1, path(p, 0)), + expr u = bind(vars, x.xval1(), b, path(p, 0)), v = bind(vars, x.xval2(), 1, path(p, 1)); y = expr(u, v); break; @@ -1075,7 +1075,10 @@ if (sym.s != "_") { if (sym.prec < 10 || sym.fix == nullary) throw err("error in pattern (bad variable symbol '"+sym.s+"')"); - if (p.len() == 0 && !b || x.tag() > 0 && p.len() > 0 && p.last() == 0) + // Unless we're doing a pattern binding, subterms at the spine of a + // function application won't be available at runtime, so we forbid + // placing an "as" pattern there. + if (!b) throw err("error in pattern (misplaced variable '"+sym.s+"')"); env::iterator it = vars.find(sym.f); if (it != vars.end()) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ag...@us...> - 2008-06-22 23:08:30
|
Revision: 282 http://pure-lang.svn.sourceforge.net/pure-lang/?rev=282&view=rev Author: agraef Date: 2008-06-22 16:08:38 -0700 (Sun, 22 Jun 2008) Log Message: ----------- Placing an "as" pattern at the head symbol of a function application causes trouble; forbid this. Modified Paths: -------------- pure/trunk/interpreter.cc Modified: pure/trunk/interpreter.cc =================================================================== --- pure/trunk/interpreter.cc 2008-06-22 22:54:24 UTC (rev 281) +++ pure/trunk/interpreter.cc 2008-06-22 23:08:38 UTC (rev 282) @@ -1075,7 +1075,7 @@ if (sym.s != "_") { if (sym.prec < 10 || sym.fix == nullary) throw err("error in pattern (bad variable symbol '"+sym.s+"')"); - if (p.len() == 0 && !b) + if (p.len() == 0 && !b || x.tag() > 0 && p.len() > 0 && p.last() == 0) throw err("error in pattern (misplaced variable '"+sym.s+"')"); env::iterator it = vars.find(sym.f); if (it != vars.end()) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ag...@us...> - 2008-06-22 22:54:15
|
Revision: 281 http://pure-lang.svn.sourceforge.net/pure-lang/?rev=281&view=rev Author: agraef Date: 2008-06-22 15:54:24 -0700 (Sun, 22 Jun 2008) Log Message: ----------- Update documentation. Modified Paths: -------------- pure/trunk/pure.1.in Modified: pure/trunk/pure.1.in =================================================================== --- pure/trunk/pure.1.in 2008-06-22 21:07:57 UTC (rev 280) +++ pure/trunk/pure.1.in 2008-06-22 22:54:24 UTC (rev 281) @@ -392,10 +392,9 @@ .B otherwise denoting an empty guard which is always true (this is nothing but syntactic sugar to point out the ``default'' case of a definition; the interpreter just -treats this as a comment). -.sp -Pure also provides some abbreviations for factoring out common left-hand or -right-hand sides in collections of rules; see below for details. +treats this as a comment). Pure also provides some abbreviations for factoring +out common left-hand or right-hand sides in collections of rules; see section +RULE SYNTAX below for details. .TP .B Global variable bindings: let\fR \fIlhs\fR = \fIrhs\fR; This binds every variable in the left-hand side pattern to the corresponding @@ -405,27 +404,46 @@ A singleton expression at the toplevel, terminated with a semicolon, simply causes the given value to be evaluated (and the result to be printed, when running in interactive mode). -.PP +.SH RULE SYNTAX Basically, the same rule syntax is used to define functions at the toplevel -and in \fBwith\fP expressions, as well as inside \fBcase\fP and \fBwhen\fP -expressions for the purpose of performing pattern bindings (however, for -obvious reasons guards are not permitted in \fBwhen\fP expressions). When -matching against a function call or the subject term in a \fBcase\fP -expression, the rules are always considered in the order in which they are -written, and the first matching rule (whose guard evaluates to a nonzero -value, if applicable) is picked. (Again, the \fBwhen\fP construct is treated -differently, because each rule is actually a separate pattern binding.) +and in \fBwith\fP expressions, as well as inside \fBcase\fP, \fBwhen\fP and +\fBlet\fP expressions for the purpose of performing pattern bindings (however, +for obvious reasons guards are not permitted in \fBwhen\fP and \fBlet\fP +expressions). When matching against a function call or the subject term in a +\fBcase\fP expression, the rules are always considered in the order in which +they are written, and the first matching rule (whose guard evaluates to a +nonzero value, if applicable) is picked. (Again, the \fBwhen\fP construct is +treated differently, because each rule is actually a separate pattern +binding.) .PP In any case, the left-hand side pattern must not contain repeated variables (i.e., rules must be ``left-linear''), except for the ``anonymous'' variable `_' which matches an arbitrary value without binding a variable -symbol. Moreover, a left-hand side variable may be followed by one of the -special type tags \fB::int\fP, \fB::bigint\fP, \fB::double\fP, \fB::string\fP, -to indicate that it can only match a constant value of the corresponding -built-in type. (This is useful if you want to write rules matching \fIany\fP -object of one of these types; note that there is no way to write out all -``constructors'' for the built-in types, as there are infinitely many.) +symbol. .PP +A left-hand side variable may be followed by one of the special type tags +\fB::int\fP, \fB::bigint\fP, \fB::double\fP, \fB::string\fP, to indicate that +it can only match a constant value of the corresponding built-in type. (This +is useful if you want to write rules matching \fIany\fP object of one of these +types; note that there is no way to write out all ``constructors'' for the +built-in types, as there are infinitely many.) +.PP +Pure also supports Haskell-style ``as'' patterns of the form +.IB variable @ pattern +which binds the given variable to the expression matched by the subpattern +.I pattern +(in addition to the variables bound by +.I pattern +itself). This is convenient if the value matched by the subpattern is to be +used on the right-hand side of an equation. Syntactically, `as'' patterns are +primary expressions; if the subpattern is not a primary expression, it must be +parenthesized. For instance, the following function duplicates the head +element of a list: +.sp +.nf +foo xs@(x:_) = x:xs; +.fi +.PP The left-hand side of a rule can be omitted if it is the same as for the previous rule. This provides a convenient means to write out a collection of equations for the same left-hand side which discriminates over different @@ -438,6 +456,13 @@ = \fIrhs\fP \fBotherwise\fP; .fi .PP +For instance: +.sp +.nf +fact n = n*fact (n-1) \fBif\fP n>0; + = 1 \fBotherwise\fP; +.fi +.PP Pure also allows a collection of rules with different left-hand sides but the same right-hand side(s) to be abbreviated as follows: .sp @@ -464,7 +489,19 @@ foo x | bar y = x*y; .fi .PP -The same works in +However, this is most useful when using an ``as'' pattern to bind a common +variable to a parameter value +.I after +checking that it matches one of several possible argument patterns (which is +slightly more efficient than using an equivalent type-checking guard). E.g., +the following definition binds the xs variable to the parameter of foo, if it +is either the empty list or a list starting with an integer: +.sp +.nf +foo xs@[] | foo xs@(_::int:_) = ... xs ...; +.fi +.PP +The same construct also works in .B case expressions, which is convenient if different cases should be mapped to the same value, e.g.: @@ -473,13 +510,11 @@ \fBcase\fP ans \fBof\fP "y" | "Y" = 1; _ = 0; \fBend\fP; .fi .PP -Here are some more definitions showing most of the elements discussed above in -action: +Here are a few more examples of rules illustrating some of the constructs +introduced above and in the previous section. The first one is a definition of +a function which generates the Fibonacci numbers: .sp .nf -fact n = n*fact (n-1) \fBif\fP n>0; - = 1 \fBotherwise\fP; - fib n = a \fBwhen\fP a, b = fibs n \fBend\fP \fBwith\fP fibs n = 0, 1 \fBif\fP n<=0; = \fBcase\fP fibs (n-1) \fBof\fP @@ -487,12 +522,11 @@ \fBend\fP; \fBend\fP; -\fBlet\fP facts = map fact (1..10); \fBlet\fP fibs = map fib (1..100); -facts; fibs; +\fBlet\fP fibs = map fib (1..100); +fibs; .fi .PP -This is a little list comprehension example: Erathosthenes' classical prime -sieve. +A little list comprehension example (Erathosthenes' classical prime sieve): .sp .nf primes n = sieve (2..n) \fBwith\fP This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ag...@us...> - 2008-06-22 21:07:49
|
Revision: 280 http://pure-lang.svn.sourceforge.net/pure-lang/?rev=280&view=rev Author: agraef Date: 2008-06-22 14:07:57 -0700 (Sun, 22 Jun 2008) Log Message: ----------- Updated ChangeLog. Modified Paths: -------------- pure/trunk/ChangeLog Modified: pure/trunk/ChangeLog =================================================================== --- pure/trunk/ChangeLog 2008-06-22 21:07:18 UTC (rev 279) +++ pure/trunk/ChangeLog 2008-06-22 21:07:57 UTC (rev 280) @@ -1,7 +1,7 @@ 2008-06-22 Albert Graef <Dr....@t-...> - * expr.cc, interpreter.cc, parser.yy, lexer.ll: Implement - Haskell-like "as" patterns. + * expr.cc, interpreter.cc, parser.yy, lexer.ll, printer.cc: + Implement Haskell-like "as" patterns. 2008-06-21 Albert Graef <Dr....@t-...> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ag...@us...> - 2008-06-22 21:07:09
|
Revision: 279 http://pure-lang.svn.sourceforge.net/pure-lang/?rev=279&view=rev Author: agraef Date: 2008-06-22 14:07:18 -0700 (Sun, 22 Jun 2008) Log Message: ----------- Implement Haskell-like "as" patterns. Modified Paths: -------------- pure/trunk/ChangeLog pure/trunk/expr.cc pure/trunk/expr.hh pure/trunk/interpreter.cc pure/trunk/interpreter.hh pure/trunk/lexer.ll pure/trunk/parser.yy pure/trunk/printer.cc Modified: pure/trunk/ChangeLog =================================================================== --- pure/trunk/ChangeLog 2008-06-21 22:23:15 UTC (rev 278) +++ pure/trunk/ChangeLog 2008-06-22 21:07:18 UTC (rev 279) @@ -1,3 +1,8 @@ +2008-06-22 Albert Graef <Dr....@t-...> + + * expr.cc, interpreter.cc, parser.yy, lexer.ll: Implement + Haskell-like "as" patterns. + 2008-06-21 Albert Graef <Dr....@t-...> * etc/pure-mode.el.in, etc/pure.vim, etc/pure.xml, etc/pure.lang: Modified: pure/trunk/expr.cc =================================================================== --- pure/trunk/expr.cc 2008-06-21 22:23:15 UTC (rev 278) +++ pure/trunk/expr.cc 2008-06-22 21:07:18 UTC (rev 279) @@ -44,6 +44,7 @@ if (data.c.e) delete data.c.e; break; } + if (aspath) delete aspath; } map<EXPR*,uint32_t> expr::h; Modified: pure/trunk/expr.hh =================================================================== --- pure/trunk/expr.hh 2008-06-21 22:23:15 UTC (rev 278) +++ pure/trunk/expr.hh 2008-06-22 21:07:18 UTC (rev 279) @@ -146,60 +146,64 @@ // extra built-in type tag used in code generation: int8_t ttag; + // "as" patterns: + int32_t astag; + path *aspath; + EXPR *incref() { refc++; return this; } uint32_t decref() { if (refc > 0) --refc; return refc; } void del() { if (decref() == 0) delete this; } static EXPR *newref(EXPR *x) { return x?x->incref():0; } EXPR(int32_t _tag) : - refc(0), tag(_tag), m(0), ttag(0) { } + refc(0), tag(_tag), m(0), ttag(0), astag(0), aspath(0) { } EXPR(int32_t _tag, int32_t _vtag, uint8_t _idx, int8_t _ttag = 0, const path& _p = path()) : - refc(0), tag(_tag), m(0), ttag(_ttag) + refc(0), tag(_tag), m(0), ttag(_ttag), astag(0), aspath(0) { assert(_tag == VAR || _tag == FVAR); data.v.vtag = _vtag; data.v.idx = _idx; data.v.p = (_tag == VAR)?new path(_p):0; } EXPR(int32_t _tag, int32_t _i) : - refc(0), tag(_tag), m(0), ttag(_tag) + refc(0), tag(_tag), m(0), ttag(_tag), astag(0), aspath(0) { assert(_tag == INT); data.i = _i; } EXPR(int32_t _tag, mpz_t _z) : - refc(0), tag(_tag), m(0), ttag(_tag) + refc(0), tag(_tag), m(0), ttag(_tag), astag(0), aspath(0) { assert(_tag == BIGINT); mpz_init_set(data.z, _z); mpz_clear(_z); } EXPR(int32_t _tag, double _d) : - refc(0), tag(_tag), m(0), ttag(_tag) + refc(0), tag(_tag), m(0), ttag(_tag), astag(0), aspath(0) { assert(_tag == DBL); data.d = _d; } explicit EXPR(int32_t _tag, char *_s) : - refc(0), tag(_tag), m(0), ttag(_tag) + refc(0), tag(_tag), m(0), ttag(_tag), astag(0), aspath(0) { assert(_tag == STR); data.s = _s; } explicit EXPR(int32_t _tag, void *_p) : - refc(0), tag(_tag), m(0), ttag(_tag) + refc(0), tag(_tag), m(0), ttag(_tag), astag(0), aspath(0) { assert(_tag == PTR); data.p = _p; } EXPR(int32_t _tag, EXPR *_arg1, EXPR *_arg2, EXPR *_arg3) : - refc(0), tag(_tag), m(0), ttag(0) + refc(0), tag(_tag), m(0), ttag(0), astag(0), aspath(0) { assert(_tag == COND); data.x[0] = newref(_arg1); data.x[1] = newref(_arg2); data.x[2] = newref(_arg3); } EXPR(int32_t _tag, EXPR *_arg, EXPR *_body) : - refc(0), tag(_tag), m(0), ttag(0) + refc(0), tag(_tag), m(0), ttag(0), astag(0), aspath(0) { assert(_tag == LAMBDA); data.x[0] = newref(_arg); data.x[1] = newref(_body); } EXPR(int32_t _tag, EXPR *_arg, rulel *_rules) : - refc(0), tag(_tag), m(0), ttag(0) + refc(0), tag(_tag), m(0), ttag(0), astag(0), aspath(0) { assert(_tag == CASE || _tag == WHEN); data.c.x = newref(_arg); data.c.r = _rules; } EXPR(int32_t _tag, EXPR *_arg, env *_e) : - refc(0), tag(_tag), m(0), ttag(0) + refc(0), tag(_tag), m(0), ttag(0), astag(0), aspath(0) { assert(_tag == WITH); data.c.x = newref(_arg); data.c.e = _e; } EXPR(EXPR *_fun, EXPR *_arg) : - refc(0), tag(APP), m(0), ttag(0) + refc(0), tag(APP), m(0), ttag(0), astag(0), aspath(0) { data.x[0] = newref(_fun); data.x[1] = newref(_arg); } EXPR(EXPR *_fun, EXPR *_arg1, EXPR *_arg2) : - refc(0), tag(APP), m(0), ttag(0) + refc(0), tag(APP), m(0), ttag(0), astag(0), aspath(0) { data.x[0] = new EXPR(_fun, _arg1); data.x[0]->incref(); data.x[1] = newref(_arg2); } EXPR(EXPR *_fun, EXPR *_arg1, EXPR *_arg2, EXPR *_arg3) : - refc(0), tag(APP), m(0), ttag(0) + refc(0), tag(APP), m(0), ttag(0), astag(0), aspath(0) { data.x[0] = new EXPR(_fun, _arg1, _arg2); data.x[0]->incref(); data.x[1] = newref(_arg3); } @@ -333,8 +337,13 @@ p->tag == EXPR::CASE || p->tag == EXPR::WHEN); return p->m; } + int32_t astag() const { return p->astag; } + path &aspath() const { assert(p->aspath); return *p->aspath; } void set_ttag(int8_t tag) { p->ttag = tag; } + void set_astag(int32_t tag) { p->astag = tag; } + void set_aspath(const path& _p) + { if (p->aspath) delete p->aspath; p->aspath = new path(_p); } bool is_null() const { return p==0; } bool is_fun() const { return p->tag > 0; } Modified: pure/trunk/interpreter.cc =================================================================== --- pure/trunk/interpreter.cc 2008-06-21 22:23:15 UTC (rev 278) +++ pure/trunk/interpreter.cc 2008-06-22 21:07:18 UTC (rev 279) @@ -671,6 +671,10 @@ void interpreter::build_env(env& vars, expr x) { assert(!x.is_null()); + if (x.astag() > 0) { + const symbol& sym = symtab.sym(x.astag()); + if (sym.s != "_") vars[sym.f] = env_info(0, x.aspath()); + } switch (x.tag()) { case EXPR::VAR: { const symbol& sym = symtab.sym(x.vtag()); @@ -999,6 +1003,7 @@ expr interpreter::bind(env& vars, expr x, bool b, path p) { assert(!x.is_null()); + expr y; switch (x.tag()) { case EXPR::VAR: { // previously bound variable (successor rule) @@ -1007,7 +1012,8 @@ assert(p == x.vpath()); vars[sym.f] = env_info(x.ttag(), p); } - return x; + y = x; + break; } // constants: case EXPR::FVAR: @@ -1016,26 +1022,33 @@ case EXPR::DBL: case EXPR::STR: case EXPR::PTR: - return x; + y = x; + break; // application: case EXPR::APP: { if (p.len() >= MAXDEPTH) throw err("error in pattern (nesting too deep)"); expr u = bind(vars, x.xval1(), 1, path(p, 0)), v = bind(vars, x.xval2(), 1, path(p, 1)); - return expr(u, v); + y = expr(u, v); + break; } // these must not occur on the lhs: case EXPR::LAMBDA: throw err("lambda expression not permitted in pattern"); + break; case EXPR::COND: throw err("conditional expression not permitted in pattern"); + break; case EXPR::CASE: throw err("case expression not permitted in pattern"); + break; case EXPR::WHEN: throw err("when expression not permitted in pattern"); + break; case EXPR::WITH: throw err("with expression not permitted in pattern"); + break; default: assert(x.tag() > 0); const symbol& sym = symtab.sym(x.tag()); @@ -1043,17 +1056,37 @@ p.len() > 0 && p.last() == 0) { // constant or constructor if (x.ttag() != 0) - throw err("error in expression (misplaced type tag)"); - return x; + throw err("error in pattern (misplaced type tag)"); + y = x; + } else { + env::iterator it = vars.find(sym.f); + if (sym.s != "_") { // '_' = anonymous variable + if (it != vars.end()) + throw err("error in pattern (repeated variable '"+sym.s+"')"); + vars[sym.f] = env_info(x.ttag(), p); + } + y = expr(EXPR::VAR, sym.f, 0, x.ttag(), p); } - env::iterator it = vars.find(sym.f); - if (sym.s != "_") { // '_' = anonymous variable - if (it != vars.end()) + break; + } + // check for "as" patterns + if (x.astag() > 0) { + const symbol& sym = symtab.sym(x.astag()); + if (sym.s != "_") { + if (sym.prec < 10 || sym.fix == nullary) + throw err("error in pattern (bad variable symbol '"+sym.s+"')"); + if (p.len() == 0 && !b) + throw err("error in pattern (misplaced variable '"+sym.s+"')"); + env::iterator it = vars.find(sym.f); + if (it != vars.end()) { throw err("error in pattern (repeated variable '"+sym.s+"')"); - vars[sym.f] = env_info(x.ttag(), p); + } + vars[sym.f] = env_info(0, p); + y.set_astag(x.astag()); + y.set_aspath(p); } - return expr(EXPR::VAR, sym.f, 0, x.ttag(), p); } + return y; } void interpreter::promote_ttags(expr f, expr x, expr u) @@ -1124,6 +1157,8 @@ expr interpreter::subst(const env& vars, expr x, uint8_t idx) { if (x.is_null()) return x; + if (x.astag() > 0) + throw err("error in expression (misplaced \"as\" pattern)"); switch (x.tag()) { // constants: case EXPR::VAR: @@ -1373,7 +1408,12 @@ expr *x; const symbol &sym = symtab.sym(*s); if (tag == 0) - x = new expr(sym.x); + if (*s == "_") + // Return a new instance here, since the anonymous variable may have + // multiple occurrences on the lhs. + x = new expr(sym.f); + else + x = new expr(sym.x); else if (sym.f <= 0 || sym.prec < 10 || sym.fix == nullary) throw err("error in expression (misplaced type tag)"); else { @@ -1385,6 +1425,22 @@ return x; } +expr *interpreter::mkas_expr(string *s, expr *x) +{ + const symbol &sym = symtab.sym(*s); + if (sym.f <= 0 || sym.prec < 10 || sym.fix == nullary) + throw err("error in pattern (bad variable symbol '"+sym.s+"')"); + if (x->tag() > 0) { + // Avoid globbering cached function symbols. + expr *y = new expr(x->tag()); + delete x; + x = y; + } + x->set_astag(sym.f); + delete s; + return x; +} + expr *interpreter::mkcond_expr(expr *x, expr *y, expr *z) { expr *u = new expr(expr::cond(*x, *y, *z)); Modified: pure/trunk/interpreter.hh =================================================================== --- pure/trunk/interpreter.hh 2008-06-21 22:23:15 UTC (rev 278) +++ pure/trunk/interpreter.hh 2008-06-22 21:07:18 UTC (rev 279) @@ -369,6 +369,7 @@ expr *mkexpr(expr *x, expr *y); expr *mkexpr(expr *x, expr *y, expr *z); expr *mksym_expr(string *s, int8_t tag = 0); + expr *mkas_expr(string *s, expr *x); expr *mkcond_expr(expr *x, expr *y, expr *z); expr *mklambda_expr(exprl *args, expr *body); expr *mkcase_expr(expr *x, rulel *rules); Modified: pure/trunk/lexer.ll =================================================================== --- pure/trunk/lexer.ll 2008-06-21 22:23:15 UTC (rev 278) +++ pure/trunk/lexer.ll 2008-06-22 21:07:18 UTC (rev 279) @@ -755,7 +755,7 @@ return token::ID; } } -[=|;()\[\]\\] return yy::parser::token_type(yytext[0]); +[@=|;()\[\]\\] return yy::parser::token_type(yytext[0]); "->" return token::MAPSTO; [[:punct:]]+ { if (yytext[0] == '/' && yytext[1] == '*') REJECT; // comment starter Modified: pure/trunk/parser.yy =================================================================== --- pure/trunk/parser.yy 2008-06-21 22:23:15 UTC (rev 278) +++ pure/trunk/parser.yy 2008-06-22 21:07:18 UTC (rev 279) @@ -498,6 +498,11 @@ interp.error(yyloc, e.what()); $$ = interp.mksym_expr($1); } } +| ID '@' prim { try { $$ = interp.mkas_expr($1, $3); } + catch (err &e) { + interp.error(yyloc, e.what()); + $$ = $3; + } } | INT { $$ = new expr(EXPR::INT, $1); } | BIGINT { $$ = new expr(EXPR::BIGINT, *$1); free($1); } | DBL { $$ = new expr(EXPR::DBL, $1); } Modified: pure/trunk/printer.cc =================================================================== --- pure/trunk/printer.cc 2008-06-21 22:23:15 UTC (rev 278) +++ pure/trunk/printer.cc 2008-06-22 21:07:18 UTC (rev 279) @@ -53,9 +53,9 @@ } } -static prec_t expr_nprec(expr x) +static prec_t expr_nprec(expr x, bool aspat = true) { - if (x.is_null()) return 100; + if (x.is_null() || aspat && x.astag()>0) return 100; switch (x.tag()) { case EXPR::VAR: case EXPR::STR: @@ -119,7 +119,8 @@ : x(_x), pat(_pat) { } }; -static ostream& printx(ostream& os, const expr& x, bool pat); +static ostream& printx(ostream& os, const expr& x, bool pat, + bool aspat = true); ostream& operator << (ostream& os, const pattern& p) { @@ -162,11 +163,23 @@ } } -static ostream& printx(ostream& os, const expr& x, bool pat) +static ostream& printx(ostream& os, const expr& x, bool pat, bool aspat) { char buf[64]; if (x.is_null()) return os << "<<NULL>>"; //os << "{" << x.refc() << "}"; + // handle "as" patterns + if (aspat && x.astag()>0) { + const symbol& sym = interpreter::g_interp->symtab.sym(x.astag()); + if (expr_nprec(x, false) < 100) { + os << sym.s << "@("; + printx(os, x, pat, false); + return os << ")"; + } else { + os << sym.s << "@"; + return printx(os, x, pat, false); + } + } switch (x.tag()) { case EXPR::VAR: { const symbol& sym = interpreter::g_interp->symtab.sym(x.vtag()); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ag...@us...> - 2008-06-22 08:09:24
|
Revision: 276 http://pure-lang.svn.sourceforge.net/pure-lang/?rev=276&view=rev Author: agraef Date: 2008-06-21 06:18:27 -0700 (Sat, 21 Jun 2008) Log Message: ----------- Fix a glitch in the definition of foldr1 which caused list elements to be processed in the wrong order. Modified Paths: -------------- pure/trunk/ChangeLog pure/trunk/lib/prelude.pure Modified: pure/trunk/ChangeLog =================================================================== --- pure/trunk/ChangeLog 2008-06-21 11:13:10 UTC (rev 275) +++ pure/trunk/ChangeLog 2008-06-21 13:18:27 UTC (rev 276) @@ -1,3 +1,8 @@ +2008-06-21 Albert Graef <Dr....@t-...> + + * lib/prelude.pure: Fixed a glitch in the definition of foldr1 + which caused list elements to be processed in the wrong order. + 2008-06-20 Albert Graef <Dr....@t-...> * 0.4 release. Modified: pure/trunk/lib/prelude.pure =================================================================== --- pure/trunk/lib/prelude.pure 2008-06-21 11:13:10 UTC (rev 275) +++ pure/trunk/lib/prelude.pure 2008-06-21 13:18:27 UTC (rev 276) @@ -252,7 +252,7 @@ = f x (foldl (flip f) a (reverse xs)); foldr1 f [x] = x; -foldr1 f (x:xs) = foldr f x xs; +foldr1 f (x:xs) = f x (foldl1 (flip f) (reverse xs)); head (x:xs) = x; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ag...@us...> - 2008-06-22 04:52:44
|
Revision: 271 http://pure-lang.svn.sourceforge.net/pure-lang/?rev=271&view=rev Author: agraef Date: 2008-06-20 12:23:08 -0700 (Fri, 20 Jun 2008) Log Message: ----------- Cosmetic fixes. Modified Paths: -------------- pure/trunk/etc/pure.lang Modified: pure/trunk/etc/pure.lang =================================================================== --- pure/trunk/etc/pure.lang 2008-06-20 02:49:17 UTC (rev 270) +++ pure/trunk/etc/pure.lang 2008-06-20 19:23:08 UTC (rev 271) @@ -10,6 +10,9 @@ # Type identifiers used as tags and in extern declarations. $KW_LIST(kwc)=bigint bool char short int long double expr string pointer void +# Numbers. +$DIGIT=regex(0[xX][0-9a-fA-F]+L?|\d+(?:\.\d+)?(?:[eE][\-\+]\d+)?L?) + # Other special symbols (lambda, parens, list brackets, type tags). $SYMBOLS= \ ( ) [ ] :: This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ag...@us...> - 2008-06-22 01:56:22
|
Revision: 278 http://pure-lang.svn.sourceforge.net/pure-lang/?rev=278&view=rev Author: agraef Date: 2008-06-21 15:23:15 -0700 (Sat, 21 Jun 2008) Log Message: ----------- Update prelude test log. Modified Paths: -------------- pure/trunk/test/prelude.log Modified: pure/trunk/test/prelude.log =================================================================== --- pure/trunk/test/prelude.log 2008-06-21 21:43:52 UTC (rev 277) +++ pure/trunk/test/prelude.log 2008-06-21 22:23:15 UTC (rev 278) @@ -724,7 +724,7 @@ foldr f/*0:001*/ a/*0:01*/ [] = a/*0:01*/; foldr f/*0:001*/ a/*0:01*/ (x/*0:101*/:xs/*0:11*/) = f/*0:001*/ x/*0:101*/ (foldl (flip f/*0:001*/) a/*0:01*/ (reverse xs/*0:11*/)); foldr1 f/*0:01*/ [x/*0:101*/] = x/*0:101*/; -foldr1 f/*0:01*/ (x/*0:101*/:xs/*0:11*/) = foldr f/*0:01*/ x/*0:101*/ xs/*0:11*/; +foldr1 f/*0:01*/ (x/*0:101*/:xs/*0:11*/) = f/*0:01*/ x/*0:101*/ (foldl1 (flip f/*0:01*/) (reverse xs/*0:11*/)); head (x/*0:101*/:xs/*0:11*/) = x/*0:101*/; init [x/*0:101*/] = []; init (x/*0:101*/:xs/*0:11*/) = accum/*0*/ [x/*0:101*/] xs/*0:11*/ with accum ys/*0:01*/ [] = reverse ys/*0:01*/; accum ys/*0:01*/ (x/*0:101*/:xs/*0:11*/) = accum/*1*/ (x/*0:101*/:ys/*0:01*/) xs/*0:11*/; accum ys/*0:01*/ xs/*0:1*/ = reverse ys/*0:01*/+init xs/*0:1*/ { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ag...@us...> - 2008-06-21 21:43:45
|
Revision: 277 http://pure-lang.svn.sourceforge.net/pure-lang/?rev=277&view=rev Author: agraef Date: 2008-06-21 14:43:52 -0700 (Sat, 21 Jun 2008) Log Message: ----------- Cosmetic changes, all modes now highlight catch/throw. Modified Paths: -------------- pure/trunk/ChangeLog pure/trunk/etc/pure-mode.el.in pure/trunk/etc/pure.lang pure/trunk/etc/pure.vim pure/trunk/etc/pure.xml Modified: pure/trunk/ChangeLog =================================================================== --- pure/trunk/ChangeLog 2008-06-21 13:18:27 UTC (rev 276) +++ pure/trunk/ChangeLog 2008-06-21 21:43:52 UTC (rev 277) @@ -1,5 +1,8 @@ 2008-06-21 Albert Graef <Dr....@t-...> + * etc/pure-mode.el.in, etc/pure.vim, etc/pure.xml, etc/pure.lang: + Cosmetic changes, all modes now highlight catch/throw. + * lib/prelude.pure: Fixed a glitch in the definition of foldr1 which caused list elements to be processed in the wrong order. Modified: pure/trunk/etc/pure-mode.el.in =================================================================== --- pure/trunk/etc/pure-mode.el.in 2008-06-21 13:18:27 UTC (rev 276) +++ pure/trunk/etc/pure-mode.el.in 2008-06-21 21:43:52 UTC (rev 277) @@ -161,6 +161,7 @@ ; (list pure-prompt-regexp 0 'font-lock-preprocessor-face t) (list pure-msg-regexp 0 'font-lock-warning-face t) (list "::\\([A-Za-z_][A-Za-z_0-9]*\\)" 1 'font-lock-type-face) + (list "\\<\\(catch\\|throw\\)\\>" 0 'font-lock-builtin-face) (list (concat "\\<\\(" "case\\|e\\(lse\\|nd\\|xtern\\)\\|i\\(f\\|nfix[lr]?\\)\\|let\\|" @@ -174,6 +175,7 @@ (list (list "^#!.*" 0 'font-lock-comment-face t) (list "::\\([A-Za-z_][A-Za-z_0-9]*\\)" 1 'font-lock-type-face) + (list "\\<\\(catch\\|throw\\)\\>" 0 'font-lock-builtin-face) (list (concat "\\<\\(" "case\\|e\\(lse\\|nd\\|xtern\\)\\|i\\(f\\|nfix[lr]?\\)\\|let\\|" Modified: pure/trunk/etc/pure.lang =================================================================== --- pure/trunk/etc/pure.lang 2008-06-21 13:18:27 UTC (rev 276) +++ pure/trunk/etc/pure.lang 2008-06-21 21:43:52 UTC (rev 277) @@ -7,6 +7,9 @@ $KW_LIST(kwa)=infix infixl infixr prefix postfix nullary case else end extern if let of otherwise then using when with +# These aren't really keywords but we want them to stick out anyway. +$KW_LIST(kwb)=catch throw + # Type identifiers used as tags and in extern declarations. $KW_LIST(kwc)=bigint bool char short int long double expr string pointer void Modified: pure/trunk/etc/pure.vim =================================================================== --- pure/trunk/etc/pure.vim 2008-06-21 13:18:27 UTC (rev 276) +++ pure/trunk/etc/pure.vim 2008-06-21 21:43:52 UTC (rev 277) @@ -35,8 +35,9 @@ syn keyword pureKeyword infix infixl infixr prefix postfix nullary syn keyword pureKeyword case else end extern if let of otherwise then syn keyword pureKeyword using when with -syn keyword pureIdentifier bigint bool char short int long double -syn keyword pureIdentifier expr string pointer void +syn keyword pureSpecial catch throw +syn keyword pureType bigint bool char short int long double +syn keyword pureType expr string pointer void syn match pureNumber "\<[0-9]*\>" syn match pureHexNumber "\<0[Xx][0-9A-Fa-f]*\>" @@ -68,6 +69,8 @@ HiLink pureSpecialCharacter Special HiLink pureNumber Number HiLink pureHexNumber Number + HiLink pureType Type + HiLink pureSpecial Identifier HiLink pureIdentifier Identifier HiLink pureCommentError Error HiLink pureString String Modified: pure/trunk/etc/pure.xml =================================================================== --- pure/trunk/etc/pure.xml 2008-06-21 13:18:27 UTC (rev 276) +++ pure/trunk/etc/pure.xml 2008-06-21 21:43:52 UTC (rev 277) @@ -22,6 +22,10 @@ <item> when </item> <item> with </item> </list> + <list name="special"> + <item> catch </item> + <item> throw </item> + </list> <list name="types"> <item> bigint </item> <item> bool </item> @@ -38,7 +42,8 @@ <contexts> <context attribute="Normal Text" lineEndContext="#stay" name="Normal"> <keyword attribute="Keyword" context="#stay" String="keywords"/> - <keyword attribute="Conid" context="#stay" String="types"/> + <keyword attribute="Function" context="#stay" String="special"/> + <keyword attribute="Type" context="#stay" String="types"/> <RegExpr attribute="Normal Text" context="#stay" String="[A-Za-z_][A-Za-z0-9_]*"/> <RegExpr attribute="Number" context="#stay" String="0x[A-Za-z0-9]+"/> <Float attribute="Number" context="#stay"/> @@ -59,7 +64,8 @@ <itemDatas> <itemData name="Normal Text" defStyleNum="dsNormal" /> <itemData name="Keyword" defStyleNum="dsKeyword" /> - <itemData name="Conid" defStyleNum="dsDataType"/> + <itemData name="Function" defStyleNum="dsFunction"/> + <itemData name="Type" defStyleNum="dsDataType"/> <itemData name="Number" defStyleNum="dsDecVal" /> <itemData name="String" defStyleNum="dsString" /> <itemData name="Comment" defStyleNum="dsComment" /> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ag...@us...> - 2008-06-21 12:42:18
|
Revision: 274 http://pure-lang.svn.sourceforge.net/pure-lang/?rev=274&view=rev Author: agraef Date: 2008-06-21 03:58:01 -0700 (Sat, 21 Jun 2008) Log Message: ----------- Fix typo. Modified Paths: -------------- pure/trunk/ChangeLog Modified: pure/trunk/ChangeLog =================================================================== --- pure/trunk/ChangeLog 2008-06-20 22:29:34 UTC (rev 273) +++ pure/trunk/ChangeLog 2008-06-21 10:58:01 UTC (rev 274) @@ -67,9 +67,9 @@ * pure.cc: Added new -q (quiet) and -x (execute) options. The former is used in pure-mode.el to suppress the sign-on message of - the interpreter. The latter can be used in conjuction with the new - #! comment syntax to add shebangs to your script, see the manpage - for details. + the interpreter. The latter can be used in conjunction with the + new #! comment syntax to add shebangs to your script, see the + manpage for details. * pure-mode.el.in: Added new Emacs Pure mode. This is a quick and dirty hack of Q mode and still needs some work (in particular, This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ag...@us...> - 2008-06-21 11:19:54
|
Revision: 275 http://pure-lang.svn.sourceforge.net/pure-lang/?rev=275&view=rev Author: agraef Date: 2008-06-21 04:13:10 -0700 (Sat, 21 Jun 2008) Log Message: ----------- Snapshot of Pure 0.4 (+some trivial post-release fixes). Added Paths: ----------- pure/releases/pure-0.4/ pure/releases/pure-0.4/ChangeLog pure/releases/pure-0.4/Makefile.in pure/releases/pure-0.4/NEWS pure/releases/pure-0.4/README pure/releases/pure-0.4/etc/pure.lang pure/releases/pure-0.4/examples/symbolic.pure pure/releases/pure-0.4/interpreter.cc pure/releases/pure-0.4/lexer.ll pure/releases/pure-0.4/pure.1.in pure/releases/pure-0.4/pure.cc Removed Paths: ------------- pure/releases/pure-0.4/ChangeLog pure/releases/pure-0.4/Makefile.in pure/releases/pure-0.4/NEWS pure/releases/pure-0.4/README pure/releases/pure-0.4/etc/pure.lang pure/releases/pure-0.4/examples/symbolic.pure pure/releases/pure-0.4/interpreter.cc pure/releases/pure-0.4/lexer.ll pure/releases/pure-0.4/pure.1.in pure/releases/pure-0.4/pure.cc Copied: pure/releases/pure-0.4 (from rev 261, pure/trunk) Deleted: pure/releases/pure-0.4/ChangeLog =================================================================== --- pure/trunk/ChangeLog 2008-06-18 20:32:46 UTC (rev 261) +++ pure/releases/pure-0.4/ChangeLog 2008-06-21 11:13:10 UTC (rev 275) @@ -1,403 +0,0 @@ -2008-06-18 Albert Graef <Dr....@t-...> - - * runtime.cc, lib/primitives.pure: Add hash function to compute 32 - bit hash codes of Pure expressions. Suggested by Jiri Spitz. - - * parser.yy, lexer.ll, interpreter.hh/cc: Add syntax for multiple - left-hand sides in function definitions and 'case' rules, as - requested by Jiri Spitz and discussed on the mailing list. See the - manual page for details. - - * symtable.cc, lib/prelude.pure, lib/primitives.pure: Rename the - bitwise operators '&' and '|' to 'and' and 'or'. - -2008-06-16 Albert Graef <Dr....@t-...> - - * etc/pure.lang: New language definition file for Andre Simon's - highlight program (http:/www.andre-simon.de/). This allows you to - format Pure sources with syntax highlighting as HTML and LaTeX - files, for instance. - - * configure.ac, Makefile.in: Clean up the source tree. Moved - auxiliary configure files and the syntax highlighting and - programming mode stuff into separate config and etc - subdirectories. Moreover, Makefile.in now has a target to - regenerate the configury using autoconf and autoheader. - -2008-06-15 Albert Graef <Dr....@t-...> - - * matcher.hh: gcc 4.3 compatibility fixes. Suggested by Toni - Graffy. - -2008-06-14 Albert Graef <Dr....@t-...> - - * lexer.ll: Various changes in order to facilitate script - execution and interfacing to Emacs. - - Initial '#!' on a line now denotes a comment line, in order to - support shebangs (see below). - - The new 'completion_matches' command provides information about - completions to programs driving the interpreter, such as Emacs - (see below). - - Paging of the 'list' command is now implemented using the program - specified with the PURE_MORE environment variable. This allows you - to disable this option (if PURE_MORE is undefined) or choose any - pager program and options that you prefer. Define PURE_MORE=more - in your shell startup files to get back the old behaviour of - piping 'list' output through 'more'. - - * pure.cc: Added new -q (quiet) and -x (execute) options. The - former is used in pure-mode.el to suppress the sign-on message of - the interpreter. The latter can be used in conjuction with the new - #! comment syntax to add shebangs to your script, see the manpage - for details. - - * pure-mode.el.in: Added new Emacs Pure mode. This is a quick and - dirty hack of Q mode and still needs some work (in particular, - auto indentation is pretty much broken right now). - -2008-06-13 Albert Graef <Dr....@t-...> - - * configure.ac, Makefile.in, etc.: Overhauled configury and bumped - the version number. - - Building a separate runtime lib on x86-64 works now (but requires - a patched LLVM, see the INSTALL file for details). Linking the - runtime lib on OSX should also work now. Moreover, it is now - possible to install different Pure versions in parallel, again see - the INSTALL file for details. - -2008-06-06 Albert Graef <Dr....@t-...> - - * 0.3 release. - - * configure.ac, etc.: Added autoconf support. Various fixes for 64 - bit and Windows compatibility. See the INSTALL file for updated - installation instructions. - -2008-06-01 Albert Graef <Dr....@t-...> - - * Makefile, interpreter.cc: Put the runtime and interpreter into a - separate shared library, to make it possible for modules to link - against the runtime, and to reduce the memory footprint when - multiple instances of the interpreter are run as different - processes. Also, this makes it possible to access the runtime - routines on systems where a program cannot dlopen itself. - -2008-05-28 Albert Graef <Dr....@t-...> - - * interpreter.cc, runtime.cc: Optimization of pure_freenew calls. - - * lib/strings.pure: Make 'cycle' work on strings. Reported by - Eddie Rucker. - - * lib/prelude.pure: Make 'index' work on lists. Code contributed - by Eddie Rucker. - -2008-05-27 Albert Graef <Dr....@t-...> - - * lib/prelude.pure: Rewrite prelude operations to make them - tail-recursive. - - * interpreter.cc (toplevel_codegen): Experimental support for - tail-recursive logical operators (&& and ||). This works but is - disabled, since it makes these operations behave in different ways - depending on the context, which is a really bad idea because it - violates referential transparency. - -2008-05-26 Albert Graef <Dr....@t-...> - - * interpreter.cc, runtime.cc: Overhaul of the shadow stack - machinery. Environment vectors are now maintained on the shadow - stack, so that all local functions and anonymous closures are - eligible for tail call optimization, even if they need access to - their environment. - -2008-05-25 Albert Graef <Dr....@t-...> - - * interpreter.cc, runtime.cc: Add marshalling between long (64 - bit) ints and Pure bigints in the C interface. This means that - both Pure ints and bigints can now be passed for 'long' arguments - of externals (with sign extension/truncation as necessary), and - 'long' values are promoted to Pure bigints on return. Hence C - functions taking 64 bit integers as arguments and returning them - as results can now be called from Pure without loosing bits due to - truncation. - - * interpreter.cc: Make toplevel if-then-else properly - tail-recursive. Thus, e.g., the following function will now run in - constant stack space: count x = if x<=0 then x else count (x-1); - This also works with nested if-then-else constructs, as long as - they form the right-hand side of an equation. - -2008-05-24 Albert Graef <Dr....@t-...> - - * interpreter.cc, runtime.cc: Fix more memory allocation bugs in - exception handling. - - * runtime.cc, lib/system.pure: Bugfixes in the scanf - functions. Reported by Jiri Spitz. - - * pure.cc, runtime.cc, util.cc: Windows/MinGW compatibility - fixes. Suggested by Jiri Spitz. - -2008-05-23 Albert Graef <Dr....@t-...> - - * runtime.cc: Fix premature freeing of eval result, and a minor - memory allocation glitch in the catch function. Reported by Eddie - Rucker. - - * Makefile: Bump version number. - - * interpreter.cc: If there are any child environments, doeval and - dodefn both create semi-permanent environments now, so that the - child environments and the corresponding LLVM IR survive for the - entire lifetime of any embedded closures, which might still be - called at a later time. This fixes the segfaults occurring when a - closure gets called after its associated environment was purged. A - partial fix for some situations (as reported earlier by Chris - Double) was already in the 0.2 release, but this didn't deal with - all cases, such as closures constructed in a call to the eval - function, as reported by Eddie Rucker. - -2008-05-22 Albert Graef <Dr....@t-...> - - * interpreter.cc, runtime.cc: Major overhaul of expression memory - handling. Fixed the shadow stack and memory debugging code. Both - function arguments and environment are now visible on the shadow - stack, and all remaining memory leaks have been fixed. Note that, - compared to previous revisions, the shadow stack slows down - compiled code by some 10% and it needs some additional memory. - OTOH, it also provides additional data that will be needed in the - planned symbolic debugger, and it seems to be the most efficient - way to handle dangling expression pointers after an exception - anyway. - -2008-05-17 Albert Graef <Dr....@t-...> - - * runtime.cc (pure_free_internal): Fixed a glitch which was - causing big memleaks. Reported by Libor Spacek. - - * interpreter.cc (define): Fixed error messages. - - * interpreter.cc, runtime.h: Reorganize pure_expr data structure - so that the data fields are *always* aligned on 8 byte boundaries. - This should now also work on 32 bit architectures where doubles - are aligned on 8 byte boundaries, such as Linux on 32 bit PPC. - Reported by Tim Haynes. - - * interpreter.cc: Fixed some case labels in switch instructions - which should be signed rather than unsigned values. Also made - void* a pointer to a dummy struct in LLVM IR, so that it can be - distinguished from all other pointer types, and added support for - short (16 bit) and long (64 bit) integer types (as well as the - corresponding pointer types) in the C interface. - - Please note that the typename 'long' *always* denotes signed 64 - bit integers in Pure's extern declarations, even if the C 'long' - type is actually 32 bit (as it usually is even on most 64 bit - systems). - -2008-05-16 Albert Graef <Dr....@t-...> - - * runtime.h: Fix compilation problems when header gets included - from C. - -2008-05-14 Albert Graef <Dr....@t-...> - - * funcall.h: Reduce maximum number of function parameters to - 64. This seems to be large enough for most purposes, and speeds up - compilation with -Ox by a factor of around 10. - - * Makefile: Overhaul of build options. In particular, the - 'default' build now includes basic optimization (-O) which makes - the interpreter almost as fast as with the 'release' build, and - produces a working interpreter also on 64 bit systems. (The - 'debug' build is still broken there, but see the SYSTEM NOTES - section in the INSTALL file for a workaround.) - - * interpreter.cc, runtime.cc: 64 bit compatibility fixes in bigint - handling. - -2008-05-12 Albert Graef <Dr....@t-...> - - * interpreter.cc: Fix a severe bug in the environment handling - code of the code generator, which could cause failed assertions in - the code generator, or wrong code to be generated in some cases. - To resolve this issue, the code generator now properly keeps - separate environments for each rule of a function - definition. Reported by John Lunney. - - * Makefile: Redirect warning and error messages from regression - tests to the logfile. - -2008-05-10 Albert Graef <Dr....@t-...> - - * interpreter.cc (uminop): Handle the value -0x80000000 at the - border of the int range, so that it is correctly treated as a - machine int. - -2008-05-09 Albert Graef <Dr....@t-...> - - * lexer.ll, printer.cc, etc.: Change the "G" suffix to denote - bigints to "L" ("G" can too easily be mistaken for a digit; also, - Python uses the same "L" notation for bigints). Reported by Eddie - Rucker. - -2008-05-06 Albert Graef <Dr....@t-...> - - * lib/primitives.pure: Made the pow function work with all - combinations of integer and double arguments. Also added the sqrt - function and the ^ operator. - - * runtime.cc, lib/primitives.pure: Added predicates funp, lambdap, - varp checking for named and anonymous closures and unbound global - variables, respectively. Requested by Libor Spacek. - - * interpreter.cc (declare_extern, fun_prolog): Handle some obscure - cases of name collisions between Pure and C functions. - -2008-05-05 Albert Graef <Dr....@t-...> - - * INSTALL: Add system-specific notes. - - * Makefile: Massaged some rules for OSX compatibility. In - particular, -rdynamic is now in the LDFLAGS, so that it can be - removed more easily, and I also removed the install -s flag so - that the pure executable is installed without stripping the - symbols which are needed to properly resolve runtime externals on - OSX. Reported by Ryan Schmidt and others. - - * matcher.cc (merge_ctrans): Fixed broken mpz_cmp() test causing - transitions on different (instead of equal) bigint constants to be - merged. Reported by Libor Spacek. - -2008-05-04 Albert Graef <Dr....@t-...> - - * 0.2 release. - - * lexer.ll, printer.cc: Add an explicit notation for big - integers. Any integer immediately followed by the uppercase letter - "G" (as in "biG" or "GMP") will now always be interpreted as a - bigint constant, even if it fits into a machine integer. This - notation is also used when printing bigint constants. This change - was necessary to make it possible to write rules matching against - "small bigint" constants. - - * lib/primitives.pure: Added operations to recognize function - applications and extract the function and argument parts, - implemented in runtime.cc. Note that these operations can't be - defined in Pure because of the "head is function" rule which means - that in a pattern of the form f x, f is always a literal function - symbol and not a variable. - -2008-05-03 Albert Graef <Dr....@t-...> - - * README: Moved installation instructions to a separate INSTALL - file, added Eddie Rucker's detailed instructions there. - - * util.cc (myiconv): Apple's iconv takes const char** as 2nd - parameter. #ifdef that case. Reported by Ryan Schmidt. - - * interpreter.cc (declare_extern): Fixed a bug in the generated - wrapper code for external calls, which caused function arguments - to be garbage-collected prematurely, when they were still needed - to create the default value, in the case of external calls - returning a null expression pointer to indicate failure. Reported - by Eddie Rucker. - - * test/test4.pure: Disabled tail call checks, as they may fail on - some platforms. Reported by Ryan Schmidt. - - * test/test1.pure: Corrected fact3 example, added test cases. - Reported by Libor Spacek. - -2008-05-02 Albert Graef <Dr....@t-...> - - * Makefile: Overhaul of regression tests so that results of - expressions are recorded. Also, 'make check' doesn't depend on the - log files any more, so that the logs can be stored in svn. You can - now use the explicit goal 'make logs' to regenerate the logs for - changed test files. - - * runtime.cc (same): Added a syntactic equality test. Requested by - Eddie Rucker. - - * Makefile: Add $(LDFLAGS) and $(LIBS) to the link line, so that - the user can easily add his own linker options and local - libraries. - - * lib/strings.pure: Add missing range check in string indexing - operation. Reported by Eddie Rucker. - - * printer.cc (operator <<): Handle stack overflow while printing - an expression. - - * interpreter.cc (dodefn): Fix a tricky bug causing the executable - code of closures bound to variables to be freed when it was still - needed. Reported by Chris Double. - -2008-05-01 Albert Graef <Dr....@t-...> - - * interpreter.cc: Proper alignment of value fields in expression - struct on 64 bit systems. Reported by Tim Haynes. - - * Makefile: g++ shouldn't be hardcoded, use $(CXX) instead. - Reported by Ryan Schmidt. - - * runtime.cc (pure_sys_vars): More OSX compatibility fixes. - Reported by Ryan Schmidt. - -2008-04-30 Albert Graef <Dr....@t-...> - - * interpreter.cc: Fix a compilation error (STL bug: - http://gcc.gnu.org/bugzilla/show_bug.cgi?id=11729) as well as some - bogus warnings with Apple gcc 4.0.1. Reported by Ryan Schmidt. - - * Makefile (make depend): Get rid of bogus LLVM dependencies. - Reported by Ryan Schmidt. - - * lexer.ll, parser.yy: Fixes for compatibility with newer flex and - bison versions. Reported by Eddie Rucker. - -2008-04-29 Albert Graef <Dr....@t-...> - - * 0.1 release. - -2008-04-28 Albert Graef <Dr....@t-...> - - * examples/symbolic.pure: Add symbolic evaluation example. This is - just a straightforward port of some Q examples. - - * runtime.cc: Add support for advisory stack checks. - - * matcher.cc: Bugfixes. - -2008-04-27 Albert Graef <Dr....@t-...> - - * lib/string.pure: Added split and join functions. - - * pure.1, examples/hello.pure: Overhaul n queens example, added - quicksort and binary search tree examples. - - * lib/prelude.pure: Added void and curry/uncurry combinators, do, - zipdo. - - * interpreter.cc, pure.cc, runtime.cc: Make SIGINT generate a - useful exception value. - - * pure.cc: Add completion for global function and variable - symbols. - -2008-04-22 Albert Graef <Dr....@t-...> - - * Got a working interpreter, at last. There's still lots of stuff - to do (see the TODO file), but the interpreter should now be - usable as it is. - -2008-03-27 Albert Graef <Dr....@t-...> - - * ChangeLog started - Copied: pure/releases/pure-0.4/ChangeLog (from rev 274, pure/trunk/ChangeLog) =================================================================== --- pure/releases/pure-0.4/ChangeLog (rev 0) +++ pure/releases/pure-0.4/ChangeLog 2008-06-21 11:13:10 UTC (rev 275) @@ -0,0 +1,420 @@ +2008-06-20 Albert Graef <Dr....@t-...> + + * 0.4 release. + + * pure.cc, lexer.ll: Fake interactive mode when we're not + connected to a terminal but -i is specified. Thus sign-on message + and command prompts will be printed as usual. This is needed, in + particular, to make Emacs Pure-Eval mode work on Windows. + +2008-06-19 Albert Graef <Dr....@t-...> + + * examples/symbolic.pure: Fix DNF example to accommodate changes + in the operator system. + + * interpreter.cc (declare): Fix segfault in reporting of + conflicting fixity declarations. + +2008-06-18 Albert Graef <Dr....@t-...> + + * runtime.cc, lib/primitives.pure: Add hash function to compute 32 + bit hash codes of Pure expressions. Suggested by Jiri Spitz. + + * parser.yy, lexer.ll, interpreter.hh/cc: Add syntax for multiple + left-hand sides in function definitions and 'case' rules, as + requested by Jiri Spitz and discussed on the mailing list. See the + manual page for details. + + * symtable.cc, lib/prelude.pure, lib/primitives.pure: Rename the + bitwise operators '&' and '|' to 'and' and 'or'. + +2008-06-16 Albert Graef <Dr....@t-...> + + * etc/pure.lang: New language definition file for Andre Simon's + highlight program (http:/www.andre-simon.de/). This allows you to + format Pure sources with syntax highlighting as HTML and LaTeX + files, for instance. + + * configure.ac, Makefile.in: Clean up the source tree. Moved + auxiliary configure files and the syntax highlighting and + programming mode stuff into separate config and etc + subdirectories. Moreover, Makefile.in now has a target to + regenerate the configury using autoconf and autoheader. + +2008-06-15 Albert Graef <Dr....@t-...> + + * matcher.hh: gcc 4.3 compatibility fixes. Suggested by Toni + Graffy. + +2008-06-14 Albert Graef <Dr....@t-...> + + * lexer.ll: Various changes in order to facilitate script + execution and interfacing to Emacs. + + Initial '#!' on a line now denotes a comment line, in order to + support shebangs (see below). + + The new 'completion_matches' command provides information about + completions to programs driving the interpreter, such as Emacs + (see below). + + Paging of the 'list' command is now implemented using the program + specified with the PURE_MORE environment variable. This allows you + to disable this option (if PURE_MORE is undefined) or choose any + pager program and options that you prefer. Define PURE_MORE=more + in your shell startup files to get back the old behaviour of + piping 'list' output through 'more'. + + * pure.cc: Added new -q (quiet) and -x (execute) options. The + former is used in pure-mode.el to suppress the sign-on message of + the interpreter. The latter can be used in conjunction with the + new #! comment syntax to add shebangs to your script, see the + manpage for details. + + * pure-mode.el.in: Added new Emacs Pure mode. This is a quick and + dirty hack of Q mode and still needs some work (in particular, + auto indentation is pretty much broken right now). + +2008-06-13 Albert Graef <Dr....@t-...> + + * configure.ac, Makefile.in, etc.: Overhauled configury and bumped + the version number. + + Building a separate runtime lib on x86-64 works now (but requires + a patched LLVM, see the INSTALL file for details). Linking the + runtime lib on OSX should also work now. Moreover, it is now + possible to install different Pure versions in parallel, again see + the INSTALL file for details. + +2008-06-06 Albert Graef <Dr....@t-...> + + * 0.3 release. + + * configure.ac, etc.: Added autoconf support. Various fixes for 64 + bit and Windows compatibility. See the INSTALL file for updated + installation instructions. + +2008-06-01 Albert Graef <Dr....@t-...> + + * Makefile, interpreter.cc: Put the runtime and interpreter into a + separate shared library, to make it possible for modules to link + against the runtime, and to reduce the memory footprint when + multiple instances of the interpreter are run as different + processes. Also, this makes it possible to access the runtime + routines on systems where a program cannot dlopen itself. + +2008-05-28 Albert Graef <Dr....@t-...> + + * interpreter.cc, runtime.cc: Optimization of pure_freenew calls. + + * lib/strings.pure: Make 'cycle' work on strings. Reported by + Eddie Rucker. + + * lib/prelude.pure: Make 'index' work on lists. Code contributed + by Eddie Rucker. + +2008-05-27 Albert Graef <Dr....@t-...> + + * lib/prelude.pure: Rewrite prelude operations to make them + tail-recursive. + + * interpreter.cc (toplevel_codegen): Experimental support for + tail-recursive logical operators (&& and ||). This works but is + disabled, since it makes these operations behave in different ways + depending on the context, which is a really bad idea because it + violates referential transparency. + +2008-05-26 Albert Graef <Dr....@t-...> + + * interpreter.cc, runtime.cc: Overhaul of the shadow stack + machinery. Environment vectors are now maintained on the shadow + stack, so that all local functions and anonymous closures are + eligible for tail call optimization, even if they need access to + their environment. + +2008-05-25 Albert Graef <Dr....@t-...> + + * interpreter.cc, runtime.cc: Add marshalling between long (64 + bit) ints and Pure bigints in the C interface. This means that + both Pure ints and bigints can now be passed for 'long' arguments + of externals (with sign extension/truncation as necessary), and + 'long' values are promoted to Pure bigints on return. Hence C + functions taking 64 bit integers as arguments and returning them + as results can now be called from Pure without loosing bits due to + truncation. + + * interpreter.cc: Make toplevel if-then-else properly + tail-recursive. Thus, e.g., the following function will now run in + constant stack space: count x = if x<=0 then x else count (x-1); + This also works with nested if-then-else constructs, as long as + they form the right-hand side of an equation. + +2008-05-24 Albert Graef <Dr....@t-...> + + * interpreter.cc, runtime.cc: Fix more memory allocation bugs in + exception handling. + + * runtime.cc, lib/system.pure: Bugfixes in the scanf + functions. Reported by Jiri Spitz. + + * pure.cc, runtime.cc, util.cc: Windows/MinGW compatibility + fixes. Suggested by Jiri Spitz. + +2008-05-23 Albert Graef <Dr....@t-...> + + * runtime.cc: Fix premature freeing of eval result, and a minor + memory allocation glitch in the catch function. Reported by Eddie + Rucker. + + * Makefile: Bump version number. + + * interpreter.cc: If there are any child environments, doeval and + dodefn both create semi-permanent environments now, so that the + child environments and the corresponding LLVM IR survive for the + entire lifetime of any embedded closures, which might still be + called at a later time. This fixes the segfaults occurring when a + closure gets called after its associated environment was purged. A + partial fix for some situations (as reported earlier by Chris + Double) was already in the 0.2 release, but this didn't deal with + all cases, such as closures constructed in a call to the eval + function, as reported by Eddie Rucker. + +2008-05-22 Albert Graef <Dr....@t-...> + + * interpreter.cc, runtime.cc: Major overhaul of expression memory + handling. Fixed the shadow stack and memory debugging code. Both + function arguments and environment are now visible on the shadow + stack, and all remaining memory leaks have been fixed. Note that, + compared to previous revisions, the shadow stack slows down + compiled code by some 10% and it needs some additional memory. + OTOH, it also provides additional data that will be needed in the + planned symbolic debugger, and it seems to be the most efficient + way to handle dangling expression pointers after an exception + anyway. + +2008-05-17 Albert Graef <Dr....@t-...> + + * runtime.cc (pure_free_internal): Fixed a glitch which was + causing big memleaks. Reported by Libor Spacek. + + * interpreter.cc (define): Fixed error messages. + + * interpreter.cc, runtime.h: Reorganize pure_expr data structure + so that the data fields are *always* aligned on 8 byte boundaries. + This should now also work on 32 bit architectures where doubles + are aligned on 8 byte boundaries, such as Linux on 32 bit PPC. + Reported by Tim Haynes. + + * interpreter.cc: Fixed some case labels in switch instructions + which should be signed rather than unsigned values. Also made + void* a pointer to a dummy struct in LLVM IR, so that it can be + distinguished from all other pointer types, and added support for + short (16 bit) and long (64 bit) integer types (as well as the + corresponding pointer types) in the C interface. + + Please note that the typename 'long' *always* denotes signed 64 + bit integers in Pure's extern declarations, even if the C 'long' + type is actually 32 bit (as it usually is even on most 64 bit + systems). + +2008-05-16 Albert Graef <Dr....@t-...> + + * runtime.h: Fix compilation problems when header gets included + from C. + +2008-05-14 Albert Graef <Dr....@t-...> + + * funcall.h: Reduce maximum number of function parameters to + 64. This seems to be large enough for most purposes, and speeds up + compilation with -Ox by a factor of around 10. + + * Makefile: Overhaul of build options. In particular, the + 'default' build now includes basic optimization (-O) which makes + the interpreter almost as fast as with the 'release' build, and + produces a working interpreter also on 64 bit systems. (The + 'debug' build is still broken there, but see the SYSTEM NOTES + section in the INSTALL file for a workaround.) + + * interpreter.cc, runtime.cc: 64 bit compatibility fixes in bigint + handling. + +2008-05-12 Albert Graef <Dr....@t-...> + + * interpreter.cc: Fix a severe bug in the environment handling + code of the code generator, which could cause failed assertions in + the code generator, or wrong code to be generated in some cases. + To resolve this issue, the code generator now properly keeps + separate environments for each rule of a function + definition. Reported by John Lunney. + + * Makefile: Redirect warning and error messages from regression + tests to the logfile. + +2008-05-10 Albert Graef <Dr....@t-...> + + * interpreter.cc (uminop): Handle the value -0x80000000 at the + border of the int range, so that it is correctly treated as a + machine int. + +2008-05-09 Albert Graef <Dr....@t-...> + + * lexer.ll, printer.cc, etc.: Change the "G" suffix to denote + bigints to "L" ("G" can too easily be mistaken for a digit; also, + Python uses the same "L" notation for bigints). Reported by Eddie + Rucker. + +2008-05-06 Albert Graef <Dr....@t-...> + + * lib/primitives.pure: Made the pow function work with all + combinations of integer and double arguments. Also added the sqrt + function and the ^ operator. + + * runtime.cc, lib/primitives.pure: Added predicates funp, lambdap, + varp checking for named and anonymous closures and unbound global + variables, respectively. Requested by Libor Spacek. + + * interpreter.cc (declare_extern, fun_prolog): Handle some obscure + cases of name collisions between Pure and C functions. + +2008-05-05 Albert Graef <Dr....@t-...> + + * INSTALL: Add system-specific notes. + + * Makefile: Massaged some rules for OSX compatibility. In + particular, -rdynamic is now in the LDFLAGS, so that it can be + removed more easily, and I also removed the install -s flag so + that the pure executable is installed without stripping the + symbols which are needed to properly resolve runtime externals on + OSX. Reported by Ryan Schmidt and others. + + * matcher.cc (merge_ctrans): Fixed broken mpz_cmp() test causing + transitions on different (instead of equal) bigint constants to be + merged. Reported by Libor Spacek. + +2008-05-04 Albert Graef <Dr....@t-...> + + * 0.2 release. + + * lexer.ll, printer.cc: Add an explicit notation for big + integers. Any integer immediately followed by the uppercase letter + "G" (as in "biG" or "GMP") will now always be interpreted as a + bigint constant, even if it fits into a machine integer. This + notation is also used when printing bigint constants. This change + was necessary to make it possible to write rules matching against + "small bigint" constants. + + * lib/primitives.pure: Added operations to recognize function + applications and extract the function and argument parts, + implemented in runtime.cc. Note that these operations can't be + defined in Pure because of the "head is function" rule which means + that in a pattern of the form f x, f is always a literal function + symbol and not a variable. + +2008-05-03 Albert Graef <Dr....@t-...> + + * README: Moved installation instructions to a separate INSTALL + file, added Eddie Rucker's detailed instructions there. + + * util.cc (myiconv): Apple's iconv takes const char** as 2nd + parameter. #ifdef that case. Reported by Ryan Schmidt. + + * interpreter.cc (declare_extern): Fixed a bug in the generated + wrapper code for external calls, which caused function arguments + to be garbage-collected prematurely, when they were still needed + to create the default value, in the case of external calls + returning a null expression pointer to indicate failure. Reported + by Eddie Rucker. + + * test/test4.pure: Disabled tail call checks, as they may fail on + some platforms. Reported by Ryan Schmidt. + + * test/test1.pure: Corrected fact3 example, added test cases. + Reported by Libor Spacek. + +2008-05-02 Albert Graef <Dr....@t-...> + + * Makefile: Overhaul of regression tests so that results of + expressions are recorded. Also, 'make check' doesn't depend on the + log files any more, so that the logs can be stored in svn. You can + now use the explicit goal 'make logs' to regenerate the logs for + changed test files. + + * runtime.cc (same): Added a syntactic equality test. Requested by + Eddie Rucker. + + * Makefile: Add $(LDFLAGS) and $(LIBS) to the link line, so that + the user can easily add his own linker options and local + libraries. + + * lib/strings.pure: Add missing range check in string indexing + operation. Reported by Eddie Rucker. + + * printer.cc (operator <<): Handle stack overflow while printing + an expression. + + * interpreter.cc (dodefn): Fix a tricky bug causing the executable + code of closures bound to variables to be freed when it was still + needed. Reported by Chris Double. + +2008-05-01 Albert Graef <Dr....@t-...> + + * interpreter.cc: Proper alignment of value fields in expression + struct on 64 bit systems. Reported by Tim Haynes. + + * Makefile: g++ shouldn't be hardcoded, use $(CXX) instead. + Reported by Ryan Schmidt. + + * runtime.cc (pure_sys_vars): More OSX compatibility fixes. + Reported by Ryan Schmidt. + +2008-04-30 Albert Graef <Dr....@t-...> + + * interpreter.cc: Fix a compilation error (STL bug: + http://gcc.gnu.org/bugzilla/show_bug.cgi?id=11729) as well as some + bogus warnings with Apple gcc 4.0.1. Reported by Ryan Schmidt. + + * Makefile (make depend): Get rid of bogus LLVM dependencies. + Reported by Ryan Schmidt. + + * lexer.ll, parser.yy: Fixes for compatibility with newer flex and + bison versions. Reported by Eddie Rucker. + +2008-04-29 Albert Graef <Dr....@t-...> + + * 0.1 release. + +2008-04-28 Albert Graef <Dr....@t-...> + + * examples/symbolic.pure: Add symbolic evaluation example. This is + just a straightforward port of some Q examples. + + * runtime.cc: Add support for advisory stack checks. + + * matcher.cc: Bugfixes. + +2008-04-27 Albert Graef <Dr....@t-...> + + * lib/string.pure: Added split and join functions. + + * pure.1, examples/hello.pure: Overhaul n queens example, added + quicksort and binary search tree examples. + + * lib/prelude.pure: Added void and curry/uncurry combinators, do, + zipdo. + + * interpreter.cc, pure.cc, runtime.cc: Make SIGINT generate a + useful exception value. + + * pure.cc: Add completion for global function and variable + symbols. + +2008-04-22 Albert Graef <Dr....@t-...> + + * Got a working interpreter, at last. There's still lots of stuff + to do (see the TODO file), but the interpreter should now be + usable as it is. + +2008-03-27 Albert Graef <Dr....@t-...> + + * ChangeLog started + Deleted: pure/releases/pure-0.4/Makefile.in =================================================================== --- pure/trunk/Makefile.in 2008-06-18 20:32:46 UTC (rev 261) +++ pure/releases/pure-0.4/Makefile.in 2008-06-21 11:13:10 UTC (rev 275) @@ -1,304 +0,0 @@ - -# This Makefile requires GNU make. Really. - -SHELL = /bin/sh - -# Package and host information. - -name = @PACKAGE_NAME@ -version = @PACKAGE_VERSION@ -dist = $(name)-$(version) - -host = @host@ - -# Source and installation paths. - -srcdir = @srcdir@ -VPATH = @srcdir@ - -prefix = @prefix@ -exec_prefix = @exec_prefix@ -datarootdir = @datarootdir@ - -bindir = @bindir@ -includedir = @includedir@ -libdir = @libdir@ -datadir = @datadir@ -mandir = @mandir@ -man1dir = $(mandir)/man1 - -# Staging directory for 'make install'. - -DESTDIR= - -# OS-specific special filename extensions. configure tries to guess this, but -# if it guesses wrong, you can set these as needed. - -EXE=@EXEEXT@ -DLL=@DLLEXT@ - -# Programs. - -CXX = @CXX@ -INSTALL = @INSTALL@ -ECHO_N = @ECHO_N@ - -# Linker flags and required libraries. These are determined automatically by -# configure, but if necessary you can also change these on the command line. - -LDFLAGS = @LDFLAGS@ -LIBS = @LIBS@ - -# Compilation flags. - -LLVM_FLAGS = `llvm-config --cppflags` -LLVM_LIBS = `llvm-config --ldflags --libs core jit native` - -CPPFLAGS = @CPPFLAGS@ -CXXFLAGS = @CXXFLAGS@ - -# Pure library name. Currently we use a simple versioning scheme, which -# requires that the library version matches that of the interpreter. This -# enables you to install different versions of the Pure interpreter on the -# same system. - -libpure_base = $(name) -libpure_vers = $(libpure_base)-$(version) - -libpure = lib$(libpure_vers)$(DLL) -libpurelnk = lib$(libpure_base)$(DLL) - -# Whether to build the Pure runtime library. If this is set to anything but -# "yes", the interpreter is linked statically and no separate library is -# produced. This is necessary on some systems where LLVM cannot be linked in -# dynamically. - -sharedlib = @sharedlib@ - -# Flag needed to create shared libraries. On most systems this is just -shared. - -shared = @shared@ - -# On some systems -fPIC is needed for code linked as a shared library. - -ifeq ($(sharedlib), yes) -PIC = @PIC@ -else -PIC = -endif - -# Auxiliary libraries to be loaded at runtime. Usually this is just libpure -# (when built), but on some systems we have to load additional dlls to resolve -# some library functions. - -ifeq ($(sharedlib), yes) -AUXLIBS = -DLIBPURE='"$(libpure)"' @AUXLIBS@ -else -AUXLIBS = @AUXLIBS@ -endif - -# No need to edit below this line. Unless you really have to. :) ############ - -SOURCE = expr.cc expr.hh funcall.h interpreter.cc interpreter.hh lexer.ll \ -matcher.cc matcher.hh parser.yy printer.cc printer.hh \ -runtime.cc runtime.h symtable.cc symtable.hh util.cc util.hh -EXTRA_SOURCE = lexer.cc parser.cc parser.hh location.hh position.hh stack.hh -OBJECT = $(subst .cc,.o,$(filter %.cc,$(SOURCE) $(EXTRA_SOURCE))) - -DISTFILES = COPYING ChangeLog INSTALL NEWS README TODO \ -Makefile.in configure.ac configure config.h.in \ -config/aclocal.m4 config/config.guess config/config.sub config/install-sh \ -$(SOURCE) $(EXTRA_SOURCE) w3centities.c \ -pure.cc pure.1 pure.1.in etc/pure-mode.el.in etc/pure.* \ -examples/*.pure lib/*.pure test/*.pure test/*.log - -.PHONY: all html dvi ps pdf clean realclean depend install uninstall strip \ -dist distcheck cleanlogs logs check config - -# compilation - -all: pure$(EXE) etc/pure-mode.el pure.1 - -ifeq ($(sharedlib), yes) -pure$(EXE): pure.o $(libpure) - $(CXX) -o $@ $(LDFLAGS) pure.o -L. -l$(libpure_vers) $(LIBS) -else -pure$(EXE): pure.o $(OBJECT) - $(CXX) -o $@ $(LDFLAGS) pure.o $(OBJECT) $(LLVM_LIBS) $(LIBS) -endif - -$(libpure): $(OBJECT) - $(CXX) $(shared) -o $@ $(LDFLAGS) $(OBJECT) $(LLVM_LIBS) $(LIBS) - ln -sf $(libpure) $(libpurelnk) - -pure.o: pure.cc - $(CXX) $(CXXFLAGS) $(CPPFLAGS) $(LLVM_FLAGS) -DPURELIB='"$(libdir)/pure-$(version)"' -c -o $@ $< - -interpreter.o: interpreter.cc - $(CXX) $(CXXFLAGS) $(PIC) $(CPPFLAGS) $(LLVM_FLAGS) $(AUXLIBS) -c -o $@ $< - -%.o: %.cc - $(CXX) $(CXXFLAGS) $(PIC) $(CPPFLAGS) $(LLVM_FLAGS) -c -o $@ $< - -lexer.cc: lexer.ll - flex -o lexer.cc $< - -parser.cc: parser.yy - bison -v -o parser.cc $< - -parser.hh location.hh position.hh stack.hh: parser.cc - -# create pure-mode.el from pure-mode.el.in - -etc/pure-mode.el: Makefile etc/pure-mode.el.in - rm -f etc/pure-mode.el etc/pure-mode.el.tmp - sed -e 's,@bindir\@,$(bindir),g' -e 's,@libdir\@,$(libdir),g' etc/pure-mode.el.in >etc/pure-mode.el.tmp - mv etc/pure-mode.el.tmp etc/pure-mode.el - -# create the manpage from pure.1.in - -pure.1: configure.ac pure.1.in - rm -f pure.1 pure.1.tmp - sed -e 's,@version\@,$(version),g' pure.1.in >pure.1.tmp - mv pure.1.tmp pure.1 - -# documentation in various formats (requires groff) - -html: pure.html -dvi: pure.dvi -ps: pure.ps -pdf: pure.pdf - -# We do the html format using rman, because it produces nicer output. If you -# don't have rman, uncomment the rule below instead. - -%.html: %.1 - rman -f HTML $< | sed -e 's/dq/\"/g' -e '/<br>/d' > $@ - -#%.html: %.1 -# groff -man -Thtml $< > $@ - -%.dvi: %.1 - groff -man -Tdvi $< > $@ - -%.ps: %.1 - groff -man -Tps $< > $@ - -%.pdf: %.1 - groff -man -Tps $< | ps2pdf - $@ - -# cleaning - -clean: - rm -f *~ *.bak *.html *.dvi *.ps *.pdf pure$(EXE) $(OBJECT) pure.o $(libpurelnk) $(libpure) parser.output - -distclean: clean - rm -f Makefile config.h config.log config.status etc/pure-mode.el $(dist).tar.gz - -realclean: distclean - rm -f $(addprefix $(srcdir)/, test/*.log $(EXTRA_SOURCE) pure.1) - -# dependencies (rerun configure after this) - -depend: $(SOURCE) $(EXTRA_SOURCE) - (cd $(srcdir) && makedepend -f Makefile.in -Y pure.cc $(SOURCE) $(EXTRA_SOURCE) 2> /dev/null) - -# regenerate configure et al - -config: configure config.h.in - -configure: configure.ac config/aclocal.m4 - autoconf -I config - -config.h.in: configure.ac config/aclocal.m4 - autoheader -I config - -# installation - -install: pure$(EXE) etc/pure-mode.el pure.1 - for x in $(addprefix $(DESTDIR), $(bindir) $(includedir)/pure-$(version) $(libdir)/pure-$(version) $(man1dir)); do $(INSTALL) -d $$x; done - $(INSTALL) pure$(EXE) $(DESTDIR)$(bindir)/pure-$(version)$(EXE) - ln -sf $(bindir)/pure-$(version)$(EXE) $(DESTDIR)$(bindir)/pure$(EXE) -ifeq ($(sharedlib), yes) - $(INSTALL) $(libpure) $(DESTDIR)$(libdir)/$(libpure) - ln -sf $(libdir)/$(libpure) $(DESTDIR)$(libdir)/$(libpurelnk) -endif - $(INSTALL) runtime.h $(DESTDIR)$(includedir)/pure-$(version) - ln -sf $(includedir)/pure-$(version) $(DESTDIR)$(includedir)/pure - for x in $(srcdir)/lib/*.pure; do $(INSTALL) -m 644 $$x $(DESTDIR)$(libdir)/pure-$(version); done - ln -sf $(libdir)/pure-$(version) $(DESTDIR)$(libdir)/pure - $(INSTALL) -m 644 pure.1 $(DESTDIR)$(man1dir)/pure-$(version).1 - ln -sf $(man1dir)/pure-$(version).1 $(DESTDIR)$(man1dir)/pure.1 - -uninstall: - rm -rf $(DESTDIR)$(bindir)/pure$(EXE) $(DESTDIR)$(bindir)/pure-$(version)$(EXE) $(DESTDIR)$(libdir)/$(libpure) $(DESTDIR)$(libdir)/$(libpurelnk) $(DESTDIR)$(includedir)/pure $(DESTDIR)$(includedir)/pure-$(version) $(DESTDIR)$(libdir)/pure $(DESTDIR)$(libdir)/pure-$(version) $(DESTDIR)$(man1dir)/pure.1 $(DESTDIR)$(man1dir)/pure-$(version).1 - -# roll a distribution tarball - -dist: pure.1 - rm -rf $(dist) - mkdir $(dist) && mkdir $(dist)/config && mkdir $(dist)/etc && mkdir $(dist)/examples && mkdir $(dist)/lib && mkdir $(dist)/test - (builddir=$$PWD; cd $(srcdir); for x in $(DISTFILES); do ln -sf $$PWD/$$x $$builddir/$(dist)/$$x; done) - rm -f $(dist).tar.gz - tar cfzh $(dist).tar.gz $(dist) - rm -rf $(dist) - -distcheck: dist - tar xfz $(dist).tar.gz - cd $(dist) && ./configure && make && make check && make install DESTDIR=./BUILD - rm -rf $(dist) - -# test logs, make check - -level=7 - -tests = $(wildcard $(srcdir)/test/*.pure) -logs = $(srcdir)/test/prelude.log $(tests:.pure=.log) - -logs: $(logs) - -cleanlogs: - rm -f $(srcdir)/test/*.log - -$(srcdir)/test/prelude.log: lib/prelude.pure lib/primitives.pure lib/strings.pure - LD_LIBRARY_PATH=. PURELIB=$(srcdir)/lib ./pure -n -v$(level) $< > $@ 2>&1 - -%.log: %.pure - LD_LIBRARY_PATH=. PURELIB=$(srcdir)/lib ./pure -v$(level) < $< > $@ 2>&1 - -check: pure - @ echo Running tests. - @ (export LD_LIBRARY_PATH=.; export PURELIB=$(srcdir)/lib; echo $(ECHO_N) "prelude.pure: "; if ./pure $(ECHO_N) -v$(level) $(srcdir)/lib/prelude.pure 2>&1 | diff -q - $(srcdir)/test/prelude.log > /dev/null; then echo passed; else echo FAILED; fi) - @ (export LD_LIBRARY_PATH=.; export PURELIB=$(srcdir)/lib; for x in $(notdir $(tests)); do echo $(ECHO_N) "$$x: "; if ./pure -v$(level) < $(srcdir)/test/$$x 2>&1 | diff -q - $(srcdir)/test/"`basename $$x .pure`.log" > /dev/null; then echo passed; else echo FAILED; fi; done) - -# DO NOT DELETE - -pure.o: interpreter.hh expr.hh matcher.hh symtable.hh printer.hh runtime.h -pure.o: parser.hh stack.hh util.hh location.hh position.hh config.h -expr.o: expr.hh interpreter.hh matcher.hh symtable.hh printer.hh runtime.h -expr.o: parser.hh stack.hh util.hh location.hh position.hh -interpreter.o: interpreter.hh expr.hh matcher.hh symtable.hh printer.hh -interpreter.o: runtime.h parser.hh stack.hh util.hh location.hh position.hh -interpreter.o: expr.hh matcher.hh symtable.hh printer.hh runtime.h parser.hh -interpreter.o: stack.hh util.hh location.hh position.hh -lexer.o: interpreter.hh expr.hh matcher.hh symtable.hh printer.hh runtime.h -lexer.o: parser.hh stack.hh util.hh location.hh position.hh -matcher.o: matcher.hh expr.hh -matcher.o: expr.hh -parser.o: expr.hh printer.hh matcher.hh runtime.h util.hh interpreter.hh -parser.o: symtable.hh parser.hh stack.hh location.hh position.hh -printer.o: printer.hh expr.hh matcher.hh runtime.h interpreter.hh symtable.hh -printer.o: parser.hh stack.hh util.hh location.hh position.hh -printer.o: expr.hh matcher.hh runtime.h -runtime.o: runtime.h expr.hh interpreter.hh matcher.hh symtable.hh printer.hh -runtime.o: parser.hh stack.hh util.hh location.hh position.hh funcall.h -symtable.o: symtable.hh expr.hh printer.hh matcher.hh runtime.h -symtable.o: expr.hh printer.hh matcher.hh runtime.h -util.o: util.hh config.h w3centities.c -lexer.o: interpreter.hh expr.hh matcher.hh symtable.hh printer.hh runtime.h -lexer.o: parser.hh stack.hh util.hh location.hh position.hh -parser.o: parser.hh stack.hh expr.hh printer.hh matcher.hh runtime.h util.hh -parser.o: location.hh position.hh interpreter.hh symtable.hh -parser.o: stack.hh expr.hh printer.hh matcher.hh runtime.h util.hh -parser.o: location.hh position.hh -location.o: position.hh Copied: pure/releases/pure-0.4/Makefile.in (from rev 267, pure/trunk/Makefile.in) =================================================================== --- pure/releases/pure-0.4/Makefile.in (rev 0) +++ pure/releases/pure-0.4/Makefile.in 2008-06-21 11:13:10 UTC (rev 275) @@ -0,0 +1,304 @@ + +# This Makefile requires GNU make. Really. + +SHELL = /bin/sh + +# Package and host information. + +name = @PACKAGE_NAME@ +version = @PACKAGE_VERSION@ +dist = $(name)-$(version) + +host = @host@ + +# Source and installation paths. + +srcdir = @srcdir@ +VPATH = @srcdir@ + +prefix = @prefix@ +exec_prefix = @exec_prefix@ +datarootdir = @datarootdir@ + +bindir = @bindir@ +includedir = @includedir@ +libdir = @libdir@ +datadir = @datadir@ +mandir = @mandir@ +man1dir = $(mandir)/man1 + +# Staging directory for 'make install'. + +DESTDIR= + +# OS-specific special filename extensions. configure tries to guess this, but +# if it guesses wrong, you can set these as needed. + +EXE=@EXEEXT@ +DLL=@DLLEXT@ + +# Programs. + +CXX = @CXX@ +INSTALL = @INSTALL@ +ECHO_N = @ECHO_N@ + +# Linker flags and required libraries. These are determined automatically by +# configure, but if necessary you can also change these on the command line. + +LDFLAGS = @LDFLAGS@ +LIBS = @LIBS@ + +# Compilation flags. + +LLVM_FLAGS = `llvm-config --cppflags` +LLVM_LIBS = `llvm-config --ldflags --libs core jit native` + +CPPFLAGS = @CPPFLAGS@ +CXXFLAGS = @CXXFLAGS@ + +# Pure library name. Currently we use a simple versioning scheme, which +# requires that the library version matches that of the interpreter. This +# enables you to install different versions of the Pure interpreter on the +# same system. + +libpure_base = $(name) +libpure_vers = $(libpure_base)-$(version) + +libpure = lib$(libpure_vers)$(DLL) +libpurelnk = lib$(libpure_base)$(DLL) + +# Whether to build the Pure runtime library. If this is set to anything but +# "yes", the interpreter is linked statically and no separate library is +# produced. This is necessary on some systems where LLVM cannot be linked in +# dynamically. + +sharedlib = @sharedlib@ + +# Flag needed to create shared libraries. On most systems this is just -shared. + +shared = @shared@ + +# On some systems -fPIC is needed for code linked as a shared library. + +ifeq ($(sharedlib), yes) +PIC = @PIC@ +else +PIC = +endif + +# Auxiliary libraries to be loaded at runtime. Usually this is just libpure +# (when built), but on some systems we have to load additional dlls to resolve +# some library functions. + +ifeq ($(sharedlib), yes) +AUXLIBS = -DLIBPURE='"$(libpure)"' @AUXLIBS@ +else +AUXLIBS = @AUXLIBS@ +endif + +# No need to edit below this line. Unless you really have to. :) ############ + +SOURCE = expr.cc expr.hh funcall.h interpreter.cc interpreter.hh lexer.ll \ +matcher.cc matcher.hh parser.yy printer.cc printer.hh \ +runtime.cc runtime.h symtable.cc symtable.hh util.cc util.hh +EXTRA_SOURCE = lexer.cc parser.cc parser.hh location.hh position.hh stack.hh +OBJECT = $(subst .cc,.o,$(filter %.cc,$(SOURCE) $(EXTRA_SOURCE))) + +DISTFILES = COPYING ChangeLog INSTALL NEWS README TODO \ +Makefile.in configure.ac configure config.h.in \ +config/aclocal.m4 config/config.guess config/config.sub config/install-sh \ +$(SOURCE) $(EXTRA_SOURCE) w3centities.c \ +pure.cc pure.1 pure.1.in etc/pure-mode.el.in etc/pure.* \ +examples/*.pure lib/*.pure test/*.pure test/*.log + +.PHONY: all html dvi ps pdf clean realclean depend install uninstall strip \ +dist distcheck cleanlogs logs check config + +# compilation + +all: pure$(EXE) etc/pure-mode.el pure.1 + +ifeq ($(sharedlib), yes) +pure$(EXE): pure.o $(libpure) + $(CXX) -o $@ $(LDFLAGS) pure.o -L. -l$(libpure_vers) $(LIBS) +else +pure$(EXE): pure.o $(OBJECT) + $(CXX) -o $@ $(LDFLAGS) pure.o $(OBJECT) $(LLVM_LIBS) $(LIBS) +endif + +$(libpure): $(OBJECT) + $(CXX) $(shared) -o $@ $(LDFLAGS) $(OBJECT) $(LLVM_LIBS) $(LIBS) + ln -sf $(libpure) $(libpurelnk) + +pure.o: pure.cc + $(CXX) $(CXXFLAGS) $(CPPFLAGS) $(LLVM_FLAGS) -DPURELIB='"$(libdir)/pure-$(version)"' -c -o $@ $< + +interpreter.o: interpreter.cc + $(CXX) $(CXXFLAGS) $(PIC) $(CPPFLAGS) $(LLVM_FLAGS) $(AUXLIBS) -c -o $@ $< + +%.o: %.cc + $(CXX) $(CXXFLAGS) $(PIC) $(CPPFLAGS) $(LLVM_FLAGS) -c -o $@ $< + +lexer.cc: lexer.ll + flex -o lexer.cc $< + +parser.cc: parser.yy + bison -v -o parser.cc $< + +parser.hh location.hh position.hh stack.hh: parser.cc + +# create pure-mode.el from pure-mode.el.in + +etc/pure-mode.el: Makefile etc/pure-mode.el.in + rm -f etc/pure-mode.el etc/pure-mode.el.tmp + sed -e 's,@bindir\@,$(bindir),g' -e 's,@libdir\@,$(libdir),g' etc/pure-mode.el.in >etc/pure-mode.el.tmp + mv etc/pure-mode.el.tmp etc/pure-mode.el + +# create the manpage from pure.1.in + +pure.1: configure.ac pure.1.in + rm -f pure.1 pure.1.tmp + sed -e 's,@version\@,$(version),g' pure.1.in >pure.1.tmp + mv pure.1.tmp pure.1 + +# documentation in various formats (requires groff) + +html: pure.html +dvi: pure.dvi +ps: pure.ps +pdf: pure.pdf + +# We do the html format using rman, because it produces nicer output. If you +# don't have rman, uncomment the rule below instead. + +%.html: %.1 + rman -f HTML $< | sed -e 's/dq/\"/g' -e '/^<br>$$/d' > $@ + +#%.html: %.1 +# groff -man -Thtml $< > $@ + +%.dvi: %.1 + groff -man -Tdvi $< > $@ + +%.ps: %.1 + groff -man -Tps $< > $@ + +%.pdf: %.1 + groff -man -Tps $< | ps2pdf - $@ + +# cleaning + +clean: + rm -f *~ *.bak *.html *.dvi *.ps *.pdf pure$(EXE) $(OBJECT) pure.o $(libpurelnk) $(libpure) parser.output + +distclean: clean + rm -f Makefile config.h config.log config.status etc/pure-mode.el $(dist).tar.gz + +realclean: distclean + rm -f $(addprefix $(srcdir)/, test/*.log $(EXTRA_SOURCE) pure.1) + +# dependencies (rerun configure after this) + +depend: $(SOURCE) $(EXTRA_SOURCE) + (cd $(srcdir) && makedepend -f Makefile.in -Y pure.cc $(SOURCE) $(EXTRA_SOURCE) 2> /dev/null) + +# regenerate configure et al + +config: configure config.h.in + +configure: configure.ac config/aclocal.m4 + autoconf -I config + +config.h.in: configure.ac config/aclocal.m4 + autoheader -I config + +# installation + +install: pure$(EXE) etc/pure-mode.el pure.1 + for x in $(addprefix $(DESTDIR), $(bindir) $(includedir)/pure-$(version) $(libdir)/pure-$(version) $(man1dir)); do $(INSTALL) -d $$x; done + $(INSTALL) pure$(EXE) $(DESTDIR)$(bindir)/pure-$(version)$(EXE) + ln -sf $(bindir)/pure-$(version)$(EXE) $(DESTDIR)$(bindir)/pure$(EXE) +ifeq ($(sharedlib), yes) + $(INSTALL) $(libpure) $(DESTDIR)$(libdir)/$(libpure) + ln -sf $(libdir)/$(libpure) $(DESTDIR)$(libdir)/$(libpurelnk) +endif + $(INSTALL) runtime.h $(DESTDIR)$(includedir)/pure-$(version) + ln -sf $(includedir)/pure-$(version) $(DESTDIR)$(includedir)/pure + for x in $(srcdir)/lib/*.pure; do $(INSTALL) -m 644 $$x $(DESTDIR)$(libdir)/pure-$(version); done + ln -sf $(libdir)/pure-$(version) $(DESTDIR)$(libdir)/pure + $(INSTALL) -m 644 pure.1 $(DESTDIR)$(man1dir)/pure-$(version).1 + ln -sf $(man1dir)/pure-$(version).1 $(DESTDIR)$(man1dir)/pure.1 + +uninstall: + rm -rf $(DESTDIR)$(bindir)/pure$(EXE) $(DESTDIR)$(bindir)/pure-$(version)$(EXE) $(DESTDIR)$(libdir)/$(libpure) $(DESTDIR)$(libdir)/$(libpurelnk) $(DESTDIR)$(includedir)/pure $(DESTDIR)$(includedir)/pure-$(version) $(DESTDIR)$(libdir)/pure $(DESTDIR)$(libdir)/pure-$(version) $(DESTDIR)$(man1dir)/pure.1 $(DESTDIR)$(man1dir)/pure-$(version).1 + +# roll a distribution tarball + +dist: pure.1 + rm -rf $(dist) + mkdir $(dist) && mkdir $(dist)/config && mkdir $(dist)/etc && mkdir $(dist)/examples && mkdir $(dist)/lib && mkdir $(dist)/test + (builddir=$$PWD; cd $(srcdir); for x in $(DISTFILES); do ln -sf $$PWD/$$x $$builddir/$(dist)/$$x; done) + rm -f $(dist).tar.gz + tar cfzh $(dist).tar.gz $(dist) + rm -rf $(dist) + +distcheck: dist + tar xfz $(dist).tar.gz + cd $(dist) && ./configure && make && make check && make install DESTDIR=./BUILD + rm -rf $(dist) + +# test logs, make check + +level=7 + +tests = $(wildcard $(srcdir)/test/*.pure) +logs = $(srcdir)/test/prelude.log $(tests:.pure=.log) + +logs: $(logs) + +cleanlogs: + rm -f $(srcdir)/test/*.log + +$(srcdir)/test/prelude.log: lib/prelude.pure lib/primitives.pure lib/strings.pure + LD_LIBRARY_PATH=. PURELIB=$(srcdir)/lib ./pure -n -v$(level) $< > $@ 2>&1 + +%.log: %.pure + LD_LIBRARY_PATH=. PURELIB=$(srcdir)/lib ./pure -v$(level) < $< > $@ 2>&1 + +check: pure + @ echo Running tests. + @ (export LD_LIBRARY_PATH=.; export PURELIB=$(srcdir)/lib; echo $(ECHO_N) "prelude.pure: "; if ./pure $(ECHO_N) -v$(level) $(srcdir)/lib/prelude.pure 2>&1 | diff -q - $(srcdir)/test/prelude.log > /dev/null; then echo passed; else echo FAILED; fi) + @ (export LD_LIBRARY_PATH=.; export PURELIB=$(srcdir)/lib; for x in $(notdir $(tests)); do echo $(ECHO_N) "$$x: "; if ./pure -v$(level) < $(srcdir)/test/$$x 2>&1 | diff -q - $(srcdir)/test/"`basename $$x .pure`.log" > /dev/null; then echo passed; else echo FAILED; fi; done) + +# DO NOT DELETE + +pure.o: interpreter.hh expr.hh matcher.hh symtable.hh printer.hh runtime.h +pure.o: parser.hh stack.hh util.hh location.hh position.hh config.h +expr.o: expr.hh interpreter.hh matcher.hh symtable.hh printer.hh runtime.h +expr.o: parser.hh stack.hh util.hh location.hh position.hh +interpreter.o: interpreter.hh expr.hh matcher.hh symtable.hh printer.hh +interpreter.o: runtime.h parser.hh stack.hh util.hh location.hh position.hh +interpreter.o: expr.hh matcher.hh symtable.hh printer.hh runtime.h parser.hh +interpreter.o: stack.hh util.hh location.hh position.hh +lexer.o: interpreter.hh expr.hh matcher.hh symtable.hh printer.hh runtime.h +lexer.o: parser.hh stack.hh util.hh location.hh position.hh +matcher.o: matcher.hh expr.hh +matcher.o: expr.hh +parser.o: expr.hh printer.hh matcher.hh runtime.h util.hh interpreter.hh +parser.o: symtable.hh parser.hh stack.hh location.hh position.hh +printer.o: printer.hh expr.hh matcher.hh runtime.h interpreter.hh symtable.hh +printer.o: parser.hh stack.hh util.hh location.hh position.hh +printer.o: expr.hh matcher.hh runtime.h +runtime.o: runtime.h expr.hh interpreter.hh matcher.hh symtable.hh printer.hh +runtime.o: parser.hh stack.hh util.hh location.hh position.hh funcall.h +symtable.o: symtable.hh expr.hh printer.hh matcher.hh runtime.h +symtable.o: expr.hh printer.hh matcher.hh runtime.h +util.o: util.hh config.h w3centities.c +lexer.o: interpreter.hh expr.hh matcher.hh symtable.hh printer.hh runtime.h +lexer.o: parser.hh stack.hh util.hh location.hh position.hh +parser.o: parser.hh stack.hh expr.hh printer.hh matcher.hh runtime.h util.hh +parser.o: location.hh position.hh interpreter.hh symtable.hh +parser.o: stack.hh expr.hh printer.hh matcher.hh runtime.h util.hh +parser.o: location.hh position.hh +location.o: position.hh Deleted: pure/releases/pure-0.4/NEWS =================================================================== --- pure/trunk/NEWS 2008-06-18 20:32:46 UTC (rev 261) +++ pure/releases/pure-0.4/NEWS 2008-06-21 11:13:10 UTC (rev 275) @@ -1,53 +0,0 @@ - -** Pure 0.3 2008-06-06 - -This release sports a lot of improvements as well as bug and portability -fixes, see the ChangeLog for details. Many memory leaks have been plugged, and -tail call elimination has been improved a lot. The build system has gone -through a major overhaul, adding autoconf support. 64 bit support has been -improved as well, and Pure now builds and runs fine on MS Windows. Many -library functions have been rewritten to make them tail-recursive, and some -new functions have been added. Last but not least, the runtime support is now -implemented as a separate shared library which makes it possible to link -external modules against the runtime, and reduces the memory footprint when -multiple instances of the interpreter are run as different processes. - -Special thanks to Tim Haynes, John Lunney, Eddie Rucker, Ryan Schmidt, Libor -Spacek and Jiri Spitz for contributions, suggestions and bug reports. - -** Pure 0.2 2008-05-04 - -On the heels of Pure 0.1 comes the first bugfix release which addresses a -couple of bugs, misfeatures and Mac OSX compatibility issues, please refer to -the ChangeLog for details. I also added a more detailed INSTALL guide (thanks -are due to Eddie Rucker who wrote most of the new material in this guide) and -updated the manpage with a few minor corrections and some remarks about issues -raised on the Pure mailing list. - -Please note that there are still some issues with Pure on 64 bit systems (as -well as on Ubuntu running on PowerPC) which are still on my TODO list, these -will hopefully be fixed in the next release. - -Thanks to all who sent in bug reports and patches, in particular: Chris -Double, Tim Haynes, Eddie Rucker, Ryan Schmidt and Libor Spacek. (I hope I -didn't forget anyone.) - -** Pure 0.1 2008-04-29 - -The much-awaited initial release. ;-) The interpreter is already fully -functional, but of course there's still a lot to be done (see the TODO file -for details). Please note that this is a preliminary, "beta" release, so -expect some bugs (and please report them to the author!). - -The Pure project is now hosted at SourceForge, see http://pure-lang.sf.net. A -mailing list should soon be available, too. - -See the INSTALLATION section in the README file to get up and running quickly. -After Pure is installed, read the Pure manual page (also available in various -formats from the Pure website) and have a look at the stuff in the examples -subdir, especially hello.pure, and review the standard library modules -(lib/*.pure). - -Enjoy! - -Albert Graef <Dr....@t-...> Copied: pure/releases/pure-0.4/NEWS (from rev 265, pure/trunk/NEWS) =================================================================== --- pure/releases/pure-0.4/NEWS (rev 0) +++ pure/releases/pure-0.4/NEWS 2008-06-21 11:13:10 UTC (rev 275) @@ -0,0 +1,74 @@ + +** Pure 0.4 2008-06-19 + +This release features some more bug and portability fixes, a cleanup of the +source tree and an overhaul of the build system, see the ChangeLog for +details. Building a separate runtime lib on x86-64 works now (but requires a +patched LLVM, see the INSTALL file for details). Moreover, it is now possible +to install different Pure versions in parallel. + +An Emacs mode for Pure and support for executing Pure scripts using "shebangs" +has been added. Paging of the 'list' command is now implemented using the +program specified with the PURE_MORE environment variable. This allows you to +disable this option (if PURE_MORE is undefined) or choose any pager program +and options that you prefer. Define PURE_MORE=more in your shell startup files +to get back the old behaviour of piping 'list' output through 'more'. + +There's also a new syntax for multiple left-hand sides in function definitions +and 'case' rules, as suggested by Jiri Spitz and discussed on the mailing +list. Please refer to the manual page for details. To accommodate this change, +the bitwise operators '&' and '|' were renamed to 'and' and 'or', +respectively. + +** Pure 0.3 2008-06-06 + +This release sports a lot of improvements as well as bug and portability +fixes, see the ChangeLog for details. Many memory leaks have been plugged, and +tail call elimination has been improved a lot. The build system has gone +through a major overhaul, adding autoconf support. 64 bit support has been +improved as well, and Pure now builds and runs fine on MS Windows. Many +library functions have been rewritten to make them tail-recursive, and some +new functions have been added. Last but not least, the runtime support is now +implemented as a separate shared library which makes it possible to link +external modules against the runtime, and reduces the memory footprint when +multiple instances ... [truncated message content] |
From: <ag...@us...> - 2008-06-21 07:00:32
|
Revision: 273 http://pure-lang.svn.sourceforge.net/pure-lang/?rev=273&view=rev Author: agraef Date: 2008-06-20 15:29:34 -0700 (Fri, 20 Jun 2008) Log Message: ----------- Remove 'preliminary' disclaimer. Modified Paths: -------------- pure/trunk/README Modified: pure/trunk/README =================================================================== --- pure/trunk/README 2008-06-20 20:02:58 UTC (rev 272) +++ pure/trunk/README 2008-06-20 22:29:34 UTC (rev 273) @@ -10,10 +10,6 @@ has an LLVM backend to do JIT compilation, hence programs run blazingly fast and interfacing to C modules is easy. -Please note that this is a preliminary, "beta" release, so please report bugs -to the author. Also have a look at the TODO file for stuff that still needs to -be done. - WHERE TO GET IT ----- -- --- -- This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ag...@us...> - 2008-06-21 03:05:48
|
Revision: 272 http://pure-lang.svn.sourceforge.net/pure-lang/?rev=272&view=rev Author: agraef Date: 2008-06-20 13:02:58 -0700 (Fri, 20 Jun 2008) Log Message: ----------- Fix typo. Modified Paths: -------------- pure/trunk/etc/pure.lang Modified: pure/trunk/etc/pure.lang =================================================================== --- pure/trunk/etc/pure.lang 2008-06-20 19:23:08 UTC (rev 271) +++ pure/trunk/etc/pure.lang 2008-06-20 20:02:58 UTC (rev 272) @@ -1,4 +1,4 @@ -# Pure language definition file for highlight (http:/www.andre-simon.de/). +# Pure language definition file for highlight (http://www.andre-simon.de/). # Copy this to your /usr/share/highlight/langDefs directory. $DESCRIPTION=Pure This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ag...@us...> - 2008-06-20 02:49:08
|
Revision: 270 http://pure-lang.svn.sourceforge.net/pure-lang/?rev=270&view=rev Author: agraef Date: 2008-06-19 19:49:17 -0700 (Thu, 19 Jun 2008) Log Message: ----------- Fix some minor formatting glitches. Modified Paths: -------------- pure/trunk/pure.1.in Modified: pure/trunk/pure.1.in =================================================================== --- pure/trunk/pure.1.in 2008-06-20 02:07:32 UTC (rev 269) +++ pure/trunk/pure.1.in 2008-06-20 02:49:17 UTC (rev 270) @@ -432,19 +432,19 @@ conditions: .sp .nf -\fIlhs\fR = \fIrhs\fB if \fIguard\fR; - = \fIrhs\fB if \fIguard\fR; +\fIlhs\fR = \fIrhs\fP \fBif\fP \fIguard\fP; + = \fIrhs\fP \fBif\fP \fIguard\fP; ... - = \fIrhs\fB otherwise\fR; + = \fIrhs\fP \fBotherwise\fP; .fi .PP Pure also allows a collection of rules with different left-hand sides but the same right-hand side(s) to be abbreviated as follows: .sp .nf -\fIlhs\fR | +\fIlhs\fP | ... -\fIlhs\fR = \fIrhs\fB; +\fIlhs\fP = \fIrhs\fP; .fi .PP This is useful if you need different specializations of the same rule which @@ -513,8 +513,8 @@ .sp .nf > list primes -primes n = sieve (2..n) with sieve [] = []; sieve (p:qs) = p:sieve -(catmap (\eq -> if q mod p then [q] else []) qs) end; +primes n = sieve (2..n) \fBwith\fP sieve [] = []; sieve (p:qs) = p:sieve +(catmap (\eq -> if q mod p then [q] else []) qs) \fBend\fP; .fi .PP We mention in passing that list comprehensions are also a useful device to This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ag...@us...> - 2008-06-20 02:07:25
|
Revision: 269 http://pure-lang.svn.sourceforge.net/pure-lang/?rev=269&view=rev Author: agraef Date: 2008-06-19 19:07:32 -0700 (Thu, 19 Jun 2008) Log Message: ----------- Updated ChangeLog. Modified Paths: -------------- pure/trunk/ChangeLog Modified: pure/trunk/ChangeLog =================================================================== --- pure/trunk/ChangeLog 2008-06-20 01:54:54 UTC (rev 268) +++ pure/trunk/ChangeLog 2008-06-20 02:07:32 UTC (rev 269) @@ -1,7 +1,14 @@ -2008-06-19 Albert Graef <Dr....@t-...> +2008-06-20 Albert Graef <Dr....@t-...> * 0.4 release. + * pure.cc, lexer.ll: Fake interactive mode when we're not + connected to a terminal but -i is specified. Thus sign-on message + and command prompts will be printed as usual. This is needed, in + particular, to make Emacs Pure-Eval mode work on Windows. + +2008-06-19 Albert Graef <Dr....@t-...> + * examples/symbolic.pure: Fix DNF example to accommodate changes in the operator system. This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ag...@us...> - 2008-06-20 01:54:46
|
Revision: 268 http://pure-lang.svn.sourceforge.net/pure-lang/?rev=268&view=rev Author: agraef Date: 2008-06-19 18:54:54 -0700 (Thu, 19 Jun 2008) Log Message: ----------- Fake interactive mode when we're not connected to a terminal but -i is specified. Modified Paths: -------------- pure/trunk/lexer.ll pure/trunk/pure.cc Modified: pure/trunk/lexer.ll =================================================================== --- pure/trunk/lexer.ll 2008-06-19 00:15:28 UTC (rev 267) +++ pure/trunk/lexer.ll 2008-06-20 01:54:54 UTC (rev 268) @@ -824,18 +824,41 @@ static char *my_buf = NULL, *my_bufptr = NULL; static int len = 0; +bool using_readline = false; + void my_readline(const char *prompt, char *buf, int &result, int max_size) { if (!my_buf) { - // read a new line using readline() - my_bufptr = my_buf = readline(prompt); - if (!my_buf) { - // EOF, bail out - result = 0; - return; + if (using_readline) { + // read a new line using readline() + my_bufptr = my_buf = readline(prompt); + if (!my_buf) { + // EOF, bail out + result = 0; + return; + } + add_history(my_buf); + } else { + // read a new line from stdin + char s[10000]; + fputs(prompt, stdout); fflush(stdout); + if (!fgets(s, 10000, stdin)) { + // EOF, bail out + result = 0; + return; + } + // get rid of the trailing newline + size_t l = strlen(s); + if (l>0 && s[l-1] == '\n') + s[l-1] = 0; + my_bufptr = my_buf = strdup(s); + if (!my_buf) { + // memory allocation error, bail out + result = 0; + return; + } } len = strlen(my_buf); - add_history(my_buf); } // how many chars we got int l = len-(my_bufptr-my_buf); Modified: pure/trunk/pure.cc =================================================================== --- pure/trunk/pure.cc 2008-06-19 00:15:28 UTC (rev 267) +++ pure/trunk/pure.cc 2008-06-20 01:54:54 UTC (rev 268) @@ -273,22 +273,28 @@ interp.symtab.init_builtins(); // enter the interactive command loop interp.interactive = true; - if (isatty(fileno(stdin))) { - // connected to a terminal, print sign-on and initialize readline + if (isatty(fileno(stdin)) || force_interactive) { + // We're connected to a terminal (or pretend that we are), print the + // sign-on message. if (!quiet) { cout << "Pure " << PACKAGE_VERSION << " (" << HOST << ") " << COPYRIGHT << endl << LICENSE; if (have_prelude) cout << "Loaded prelude from " << prelude << ".\n\n"; } + interp.compile(); + interp.ttymode = true; + } + if (isatty(fileno(stdin))) { + // initialize readline + extern bool using_readline; + using_readline = true; rl_readline_name = "Pure"; rl_attempted_completion_function = pure_completion; using_history(); read_history(interp.histfile.c_str()); stifle_history(600); histfile = strdup(interp.histfile.c_str()); - interp.compile(); - interp.ttymode = true; } interp.temp = 1; interp.run(""); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ag...@us...> - 2008-06-19 00:15:19
|
Revision: 267 http://pure-lang.svn.sourceforge.net/pure-lang/?rev=267&view=rev Author: agraef Date: 2008-06-18 17:15:28 -0700 (Wed, 18 Jun 2008) Log Message: ----------- Fix up linebreaks in html version of the manual. Modified Paths: -------------- pure/trunk/Makefile.in Modified: pure/trunk/Makefile.in =================================================================== --- pure/trunk/Makefile.in 2008-06-19 00:05:07 UTC (rev 266) +++ pure/trunk/Makefile.in 2008-06-19 00:15:28 UTC (rev 267) @@ -173,7 +173,7 @@ # don't have rman, uncomment the rule below instead. %.html: %.1 - rman -f HTML $< | sed -e 's/dq/\"/g' -e '/<br>/d' > $@ + rman -f HTML $< | sed -e 's/dq/\"/g' -e '/^<br>$$/d' > $@ #%.html: %.1 # groff -man -Thtml $< > $@ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |