RE: [ZEND-ENGINE-CVS] cvs: ZendEngine2 / zend_compile.c zend_compile.h zend_globals.h zend_highlight.c zend_language_parser.y
zend_language_scanner.l

From: Date: Wed, 19 Mar 2003 22:58:04 +0000
Subject: RE: [ZEND-ENGINE-CVS] cvs: ZendEngine2 / zend_compile.c zend_compile.h zend_globals.h zend_highlight.c zend_language_parser.y
zend_language_scanner.l
References: 1  Groups: php.zend-engine.cvs 
Request: Send a blank email to php-zend-engine-cvs+get-1056@lists.php.net to get a copy of this message
Andi, Yes, the comment is not processed it all, it is simply saved in CG(doc_comment). But there is nothing to associate it with the variable/function/class that it precedes. I thought of adding a couple of rules to the parser to store the doc comments in the appropriate structures, something like (can't remember all the names so just making them up): class_type_entry: simple_class_type_entry | doc_class_type_entry; doc_class_type_entry: T_DOC_COMMENT class_declaration { zend_do_start_class_declaration(.. , .., $1); } And the zend_do_* functions would store the doc comment in zend_class_entry or zend_op_array, where appropriate. What do you think? -Andrei > -----Original Message----- > From: Andi Gutmans [mailto:andi@zend.com] > Sent: Wednesday, March 19, 2003 4:40 PM > To: Andrei Zmievski; zend-engine-cvs@lists.php.net > Subject: Re: [ZEND-ENGINE-CVS] cvs: ZendEngine2 / zend_compile.c > zend_compile.h zend_globals.h zend_highlight.c zend_language_parser.y > zend_language_scanner.l > > > Looking at your code again, I understand from your patch that this is the > first and last patch in the series. You save the whole comment as-is and > extensions will parse it for individual variable names and other > information. Am I correct? If so I think this is fine as long as we won't > have to do more work on the engine level. > > Andi > > At 09:17 PM 3/19/2003 +0000, Andrei Zmievski wrote: > >andrei Wed Mar 19 16:17:47 2003 EDT > > > > Modified files: > > /ZendEngine2 zend_compile.c zend_compile.h zend_globals.h > > zend_highlight.c zend_language_parser.y > > zend_language_scanner.l > > Log: > > - Keep track of starting/ending line numbers for user functions. > > - Store last parsed doc comment in a compiler global for future use. > > > > > >Index: ZendEngine2/zend_compile.c > >diff -u ZendEngine2/zend_compile.c:1.396 ZendEngine2/zend_compile.c:1.397 > >--- ZendEngine2/zend_compile.c:1.396 Tue Mar 18 11:30:23 2003 > >+++ ZendEngine2/zend_compile.c Wed Mar 19 16:17:47 2003 > >@@ -17,7 +17,7 @@ > > > +----------------------------------------------------------------------+ > > */ > > > >-/* $Id: zend_compile.c,v 1.396 2003/03/18 16:30:23 zeev Exp $ */ > >+/* $Id: zend_compile.c,v 1.397 2003/03/19 21:17:47 andrei Exp $ */ > > > > #include "zend_language_parser.h" > > #include "zend.h" > >@@ -976,6 +976,8 @@ > > op_array.scope = CG(active_class_entry); > > op_array.ns = CG(active_namespace); > > > >+ op_array.line_start = CG(zend_lineno); > >+ > > if (is_method) { > > char *short_class_name = CG(active_class_entry)->name; > > int short_class_name_length = > > CG(active_class_entry)->name_length; > >@@ -1073,6 +1075,7 @@ > > zend_do_extended_info(TSRMLS_C); > > zend_do_return(NULL, 0 TSRMLS_CC); > > pass_two(CG(active_op_array) TSRMLS_CC); > >+ CG(active_op_array)->line_end = CG(zend_lineno); > > CG(active_op_array) = function_token->u.op_array; > > > > /* Pop the switch and foreach seperators */ > >@@ -3210,6 +3213,7 @@ > > retval = lex_scan(&zendlval->u.constant TSRMLS_CC); > > switch (retval) { > > case T_COMMENT: > >+ case T_DOC_COMMENT: > > case T_OPEN_TAG: > > case T_WHITESPACE: > > retval = zendlex(zendlval TSRMLS_CC); > >Index: ZendEngine2/zend_compile.h > >diff -u ZendEngine2/zend_compile.h:1.224 ZendEngine2/zend_compile.h:1.225 > >--- ZendEngine2/zend_compile.h:1.224 Sun Mar 9 17:17:15 2003 > >+++ ZendEngine2/zend_compile.h Wed Mar 19 16:17:47 2003 > >@@ -17,7 +17,7 @@ > > > +----------------------------------------------------------------------+ > > */ > > > >-/* $Id: zend_compile.h,v 1.224 2003/03/09 22:17:15 zeev Exp $ */ > >+/* $Id: zend_compile.h,v 1.225 2003/03/19 21:17:47 andrei Exp $ */ > > > > #ifndef ZEND_COMPILE_H > > #define ZEND_COMPILE_H > >@@ -146,6 +146,8 @@ > > zend_bool uses_this; > > > > char *filename; > >+ int line_start; > >+ int line_end; > > > > void *reserved[ZEND_MAX_RESERVED_RESOURCES]; > > }; > >Index: ZendEngine2/zend_globals.h > >diff -u ZendEngine2/zend_globals.h:1.120 ZendEngine2/zend_globals.h:1.121 > >--- ZendEngine2/zend_globals.h:1.120 Wed Mar 5 06:14:43 2003 > >+++ ZendEngine2/zend_globals.h Wed Mar 19 16:17:47 2003 > >@@ -17,7 +17,7 @@ > > > +----------------------------------------------------------------------+ > > */ > > > >-/* $Id: zend_globals.h,v 1.120 2003/03/05 11:14:43 zeev Exp $ */ > >+/* $Id: zend_globals.h,v 1.121 2003/03/19 21:17:47 andrei Exp $ */ > > > > #ifndef ZEND_GLOBALS_H > > #define ZEND_GLOBALS_H > >@@ -85,6 +85,8 @@ > > int comment_start_line; > > char *heredoc; > > int heredoc_len; > >+ char *doc_comment; > >+ int doc_comment_len; > > > > zend_op_array *active_op_array; > > > >Index: ZendEngine2/zend_highlight.c > >diff -u ZendEngine2/zend_highlight.c:1.35 > ZendEngine2/zend_highlight.c:1.36 > >--- ZendEngine2/zend_highlight.c:1.35 Thu Mar 6 10:38:28 2003 > >+++ ZendEngine2/zend_highlight.c Wed Mar 19 16:17:47 2003 > >@@ -17,7 +17,7 @@ > > > +----------------------------------------------------------------------+ > > */ > > > >-/* $Id: zend_highlight.c,v 1.35 2003/03/06 15:38:28 iliaa Exp $ */ > >+/* $Id: zend_highlight.c,v 1.36 2003/03/19 21:17:47 andrei Exp $ */ > > > > #include "zend.h" > > #include "zend_language_parser.h" > >@@ -97,6 +97,7 @@ > > next_color = > > syntax_highlighter_ini->highlight_html; > > break; > > case T_COMMENT: > >+ case T_DOC_COMMENT: > > next_color = > > syntax_highlighter_ini->highlight_comment; > > break; > > case T_OPEN_TAG: > >Index: ZendEngine2/zend_language_parser.y > >diff -u ZendEngine2/zend_language_parser.y:1.103 > >ZendEngine2/zend_language_parser.y:1.104 > >--- ZendEngine2/zend_language_parser.y:1.103 Sun Mar 9 17:23:27 2003 > >+++ ZendEngine2/zend_language_parser.y Wed Mar 19 16:17:47 2003 > >@@ -18,7 +18,7 @@ > > > +----------------------------------------------------------------------+ > > */ > > > >-/* $Id: zend_language_parser.y,v 1.103 2003/03/09 22:23:27 zeev Exp $ */ > >+/* $Id: zend_language_parser.y,v 1.104 2003/03/19 21:17:47 > andrei Exp $ */ > > > > /* > > * LALR shift/reduce conflicts and how they are resolved: > >@@ -130,7 +130,7 @@ > > %token T_LINE > > %token T_FILE > > %token T_COMMENT > >-%token T_ML_COMMENT > >+%token T_DOC_COMMENT > > %token T_OPEN_TAG > > %token T_OPEN_TAG_WITH_ECHO > > %token T_CLOSE_TAG > >Index: ZendEngine2/zend_language_scanner.l > >diff -u ZendEngine2/zend_language_scanner.l:1.80 > >ZendEngine2/zend_language_scanner.l:1.81 > >--- ZendEngine2/zend_language_scanner.l:1.80 Sun Mar 9 16:12:12 2003 > >+++ ZendEngine2/zend_language_scanner.l Wed Mar 19 16:17:47 2003 > >@@ -19,7 +19,7 @@ > > > +----------------------------------------------------------------------+ > > */ > > > >-/* $Id: zend_language_scanner.l,v 1.80 2003/03/09 21:12:12 andi Exp $ */ > >+/* $Id: zend_language_scanner.l,v 1.81 2003/03/19 21:17:47 > andrei Exp $ */ > > > > #define yyleng SCNG(yy_leng) > > #define yytext SCNG(yy_text) > >@@ -41,6 +41,7 @@ > > %x ST_LOOKING_FOR_PROPERTY > > %x ST_LOOKING_FOR_VARNAME > > %x ST_COMMENT > >+%x ST_DOC_COMMENT > > %x ST_ONE_LINE_COMMENT > > %option stack > > > >@@ -134,6 +135,10 @@ > > efree(CG(heredoc)); > > CG(heredoc_len)=0; > > } > >+ if (CG(doc_comment)) { > >+ efree(CG(doc_comment)); > >+ CG(doc_comment_len) = 0; > >+ } > > } > > END_EXTERN_C() > > > >@@ -1169,6 +1174,12 @@ > > } > > } > > > >+<ST_IN_SCRIPTING>"/** "{NEWLINE} { > >+ CG(comment_start_line) = CG(zend_lineno); > >+ BEGIN(ST_DOC_COMMENT); > >+ yymore(); > >+} > >+ > > <ST_IN_SCRIPTING>"/*" { > > CG(comment_start_line) = CG(zend_lineno); > > BEGIN(ST_COMMENT); > >@@ -1176,17 +1187,28 @@ > > } > > > > > >-<ST_COMMENT>[^*]+ { > >+<ST_COMMENT,ST_DOC_COMMENT>[^*]+ { > > yymore(); > > } > > > >+<ST_DOC_COMMENT>"*/" { > >+ if (CG(doc_comment)) { > >+ efree(CG(doc_comment)); > >+ } > >+ CG(doc_comment) = estrndup(yytext, yyleng); > >+ CG(doc_comment_len) = yyleng; > >+ HANDLE_NEWLINES(yytext, yyleng); > >+ BEGIN(ST_IN_SCRIPTING); > >+ return T_DOC_COMMENT; > >+} > >+ > > <ST_COMMENT>"*/" { > > HANDLE_NEWLINES(yytext, yyleng); > > BEGIN(ST_IN_SCRIPTING); > > return T_COMMENT; > > } > > > >-<ST_COMMENT>"*" { > >+<ST_COMMENT,ST_DOC_COMMENT>"*" { > > yymore(); > > } > > > >@@ -1552,7 +1574,7 @@ > > return 0; > > } > > > >-<ST_COMMENT><<EOF>> { > >+<ST_COMMENT,ST_DOC_COMMENT><<EOF>> { > > zend_error(E_COMPILE_WARNING,"Unterminated comment > starting line > > %d", CG(comment_start_line)); > > return 0; > > } > > > > > > > >-- > >Zend Engine CVS Mailing List (http://cvs.php.net/) > >To unsubscribe, visit: http://www.php.net/unsub.php >

« previous php.zend-engine.cvs (#1056) next »