parser/src
2022-11-27 02:49:28 +00:00
..
lexer chore: move all code into a single library 2022-11-27 02:49:28 +00:00
parser chore: move all code into a single library 2022-11-27 02:49:28 +00:00
ast.rs chore: move all code into a single library 2022-11-27 02:49:28 +00:00
lib.rs chore: move all code into a single library 2022-11-27 02:49:28 +00:00
main.rs chore: move all code into a single library 2022-11-27 02:49:28 +00:00
README.md chore: move all code into a single library 2022-11-27 02:49:28 +00: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.