parser/trunk_parser
2022-09-22 21:13:17 +01:00
..
src parser: only allow certain statements at top level 2022-09-22 21:13:17 +01:00
Cargo.toml parser: get failing test cases passing on precedence changes 2022-09-14 12:01:10 +01:00
README.md parser/docs: better README 2022-09-12 00:45:42 +01:00

Trunk Parser

A handwritten recursive-descent parser for PHP code.


Overview

The parser produces an abstract syntax tree containing Statement and Expression types describing the PHP code provided.

Usage

use trunk_lexer::*;
use trunk_parser::*;

let mut lexer = Lexer::new(None);
let tokens = lexer.tokenize(&source_code[..]).unwrap();

let mut parser = Parser::new(None);
let ast = parser.parse(tokens).unwrap();

The resulting ast is a Vec<trunk_parser::Statement> and can easily be iterated or converted into a dedicated iterator type.