mirror of
https://github.com/danog/parser.git
synced 2024-11-26 20:04:57 +01:00
chore: README
This commit is contained in:
parent
e53c9ec6d0
commit
c831557752
12
README.md
12
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.
|
||||
|
@ -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.
|
@ -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();
|
||||
|
Loading…
Reference in New Issue
Block a user