Lexer and parser for PHP source implemented using PLY
Project description
phply
Lexer and parser for PHP source code implemented in Python using PLY (Python Lex-Yacc).
Supports PHP 5.6 through 8.5 syntax.
Installation
pip install lphply
注意: 由于
lphply的内部包名仍为phply,与上游viraptor/phply的 PyPI 包冲突。如果之前安装过phply,请先卸载:pip uninstall phply && pip install lphply。
Usage
Lexer
from phply.phplex import lexer
lexer.input('<?php echo "Hello, World!"; ?>')
for token in lexer:
print(token)
Parser
from phply.phplex import lexer
from phply.phpparse import make_parser
parser = make_parser()
with open('example.php', 'r') as f:
code = f.read()
result = parser.parse(code, lexer=lexer)
Command-line tools
# Parse a PHP file
phpparse file.php
# Lex a PHP file
phplex file.php
Development
Clone the repository and install in development mode:
git clone https://github.com/LoRexxar/Lphply.git
cd Lphply
pip install -e ".[test]"
Running tests
pytest
License
BSD-3-Clause. See LICENSE for details.
Credits
Fork of viraptor/phply, originally by Dave Benjamin.
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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file lphply-2.0.0.tar.gz.
File metadata
- Download URL: lphply-2.0.0.tar.gz
- Upload date:
- Size: 89.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
790d6ae17f85f6980a120061364c6983be4acfd5e0520b372515111d69f1d240
|
|
| MD5 |
3d2060b3406102ccf7a636bf6e20d12f
|
|
| BLAKE2b-256 |
2840897101c060b6f47efbfdc5712a3143afc6601d2598cdb44458da1735c17f
|
File details
Details for the file lphply-2.0.0-py3-none-any.whl.
File metadata
- Download URL: lphply-2.0.0-py3-none-any.whl
- Upload date:
- Size: 79.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2136ab160d06326cedba280e1e2980d66213a404f0b5dd8b30d339434ad6bc32
|
|
| MD5 |
1f9f0d88754ea9841d32081b86484795
|
|
| BLAKE2b-256 |
ef6a55fa5f3cbebea12daa47068d02aee49f64d275362ded37c3505930bc4c15
|