[#120] move dog.go from root folder
This commit is contained in:
parent
15562c740e
commit
d9bd1df2a2
54
doc.go
54
doc.go
@ -1,54 +0,0 @@
|
||||
/*
|
||||
|
||||
A Parser for PHP written in Go
|
||||
|
||||
Features:
|
||||
|
||||
* Fully support PHP5 and PHP7 syntax
|
||||
* Abstract syntax tree representation
|
||||
* Traversing AST
|
||||
* Namespace resolver
|
||||
|
||||
Install:
|
||||
|
||||
go get github.com/z7zmey/php-parser
|
||||
|
||||
CLI dumper:
|
||||
|
||||
$GOPATH/bin/php-parser -php5 /path/to/file/or/dir
|
||||
|
||||
Package usage example:
|
||||
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"bytes"
|
||||
"os"
|
||||
|
||||
"github.com/z7zmey/php-parser/php7"
|
||||
"github.com/z7zmey/php-parser/visitor"
|
||||
)
|
||||
|
||||
func main() {
|
||||
src := bytes.NewBufferString(`<? echo "Hello world";`)
|
||||
|
||||
parser := php7.NewParser(src, "example.php")
|
||||
parser.Parse()
|
||||
|
||||
for _, e := range parser.GetErrors() {
|
||||
fmt.Println(e)
|
||||
}
|
||||
|
||||
visitor := visitor.Dumper{
|
||||
Writer: os.Stdout,
|
||||
Indent: "",
|
||||
Comments: parser.GetComments(),
|
||||
Positions: parser.GetPositions(),
|
||||
}
|
||||
|
||||
rootNode := parser.GetRootNode()
|
||||
rootNode.Walk(visitor)
|
||||
}
|
||||
*/
|
||||
package main // import "github.com/z7zmey/php-parser"
|
50
pkg/parser/doc.go
Normal file
50
pkg/parser/doc.go
Normal file
@ -0,0 +1,50 @@
|
||||
/*
|
||||
|
||||
A Parser for PHP written in Go
|
||||
|
||||
Package usage example:
|
||||
|
||||
package main
|
||||
|
||||
import (
|
||||
"log"
|
||||
"os"
|
||||
|
||||
"github.com/z7zmey/php-parser/pkg/cfg"
|
||||
"github.com/z7zmey/php-parser/pkg/errors"
|
||||
"github.com/z7zmey/php-parser/pkg/parser"
|
||||
"github.com/z7zmey/php-parser/pkg/version"
|
||||
"github.com/z7zmey/php-parser/pkg/visitor/dumper"
|
||||
)
|
||||
|
||||
func main() {
|
||||
src := []byte(`<? echo "Hello world";`)
|
||||
|
||||
// Error handler
|
||||
|
||||
var parserErrors []*errors.Error
|
||||
errorHandler := func(e *errors.Error) {
|
||||
parserErrors = append(parserErrors, e)
|
||||
}
|
||||
|
||||
// Parse
|
||||
|
||||
rootNode, err := parser.Parse(src, cfg.Config{
|
||||
Version: &version.Version{Major: 5, Minor: 6},
|
||||
ErrorHandlerFunc: errorHandler,
|
||||
})
|
||||
|
||||
if err != nil {
|
||||
log.Fatal("Error:" + err.Error())
|
||||
}
|
||||
|
||||
// Dump
|
||||
|
||||
goDumper := dumper.NewDumper(os.Stdout).
|
||||
WithTokens().
|
||||
WithPositions()
|
||||
|
||||
rootNode.Accept(goDumper)
|
||||
}
|
||||
*/
|
||||
package parser
|
Loading…
Reference in New Issue
Block a user