1.4 KiB
1.4 KiB
PHP-Parser
A Parser for PHP written in Go inspired by Nikic PHP Parser
Features:
- Fully support PHP5 and PHP7 syntax
- Abstract syntax tree representation
- Traversing AST
Example
package main
import (
"bytes"
"github.com/z7zmey/php-parser/php5"
"github.com/z7zmey/php-parser/visitor"
)
func main() {
src := bytes.NewBufferString(`<? echo "Hello world";`)
nodes, comments, positions := php5.Parse(src, "example.php")
visitor := visitor.Dumper{
Indent: "",
Comments: comments,
Positions: positions,
}
nodes.Walk(visitor)
}
Roadmap
- Lexer
- PHP 7 syntax analyzer (completely)
- AST nodes
- AST visitor
- AST dumper
- node position
- handling comments
- PHP 5 syntax analyzer
- Tests
- Error handling
- Stabilize api
- Documentation
- Pretty printer
- Code flow graph