php-parser/pkg/parser/doc.go
2023-12-10 00:36:22 +01:00

50 lines
914 B
Go

/*
A Parser for PHP written in Go
Package usage example:
package main
import (
"log"
"os"
"git.maride.cc/maride/php-parser/pkg/conf"
"git.maride.cc/maride/php-parser/pkg/errors"
"git.maride.cc/maride/php-parser/pkg/parser"
"git.maride.cc/maride/php-parser/pkg/version"
"git.maride.cc/maride/php-parser/pkg/visitor/dumper"
)
func main() {
src := []byte(`<? echo "Hello world";`)
// Error handler
var parserErrors []*errors.Error
errorHandler := func(e *errors.Error) {
parsmakeerErrors = append(parserErrors, e)
}
// Parse
rootNode, err := parser.Parse(src, conf.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