<commit_before><commit_msg>Write some copy for the README<commit_after># phply

phply is a parser for the PHP programming language written using PLY, a
Lex/YACC-style parser generator toolkit for Python.

## Why?

Good question. Because I'm crazy. Because it seemed possible.

Things I'm interested in doing with it:

* Converting PHP code to Python
* Running PHP templates in a Python environment
* Learning more about parsing "industrial" languages, warts and all

## What does it stand for?

* phply -> PHP PLY
* phply -> PHP Hypertext Preprocessor Python Lex YACC
* phply -> PHP Hypertext Preprocessor Hypertext Preprocessor Python Lexx Yet Another Compiler Compiler
* (... to be completed ...)

## How do you pronounce it?

If you're conservative, it's pronounced "pee aich ply". If you're liberal,
it's "fiply". And if you're anarchist, pronounce it however you want. Who am I
to tell you what to do?

## What's working?

* Lexer matching the standard PHP lexer token-for-token
* Parser and abstract syntax tree for most of the PHP grammar
* Script to convert PHP source to JSON-based ASTs
* Script to convert PHP source to Jinja2 source (experimental)

## What's not?

Some things can't be parsed yet. They are getting fewer by the day, but there
is still a fair amount of work to do:

* Heredocs/Nowdocs
* Namespaces
* Anonymous functions
* Some string interpolation syntax, such as: `"$foo["$bar"]"`
* Variable function calls: `$f()`
* Class variables: `ClassName::$variable`
* Methods named after keywords: `$this->use()`
* Some other stuff, probably

## Who's working on it?

* <NAME> (ramen)
* <NAME> (dcolish)

## How do I use it?

* Lexer test: python phply/phplex.py
* Parser test: python phply/phpparse.py
* JSON dump: cd tools; python php2json.py < input.php > output.json
* Jinja2 conversion: cd tools; python php2jinja.py < input.php > output.html
* Fork me on GitHub and start hacking :)
{'fraction_non_alphanumeric': 0.09071840587309911, 'fraction_numerical': 0.002097535395909806, 'mean_word_length': 4.314763231197771, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4341923', 'n_tokens_mistral': 592, 'n_tokens_neox': 551, 'n_words': 264}