jk_php_tokenizer
Introduction
This python module is a tokenizer for configuration files written in PHP.
Information about this module can be found here:
Why this module?
Quite some web applications store their configuration data in PHP files. While this is convenient for the web application developers this has a problematic drawback: If for some reason this configuration needs to be processed (e.g. if you want to do a backup) this is a problem as this configuration data can not be read easily.
This module helps moving towards building a parser for these files by providing a ready to use PHP tokenizer.
Limitations of this module
This module only performs tokenization, not parsing.
As it is intended for reading PHP configuration files it has not been extensively been tested with files other than configuration files.
How to use this module
Import this module
Please include this module into your application using the following code:
import jk_php_tokenizer
Tokenize a file
Tokenizing is easy. The next lines show how to use the tokenizer:
PATH_OF_PHP_FILE = "..."
tokenizer = jk_php_tokenizer.PHPTokenizer()
with open(PATH_OF_PHP_FILE, "r") as f:
for token in tokenizer.tokenize(f.read()):
print(token)
The token data structure
A token is a jk_utils.Token data structure. It has the following fields:
type- the type of the tokenvalue- the token textlineNo- the line number where the token beginscolNo- the colum number where the token begins
Token types
The following types of tokens are provided by the tokenizer:
intstr1str2boolnullcommentphpintrophpoutrovarrefcommentxlparen1rparen1lparen2rparen2lparen3rparen3boolwordopSPACENEWLINEsemicolon
Contact Information
This work is Open Source. This enables you to use this work for free.
Please have in mind this also enables you to contribute. We, the subspecies of software developers, can create great things. But the more collaborate, the more fantastic these things can become. Therefore Feel free to contact the author(s) listed below, either for giving feedback, providing comments, hints, indicate possible collaborations, ideas, improvements. Or maybe for "only" reporting some bugs:
- Jürgen Knauth: jknauth@uni-goettingen.de, pubsrc@binary-overflow.de
License
This software is provided under the following license:
- Apache Software License 2.0
Metadata
Release files for jk-php-tokenizer 0.2020.3.9
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| jk_php_tokenizer-0.2020.3.9.tar.gz | 8.5 kB | Details |
Release files / jk_php_tokenizer-0.2020.3.9.tar.gz
| Download URL | jk_php_tokenizer-0.2020.3.9.tar.gz |
|---|---|
| Size | 8.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
d8994310d45cee4f02c2f455da5d070a69e9f1ba933aa9678ca365107032d3c5
|
|
BLAKE2b-256 checksum How to use checksums |
10c01cbe222e1796ad903e5e503c220e38a3c9d42f8e2fd9c59200b0480aa885
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/1.14.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/45.2.0 requests-toolbelt/0.8.0 tqdm/4.41.1 CPython/3.6.9
|