+++ /dev/null
-<?php\r
-/**\r
-* Defines all regular expressions.\r
-*\r
-* This class defines all regular expressions. To make the \r
-* configuration and customization of PHPDoc as simple as\r
-* possible I decided to define all regular expressions in one class.\r
-* From a programming point of view there's no need to do so. \r
-*\r
-* @version $Id: PhpdocParserRegExp.php,v 1.4 2000/12/03 22:37:37 uw Exp $\r
-*/\r
-class PhpdocParserRegExp extends PhpdocObject {\r
-\r
- /**\r
- * Array of phpdoc tags, indexed by the tagname.\r
- *\r
- * ... grepping information is really not a parser. Don't \r
- * change the order the tags are listed. If you introduce\r
- * new tags write the long variant of the tagname (parameter)\r
- * in front of the shortcut (param).\r
- *\r
- * @var array List of all PHPDoc documentation tags.\r
- */\r
- var $PHPDOC_TAGS = array(\r
- "@parameter" => '@param[eter] (object objectname|type) [$varname] [description]',\r
- "@param" => '@param[eter] (object objectname|type) [$varname] [description]',\r
- \r
- "@return" => '@return (object objectname|type) [$varname] [description]',\r
- \r
- "@access" => '@access',\r
- "@abstract" => '@abstract',\r
- "@static" => '@static',\r
- "@final" => '@final',\r
- \r
- "@throws" => '@throws exception [, exception]',\r
- \r
- "@see" => '@see (function()|$varname|(module|class)(function()|$varname)) [, (funtion()|$varname|(module|class)(function()|$varname))]',\r
- "@link" => '@link URL [description]',\r
- \r
- "@var" => '@var (object objectname|type) [$varname]',\r
- "@global" => '@global (object objectname|type) $varname [description]',\r
- \r
- "@constant" => '@const[ant] label [description]',\r
- "@const" => '@const[ant] label [description]',\r
- \r
- "@author" => '@author Name [<email>] [, Name [<email>]',\r
- "@copyright" => '@copyright description',\r
- \r
- "@version" => '@version label',\r
- "@since" => '@since label',\r
-\r
- "@deprecated" => '@deprec[ated] description', \r
- "@deprec" => '@deprec[ated] description',\r
- \r
- "@brother" => '@(brother|sister) (function()|$varname)',\r
- "@sister" => '@(brother|sister) (function()|$varname)',\r
- \r
- "@include" => '@include description', \r
- \r
- "@exclude" => '@exclude label',\r
- \r
- "@modulegroup" => '@modulegroup label',\r
- "@module" => '@module label',\r
- \r
- "@package" => '@package label',\r
- \r
- "@magic" => '@magic description',\r
- "@todo" => '@todo description'\r
- );\r
-\r
- /**\r
- * Basis regular expressions used to compose complex expressions to grep doc comments.\r
- *\r
- * PHPDoc tries to compose all complex regular expressions\r
- * from a list of basic ones. This array contains all expressions\r
- * used grep complex doc comments and the surrounding keywords.\r
- *\r
- * @var array List of basic regular expressions matching parts of doc comments: \r
- * module names, module separator, vartypes, accesstypes.\r
- * @final\r
- * @see buildComplexRegExps(), $C_COMPLEX\r
- */\r
- var $C_BASE = array(\r
- #"block" => '/\*\*((?:(?!\*).)*(?:\n(?!\s*\*/)\s*\*(?:(?!\*/).)*)*)\*/',\r
- "module" => "[^\s]+",\r
- "module_separator" => "::",\r
- "module_tags" => "(@modulegroup|@module)",\r
- \r
- "vartype" => "(string|integer|int|long|real|double|float|boolean|bool|mixed|array|object)",\r
- "access" => "(private|public)"\r
- );\r
-\r
- /**\r
- * List of regular expressions used to grep complex doc comments.\r
- * \r
- * As with $PHP_COMPLEX all complex expressions are build using basic\r
- * ones in buildComplexRegExps().\r
- *\r
- * @var array Regular expressions matching see and optional objectnames.\r
- * @final\r
- * @see buildComplexRegexps(), $C_BASE\r
- */ \r
- var $C_COMPLEX = array( \r
- "objectname_optional" => "",\r
- \r
- "see_var" => "",\r
- "see_function" => "",\r
- "see_moduleclass" => "",\r
- \r
- "module_doc" => "",\r
- "module_tags" => "",\r
- "module_separator" => "",\r
- "module_separator_len" => 0,\r
- "module_separator_len_neg" => 0\r
- \r
- );\r
- \r
- /**\r
- * Basic RegExps used to analyse PHP Code.\r
- *\r
- * PHPDoc tries to compose all complex regular expressions\r
- * from some basic expressions. This array contains\r
- * all expressions used to build $PHP_COMPLEX. \r
- * There're some differences to the RegExps in zend-scanner.l, \r
- * e.g. I decided to write "\s+" instead of "[ \n\r\t]+" which\r
- * should be identical as long as perl compatible regular \r
- * expressions are used. Another point is that I did not break \r
- * down numbers to LNUM/DNUM.\r
- * \r
- * @var array List of basis regular expressions matching php code elements:\r
- * spaces, optional spaces, linebreaks, labels, use (include and friends),\r
- * optional argument assignment, boolean, several variable types.\r
- * @final\r
- * @see $PHP_COMPLEX\r
- */\r
- var $PHP_BASE = array (\r
-\r
- "space" => "\s+",\r
- "space_optional" => "\s*",\r
- "break" => "[\n\r]",\r
- \r
- "php_open_long" => "<\?php\s", # zend_scanner.l use {WHITESPACE} (space in our case) eighter. Might be slightly faster.\r
- "php_open_short" => "<\?",\r
- "php_open_asp" => "<%",\r
- "php_open_short_print" => "<\?=",\r
- "php_open_asp_print" => "<%=",\r
- \r
- # do not change the single quotes to double ones\r
- "label" => '[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\xzf-\xff]*', \r
- "use" => "(include_once|include|require_once|require)",\r
- "assignment" => "\s*([,=])\s*",\r
- \r
- "boolean" => "(true|false)",\r
- \r
- "string" => "[^\s]+",\r
- "string_enclosed" => "(['\"])(?:\\\\\\1|[^\\1])*?\\1",\r
-\r
- "int_oct" => "[+-]?\s*0[0-7]+",\r
- "int_hex" => "[+-]?\s*0[xX][0-9A-Fa-f]+",\r
- \r
- "float" => "[+-]?\s*\d*\.\d+",\r
- "float_exponent" => "[+-]?\s*\d*(?:\.\d+)*[eE][+-]?\d+",\r
- \r
- "number" => "[+-]?\s*\d+",\r
- \r
- "array" => "array\s*\(",\r
- "empty_array" => "array\s*\(\s*\)\s*"\r
- );\r
-\r
- /**\r
- * List of regular expressions used to grep complex php code elements.\r
- *\r
- * The RegExp of the variable types is slightly changed to that\r
- * one in $PHP_BASE, getVariableTypeAndValue() needs this.\r
- * "undoc_*" is used to grep all keywords those who have a doc \r
- * comment in front and those without. See getPhodocParagraphs() \r
- * for more details on this.\r
- *\r
- * @var array RegExps to match: variablenames, functionnames, classnames,\r
- * class variable declarations, function declarations,\r
- * class declarations, defines, uses (include and friends), \r
- * function arguments, several variables types. \r
- * @see buildComplexRegExps(), getVariableTypeAndValue(), getPhpdocParagraphs(), $PHP_BASE\r
- */ \r
- var $PHP_COMPLEX = array (\r
- "varname" => "",\r
- "functionname" => "",\r
- "classname" => "",\r
- \r
- "php_open_script" => "",\r
- \r
- "var" => "",\r
- "undoc_var" => "",\r
- \r
- "function" => "",\r
- "undoc_function" => "",\r
- \r
- "class" => "",\r
- "undoc_class" => "",\r
- \r
- "class_extends" => "",\r
- "undoc_class_extends" => "",\r
- \r
- "const" => "",\r
- "undoc_const" => "",\r
- \r
- "use" => "",\r
- "undoc_use" => "",\r
- \r
- "argument" => "",\r
- \r
- "type_boolean" => "",\r
- \r
- "type_string" => "",\r
- "type_string_enclosed" => "",\r
- \r
- "type_int_oct" => "",\r
- "type_int_hex" => "",\r
- \r
- "type_float" => "",\r
- "type_float_exponent" => "",\r
- \r
- "type_number" => "",\r
- \r
- "type_array" => "",\r
- "type_empty_array" => ""\r
- ); \r
- \r
- /**\r
- * Array of RegExp matching the syntax of several complex tags.\r
- *\r
- * The array is filled by the constructor.\r
- *\r
- * @var array Used to analyse return, var, param, \r
- * global, see and to find tags in general\r
- * @see PhpdocParserObject()\r
- */\r
- var $TAGS = array ( \r
- "return" => "", \r
- "var" => "", # @var, @param\r
- "global" => "", \r
- "access" => "", \r
- \r
- "module" => "", # @module, @modulegroup\r
- \r
- "const" => "", # @const, @constant\r
- \r
- "see_var" => "", # @see\r
- "see_function" => "", # @see\r
- "see_class" => "", # @see\r
- "see_module" => "", # @see\r
- \r
- "link" => "@([^\s]+)(.*)@is", # @link\r
- \r
- "brother" => "",\r
- \r
- "author" => "<\s*([a-z]([-a-z0-9_.])*@([-a-z0-9_]*\.)+[a-z]{2,})\s*>", # @author <email> part\r
- \r
- "all" => "" # list of all known tags\r
- );\r
- \r
- /**\r
- * Builds complex regular expressions for the parser.\r
- *\r
- * PHPDoc has a small set of basic regular expressions. All complex\r
- * regular expressions are made out of the basic ones. The composition \r
- * in done in this method. Note: every derived class must \r
- * call this method in it's constructor!\r
- * @see $PHP_BASE, $PHP_COMPLEX, $C_BASE, $C_COMPLEX\r
- */ \r
- function buildComplexRegExps() {\r
- \r
- //\r
- // Do not change the order of the variable initializations there're dependencies.\r
- // It starts with some php names.\r
- // \r
- \r
- // some names\r
- $this->PHP_COMPLEX["varname"] = sprintf("[&]?[$]%s", $this->PHP_BASE["label"] );\r
- $this->PHP_COMPLEX["functionname"] = sprintf("[&]?%s", $this->PHP_BASE["label"] );\r
- $this->PHP_COMPLEX["classname"] = $this->PHP_BASE["label"]; \r
- \r
- // \r
- // Now build all regexps used to grep doc comment elements.\r
- // \r
- \r
- // optional object name\r
- $this->C_COMPLEX["objectname_optional"] = sprintf("(?:object%s%s)?", \r
- $this->PHP_BASE["space"],\r
- $this->PHP_COMPLEX["classname"] \r
- );\r
- \r
- $this->C_COMPLEX["module_separator"] = sprintf("(?:%s)", $this->C_BASE["module_separator"]);\r
- $this->C_COMPLEX["module_separator_len"] = strlen($this->C_BASE["module_separator"]);\r
- $this->C_COMPLEX["module_separator_len_neg"] = -1*strlen($this->C_BASE["module_separator"]);\r
-\r
- // References to other elements\r
- $this->C_COMPLEX["see_var"] = sprintf("(%s%s)?([$][^:]%s)",\r
- $this->C_BASE["module"],\r
- $this->C_COMPLEX["module_separator"],\r
- $this->PHP_BASE["label"]\r
- );\r
- \r
- $this->C_COMPLEX["see_function"] = sprintf("(%s%s)?([^:]%s\(%s\))",\r
- $this->C_BASE["module"],\r
- $this->C_COMPLEX["module_separator"],\r
- $this->PHP_BASE["label"],\r
- $this->PHP_BASE["space_optional"]\r
- );\r
-\r
- $this->C_COMPLEX["see_moduleclass"] = sprintf("(%s)", $this->C_BASE["module"] );\r
-\r
- //\r
- // RegExps used to grep certain php code elements.\r
- //\r
- \r
- // var statements\r
- $this->PHP_COMPLEX["var"] = sprintf("|^%svar%s([$]%s)%s(=?)|is",\r
- $this->PHP_BASE["space_optional"],\r
- $this->PHP_BASE["space"],\r
- $this->PHP_BASE["label"],\r
- $this->PHP_BASE["space_optional"],\r
- $this->PHP_BASE["space_optional"]\r
- ); \r
- $this->PHP_COMPLEX["undoc_var"] = sprintf("|%s|isS", substr($this->PHP_COMPLEX["var"], 2, -3) );\r
-\r
- // function statements\r
- $this->PHP_COMPLEX["function"] = sprintf("|^%sfunction%s(%s)%s\(|is",\r
- $this->PHP_BASE["space_optional"],\r
- $this->PHP_BASE["space"],\r
- $this->PHP_COMPLEX["functionname"],\r
- $this->PHP_BASE["space_optional"]\r
- ); \r
- $this->PHP_COMPLEX["undoc_function"] = sprintf("|%s|isS", substr($this->PHP_COMPLEX["function"], 2, -3) );\r
-\r
- // class statements\r
- $this->PHP_COMPLEX["class"] = sprintf("|^%sclass%s(%s)%s{|is",\r
- $this->PHP_BASE["space_optional"],\r
- $this->PHP_BASE["space"],\r
- $this->PHP_COMPLEX["classname"],\r
- $this->PHP_BASE["space_optional"]\r
- ); \r
- $this->PHP_COMPLEX["undoc_class"] = sprintf("|%s|isS", substr($this->PHP_COMPLEX["class"], 2, -3) );\r
- \r
- $this->PHP_COMPLEX["class_extends"] = sprintf("|^%sclass%s(%s)%sextends%s(%s)%s{|is",\r
- $this->PHP_BASE["space_optional"], \r
- $this->PHP_BASE["space"],\r
- $this->PHP_COMPLEX["classname"],\r
- $this->PHP_BASE["space"],\r
- $this->PHP_BASE["space"],\r
- $this->PHP_COMPLEX["classname"],\r
- $this->PHP_BASE["space_optional"]\r
- ); \r
- $this->PHP_COMPLEX["undoc_class_extends"] = sprintf("|%s|isS", substr($this->PHP_COMPLEX["class_extends"], 2, -3) );\r
- \r
- // \r
- // RegExp used to grep define statements.\r
- // NOTE: the backticks do not allow the usage of $this->PHP_BASE\r
- //\r
- $this->PHP_COMPLEX["const"] = sprintf("@^%sdefine%s\(%s(%s)%s,%s(%s)%s(?:,%s(%s))?%s\)%s;@is", \r
- $this->PHP_BASE["space_optional"],\r
- $this->PHP_BASE["space_optional"],\r
- $this->PHP_BASE["space_optional"],\r
- "[$]?\w[\w-_]*|(['\"])(?:\\\\\\2|[^\\2])*?\\2",\r
- $this->PHP_BASE["space_optional"],\r
- $this->PHP_BASE["space_optional"],\r
- "(['\"])(?:\\\\\\4|[^\\4])*?\\4|(?:true|false)|[+-]?\s*0[0-7]+|[+-]?\s*0[xX][0-9A-Fa-f]+|[+-]?\s*\d*(?:\.\d+)*[eE][+-]?\d+|[+-]?\s*\d*\.\d+|[+-]?\s*\d+|&?[$]?\w[\w-_]*",\r
- $this->PHP_BASE["space_optional"],\r
- $this->PHP_BASE["space_optional"],\r
- "(?:true|false)|[+-]?\s*0[0-7]+|[+-]?\s*0[xX][0-9A-Fa-f]+|[+-]?\s*\d*(?:\.\d+)*[eE][+-]?\d+|[+-]?\s*\d*\.\d+|[+-]?\s*\d+|&?[$]?\w[\w-_]*|(['])(?:\\\\\\6|[^\\6])*?\\6",\r
- $this->PHP_BASE["space_optional"],\r
- $this->PHP_BASE["space_optional"]\r
- ); \r
- $this->PHP_COMPLEX["undoc_const"] = sprintf("@%s@isS", substr($this->PHP_COMPLEX["const"], 2, -3) );\r
- \r
- //\r
- // include, include_once, require, require_once and friends \r
- //\r
-// ? removed!\r
- $this->PHP_COMPLEX["use"] = sprintf("@^%s%s[\(]%s((['\"])((?:\\\\\\3|[^\\3])*?)\\3|([^\s]+))%s[\)]%s;@is",\r
- $this->PHP_BASE["use"],\r
- $this->PHP_BASE["space_optional"],\r
- $this->PHP_BASE["space_optional"],\r
- $this->PHP_BASE["space_optional"],\r
- $this->PHP_BASE["space_optional"]\r
- );\r
- $this->PHP_COMPLEX["undoc_use"] = sprintf("@%s@isS", substr($this->PHP_COMPLEX["use"], 2, -3) );\r
- \r
- // \r
- // Variable name with an optional assignment operator. This one is used\r
- // to analyse function heads [parameter lists] as well as class variable\r
- // declarations.\r
- //\r
- $this->PHP_COMPLEX["argument"] = sprintf("|(%s)(%s)?|s", \r
- $this->PHP_COMPLEX["varname"],\r
- $this->PHP_BASE["assignment"]\r
- );\r
-\r
-\r
- //\r
- // <script language="php"> syntax\r
- // \r
- $this->PHP_COMPLEX["php_open_script"] = sprintf("<script%slanguage%s=%s[\"']php[\"']%s>",\r
- $this->PHP_BASE["space"],\r
- $this->PHP_BASE["space_optional"],\r
- $this->PHP_BASE["space_optional"],\r
- $this->PHP_BASE["space_optional"]\r
- );\r
-\r
- $this->PHP_COMPLEX["php_open_all"] = sprintf("(?:%s|%s|%s|%s|%s|%s)",\r
- $this->PHP_BASE["php_open_long"],\r
- $this->PHP_BASE["php_open_short"],\r
- $this->PHP_BASE["php_open_asp"],\r
- $this->PHP_BASE["php_open_short_print"],\r
- $this->PHP_BASE["php_open_asp_print"],\r
- $this->PHP_COMPLEX["php_open_script"]\r
- );\r
-\r
- $this->C_COMPLEX["module_doc"] = sprintf("@^%s%s%s/\*\*@is", \r
- $this->PHP_BASE["space_optional"],\r
- $this->PHP_COMPLEX["php_open_all"],\r
- $this->PHP_BASE["space_optional"]\r
- );\r
-\r
- $this->C_COMPLEX["module_tags"] = sprintf("/%s/is", $this->C_BASE["module_tags"] );\r
-\r
- //\r
- // RegExp used to grep variables types\r
- //\r
- $elements = array( \r
- "boolean", "string", "string_enclosed", \r
- "int_oct", "int_hex", "float", "float_exponent", \r
- "number", "array", "empty_array" \r
- );\r
- reset($elements);\r
- while (list($key, $name)=each($elements)) \r
- $this->PHP_COMPLEX["type_".$name] = sprintf("@^%s@", $this->PHP_BASE[$name]);\r
- \r
- // \r
- // Regular expressions used to analyse phpdoc tags.\r
- // \r
- $this->TAGS["var"] = sprintf("/%s(?:%s(%s))?(?:%s(%s))?%s(.*)?/is",\r
- $this->C_BASE["vartype"],\r
- $this->PHP_BASE["space"],\r
- $this->PHP_BASE["label"],\r
- $this->PHP_BASE["space"],\r
- $this->PHP_COMPLEX["varname"],\r
- $this->PHP_BASE["space_optional"]\r
- ); \r
- $this->TAGS["return"] = $this->TAGS["var"]; \r
- \r
- $this->TAGS["global"] = sprintf("/%s%s(%s)%s(%s)%s(.*)/is",\r
- $this->C_BASE["vartype"],\r
- $this->PHP_BASE["space_optional"],\r
- $this->C_COMPLEX["objectname_optional"],\r
- $this->PHP_BASE["space"],\r
- $this->PHP_COMPLEX["varname"],\r
- $this->PHP_BASE["space_optional"]\r
- ); \r
- \r
- $this->TAGS["brother"] = sprintf("/(%s\(\)|\$%s)/is", \r
- $this->PHP_BASE["label"],\r
- $this->PHP_BASE["label"]\r
- );\r
- \r
- $this->TAGS["const"] = sprintf("/(%s)%s(.*)?/is",\r
- $this->PHP_BASE["label"],\r
- $this->PHP_BASE["space_optional"]\r
- );\r
- \r
- $this->TAGS["access"] = sprintf("/%s/is", $this->C_BASE["access"]);\r
- $this->TAGS["module"] = sprintf("/%s/is", $this->PHP_BASE["label"]);\r
- \r
- $this->TAGS["author"] = sprintf("/%s/is", $this->TAGS["author"]);\r
- \r
- $all_tags = ""; \r
- reset($this->PHPDOC_TAGS); \r
- while (list($tag, $v)=each($this->PHPDOC_TAGS))\r
- $all_tags.= substr($tag, 1)."|";\r
- $all_tags = substr($all_tags, 0, -1);\r
- \r
- $this->TAGS["all"] = "/@($all_tags)/is";\r
- \r
- $elements = array ( "see_function", "see_var", "see_moduleclass" );\r
- reset($elements);\r
- while (list($k, $index)=each($elements))\r
- $this->TAGS[$index] = sprintf("/%s/is", $this->C_COMPLEX[$index]);\r
-\r
- } // end func buildComplexRegExps\r
- \r
-} // end class PhpdocParserRegExp\r
-?>
\ No newline at end of file