[Commit]
nickle ChangeLog, 1.45, 1.46 compile.c, 1.148, 1.149 gram.y,
1.130, 1.131 pretty.c, 1.67, 1.68 version.m4, 1.12, 1.13
Bart Massey
commit at keithp.com
Thu May 20 02:37:40 PDT 2004
- Previous message: [Commit] nickle parse-args.5c, NONE, 1.1 ChangeLog, 1.44,
1.45 Makefile.am, 1.51, 1.52 version.m4, 1.11, 1.12
- Next message: [Commit] nickle pretty.c,1.68,1.69
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
Committed by: bart
Update of /local/src/CVS/nickle
In directory home.keithp.com:/tmp/cvs-serv9268
Modified Files:
ChangeLog compile.c gram.y pretty.c version.m4
Log Message:
Two-argument for() loop is legal
now (no init expr).
Index: ChangeLog
===================================================================
RCS file: /local/src/CVS/nickle/ChangeLog,v
retrieving revision 1.45
retrieving revision 1.46
diff -u -d -r1.45 -r1.46
--- a/ChangeLog 18 May 2004 06:26:03 -0000 1.45
+++ b/ChangeLog 20 May 2004 09:37:37 -0000 1.46
@@ -1,3 +1,11 @@
+2004-05-20 Bart Massey <bart at cs.pdx.edu>
+
+ * gram.y, compile.c pretty.c
+ Two-argument for() loop is legal
+ now (no init expr).
+ * version.m4
+ Bumped the version to 2.33
+
2004-05-17 Bart Massey <bart at cs.pdx.edu>
* parse-args.5c:
Index: compile.c
===================================================================
RCS file: /local/src/CVS/nickle/compile.c,v
retrieving revision 1.148
retrieving revision 1.149
diff -u -d -r1.148 -r1.149
--- a/compile.c 16 Apr 2004 05:26:44 -0000 1.148
+++ b/compile.c 20 May 2004 09:37:37 -0000 1.149
@@ -3198,21 +3198,21 @@
/* check for b */
bobj = 0;
- if (expr->tree.left->tree.right)
+ if (expr->tree.left->tree.right->tree.left)
{
bobj = NewObj (OBJ_INCR, OBJ_STAT_INCR);
bobj = _CompileBoolExpr (bobj,
- expr->tree.left->tree.right,
+ expr->tree.left->tree.right->tree.left,
True, expr, code);
NewInst (obj, OpBranch, start_inst, expr);
}
/* check for c */
cobj = 0;
- if (expr->tree.right->tree.left)
+ if (expr->tree.left->tree.right->tree.right->tree.left)
{
cobj = NewObj (OBJ_INCR, OBJ_STAT_INCR);
- cobj = _CompileExpr (cobj, expr->tree.right->tree.left, False, expr, code);
+ cobj = _CompileExpr (cobj, expr->tree.left->tree.right->tree.right->tree.left, False, expr, code);
}
top_inst = obj->used;
@@ -3220,7 +3220,7 @@
/* d */
obj->nonLocal = NewNonLocal (obj->nonLocal, NonLocalControl,
NON_LOCAL_BREAK|NON_LOCAL_CONTINUE);
- obj = _CompileStat (obj, expr->tree.right->tree.right, False, code);
+ obj = _CompileStat (obj, expr->tree.right, False, code);
obj->nonLocal = obj->nonLocal->prev;
/* glue c into place */
Index: gram.y
===================================================================
RCS file: /local/src/CVS/nickle/gram.y,v
retrieving revision 1.130
retrieving revision 1.131
diff -u -d -r1.130 -r1.131
--- a/gram.y 16 Apr 2004 05:26:45 -0000 1.130
+++ b/gram.y 20 May 2004 09:37:37 -0000 1.131
@@ -35,7 +35,8 @@
*
* This says that you can have multiple NLs in a row
* and the grammar can't tell which opt_nl is reduced.
- * No big deal.
+ * No big deal. (Could be fixed by replacing with opt_nls
+ * everywhere, but would change the semantics? --Bart)
*
* shift/reduce conflict on CATCH:
*
@@ -69,6 +70,9 @@
CanonTypeDefined,
} CanonTypeResult;
+static Expr *
+ParseCanonFor (Expr *expr);
+
static CanonTypeResult
ParseCanonType (TypePtr type, Bool forwardAllowed);
@@ -130,7 +134,7 @@
%type <argDecl> argdefine
%type <bool> opt_dotdotdot
-%type <expr> opt_expr expr opt_exprs exprs simpleexpr primary
+%type <expr> opt_expr for_exprs expr opt_exprs exprs simpleexpr primary
%type <expr> opt_actuals actuals
%type <expr> comma_expr
%type <ints> assignop
@@ -447,10 +451,11 @@
{ $$ = NewExprTree(WHILE, $5, $7); }
| DO ignorenl namespace_start statement WHILE OP expr CP namespace_end attendnl
{ $$ = NewExprTree(DO, $4, $7); }
- | FOR ignorenl namespace_start OP opt_expr SEMI opt_expr SEMI opt_expr CP statement namespace_end attendnl
- { $$ = NewExprTree(FOR, NewExprTree(FOR, $5, $7),
- NewExprTree(FOR, $9, $11));
- }
+ | FOR ignorenl namespace_start OP for_exprs CP statement namespace_end attendnl
+ { Expr *expr = ParseCanonFor($5);
+ if (!expr)
+ YYERROR;
+ $$ = NewExprTree(FOR, expr, $7); }
| SWITCH ignorenl namespace_start OP expr CP case_block namespace_end attendnl
{ $$ = NewExprTree (SWITCH, $5, $7); }
| UNION SWITCH ignorenl namespace_start OP expr CP union_case_block namespace_end attendnl
@@ -616,6 +621,11 @@
NewExprTree (TWIXT, $9, 0));
}
;
+for_exprs : opt_expr SEMI for_exprs
+ { $$ = NewExprTree(SEMI, $1, $3); }
+ | opt_expr
+ { $$ = NewExprTree(SEMI, $1, 0); }
+ ;
catches : catches catch
{ $$ = NewExprTree (CATCH, $1, $2); }
|
@@ -1745,6 +1755,27 @@
}
/*
+ * Walk for() loop arguments and normalize the list
+ */
+static Expr *
+ParseCanonFor (Expr *expr)
+{
+ if (!expr || !expr->tree.right) {
+ ParseError ("Too few exprs in for()\n");
+ return 0;
+ }
+ if (!expr->tree.right->tree.right) {
+ /* 2-argument for() */
+ expr = NewExprTree(FOR, 0, expr);
+ }
+ if (expr->tree.right->tree.right->tree.right) {
+ ParseError ("Too many exprs in for()\n");
+ return 0;
+ }
+ return expr;
+}
+
+/*
* Walk a type structure and resolve any type names
*/
static CanonTypeResult
Index: pretty.c
===================================================================
RCS file: /local/src/CVS/nickle/pretty.c,v
retrieving revision 1.67
retrieving revision 1.68
diff -u -d -r1.67 -r1.68
--- a/pretty.c 19 Apr 2004 03:13:39 -0000 1.67
+++ b/pretty.c 20 May 2004 09:37:37 -0000 1.68
@@ -656,18 +656,20 @@
case FOR:
PrettyIndent (f, e, level, pd);
FilePuts (f, "for (");
- PrettyExpr (f, e->tree.left->tree.left, -1, level, nest, pd);
- FilePuts (f, ";");
- if (e->tree.left->tree.right)
+ if (e->tree.left->tree.left)
+ PrettyExpr (f, e->tree.left->tree.left, -1, level, nest, pd);
+ if (e->base.tag == SEMI)
+ FilePuts (f, ";");
+ if (e->tree.left->tree.right->tree.left)
{
FilePuts (f, " ");
- PrettyExpr (f, e->tree.left->tree.right, -1, level, nest, pd);
+ PrettyExpr (f, e->tree.left->tree.right->tree.left, -1, level, nest, pd);
}
FilePuts (f, ";");
- if (e->tree.right->tree.left)
+ if (e->tree.left->tree.right->tree.right->tree.left)
{
FilePuts (f, " ");
- PrettyExpr (f, e->tree.right->tree.left, -1, level, nest, pd);
+ PrettyExpr (f, e->tree.left->tree.right->tree.right->tree.left, -1, level, nest, pd);
}
FilePuts (f, ")\n");
if (nest)
Index: version.m4
===================================================================
RCS file: /local/src/CVS/nickle/version.m4,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -d -r1.12 -r1.13
--- a/version.m4 18 May 2004 06:26:03 -0000 1.12
+++ b/version.m4 20 May 2004 09:37:38 -0000 1.13
@@ -2,5 +2,5 @@
dnl The file format is finicky, so do not hand-edit lightly.
dnl CURHEADER $Header$
dnl OLDHEADER <Header: /local/src/CVS/nickle/version.m4,v 1.10 2004/04/11 07:02:11 keithp Exp >
-dnl CURVERSION 2.32
-define([VERSION_NUMBER],[2.32])
+dnl CURVERSION 2.33
+define([VERSION_NUMBER],[2.33])
- Previous message: [Commit] nickle parse-args.5c, NONE, 1.1 ChangeLog, 1.44,
1.45 Makefile.am, 1.51, 1.52 version.m4, 1.11, 1.12
- Next message: [Commit] nickle pretty.c,1.68,1.69
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
More information about the Commit
mailing list