7 releases
0.1.10 | Dec 17, 2024 |
---|---|
0.1.9 | Dec 12, 2024 |
0.1.5 | Nov 29, 2024 |
#366 in Programming languages
739 downloads per month
Used in backyard-generator
375KB
10K
SLoC
backyard-parser
Parse PHP code to AST node.
features
- Parse string to AST (parse() & parse_eval())
usage
fn main() {
let arena = bumpalo::Bump::new();
let code = r#"<?php
function hello_world($foo) {
var_dump($foo);
}"#;
let parsed = backyard_parser::parse(&arena, code).unwrap();
println!("{:?}", parsed.print(false, false));
}
Notice this output is not including leadings, trailings and location because we print it with print(false, false)
, more on backyard-nodes.
ProgramNode
└-children[]
╙-FunctionNode
├-is_ref: false
├-name
│ └-IdentifierNode
│ └-name: "hello_world"
├-parameters[]
│ ╙-ParameterNode
│ ├-variable_type: -
│ ├-is_ref: false
│ ├-is_ellipsis: false
│ ├-name
│ │ └-IdentifierNode
│ │ └-name: "foo"
│ └-value: -
├-return_type: -
└-body
└-BlockNode
└-statements[]
╙-CallNode
├-name
│ └-IdentifierNode
│ └-name: "var_dump"
└-arguments[]
╙-CallArgumentNode
├-name: -
└-value
└-VariableNode
└-name
└-IdentifierNode
└-name: "foo"
ecosystem
- backyard-nodes (Node / AST, with builder, walker and printer)
- backyard-lexer (Tokenizer)
- backyard-generator
heavily inspired by
license
Dependencies
~1–1.7MB
~32K SLoC