#php #parser #ast-node #convert #back

backyard-generator

Convert AST node back to PHP code

6 releases

new 0.1.9 Dec 12, 2024
0.1.8 Dec 9, 2024
0.1.5 Nov 29, 2024

#1318 in Algorithms

Download history 249/week @ 2024-11-27 330/week @ 2024-12-04

579 downloads per month

MIT license

365KB
10K SLoC

backyard-generator

Convert AST node back to PHP code.

features

  • Convert AST back to string (generator())

usage

fn main() {
  let code = r#"<?php
    function hello_world($foo) {
      var_dump($foo);
    }"#;

  let parsed = backyard_parser::parse(code).unwrap();
  let code = backyard_generator::generate(parsed);
  println!("{:?}", code);
}

Resulting this code:

function hello_world($foo) {
  var_dump($foo);
}

ecosystem

heavily inspired by

license

MIT

Dependencies

~1.6–2.7MB
~53K SLoC