Back to index

php5  5.3.10
Defines | Functions | Variables
tokenizer.c File Reference
#include "php.h"
#include "php_ini.h"
#include "ext/standard/info.h"
#include "php_tokenizer.h"
#include "zend.h"
#include "zend_language_scanner.h"
#include "zend_language_scanner_defs.h"
#include <zend_language_parser.h>

Go to the source code of this file.

Defines

#define zendtext   LANG_SCNG(yy_text)
#define zendleng   LANG_SCNG(yy_leng)

Functions

 PHP_MINIT_FUNCTION (tokenizer)
 PHP_MINFO_FUNCTION (tokenizer)
static void tokenize (zval *return_value TSRMLS_DC)
 PHP_FUNCTION (token_get_all)
 PHP_FUNCTION (token_name)

Variables

const zend_function_entry tokenizer_functions []
zend_module_entry tokenizer_module_entry

Define Documentation

#define zendleng   LANG_SCNG(yy_leng)

Definition at line 36 of file tokenizer.c.

#define zendtext   LANG_SCNG(yy_text)

Definition at line 35 of file tokenizer.c.


Function Documentation

PHP_FUNCTION ( token_get_all  )

Definition at line 163 of file tokenizer.c.

{
       char *source = NULL;
       int argc = ZEND_NUM_ARGS();
       int source_len;
       zval source_z;
       zend_lex_state original_lex_state;

       if (zend_parse_parameters(argc TSRMLS_CC, "s", &source, &source_len) == FAILURE) 
              return;

       ZVAL_STRINGL(&source_z, source, source_len, 1);
       zend_save_lexical_state(&original_lex_state TSRMLS_CC);

       if (zend_prepare_string_for_scanning(&source_z, "" TSRMLS_CC) == FAILURE) {
              zend_restore_lexical_state(&original_lex_state TSRMLS_CC);
              RETURN_EMPTY_STRING();
       }

       LANG_SCNG(yy_state) = yycINITIAL;

       tokenize(return_value TSRMLS_CC);
       
       zend_restore_lexical_state(&original_lex_state TSRMLS_CC);
       zval_dtor(&source_z);
}

Here is the call graph for this function:

PHP_FUNCTION ( token_name  )

Definition at line 193 of file tokenizer.c.

{
       int argc = ZEND_NUM_ARGS();
       long type;

       if (zend_parse_parameters(argc TSRMLS_CC, "l", &type) == FAILURE) {
              return;
       }
       RETVAL_STRING(get_token_type_name(type), 1);
}

Here is the call graph for this function:

PHP_MINFO_FUNCTION ( tokenizer  )

Definition at line 94 of file tokenizer.c.

Here is the call graph for this function:

PHP_MINIT_FUNCTION ( tokenizer  )

Definition at line 85 of file tokenizer.c.

Here is the call graph for this function:

static void tokenize ( zval *return_value  TSRMLS_DC) [static]

Definition at line 102 of file tokenizer.c.

{
       zval token;
       zval *keyword;
       int token_type;
       zend_bool destroy;
       int token_line = 1;

       array_init(return_value);

       ZVAL_NULL(&token);
       while ((token_type = lex_scan(&token TSRMLS_CC))) {
              destroy = 1;
              switch (token_type) {
                     case T_CLOSE_TAG:
                            if (zendtext[zendleng - 1] != '>') {
                                   CG(zend_lineno)++;
                            }
                     case T_OPEN_TAG:
                     case T_OPEN_TAG_WITH_ECHO:
                     case T_WHITESPACE:
                     case T_COMMENT:
                     case T_DOC_COMMENT:
                            destroy = 0;
                            break;
              }

              if (token_type >= 256) {
                     MAKE_STD_ZVAL(keyword);
                     array_init(keyword);
                     add_next_index_long(keyword, token_type);
                     if (token_type == T_END_HEREDOC) {
                            if (CG(increment_lineno)) {
                                   token_line = ++CG(zend_lineno);
                                   CG(increment_lineno) = 0;
                            }
                            add_next_index_stringl(keyword, Z_STRVAL(token), Z_STRLEN(token), 1);
                            efree(Z_STRVAL(token));
                     } else {
                            add_next_index_stringl(keyword, (char *)zendtext, zendleng, 1);
                     }
                     add_next_index_long(keyword, token_line);
                     add_next_index_zval(return_value, keyword);
              } else {
                     add_next_index_stringl(return_value, (char *)zendtext, zendleng, 1);
              }
              if (destroy && Z_TYPE(token) != IS_NULL) {
                     zval_dtor(&token);
              }
              ZVAL_NULL(&token);

              token_line = CG(zend_lineno);

              if (token_type == T_HALT_COMPILER) {
                     break;
              }
       }
}

Here is the call graph for this function:

Here is the caller graph for this function:


Variable Documentation

Initial value:

Definition at line 52 of file tokenizer.c.

zend_module_entry tokenizer_module_entry
Initial value:
 {



       "tokenizer",
       tokenizer_functions,
       PHP_MINIT(tokenizer),
       NULL,
       NULL,
       NULL,
       PHP_MINFO(tokenizer),



       STANDARD_MODULE_PROPERTIES
}

Definition at line 61 of file tokenizer.c.