diff --git a/README.md b/README.md index c191250..5467b35 100644 --- a/README.md +++ b/README.md @@ -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. diff --git a/src/README.md b/src/README.md deleted file mode 100644 index d909439..0000000 --- a/src/README.md +++ /dev/null @@ -1,28 +0,0 @@ -

- 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 - -```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` and can easily be iterated or converted into a dedicated iterator type. \ No newline at end of file diff --git a/src/main.rs b/src/main.rs index ca3e660..a001e08 100644 --- a/src/main.rs +++ b/src/main.rs @@ -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();