This python module is a tokenizer for configuration files written in PHP.
Project description
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:
int
str1
str2
bool
null
comment
phpintro
phpoutro
varref
commentx
lparen1
rparen1
lparen2
rparen2
lparen3
rparen3
bool
word
op
SPACE
NEWLINE
semicolon
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
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
File details
Details for the file jk_php_tokenizer-0.2020.3.9.tar.gz
.
File metadata
- Download URL: jk_php_tokenizer-0.2020.3.9.tar.gz
- Upload date:
- Size: 8.5 kB
- Tags: Source
- Uploaded using 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
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | d8994310d45cee4f02c2f455da5d070a69e9f1ba933aa9678ca365107032d3c5 |
|
MD5 | 21ca5e961c7aa9acc29276f9f859f834 |
|
BLAKE2b-256 | 10c01cbe222e1796ad903e5e503c220e38a3c9d42f8e2fd9c59200b0480aa885 |