Go to file
2018-01-12 10:29:18 +02:00
comment fix golint comments warnings 2018-01-12 08:23:58 +02:00
node reorganize tests 2018-01-12 09:41:08 +02:00
parser create position builder 2018-01-11 20:19:02 +02:00
position fix golint comments warnings 2018-01-12 08:23:58 +02:00
token add token comments 2018-01-11 20:49:00 +02:00
visitor update dumper.go comments 2018-01-12 10:16:09 +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 move dumper to visitor package 2018-01-12 10:05:33 +02:00
Makefile improve Makefile allow call make run PHPFILE=/path/to/php/file/to/parse 2018-01-05 13:17:59 +02:00
README.md update README.md 2018-01-12 10:29:18 +02:00

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/parser"
	"github.com/z7zmey/php-parser/visitor"
)

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

	visitor := 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