Update README.md
This commit is contained in:
		
							parent
							
								
									219bb36c69
								
							
						
					
					
						commit
						04bd98eec2
					
				
							
								
								
									
										56
									
								
								README.md
									
									
									
									
									
								
							
							
						
						
									
										56
									
								
								README.md
									
									
									
									
									
								
							| @ -5,7 +5,7 @@ | |||||||
|   Keywords: go golang php php-parser ast |   Keywords: go golang php php-parser ast | ||||||
|   --> |   --> | ||||||
| 
 | 
 | ||||||
| <img src="./parser.jpg" alt="A parser for PHP written in Go" width="980"/> | <img src="./parser.jpg" alt="PHP Parser written in Go" width="980"/> | ||||||
| 
 | 
 | ||||||
| [](https://goreportcard.com/report/github.com/z7zmey/php-parser) | [](https://goreportcard.com/report/github.com/z7zmey/php-parser) | ||||||
| [](https://exago.io/project/github.com/z7zmey/php-parser) | [](https://exago.io/project/github.com/z7zmey/php-parser) | ||||||
| @ -15,10 +15,17 @@ | |||||||
| #### Try it online: [demo](https://php-parser.com) | #### Try it online: [demo](https://php-parser.com) | ||||||
| 
 | 
 | ||||||
| ## Features: | ## Features: | ||||||
| - Fully support PHP5 and PHP7 syntax | - Fully support PHP 5 and PHP 7 syntax | ||||||
| - Abstract syntax tree representation | - Abstract syntax tree (AST) representation | ||||||
| - Traversing AST | - Traversing AST | ||||||
| - Namespace resolver | - Namespace resolver | ||||||
|  | - Able to parse syntax-invalid PHP files | ||||||
|  | 
 | ||||||
|  | ## Roadmap | ||||||
|  | 
 | ||||||
|  | - Control Flow Graph (CFG) | ||||||
|  | - PhpDocComment parser | ||||||
|  | - Stabilize api | ||||||
| 
 | 
 | ||||||
| ## Install | ## Install | ||||||
| 
 | 
 | ||||||
| @ -26,6 +33,14 @@ | |||||||
| go get github.com/z7zmey/php-parser | go get github.com/z7zmey/php-parser | ||||||
| ``` | ``` | ||||||
| 
 | 
 | ||||||
|  | ## CLI | ||||||
|  | 
 | ||||||
|  | ``` | ||||||
|  | php-parser [-php5] <path> ... | ||||||
|  | ``` | ||||||
|  | 
 | ||||||
|  | Dump AST to stdout. | ||||||
|  | 
 | ||||||
| ## Example | ## Example | ||||||
| ```Golang | ```Golang | ||||||
| package main | package main | ||||||
| @ -61,19 +76,16 @@ func main() { | |||||||
| } | } | ||||||
| ``` | ``` | ||||||
| 
 | 
 | ||||||
| ## CLI dumper |  | ||||||
| 
 |  | ||||||
| ``` |  | ||||||
| $GOPATH/bin/php-parser /path/to/file/or/dir |  | ||||||
| ``` |  | ||||||
| 
 |  | ||||||
| ## Namespace resolver | ## Namespace resolver | ||||||
| 
 | 
 | ||||||
| Namespace resolver is a visitor that traverses nodes and resolves nodes fully qualified name. | Namespace resolver is a visitor that resolves nodes fully qualified name and saves into `map[node.Node]string` structure | ||||||
| It does not change AST but collects resolved names into `map[node.Node]string` |  | ||||||
| 
 | 
 | ||||||
| - For `Class`, `Interface`, `Trait`, `Function`, `ConstList` nodes collects name with current namespace. | - For `Class`, `Interface`, `Trait`, `Function`, `Constant` nodes it saves name with current namespace. | ||||||
| - For `Name`, `Relative`, `FullyQualified` nodes resolves `use` aliases and collects a fully qualified name. | - For `Name`, `Relative`, `FullyQualified` nodes it resolves `use` aliases and saves a fully qualified name. | ||||||
|  | 
 | ||||||
|  | ## Parsing syntax-invalid PHP files | ||||||
|  | 
 | ||||||
|  | If we try to parse `$a$b;` then the parser triggers error 'syntax error: unexpected T_VARIABLE'. Token `$b` is unexpected, but parser recovers parsing process and returns `$b;` statement to AST, because it is syntactically correct. | ||||||
| 
 | 
 | ||||||
| ## Pretty printer | ## Pretty printer | ||||||
| 
 | 
 | ||||||
| @ -121,21 +133,3 @@ abstract class Bar extends Baz | |||||||
|     } |     } | ||||||
| } | } | ||||||
| ``` | ``` | ||||||
| 
 |  | ||||||
| ## Roadmap |  | ||||||
| - [X] Lexer |  | ||||||
| - [x] PHP 7 syntax analyzer |  | ||||||
| - [x] AST nodes |  | ||||||
| - [x] AST visitor |  | ||||||
| - [x] AST dumper |  | ||||||
| - [x] node position |  | ||||||
| - [x] handling comments |  | ||||||
| - [x] PHP 5 syntax analyzer |  | ||||||
| - [x] Tests |  | ||||||
| - [x] Namespace resolver |  | ||||||
| - [x] Pretty printer |  | ||||||
| - [ ] PhpDocComment parser |  | ||||||
| - [ ] Error handling |  | ||||||
| - [ ] Stabilize api |  | ||||||
| - [ ] Documentation |  | ||||||
| - [ ] Code flow graph |  | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user