Skip to main content

Lexer and parser for PHP source implemented using PLY

Project description

phply

PyPI version PyPI - Python Version GitHub release License

Enhanced fork of phply — fixes core AST bugs, supports PHP 5.6 through 8.5 syntax.

Installation

pip install lphply

Note: Since the internal package name of lphply is still phply, it conflicts with the upstream viraptor/phply PyPI package. If you have previously installed phply, please uninstall it first: 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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

lphply-2.1.0.tar.gz (90.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

lphply-2.1.0-py3-none-any.whl (80.6 kB view details)

Uploaded Python 3

File details

Details for the file lphply-2.1.0.tar.gz.

File metadata

  • Download URL: lphply-2.1.0.tar.gz
  • Upload date:
  • Size: 90.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.15

File hashes

Hashes for lphply-2.1.0.tar.gz
Algorithm Hash digest
SHA256 3d9d374a408e234aad660680679c143db0d47c093c3149ebbee6fd947a3cb035
MD5 0ee7f263412b849129bf3909cd3194fa
BLAKE2b-256 1b018ab12a913f6ecb86aa89ba183dd8b0f56fa5c6db5c8f628ec56be1592d66

See more details on using hashes here.

File details

Details for the file lphply-2.1.0-py3-none-any.whl.

File metadata

  • Download URL: lphply-2.1.0-py3-none-any.whl
  • Upload date:
  • Size: 80.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.15

File hashes

Hashes for lphply-2.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 db33f6f4600f4fa3fc572f1846474b7446d94e689b6291e6d379f3632eeb5dbc
MD5 7aca24a1522d14b5e81ca3515c748110
BLAKE2b-256 f09dd8d99682480a1f33a42f44e3cff3e315cd75580db7d0f544a122d09ddad4

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page