Hello Stanislav, Sunday, July 16, 2006, 9:52:59 AM, you wrote:
RC>>>will tell them in what included template source file and on what line RC>>>they screwed up rather than them seeing an error that has no obvious RC>>>relationship whatsoever to what they did (did I get that right RC>>>Marcus?). > Why can't you make your engine put comments in the code? He most likely can. But then he still has to do some arithmetic in the error messages after having looked up the code. Ok let's get this in a more detailed exxample. Lets look at what a potential xml-template based code generator might do. Not that the example makes much sense - sorry for that - but i had to find an easy warning. and I also had to come up with a very easy generator, for that i hope my mini template stuff is self explanatory.... file-a.pxp: The template 1. <template><code><![CDATA[include 'file-b.php';]]></code> 2. <include file='file-c.inc'/> 3. <code><![CDATA[var_dump(in_array(1,1));]]</code> 4. <finalize/> 5. </template> file-b.php: Some valid php file 1. <?php 2. var_dump(in_array(1,1)); 3. ?> file-c.inc: Some code note that we do not have '<?php' here 1. var_dump(in_array(1,1)); 2. var_dump(in_array(1,1)); output.php: generated file 1. <?php #line 1 "file-a.pxp" 2. include 'file-b.php'; // line 1, file-a.pxp, include errors unchanged 3. #line 1 "file-c.inc" 4. var_dump(in_array(1,1)); // line 1, file-c.php 5. var_dump(in_array(1,1)); // line 2, file-c.php 6. #line 3 "file-a.pxp" 7. var_dump(in_array(1,1)); // line 3, file-a.pxp 8. #line 9 "output.php" 9. var_dump(in_array(1,1)); Now the above works quite fine and for all errors you get the correct original source location: Warning: in_array() expects parameter 2 to be array, integer given in file-b.php on line 2 NULL Warning: in_array() expects parameter 2 to be array, integer given in file-c.inc on line 1 NULL Warning: in_array() expects parameter 2 to be array, integer given in file-c.inc on line 2 NULL Warning: in_array() expects parameter 2 to be array, integer given in file-a.pxp on line 3 NULL Warning: in_array() expects parameter 2 to be array, integer given in output.php on line 9 NULL The problem is that not all generator output all line informations. That is some only get the directive for the original input file. And others create their own code but do not start those blocks with line directives. Case one means the second error message would be output.php: generated file 1. <?php #line 1 "file-a.pxp" 2. include 'file-b.php'; // line 1, file-a.pxp, include errors unchanged 4. var_dump(in_array(1,1)); // line 2, file-a.pxp 5. var_dump(in_array(1,1)); // line 3, file-a.pxp 6. #line 3 "file-a.pxp" 7. var_dump(in_array(1,1)); // line 4, file-a.pxp 9. var_dump(in_array(1,1)); Now the error in line 5 is output as line 3 in file-a.pxp. It will take you an endless amount to locate the original source. And this is exactly what happens when you work with comments, only then you even get the error message as output.php. In the second case the problem is the omitted line 8 which leads to the last error been seen as line 5 of file-a.pxp. This will make you think either your code generator or php is broken. Best regards, Marcus -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php