Question about parser implementation details

From: Date: Sun, 01 Apr 2012 12:19:22 +0000
Subject: Question about parser implementation details
Groups: php.internals 
Request: Send a blank email to internals+get-59300@lists.php.net to get a copy of this message
Hey there, due to the widespread acceptance of binary number format (0b1010101) and the growing demand for backwards compatibility I've started to work on support for Roman Numerals (I, II, III, ...) As you might know, this format cannot be strictly parsed from left to right or right to left, as several number values need a look-ahead before being able to compute them (like IV), so my naive first implementation splits the string into tokens (like in 1990 = MCMXC => M,CM,XC => 1000,900,90) then simplifying those 3 on their own, then adding the results, but I'm not sure this could kill performance if calculated inside zend_language_scanner.l. I'd appreciate any hints on how to tackle this serious concern. Btw, in the spirit of x for hex and b for binary I thought about using this syntax: <?php $a = 0spqrMMXII; //set $a to 2012 ?> unless anyone has any better suggestions? Greetings, Florian

« previous php.internals (#59300) next »