php-parser/README.md
2018-02-04 21:35:46 +02:00

1.4 KiB

PHP-Parser

Go Report Card Exago Exago

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/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
  • Tests
  • Error handling
  • Stabilize api
  • Documentation
  • PHP 5 syntax analyzer
  • Code flow graph
  • Pretty printer