refactoring: update api
This commit is contained in:
@@ -1,9 +1,10 @@
|
||||
package php5
|
||||
|
||||
import (
|
||||
builder "github.com/z7zmey/php-parser/internal/position"
|
||||
"github.com/z7zmey/php-parser/internal/position"
|
||||
"github.com/z7zmey/php-parser/internal/scanner"
|
||||
"github.com/z7zmey/php-parser/pkg/ast"
|
||||
"github.com/z7zmey/php-parser/pkg/cfg"
|
||||
"github.com/z7zmey/php-parser/pkg/errors"
|
||||
"github.com/z7zmey/php-parser/pkg/token"
|
||||
)
|
||||
@@ -14,15 +15,15 @@ type Parser struct {
|
||||
currentToken *token.Token
|
||||
rootNode ast.Vertex
|
||||
errHandlerFunc func(*errors.Error)
|
||||
builder *builder.Builder
|
||||
builder *position.Builder
|
||||
}
|
||||
|
||||
// NewParser creates and returns new Parser
|
||||
func NewParser(lexer *scanner.Lexer, errHandlerFunc func(*errors.Error)) *Parser {
|
||||
func NewParser(lexer *scanner.Lexer, config cfg.Config) *Parser {
|
||||
return &Parser{
|
||||
Lexer: lexer,
|
||||
errHandlerFunc: errHandlerFunc,
|
||||
builder: builder.NewBuilder(),
|
||||
errHandlerFunc: config.ErrorHandlerFunc,
|
||||
builder: position.NewBuilder(),
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -6,6 +6,8 @@ import (
|
||||
|
||||
"github.com/z7zmey/php-parser/internal/php5"
|
||||
"github.com/z7zmey/php-parser/internal/scanner"
|
||||
"github.com/z7zmey/php-parser/pkg/cfg"
|
||||
"github.com/z7zmey/php-parser/pkg/version"
|
||||
)
|
||||
|
||||
func BenchmarkPhp5(b *testing.B) {
|
||||
@@ -15,8 +17,14 @@ func BenchmarkPhp5(b *testing.B) {
|
||||
}
|
||||
|
||||
for n := 0; n < b.N; n++ {
|
||||
lexer := scanner.NewLexer([]byte(src), "5.6", nil)
|
||||
php5parser := php5.NewParser(lexer, nil)
|
||||
config := cfg.Config{
|
||||
Version: &version.Version{
|
||||
Major: 5,
|
||||
Minor: 6,
|
||||
},
|
||||
}
|
||||
lexer := scanner.NewLexer(src, config)
|
||||
php5parser := php5.NewParser(lexer, config)
|
||||
php5parser.Parse()
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user