chore: README

This commit is contained in:
Ryan Chandler 2022-11-27 02:47:07 +00:00
parent e53c9ec6d0
commit c831557752
3 changed files with 13 additions and 29 deletions

View File

@ -8,6 +8,18 @@
---
#### Usage
```rust
use php_parser_rs::*;
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();
```
#### Contributing
All contributions to this repository are welcome. It's the perfect project for Rust beginners since we don't use many of Rust's complex features and the core concepts in the parser are purposely simple.

View File

@ -1,28 +0,0 @@
<h3 align="center">
Trunk Parser
</h3>
<p align="center">
A handwritten recursive-descent parser for PHP code.
</p>
---
#### Overview
The parser produces an abstract syntax tree containing `Statement` and `Expression` types describing the PHP code provided.
#### Usage
```rust
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.

View File

@ -1,4 +1,4 @@
use trunk_parser::{Lexer, Parser};
use php_parser_rs::{Lexer, Parser};
fn main() {
let file = std::env::args().nth(1).unwrap();