[refactoring] parsing error handler

This commit is contained in:
Vadym Slizov
2020-06-29 23:00:56 +03:00
parent 424f7a132c
commit d7652b1c7f
12 changed files with 1191 additions and 631 deletions

View File

@@ -2,15 +2,18 @@ package printer_test
import (
"bytes"
"github.com/z7zmey/php-parser/pkg/ast"
"testing"
"github.com/z7zmey/php-parser/pkg/ast"
"github.com/z7zmey/php-parser/internal/php5"
"github.com/z7zmey/php-parser/internal/scanner"
"github.com/z7zmey/php-parser/pkg/printer"
)
func parsePhp5(src string) ast.Vertex {
php5parser := php5.NewParser([]byte(src), "5.6", true)
lexer := scanner.NewLexer([]byte(src), "5.6", true, nil)
php5parser := php5.NewParser(lexer, true, nil)
php5parser.Parse()
return php5parser.GetRootNode()

View File

@@ -2,11 +2,13 @@ package printer_test
import (
"bytes"
"github.com/z7zmey/php-parser/pkg/ast"
"os"
"testing"
"github.com/z7zmey/php-parser/pkg/ast"
"github.com/z7zmey/php-parser/internal/php7"
"github.com/z7zmey/php-parser/internal/scanner"
"github.com/z7zmey/php-parser/pkg/printer"
)
@@ -27,7 +29,8 @@ abstract class Bar extends Baz
// parse
php7parser := php7.NewParser([]byte(src), "7.4", true)
lexer := scanner.NewLexer([]byte(src), "7.4", true, nil)
php7parser := php7.NewParser(lexer, true, nil)
php7parser.Parse()
rootNode := php7parser.GetRootNode()
@@ -58,7 +61,8 @@ abstract class Bar extends Baz
}
func parse(src string) ast.Vertex {
php7parser := php7.NewParser([]byte(src), "7.4", true)
lexer := scanner.NewLexer([]byte(src), "7.4", true, nil)
php7parser := php7.NewParser(lexer, true, nil)
php7parser.Parse()
return php7parser.GetRootNode()