sebastian               Fri Dec 14 01:42:15 2001 EDT

  Modified files:              
    /pear/PECL/phpdoc   phpdoc.c 
  Log:
  Enable to use constant in function default param as function foo($bar= TRUE){...}. 
Static support for var (works like global one). var default value support in XML 
output. recognize phpdoc comments beginning like /** (Use <phpdoc> tag to this kind of 
comments instead of <comment>). (Patch by Olivier Courtin <[EMAIL PROTECTED]>)
  
Index: pear/PECL/phpdoc/phpdoc.c
diff -u pear/PECL/phpdoc/phpdoc.c:1.1 pear/PECL/phpdoc/phpdoc.c:1.2
--- pear/PECL/phpdoc/phpdoc.c:1.1       Wed Dec 12 06:20:49 2001
+++ pear/PECL/phpdoc/phpdoc.c   Fri Dec 14 01:42:15 2001
@@ -1,21 +1,22 @@
 /*
-   +----------------------------------------------------------------------+
-   | PHP version 4.0                                                      |
-   +----------------------------------------------------------------------+
-   | Copyright (c) 1997, 1998, 1999, 2000 The PHP Group                   |
-   +----------------------------------------------------------------------+
-   | This source file is subject to version 2.02 of the PHP license,      |
-   | that is bundled with this package in the file LICENSE, and is        |
-   | available at through the world-wide-web at                           |
-   | http://www.php.net/license/2_02.txt.                                 |
-   | If you did not receive a copy of the PHP license and are unable to   |
-   | obtain it through the world-wide-web, please send a note to          |
-   | [EMAIL PROTECTED] so we can mail you a copy immediately.               |
-   +----------------------------------------------------------------------+
-   | Authors:                                                             |
-   |   Jan Kneschke <[EMAIL PROTECTED]>                              |
-   +----------------------------------------------------------------------+
- */
+  +----------------------------------------------------------------------+
+  | PHP Version 4                                                        |
+  +----------------------------------------------------------------------+
+  | Copyright (c) 1997-2002 The PHP Group                                |
+  +----------------------------------------------------------------------+
+  | This source file is subject to version 2.02 of the PHP license,      |
+  | that is bundled with this package in the file LICENSE, and is        |
+  | available at through the world-wide-web at                           |
+  | http://www.php.net/license/2_02.txt.                                 |
+  | If you did not receive a copy of the PHP license and are unable to   |
+  | obtain it through the world-wide-web, please send a note to          |
+  | [EMAIL PROTECTED] so we can mail you a copy immediately.               |
+  +----------------------------------------------------------------------+
+  | Authors: Jan Kneschke <[EMAIL PROTECTED]>                       |
+  +----------------------------------------------------------------------+
+*/
+
+/* $Id: phpdoc.c,v 1.2 2001/12/14 06:42:15 sebastian Exp $ */
 
 #include "php.h"
 #include "php_ini.h"
@@ -218,6 +219,7 @@
        for (; i >= 0; i--) {
                zend_printf("[%d]",stack[i]);
        }
+       zend_printf("\n");
 #endif
        return (stack_pos > 0) ? stack[stack_pos-1] : -1;
 }
@@ -307,7 +309,7 @@
        st.stack[0] = -1; 
        
        token.type = 0;
-       while ((token_type=CG(lang_scanner).lex_scan(&token CLS_CC))) {
+       while ((token_type=lex_scan(&token CLS_CC))) {
                if (debug)
                        zend_printf("// %s(%d)\n",zendtext, token_type);
                        
@@ -343,13 +345,21 @@
                case T_GLOBAL:
                        st.stack[st.pos++] = token_type;
                        break;
+               case T_STATIC:
+                       st.stack[st.pos++] = token_type;
+                       break;
                case T_ML_COMMENT:
                case T_COMMENT:
-                       PHPDOC_STRCAT(new_string, "<comment>");
-                       
-                       sprint_xml(new_string, zendtext);
-                       
-                       PHPDOC_STRCAT(new_string, "</comment>\n");
+                       /* Don't know if it's the best way to do it ? */
+                       if(!strncmp(zendtext, "/**", 3)){
+                               PHPDOC_STRCAT(new_string, "<phpdoc>");
+                               sprint_xml(new_string, zendtext);
+                               PHPDOC_STRCAT(new_string, "</phpdoc>\n");
+                       } else {
+                               PHPDOC_STRCAT(new_string, "<comment>");
+                               sprint_xml(new_string, zendtext);
+                               PHPDOC_STRCAT(new_string, "</comment>\n");
+                       }
                        break;
                case T_EXTENDS:
                        switch(find_something(st.stack, st.pos)) {
@@ -379,6 +389,10 @@
                                zend_sprintf(buffer, "<global name=\"%s\"/>",zendtext);
                                PHPDOC_STRCAT(new_string, buffer);
                                break;
+                       case T_STATIC:
+                               zend_sprintf(buffer, "<static name=\"%s\"/>",zendtext);
+                               PHPDOC_STRCAT(new_string, buffer);
+                               break;
                        default:
                                break;
                        }
@@ -405,17 +419,16 @@
                                break;
                        }
                        break;
-               case T_DNUMBER:
-                       switch(find_something(st.stack, st.pos)) {
-                       case T_FUNCTION_PARAM_DEFAULT:
+               case T_FUNCTION_PARAM_DEFAULT:
                                PHPDOC_STRCAT(new_string, zendtext);
                                PHPDOC_STRCAT(new_string, "\"");
                                st.pos--;
                                break;
-                       default:
-                               break;
                        }
                        break;
+               case T_FILE:
+               case T_LINE:
+               case T_DNUMBER:
                case T_LNUMBER:
                        switch(find_something(st.stack, st.pos)) {
                        case T_FUNCTION_PARAM_DEFAULT:
@@ -495,9 +508,12 @@
                                PHPDOC_STRCAT(new_string, buffer);
                                st.pos--;
                                break;
+                       case T_VARIABLE:
+                               st.pos--;
+                               break;
                        }
                        break;
-               case '=':
+               case '=':
                        switch (find_something(st.stack, st.pos)) {
                        case T_VAR:
                                zend_sprintf(buffer, ">");
@@ -523,6 +539,7 @@
                                st.pos--;
                                break;
                        case T_GLOBAL:
+                       case T_STATIC:
                        case T_VARIABLE:
                                st.pos--;
                                break;
@@ -540,6 +557,7 @@
                case T_ARRAY:
                        switch (find_something(st.stack, st.pos)) {
                        case T_FUNCTION_PARAM:
+                       case T_VAR:
                                zend_sprintf(buffer, "/>");
                                PHPDOC_STRCAT(new_string, buffer);
                                st.pos--;
@@ -627,7 +645,7 @@
        
        convert_to_string_ex(arg);
 
-       CG(lang_scanner).save_lexical_state(&original_lex_state CLS_CC);
+       save_lexical_state(&original_lex_state CLS_CC);
        
 #ifndef ZTS
        if (prepare_string_for_scanning(*arg, "dummy.php")==FAILURE) {
@@ -642,7 +660,7 @@
        MAKE_STD_ZVAL(return_value);
        ZVAL_EMPTY_STRING(return_value);
 #endif
-       CG(lang_scanner).restore_lexical_state(&original_lex_state CLS_CC);
+       restore_lexical_state(&original_lex_state CLS_CC);
 #ifdef ZTS
        delete input_stream;
 #endif


Reply via email to