Compare commits

...

5 Commits

Author SHA1 Message Date
sam 5ba5ffc44d build: release 0.99.8.
git-svn-id: svn://svn.zoy.org/elk/trunk@281 55e467fa-43c5-0310-a8a2-de718669efc6
2011-06-18 11:45:45 +00:00
sam edaad7697e test: fix the source code checker POSIX conformity.
git-svn-id: svn://svn.zoy.org/elk/trunk@280 55e467fa-43c5-0310-a8a2-de718669efc6
2011-06-18 10:41:59 +00:00
sam 247a29cb18 Support for [] delimiters in addition to (), courtesy of Sanel Zukan.
git-svn-id: svn://svn.zoy.org/elk/trunk@279 55e467fa-43c5-0310-a8a2-de718669efc6
2009-12-23 23:30:19 +00:00
sam cb4532eb43 Fix a link in the README. This was reported to me 4 years ago :(
git-svn-id: svn://svn.zoy.org/elk/trunk@278 55e467fa-43c5-0310-a8a2-de718669efc6
2009-12-19 13:51:56 +00:00
sam 8797e16d7b Add support for primitive->string, compound->string and macro->string,
thanks to Derek Peschel <dpeschel@eskimo.com>. Patch slightly reworked.

git-svn-id: svn://svn.zoy.org/elk/trunk@277 55e467fa-43c5-0310-a8a2-de718669efc6
2009-12-19 13:08:32 +00:00
10 changed files with 85 additions and 31 deletions

View File

@ -30,6 +30,6 @@ Scott Watson, and Mike Wray. Oliver apologizes for any omissions from
this--necessarily incomplete--list.
Sam would like to thank James Bostock, Sven Hartrumpf, Mark Sapa, Phillip
Rulon and Martin Rumori for their useful bug reports and patches on the road
to Elk 4.0.
Rulon, Martin Rumori and Sanel Zukan (support for [] delimiters) for their
useful bug reports and patches on the road to Elk 4.0.

3
NEWS
View File

@ -3,6 +3,9 @@ $Id$
Changes between 3.0 and 4.0:
----------------------------
* New in 3.99.8 prerelease:
+ Maintenance release with minor bugfixes.
* New in 3.99.7 prerelease:
+ Last known garbage collector bug was fixed.

2
README
View File

@ -35,7 +35,7 @@ Getting Elk
You can obtain the Elk 3.99 distribution as well as additional information
about Elk in the World Wide Web at
http://sam.zoy.org/projects/sam/
http://sam.zoy.org/elk/
The distribution is also available for anonymous FTP from a number of
servers including these:

View File

@ -6,7 +6,7 @@ AC_PREREQ(2.50)
AC_CONFIG_AUX_DIR(.auto)
AC_CANONICAL_SYSTEM
AM_INIT_AUTOMAKE(elk, 3.99.7)
AM_INIT_AUTOMAKE(elk, 3.99.8)
dnl AM_MAINTAINER_MODE
AM_CONFIG_HEADER(config.h)

View File

@ -366,8 +366,11 @@ extern Object P_Macro (Object);
extern Object P_Macro_Body (Object);
extern Object P_Macro_Expand (Object);
extern Object P_Primitivep (Object);
extern Object P_Primitive_To_String (Object);
extern Object P_Compoundp (Object);
extern Object P_Compound_To_String (Object);
extern Object P_Macrop (Object);
extern Object P_Macro_To_String (Object);
extern void Check_Procedure (Object);
/* Delay and force

View File

@ -41,7 +41,7 @@ extern_c Object elk_import False2;
#define Numeric(t) (t == T_Fixnum || t == T_Flonum || t == T_Bignum)
#define Whitespace(c) (c == ' ' || c == '\t' || c == '\014' || c == '\n' || c == '\r')
#define Delimiter(c) (c == ';' || c == ')' || c == '(' || c == '"')
#define Delimiter(c) (c == ';' || c == ')' || c == '(' || c == '[' || c == ']' || c == '"')
/* Align heap addresses */

View File

@ -301,8 +301,13 @@ struct Prim_Init {
*/
{ P_Procedurep, "procedure?", 1, 1, EVAL },
{ P_Primitivep, "primitive?", 1, 1, EVAL },
{ P_Primitive_To_String,
"primitive->string", 1, 1, EVAL },
{ P_Compoundp, "compound?", 1, 1, EVAL },
{ P_Compound_To_String,
"compound->string", 1, 1, EVAL },
{ P_Macrop, "macro?", 1, 1, EVAL },
{ P_Macro_To_String, "macro->string", 1, 1, EVAL },
{ P_Eval, "eval", 1, 2, VARARGS },
{ P_Apply, "apply", 2, MANY, VARARGS },
{ P_Lambda, "lambda", 2, MANY, NOEVAL },

View File

@ -100,14 +100,39 @@ Object P_Primitivep (Object x) {
return TYPE(x) == T_Primitive ? True : False;
}
Object P_Primitive_To_String (Object x) {
Check_Type (x, T_Primitive);
return Make_String (PRIM(x)->name, strlen(PRIM(x)->name));
}
Object P_Compoundp (Object x) {
return TYPE(x) == T_Compound ? True : False;
}
Object P_Compound_To_String (Object x) {
Check_Type (x, T_Compound);
if (Nullp (COMPOUND(x)->name)) {
static char buf[64];
sprintf (buf, "#<compound %lu>", POINTER(x));
return Make_String (buf, strlen(buf));
}
return COMPOUND(x)->name;
}
Object P_Macrop (Object x) {
return TYPE(x) == T_Macro ? True : False;
}
Object P_Macro_To_String (Object x) {
Check_Type (x, T_Macro);
if (Nullp (MACRO(x)->name)) {
static char buf[64];
sprintf (buf, "#<macro %lu>", POINTER(x));
return Make_String (buf, strlen(buf));
}
return MACRO(x)->name;
}
Object Make_Compound () {
Object proc;

View File

@ -80,7 +80,7 @@ static void Read_Grow () {
Object General_Read(), Read_Sequence(), Read_Atom(), Read_Special();
Object Read_String(), Read_Sharp(), Read_True(), Read_False(), Read_Void();
Object Read_Kludge(), Read_Vector(), Read_Radix(), Read_Char();
Object Read_Kludge(), Read_Vector_Paren(), Read_Vector_Bracket(), Read_Radix(), Read_Char();
void Init_Read () {
Define_Symbol (&Sym_Quote, "quote");
@ -92,7 +92,8 @@ void Init_Read () {
Readers['f'] = Readers['F'] = Read_False;
Readers['v'] = Readers['V'] = Read_Void;
Readers['!'] = Read_Kludge; /* for interpreter files */
Readers['('] = Read_Vector;
Readers['('] = Read_Vector_Paren;
Readers['['] = Read_Vector_Bracket;
Readers['b'] = Readers['B'] =
Readers['o'] = Readers['O'] =
Readers['d'] = Readers['D'] =
@ -273,8 +274,8 @@ comment:
}
continue;
}
if (c == '(') {
ret = Read_Sequence (port, 0, konst);
if (c == '(' || c == '[') {
ret = Read_Sequence (port, 0, konst, c);
} else if (c == '#') {
ret = Read_Sharp (port, konst);
if (TYPE(ret) == T_Special) /* it was a #! */
@ -333,11 +334,13 @@ eof:
if (Skip_Comment (port) == EOF)
goto eof;
goto again;
case ']':
case ')':
SET(ret, T_Special, c);
return ret;
case '[':
case '(':
return Read_Sequence (port, 0, konst);
return Read_Sequence (port, 0, konst, c);
case '\'':
return READ_QUOTE(Sym_Quote);
case '`':
@ -394,7 +397,7 @@ eof:
/*NOTREACHED*/
}
Object Read_Sequence (Object port, int vec, int konst) {
Object Read_Sequence (Object port, int vec, int konst, int start_chr) {
Object ret, e, tail, t;
GC_Node3;
@ -403,7 +406,14 @@ Object Read_Sequence (Object port, int vec, int konst) {
while (1) {
e = Read_Special (port, konst);
if (TYPE(e) == T_Special) {
if (CHAR(e) == ')') {
if (CHAR(e) == ')' || CHAR(e) == ']') {
if ((start_chr == '(' && CHAR(e) == ']')
|| (start_chr == '[' && CHAR(e) == ')')) {
char buf[64];
sprintf(buf, "expression starts with '%c' but ends "
"with '%c'", start_chr, CHAR(e));
Reader_Error (port, buf);
}
GC_Unlink;
return ret;
}
@ -420,7 +430,7 @@ Object Read_Sequence (Object port, int vec, int konst) {
Cdr (tail) = e;
}
e = Read_Special (port, konst);
if (TYPE(e) == T_Special && CHAR(e) == ')') {
if (TYPE(e) == T_Special && (CHAR(e) == ')' || CHAR(e) == ']')) {
GC_Unlink;
return ret;
}
@ -522,8 +532,13 @@ Object Read_Kludge (Object port, int chr, int konst) {
}
/*ARGSUSED*/
Object Read_Vector (Object port, int chr, int konst) {
return List_To_Vector (Read_Sequence (port, 1, konst), konst);
Object Read_Vector_Paren (Object port, int chr, int konst) {
return List_To_Vector (Read_Sequence (port, 1, konst, '('), konst);
}
/*ARGSUSED*/
Object Read_Vector_Bracket (Object port, int chr, int konst) {
return List_To_Vector (Read_Sequence (port, 1, konst, '['), konst);
}
/*ARGSUSED*/

View File

@ -1,33 +1,36 @@
#!/bin/sh
ret=0
#
# Check that we have no tabs or trailing spaces in the source code
#
failure=0
nfails=0
nfiles=0
nlines=0
for dir in lib/misc lib/unix lib/xlib lib/xwidgets lib/xwidgets/motif \
lib/xwidgets/xaw src; do
pushd ../$dir >/dev/null
for x in $(make echo-sources); do
if grep '[[:space:]]$' "$x" >/dev/null 2>&1; then
if [ ! -d "../$dir" ]; then continue; fi
for x in $(make -s echo-sources -C ../$dir); do
case "$x" in
*.c|*.cpp|*.h|*.m|*.php|*.cs|*.java|.py|.pl)
nfiles=$(($nfiles + 1));
nlines=$(($nlines + `grep -c . "../$dir/$x"`)) ;;
*)
continue ;;
esac
if grep '[[:space:]]$' "../$dir/$x" >/dev/null 2>&1; then
echo "error: $dir/$x contains trailing spaces"
failure=1
nfails=$(($nfails + 1))
fi
if grep ' ' "$x" >/dev/null 2>&1; then
if grep ' ' "../$dir/$x" >/dev/null 2>&1; then
echo "error: $dir/$x contains tabs"
failure=1
nfails=$(($nfails + 1))
fi
done
popd >/dev/null
done
if test "$failure" != "0"; then
ret=1
else
echo "0 errors in source code"
fi
if test "$ret" != "0"; then
echo "$nfiles files, $nlines lines, $nfails errors in source code"
if test "$nfails" != "0"; then
exit 1
fi