Documentation
¶
Overview ¶
A Parser for PHP written in Go
Package usage example:
package main
import (
"log"
"os"
"github.com/Demooon86/php-parser/pkg/conf"
"github.com/Demooon86/php-parser/pkg/errors"
"github.com/Demooon86/php-parser/pkg/parser"
"github.com/Demooon86/php-parser/pkg/version"
"github.com/Demooon86/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)
}
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ErrVersionOutOfRange = errors.New("the version is out of supported range")
ErrVersionOutOfRange is returned if the version is not supported
Functions ¶
Types ¶
Click to show internal directories.
Click to hide internal directories.