Go to file
2018-02-06 17:38:49 +02:00
comment add comment tests 2018-01-13 01:58:59 +02:00
node rename files add prefixes for nodes and tests files 2018-02-06 17:38:49 +02:00
php5 cmd: add php5 flag 2018-02-06 12:39:42 +02:00
php7 cmd: add php5 flag 2018-02-06 12:39:42 +02:00
position fix golint comments warnings 2018-01-12 08:23:58 +02:00
scanner fix token consts 2018-01-29 16:11:45 +02:00
token add token comments 2018-01-11 20:49:00 +02:00
visitor update README.md 2018-02-04 21:35:46 +02:00
walker walker pakage 2018-01-17 19:01:28 +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
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 cmd: add php5 flag 2018-02-06 12:39:42 +02:00
Makefile rename files add prefixes for nodes and tests files 2018-02-06 17:38:49 +02:00
README.md Update README.md 2018-02-06 12:52:31 +02:00

PHP-Parser

Go Report Card Exago Exago

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
  • Error handling
  • Stabilize api
  • Documentation
  • Pretty printer
  • Code flow graph