GithubHelp home page GithubHelp logo

phply's Introduction

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 Lex 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:

  • Nowdocs
  • Backticks
  • Binary string literals and casts
  • Labels and goto
  • Some other stuff, probably

Who's working on it?

  • Dave Benjamin (ramen)
  • Dan Colish (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 :)

phply's People

Contributors

dcolish avatar kevinjqiu avatar ramen avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.