php-parser/README.md

57 lines
1.4 KiB
Markdown
Raw Normal View History

2018-01-02 12:41:54 +00:00
<!--
Title: PHP Parser
Description: A Parser for PHP written in Go.
Author: Slizov Vadim
2018-01-10 22:49:01 +00:00
Keywords: go golang php php-parser ast
2018-01-02 12:41:54 +00:00
-->
# PHP-Parser
2018-01-09 16:36:06 +00:00
2018-01-10 22:32:20 +00:00
[![Go Report Card](https://goreportcard.com/badge/github.com/z7zmey/php-parser)](https://goreportcard.com/report/github.com/z7zmey/php-parser)
2018-01-09 16:36:06 +00:00
[![Exago](https://api.exago.io:443/badge/tests/github.com/z7zmey/php-parser)](https://exago.io/project/github.com/z7zmey/php-parser)
2018-01-12 07:44:56 +00:00
[![Exago](https://api.exago.io:443/badge/cov/github.com/z7zmey/php-parser)](https://exago.io/project/github.com/z7zmey/php-parser)
2018-01-09 16:36:06 +00:00
2018-01-05 09:53:00 +00:00
A Parser for PHP written in Go inspired by [Nikic PHP Parser](https://github.com/nikic/PHP-Parser)
2018-01-02 12:34:26 +00:00
2018-01-09 16:29:05 +00:00
## Features:
- Fully support PHP7 syntax (PHP5 in future)
- Abstract syntax tree representation
2018-01-09 16:36:06 +00:00
- Traversing AST
2018-01-09 16:29:05 +00:00
2018-01-12 08:04:31 +00:00
## Example
```Golang
package main
import (
"bytes"
"github.com/z7zmey/php-parser/parser"
"github.com/z7zmey/php-parser/visitor"
)
func main() {
src := `<? echo "Hello world";`
nodes, comments, positions := parser.Parse(bytes.NewBufferString(src), "example.php")
visitor := visitor.Dumper{" | ", comments, positions}
nodes.Walk(visitor)
}
```
2018-01-02 12:41:54 +00:00
## Roadmap
2018-01-02 12:34:26 +00:00
- [X] Lexer
2018-01-05 17:48:20 +00:00
- [x] PHP 7 syntax analyzer (completely)
2018-01-02 12:34:26 +00:00
- [x] AST nodes
2018-01-02 12:41:54 +00:00
- [x] AST visitor
2018-01-04 22:33:50 +00:00
- [x] AST dumper
- [x] node position
2018-01-05 15:03:59 +00:00
- [x] handling comments
2018-01-02 12:41:54 +00:00
- [ ] Tests
2018-01-09 16:29:05 +00:00
- [ ] Error handling
- [ ] Stabilize api
2018-01-02 12:41:54 +00:00
- [ ] Documentation
2018-01-02 12:34:26 +00:00
- [ ] PHP 5 syntax analyzer
- [ ] Code flow graph
2018-01-05 09:53:00 +00:00
- [ ] Pretty printer