php-parser/main.go
2017-12-19 00:55:57 +02:00

36 lines
513 B
Go

package main
import (
"bytes"
"flag"
"fmt"
"log"
"os"
"github.com/yookoala/realpath"
"github.com/z7zmey/php-parser/parser"
)
func main() {
flag.Parse()
for _, path := range flag.Args() {
real, err := realpath.Realpath(path)
checkErr(err)
fmt.Printf("\n==> %s", real)
src, _ := os.Open(string(real))
rootnode := parser.Parse(src, real)
buf := new(bytes.Buffer)
rootnode.Print(buf, "")
fmt.Println(buf.String())
}
}
func checkErr(err error) {
if err != nil {
log.Fatal(err)
}
}