Hi all,

I realized awhile ago that PHP creates a ZEND_SUB opcode even with a literal
number after the '-' (-123), which of course causes the number to be negated
each time it's used during runtime.  So a few months ago, and again
recently, I took a look at the parser grammar to see if I could get these
"common_scalar"/numbers to be negated once in parse/compile stage (like
"static_scalar") but didn't really get anywhere. :-/  Just "reduce/reduce
conflicts" even if the rules seem like they should work (but I have no idea
about this Bison stuff!).  Well, there was one way I eliminated the
conflicts, but it seems kinda sloppy and no idea if it would actually work.

For the Bison gurus, is there a simple way this could be done with a little
grammar rearranging?  Of course there would be a runtime improvement with
negative numbers, but it should also compile faster, skipping opcode
creation, etc.

BTW, for "expr_without_variable",   '+' expr   generates ZEND_ADD.  As far
as I know there's no point to that, right? ;-)  Its action should simply be
$$ = $2;


Thanks,
Matt

P.S.  Here on Windows, I wouldn't be able to test any parser changes
anyway -- Bison is somehow creating wrong files or such since if it's run
with a default zend_language_parser.y, I then get "unexpected ..." parse
errors that are obviously bogus.  Any ideas?

-- 
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to