Re: Long awaited line directive
| From: | Marcus Boerger | Date: | Sat, 15 Jul 2006 18:51:44 +0000 |
| Subject: | Re: Long awaited line directive | ||
| References: | 1 2 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-24404@lists.php.net to get a copy of this message | ||
Hello Pierre,
Saturday, July 15, 2006, 8:48:01 PM, you wrote:
> On Sat, 15 Jul 2006 20:26:22 +0200
> mail@marcus-boerger.de (Marcus Boerger) wrote:
>> Hello internals,
>>
>> attached is a patch that brings the '#line' directive to php.
>> This is especially usefull for parser generators or any other
>> code shuffling/generator tools. Any opinions? If nothing speaks
>> against i'd like to commit this before heading towards OSCON
>> be end of next week. (oatch is against head of course).
>>
> To complete the request, one example (if you are not familiar with
> other generators or languages):
> 1. include 'somfile.php'
> 2.
> #line 1 "linedirective.php"
> 4. class Foo // treated as line 1
> 5. { // treated as line 2
> 6. var $prop1; // treated as line 3
> 7. // treated as line 4
> 8. function bar ($args) // treated as line 5
> 9. { // treated as line 6
> 10. Some invalid syntax; // treated as line 7
> 11. return; // treated as line 8
> ...
> Even if the syntax error happens on line 10 of this file, it will be
> reported on line 7 of the file "linedirective.php". Not sure if it will
> work exactly like that in php, but this is how it works in c# for
> example.
> I would love to have it in 5.x :)
Yes it works as expected. The directive is taken into account for both
compiler and executor.
Best regards,
Marcus