diff options
author | Otto Moerbeek <otto@cvs.openbsd.org> | 2003-10-19 19:21:49 +0000 |
---|---|---|
committer | Otto Moerbeek <otto@cvs.openbsd.org> | 2003-10-19 19:21:49 +0000 |
commit | 9e2087d37770e4201db1975a051d3287b93b6bc3 (patch) | |
tree | 236c58bd348efda43233be8f03d7676549a6e70f /usr.bin/bc/bc.y | |
parent | 06440e33f8e3c7edd8c078ab22e291742234aeb5 (diff) |
Allow the expressions in for (E ; E ; E ) to be empty.
Diffstat (limited to 'usr.bin/bc/bc.y')
-rw-r--r-- | usr.bin/bc/bc.y | 26 |
1 files changed, 21 insertions, 5 deletions
diff --git a/usr.bin/bc/bc.y b/usr.bin/bc/bc.y index c97fbeb803a..e0f876f8a00 100644 --- a/usr.bin/bc/bc.y +++ b/usr.bin/bc/bc.y @@ -1,5 +1,5 @@ %{ -/* $OpenBSD: bc.y,v 1.12 2003/10/18 20:35:36 otto Exp $ */ +/* $OpenBSD: bc.y,v 1.13 2003/10/19 19:21:48 otto Exp $ */ /* * Copyright (c) 2003, Otto Moerbeek <otto@drijf.net> @@ -31,7 +31,7 @@ */ #ifndef lint -static const char rcsid[] = "$OpenBSD: bc.y,v 1.12 2003/10/18 20:35:36 otto Exp $"; +static const char rcsid[] = "$OpenBSD: bc.y,v 1.13 2003/10/19 19:21:48 otto Exp $"; #endif /* not lint */ #include <ctype.h> @@ -138,6 +138,8 @@ extern char *__progname; %type <node> function_header %type <node> input_item %type <node> opt_argument_list +%type <node> opt_expression +%type <node> opt_relational_expression %type <node> opt_statement %type <node> relational_expression %type <node> return_expression @@ -278,9 +280,9 @@ statement : expression } $$ = $3; } - | FOR LPAR alloc_macro expression SEMICOLON - relational_expression SEMICOLON - expression RPAR opt_statement pop_nesting + | FOR LPAR alloc_macro opt_expression SEMICOLON + opt_relational_expression SEMICOLON + opt_expression RPAR opt_statement pop_nesting { ssize_t n; @@ -443,6 +445,13 @@ argument_list : expression } ; +opt_relational_expression + : /* empty */ + { + $$ = cs(" 0 0="); + } + | relational_expression + ; relational_expression : expression @@ -490,6 +499,13 @@ return_expression ; +opt_expression : /* empty */ + { + $$ = cs(" 0"); + } + | expression + ; + expression : named_expression { $$ = node($1.load, END_NODE); |