[Commit] nickle ChangeLog, 1.119, 1.120 builtin-file.c, 1.19, 1.20 builtin-toplevel.c, 1.28, 1.29 execute.c, 1.94, 1.95 file.c, 1.66, 1.67 float.c, 1.27, 1.28 gram.y, 1.144, 1.145 lex.l, 1.81, 1.82 sched.c, 1.59, 1.60

Keith Packard commit at keithp.com
Thu Jan 13 21:44:05 PST 2005


Committed by: keithp

Update of /local/src/CVS/nickle
In directory home.keithp.com:/tmp/cvs-serv29493

Modified Files:
	ChangeLog builtin-file.c builtin-toplevel.c execute.c file.c 
	float.c gram.y lex.l sched.c 
Log Message:
2005-01-13  Keith Packard  <keithp at keithp.com>

	reviewed by: <delete if not using a buddy>

	* builtin-file.c: (import_File_namespace):
	* file.c: (FileInitErrors), (FileGetError):
	Use error_type typedef instead of directly using the type.
	
	* builtin-toplevel.c: (do_setdims):
	* execute.c: (ThreadArrayInd):
	* sched.c: (RaiseException):
	Use ArrayValue to catch uninitialized values
	
	* float.c: (DoublePart):
	Raise exception on non-float args
	
	* gram.y:
	* lex.l:
	Rearrange publish/class/type grammar elements to make them prettier
	Fix ignorenl decrementing to avoid going below zero on syntax error.


Index: ChangeLog
===================================================================
RCS file: /local/src/CVS/nickle/ChangeLog,v
retrieving revision 1.119
retrieving revision 1.120
diff -u -d -r1.119 -r1.120
--- ChangeLog	24 Dec 2004 09:20:47 -0000	1.119
+++ ChangeLog	14 Jan 2005 05:44:00 -0000	1.120
@@ -1,3 +1,24 @@
+2005-01-13  Keith Packard  <keithp at keithp.com>
+
+	reviewed by: <delete if not using a buddy>
+
+	* builtin-file.c: (import_File_namespace):
+	* file.c: (FileInitErrors), (FileGetError):
+	Use error_type typedef instead of directly using the type.
+	
+	* builtin-toplevel.c: (do_setdims):
+	* execute.c: (ThreadArrayInd):
+	* sched.c: (RaiseException):
+	Use ArrayValue to catch uninitialized values
+	
+	* float.c: (DoublePart):
+	Raise exception on non-float args
+	
+	* gram.y:
+	* lex.l:
+	Rearrange publish/class/type grammar elements to make them prettier
+	Fix ignorenl decrementing to avoid going below zero on syntax error.
+
 2004-12-24  Keith Packard  <keithp at keithp.com>
 version 2.45
 

Index: builtin-file.c
===================================================================
RCS file: /local/src/CVS/nickle/builtin-file.c,v
retrieving revision 1.19
retrieving revision 1.20
diff -u -d -r1.19 -r1.20
--- builtin-file.c	23 Aug 2004 00:42:06 -0000	1.19
+++ builtin-file.c	14 Jan 2005 05:44:00 -0000	1.20
@@ -197,10 +197,10 @@
     for (e = excepts; e->name; e++)
 	BuiltinAddException (&FileNamespace, e->exception, e->name, e->args, e->doc);
 
-    s = NewSymbolType (AtomId("errorType"), typeFileError);
+    s = typeFileError->name.name;
     NamespaceAddName (FileNamespace, s, publish_public);
     
-    s = NewSymbolType (AtomId("error_type"), typeFileError);
+    s = NewSymbolType (AtomId("errorType"), typeFileError);
     NamespaceAddName (FileNamespace, s, publish_public);
     
     EXIT ();

Index: builtin-toplevel.c
===================================================================
RCS file: /local/src/CVS/nickle/builtin-toplevel.c,v
retrieving revision 1.28
retrieving revision 1.29
diff -u -d -r1.28 -r1.29
--- builtin-toplevel.c	23 Nov 2004 05:02:07 -0000	1.28
+++ builtin-toplevel.c	14 Jan 2005 05:44:00 -0000	1.29
@@ -485,7 +485,7 @@
     for (i = 0; i < a->ndim; i++)
     {
 	int j = a->ndim - 1 - i;
-	dims[j] = IntPart (ArrayValueGet (d,i), "setdims: invalid dimension");
+	dims[j] = IntPart (ArrayValue (d,i), "setdims: invalid dimension");
 	if (aborting)
 	    RETURN (Void);
 	if (dims[j] < 0)

Index: execute.c
===================================================================
RCS file: /local/src/CVS/nickle/execute.c,v
retrieving revision 1.94
retrieving revision 1.95
diff -u -d -r1.94 -r1.95
--- execute.c	11 Dec 2004 06:02:23 -0000	1.94
+++ execute.c	14 Jan 2005 05:44:00 -0000	1.95
@@ -348,7 +348,7 @@
     dims = AllocateTemp (ndim * sizeof (int));
     for (i = 0; i < ndim; i++)
     {
-	Value	d = ArrayValueGet(a, i);
+	Value	d = ArrayValue (a, i);
 	dims[i] = IntPart (d, "Invalid array dimension");
 	if (dims[i] < 0)
 	    RaiseStandardException (exception_invalid_argument,

Index: file.c
===================================================================
RCS file: /local/src/CVS/nickle/file.c,v
retrieving revision 1.66
retrieving revision 1.67
diff -u -d -r1.66 -r1.67
--- file.c	17 Dec 2004 02:05:20 -0000	1.66
+++ file.c	14 Jan 2005 05:44:00 -0000	1.67
@@ -423,7 +423,7 @@
 
 #define NUM_FILE_ERRORS	(sizeof (fileErrorMap) / sizeof (fileErrorMap[0]))
 
-Type	*typeFileError;
+Type    *typeFileError;
 
 static int
 FileInitErrors (void)
@@ -432,7 +432,9 @@
     StructType	    *st;
     Atom	    *atoms;
     int		    i;
+    SymbolPtr	    error_type;
 
+    error_type = NewSymbolType (AtomId("error_type"), 0);
     st = NewStructType (NUM_FILE_ERRORS);
     atoms = StructTypeAtoms (st);
     for (i = 0; i < NUM_FILE_ERRORS; i++)
@@ -440,7 +442,9 @@
 	AddBoxType (&st->types, typePrim[rep_void]);
 	atoms[i] = AtomId (fileErrorMap[i].name);
     }
-    typeFileError = NewTypeUnion (st, True);
+    error_type->symbol.type = NewTypeUnion (st, True);
+    typeFileError = NewTypeName (NewExprAtom (AtomId ("error_type"), 0, False),
+				 error_type);
     MemAddRoot (typeFileError);
     EXIT ();
     return 1;
@@ -493,7 +497,7 @@
 	    break;
     if (i == NUM_FILE_ERRORS)
 	i = 0;	    /* XXX weird error */
-    st = typeFileError->structs.structs;
+    st = TypeCanon (typeFileError)->structs.structs;
     ret = NewUnion (st, True);
     ret->unions.tag = StructTypeAtoms(st)[i];
     BoxValueSet (ret->unions.value,0,Void);

Index: float.c
===================================================================
RCS file: /local/src/CVS/nickle/float.c,v
retrieving revision 1.27
retrieving revision 1.28
diff -u -d -r1.27 -r1.28
--- float.c	17 Dec 2004 05:49:33 -0000	1.27
+++ float.c	14 Jan 2005 05:44:00 -0000	1.28
@@ -1163,6 +1163,12 @@
     double  div;
     
     av = NewValueFloat (av, 64);
+    if (!ValueIsFloat (av))
+    {
+	RaiseStandardException (exception_invalid_argument, error, 
+				2, NewInt (0), av);
+	return 0.0;
+    }
     if (NaturalLess (av->floats.exp->mag, max_int_natural))
 	e = NaturalToInt (av->floats.exp->mag);
     else

Index: gram.y
===================================================================
RCS file: /local/src/CVS/nickle/gram.y,v
retrieving revision 1.144
retrieving revision 1.145
diff -u -d -r1.144 -r1.145
--- gram.y	11 Dec 2004 06:02:23 -0000	1.144
+++ gram.y	14 Jan 2005 05:44:00 -0000	1.145
@@ -106,7 +106,8 @@
 %type  <declList>   initnames typenames
 %type  <symbol>	    name opt_name
 %type  <funcDecl>   func_decl func_name
-%type  <atom>	    typename
+%type  <atom>	    typename 
+%type  <symbol>	    opt_typename
 %type  <expr>	    opt_init
 %type  <fulltype>   decl next_decl
 %type  <type>	    opt_type type subscripts subtype
@@ -114,7 +115,7 @@
 %type  <type>	    basetype
 %type  <expr>	    dims
 %type  <memList>    struct_members union_members
-%type  <class>	    class
+%type  <class>	    class opt_class
 %type  <publish>    opt_publish publish publish_extend
 %type  <atom>	    namespacename
 
@@ -208,7 +209,7 @@
 		    { ignorenl++; }
 		;
 attendnl	:
-		    { ignorenl--; }
+		    { if (ignorenl > 0) ignorenl--; }
 		;
 reset		:
 		    { 
@@ -779,6 +780,7 @@
 typename	: TYPENAME
 		| NAME
 		;
+
 /*
  * Ok, a few cute hacks to fetch the fulltype from the
  * value stack -- initnames always immediately follows a decl,
@@ -880,20 +882,12 @@
 /*
  * Full declaration including storage, type and publication
  */
-decl		: publish class type opt_nl
+decl		: publish opt_class opt_type opt_nl
 		    { $$.publish = $1; $$.class = $2; $$.type = $3; }
-		| class type opt_nl
+		| class opt_type opt_nl
 		    { $$.publish = publish_private; $$.class = $1; $$.type = $2; }
-		| publish type opt_nl
-		    { $$.publish = $1; $$.class = class_undef; $$.type = $2; }
 		| type opt_nl
 		    { $$.publish = publish_private; $$.class = class_undef; $$.type = $1; }
-		| publish class opt_nl
-		    { $$.publish = $1; $$.class = $2; $$.type = typePoly; }
-		| class opt_nl
-		    { $$.publish = publish_private; $$.class = $1; $$.type = typePoly; }
-		| publish opt_nl
-		    { $$.publish = $1; $$.class = class_undef; $$.type = typePoly; }
 		;
 /*
  * Type declarations
@@ -1080,12 +1074,15 @@
 /*
 * Declaration modifiers
 */
+opt_class	: class
+		|
+		    { $$ = class_undef; }
+		;
 class		: GLOBAL
 		| AUTO
 		| STATIC
 		| CONST
 		;
-
 opt_publish	: publish
 		|
 		    { $$ = publish_private; }
@@ -2090,5 +2087,6 @@
 void
 yyerror (char *msg)
 {
+    ignorenl = 0;
     ParseError ("%s before %S", msg, yytext);
 }

Index: lex.l
===================================================================
RCS file: /local/src/CVS/nickle/lex.l,v
retrieving revision 1.81
retrieving revision 1.82
diff -u -d -r1.81 -r1.82
--- lex.l	11 Dec 2004 06:02:23 -0000	1.81
+++ lex.l	14 Jan 2005 05:44:00 -0000	1.82
@@ -203,8 +203,11 @@
 	for (;;)
 	{
 	    FileFlush (FileStdout, False);
+	    FileFlush (FileStderr, False);
 	    if (FileStdout->file.flags & FileOutputBlocked)
 		ThreadsRun (0, FileStdout);
+	    else if (FileStderr->file.flags & FileOutputBlocked)
+		ThreadsRun (0, FileStderr);
 	    else
 		break;
 	}
@@ -368,12 +371,12 @@
 		    if (!ignorenl) { yylval.ints = NL; return NL; } 
 		}
 "("		{ yylval.ints = OP; ++ignorenl; return OP; }
-")"		{ yylval.ints = CP; --ignorenl; return CP; }
+")"		{ yylval.ints = CP; if (ignorenl > 0) --ignorenl; return CP; }
 "*["		{ yylval.ints = STAROS; ++ignorenl; return STAROS; }
 "["		{ yylval.ints = OS; ++ignorenl; return OS; }
-"]"		{ yylval.ints = CS; --ignorenl; return CS; }
+"]"		{ yylval.ints = CS; if (ignorenl > 0) --ignorenl; return CS; }
 "{"		{ yylval.ints = OC; ++ignorenl; return OC; }
-"}"		{ yylval.ints = CC; --ignorenl; return CC; }
+"}"		{ yylval.ints = CC; if (ignorenl > 0) --ignorenl; return CC; }
 "+="		{ yylval.ints = ASSIGNPLUS; return ASSIGNPLUS; }
 "-="		{ yylval.ints = ASSIGNMINUS; return ASSIGNMINUS; }
 "*="		{ yylval.ints = ASSIGNTIMES; return ASSIGNTIMES; }

Index: sched.c
===================================================================
RCS file: /local/src/CVS/nickle/sched.c,v
retrieving revision 1.59
retrieving revision 1.60
diff -u -d -r1.59 -r1.60
--- sched.c	11 Dec 2004 06:02:23 -0000	1.59
+++ sched.c	14 Jan 2005 05:44:00 -0000	1.60
@@ -1170,7 +1170,7 @@
 	    int	    dim = ArrayLimits(&args->array)[0];
 	    for (i = 0; i < dim; i++)
 	    {
-		PrintError ("%g", ArrayValueGet (&args->array, i));
+		PrintError ("%g", ArrayValue (&args->array, i));
 		if (i < dim - 1)
 		    PrintError (", ");
 	    }




More information about the Commit mailing list