[Commit] nickle compile.c,1.131,1.132 gram.y,1.115,1.116 pretty.c,1.60,1.61

Keith Packard commit@keithp.com
Thu, 01 May 2003 12:00:20 -0700


Committed by: keithp

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

Modified Files:
	compile.c gram.y pretty.c 
Log Message:
Rewrite . and $n in the compiler not the grammar to make pretty printing look right


Index: compile.c
===================================================================
RCS file: /local/src/CVS/nickle/compile.c,v
retrieving revision 1.131
retrieving revision 1.132
diff -u -d -r1.131 -r1.132
--- compile.c	17 Mar 2003 05:51:33 -0000	1.131
+++ compile.c	1 May 2003 19:00:18 -0000	1.132
@@ -2481,6 +2481,19 @@
 	expr->base.type = typePrim[rep_thread];
 	break;
     case DOLLAR:
+	{
+	    ExprPtr value, new;
+	    
+	    if (expr->tree.left)
+		value = expr->tree.left;
+	    else
+		value = NewExprConst (TEN_NUM, Zero);
+	    new = BuildCall ("History", "fetch", 1, value);
+	    obj = _CompileExpr (obj, new, True, stat, code);
+	}
+	expr->base.type = typePoly;
+	break;
+    case EXPR:
 	/* reposition statement reference so top-level errors are nicer*/
 	obj = _CompileExpr (obj, expr->tree.left, evaluate, expr, code);
 	expr->base.type = expr->tree.left->base.type;

Index: gram.y
===================================================================
RCS file: /local/src/CVS/nickle/gram.y,v
retrieving revision 1.115
retrieving revision 1.116
diff -u -d -r1.115 -r1.116
--- gram.y	17 Mar 2003 05:51:33 -0000	1.115
+++ gram.y	1 May 2003 19:00:18 -0000	1.116
@@ -241,7 +241,7 @@
 			FramePtr	f;
 			
 			e = BuildCall ("Command", "display",
-				       1,NewExprTree (DOLLAR, $2, 0));
+				       1,NewExprTree (EXPR, $2, 0));
 			GetNamespace (&s, &f);
 			t = NewThread (f, CompileExpr (e, 0));
 			ThreadsRun (t, 0);
@@ -1332,7 +1332,7 @@
 		| DOLLAR opt_integer
 		    { $$ = BuildCall ("History", "fetch", 1, NewExprConst (TEN_NUM, $2)); }
 		| DOT
-		    { $$ = BuildCall ("History", "fetch", 1, NewExprConst (TEN_NUM, Zero)); }
+		    { $$ = NewExprTree (DOLLAR, 0, 0); }
 		| OP expr CP
 		    { $$ = $2; }
 		| OP block CP

Index: pretty.c
===================================================================
RCS file: /local/src/CVS/nickle/pretty.c,v
retrieving revision 1.60
retrieving revision 1.61
diff -u -d -r1.60 -r1.61
--- pretty.c	2 Nov 2002 21:34:50 -0000	1.60
+++ pretty.c	1 May 2003 19:00:18 -0000	1.61
@@ -539,6 +539,15 @@
 	PrettyExpr (f, e->tree.right->tree.right, selfPrec, level, nest, pd);
 	break;
     case DOLLAR:
+	if (e->tree.left)
+	{
+	    FilePuts (f, "$");
+	    PrettyExpr (f, e->tree.left, selfPrec, level, nest, pd);
+	}
+	else
+	    FilePuts (f, ".");
+	break;
+    case EXPR:
 	PrettyExpr (f, e->tree.left, selfPrec, level, nest, pd);
 	break;
     }