Go to file
2018-02-27 15:38:58 +02:00
comment add comment tests 2018-01-13 01:58:59 +02:00
node Names interface 2018-02-27 15:34:43 +02:00
php5 update package comments 2018-02-20 20:22:15 +02:00
php7 update package comments 2018-02-20 20:22:15 +02:00
position positions tests 2018-02-18 13:51:03 +02:00
scanner update package comments 2018-02-20 20:22:15 +02:00
token token test 2018-02-18 12:55:32 +02:00
visitor replace Namespace struct 2018-02-27 15:38:58 +02:00
walker update package comments 2018-02-20 20:22:15 +02:00
.gitignore ignore example.php 2018-01-05 13:22:38 +02:00
CODE_OF_CONDUCT.md update CODE_OF_CONDUCT.md 2018-01-05 19:49:29 +02:00
CONTRIBUTING.md create CONTRIBUTING.md 2018-01-05 19:37:08 +02:00
doc.go update doc.go 2018-02-20 19:37:42 +02:00
ISSUE_TEMPLATE.md Create ISSUE_TEMPLATE.md 2018-01-05 19:23:10 +02:00
LICENSE Create LICENSE 2018-01-02 14:37:19 +02:00
main.go type resolving 2018-02-26 23:29:36 +02:00
Makefile update Makefile 2018-02-24 00:19:05 +02:00
README.md Update README.md 2018-02-19 14:36:06 +02:00

PHP-Parser

Go Report Card Exago Exago GoDoc

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

Install

go get github.com/z7zmey/php-parser

Example

package main

import (
	"bytes"

	"github.com/z7zmey/php-parser/php7"
	"github.com/z7zmey/php-parser/visitor"
)

func main() {
	src := bytes.NewBufferString(`<? echo "Hello world";`)
	nodes, comments, positions := php7.Parse(src, "example.php")

	visitor := visitor.Dumper{
		Indent:    "",
		Comments:  comments,
		Positions: positions,
	}
	nodes.Walk(visitor)
}

CLI dumper

$GOPATH/bin/php-parser /path/to/file/or/dir

Roadmap

  • Lexer
  • PHP 7 syntax analyzer
  • AST nodes
  • AST visitor
  • AST dumper
  • node position
  • handling comments
  • PHP 5 syntax analyzer
  • Tests
  • PhpDocComment parser
  • Namespace resolver
  • Error handling
  • Stabilize api
  • Documentation
  • Pretty printer
  • Code flow graph