refactoring: update api
This commit is contained in:
@@ -1,9 +1,10 @@
|
||||
package php7
|
||||
|
||||
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/php7"
|
||||
"github.com/z7zmey/php-parser/internal/scanner"
|
||||
"github.com/z7zmey/php-parser/pkg/cfg"
|
||||
"github.com/z7zmey/php-parser/pkg/version"
|
||||
)
|
||||
|
||||
func BenchmarkPhp7(b *testing.B) {
|
||||
@@ -16,8 +18,14 @@ func BenchmarkPhp7(b *testing.B) {
|
||||
}
|
||||
|
||||
for n := 0; n < b.N; n++ {
|
||||
lexer := scanner.NewLexer(src, "7.4", nil)
|
||||
php7parser := php7.NewParser(lexer, nil)
|
||||
config := cfg.Config{
|
||||
Version: &version.Version{
|
||||
Major: 7,
|
||||
Minor: 4,
|
||||
},
|
||||
}
|
||||
lexer := scanner.NewLexer(src, config)
|
||||
php7parser := php7.NewParser(lexer, config)
|
||||
php7parser.Parse()
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user