[PATCH] Allow constant expressions
| From: | Sterling Hughes | Date: | Tue, 08 Apr 2003 01:06:51 +0000 |
| Subject: | [PATCH] Allow constant expressions | ||
| Groups: | php.internals | ||
| Request: | Send a blank email to internals+get-775@lists.php.net to get a copy of this message | ||
Hi,
The attached patch allows constant expressions within class variables
and constants. I came into this problem when I wanted the following
sequence:
class foo {
const A = 1<<0;
const B = 1<<1;
const C = 1<<2;
}
And the current parser doesn't allow such rules. I therefore added the
attached patch which allows operators to be used on constants within
these expressions (and also within array declarations). This is
achieved by folding statements such as '1<<0' into their equivalent
values at compile time. The following operators are supported: << >> |
& + - * / . % ^ ~ xor
Please review it, and let me know if its ok to commit. :)
-Sterling
--
"People can have the Model T in any colour -- so long as it's black."
- Henry Ford
Attachment: [text/x-patch] const_fold.diff
Attachment: [text/x-patch] const_fold.diff