File tree 2 files changed +50
-54
lines changed
2 files changed +50
-54
lines changed Load Diff This file was deleted.
Original file line number Diff line number Diff line change
1
+ /*
2
+
3
+ A Parser for PHP written in Go
4
+
5
+ Package usage example:
6
+
7
+ package main
8
+
9
+ import (
10
+ "log"
11
+ "os"
12
+
13
+ "github.com/z7zmey/php-parser/pkg/cfg"
14
+ "github.com/z7zmey/php-parser/pkg/errors"
15
+ "github.com/z7zmey/php-parser/pkg/parser"
16
+ "github.com/z7zmey/php-parser/pkg/version"
17
+ "github.com/z7zmey/php-parser/pkg/visitor/dumper"
18
+ )
19
+
20
+ func main() {
21
+ src := []byte(`<? echo "Hello world";`)
22
+
23
+ // Error handler
24
+
25
+ var parserErrors []*errors.Error
26
+ errorHandler := func(e *errors.Error) {
27
+ parserErrors = append(parserErrors, e)
28
+ }
29
+
30
+ // Parse
31
+
32
+ rootNode, err := parser.Parse(src, cfg.Config{
33
+ Version: &version.Version{Major: 5, Minor: 6},
34
+ ErrorHandlerFunc: errorHandler,
35
+ })
36
+
37
+ if err != nil {
38
+ log.Fatal("Error:" + err.Error())
39
+ }
40
+
41
+ // Dump
42
+
43
+ goDumper := dumper.NewDumper(os.Stdout).
44
+ WithTokens().
45
+ WithPositions()
46
+
47
+ rootNode.Accept(goDumper)
48
+ }
49
+ */
50
+ package parser
You can’t perform that action at this time.
0 commit comments