From 1de2f41d925600d597129fb5861a53f9d3481dee Mon Sep 17 00:00:00 2001 From: Hartmut Holzgraefe Date: Thu, 6 Feb 2003 09:38:26 +0000 Subject: [PATCH] tokenizer no longer undocumented :) git-svn-id: https://svn.php.net/repository/phpdoc/en/trunk@114924 c90b9560-bf6c-de11-be94-00142212c4b1 --- .../tokenizer/functions/token-get-all.xml | 32 +++++++++--- reference/tokenizer/functions/token-name.xml | 32 +++++++++--- reference/tokenizer/reference.xml | 50 ++++++++++++++++++- 3 files changed, 96 insertions(+), 18 deletions(-) diff --git a/reference/tokenizer/functions/token-get-all.xml b/reference/tokenizer/functions/token-get-all.xml index c0f4a3d69c..69a73aa021 100644 --- a/reference/tokenizer/functions/token-get-all.xml +++ b/reference/tokenizer/functions/token-get-all.xml @@ -1,18 +1,34 @@ - + token_get_all - Split given source in tokens + Split given source into PHP tokens Description - - arraytoken_get_all - stringsource - - &warn.experimental.func; - &warn.undocumented.func; + + arraytoken_get_all + stringsource + + + token_get_all parses the given source + string into PHP language tokens using the Zend engines lexical scanner. + The function returns an array of token descriptions. Each array element itself is + either a one character string or itself an array containing a token id and the + string representation of that token in the source code. + + + + array(";"); + $tokens = token_get_all("foreach") // => array(T_FOREACH => "foreach"); + $tokens = token_get_all("/* comment */") // => array(T_ML_COMMENT => "/* comment */"); +?> +]]> + + diff --git a/reference/tokenizer/functions/token-name.xml b/reference/tokenizer/functions/token-name.xml index b8489b48c6..3e491233d1 100644 --- a/reference/tokenizer/functions/token-name.xml +++ b/reference/tokenizer/functions/token-name.xml @@ -1,18 +1,34 @@ - + token_name - Get the name of a given token + Get the symbolic name of a given PHP token Description - - stringtoken_name - inttype - - &warn.experimental.func; - &warn.undocumented.func; + + stringtoken_name + inttoken + + + This function will returen the symbolic name for a PHP + token value. The symbolic name + returned matches the name of the matching token constant. + + + + "T_REQUIRE" + + // a token constant maps to its own name + echo token_name(T_FUNCTION); // -> "T_FUNCTION" +?> +]]> + + diff --git a/reference/tokenizer/reference.xml b/reference/tokenizer/reference.xml index 8663f0a97e..afcfa54db2 100644 --- a/reference/tokenizer/reference.xml +++ b/reference/tokenizer/reference.xml @@ -1,5 +1,5 @@ - + Tokenizer functions Tokenizer functions @@ -7,7 +7,13 @@
&reftitle.intro; - &warn.experimental; + + The tokenizer functions provide an interface to the + PHP tokenizer embedded in the Zend Engine. Using these + functions you may write your own PHP source analyzation + or modification tools without having to deal with the + language specification at the lexical level. + See also the appendix about tokens. @@ -26,6 +32,46 @@ &reference.tokenizer.constants; +
+ &reftitle.examples; + + Here is a simple example PHP scripts using the tokenizer that + will read in a PHP file, strip all comments from the source + and print the pure code only. + + + Strip comments + + output "as is" + echo $text; + break; + } + } + } +?> +]]> + + +
+ + &reference.tokenizer.functions;