comment | ||
node | ||
parser | ||
position | ||
token | ||
walker | ||
.gitignore | ||
CODE_OF_CONDUCT.md | ||
CONTRIBUTING.md | ||
dumper.go | ||
ISSUE_TEMPLATE.md | ||
LICENSE | ||
main.go | ||
Makefile | ||
README.md |
PHP-Parser
A Parser for PHP written in Go inspired by Nikic PHP Parser
Features:
- Fully support PHP7 syntax (PHP5 in future)
- Abstract syntax tree representation
- Traversing AST
Example
package main
import (
"bytes"
"github.com/z7zmey/php-parser/parser"
"github.com/z7zmey/php-parser/visitor"
)
func main() {
src := bytes.NewBufferString(`<? echo "Hello world";`)
nodes, comments, positions := parser.ParsePhp7(src, "example.php")
visitor := Dumper{"", comments, positions}
nodes.Walk(visitor)
}
Roadmap
- Lexer
- PHP 7 syntax analyzer (completely)
- AST nodes
- AST visitor
- AST dumper
- node position
- handling comments
- Tests
- Error handling
- Stabilize api
- Documentation
- PHP 5 syntax analyzer
- Code flow graph
- Pretty printer